com.dlsc.flexgantt.swing.layer.system
Class LassoLayer

java.lang.Object
  extended by com.dlsc.flexgantt.swing.layer.AbstractLayer
      extended by com.dlsc.flexgantt.swing.layer.system.AbstractSystemLayer
          extended by com.dlsc.flexgantt.swing.layer.system.LassoLayer
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.KeyEventDispatcher, java.util.EventListener

public class LassoLayer
extends AbstractSystemLayer
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.KeyEventDispatcher

A layer that focuses on visualizing a lasso / selection rectangle.

Since:
1.0
Author:
Dirk Lemmermann

Nested Class Summary
static class LassoLayer.LassoMode
          A selection mode enumerator that can be used to instruct the lasso layer what to select when a lasso operation finishes.
 
Field Summary
 
Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer
alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE
 
Constructor Summary
LassoLayer(LayerContainer lc)
          Constructs a new lasso layer.
 
Method Summary
protected  java.awt.Cursor createLassoCursor(LassoLayer.LassoMode mode, boolean multi)
          Creates a cursor that will be used for the given lasso mode.
 boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
          Intercepts key events from the KeyboardFocusManager in order to temporarily change the edit mode.
 LassoLayer.LassoMode getLassoMode()
          Returns the lasso mode used by the lasso layer (selecting timeline objects or selecting time spans).
 java.awt.Color getLinkingLineColor()
          Returns the color used for the line drawn while linking two timeline objects / creating a relationship.
 java.awt.Color getSelectionColor()
          Returns the color used for filling the selection color.
 LassoLayer.LassoMode[] getSupportedLassoModes()
          Returns the supported lasso modes.
 boolean isSelecting()
          Determines if a selection / lasso operation is currently taking place.
 boolean isSingleRowObjectCreation()
          Determines whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.
 boolean isSupportedLassoMode(LassoLayer.LassoMode mode)
          Checks whether the given lasso mode is supported by the lasso layer.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void paintFocusedBounds(java.awt.Graphics g, ObjectBounds bounds)
          Adds focus feedback to the given object bounds.
protected  void paintLasso(java.awt.Graphics g, int x1, int y1, int x2, int y2)
          Draws the actual lasso.
protected  void paintLayer(java.awt.Graphics g)
           
protected  void paintLinking(java.awt.Graphics g)
          Renders visual feedback when two timeline objects are being linked together by the user.
 void setLassoMode(LassoLayer.LassoMode mode)
          Sets the lasso mode so that the layer can switch between selecting timeline objects and selecting time spans and creating timeline objects.
 void setLinkingLineColor(java.awt.Color color)
          Sets the color used for the line drawn while linking two timeline objects / creating a relationship.
 void setSelectionColor(java.awt.Color color)
          Sets the color used for filling the selection rectangle.
 void setSingleRowObjectCreation(boolean single)
          Specifies whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.
 void setSupportedLassoModes(LassoLayer.LassoMode... modes)
          Sets the supported lasso modes.
 
Methods inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer
addPropertyChangeListener, getAlpha, getDateline, getEventline, getGanttChart, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getTimeSpanUsed, getToolTipText, getTreeTable, getTreeTablePolicyProvider, isVisible, removePropertyChangeListener, repaint, repaint, repaint, setAlpha, setVisible, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LassoLayer

public LassoLayer(LayerContainer lc)
Constructs a new lasso layer.

Parameters:
lc - the layer container to which the layer belongs
Since:
1.0
Method Detail

isSelecting

public boolean isSelecting()
Determines if a selection / lasso operation is currently taking place.

Returns:
TRUE if the user is currently selecting something
Since:
1.0

paintLayer

protected void paintLayer(java.awt.Graphics g)
Overrides:
paintLayer in class AbstractLayer

paintLinking

protected void paintLinking(java.awt.Graphics g)
Renders visual feedback when two timeline objects are being linked together by the user. The method will draw a line with an arrow at its end.

Parameters:
g - the graphics context into which to draw
Since:
1.0

paintFocusedBounds

protected void paintFocusedBounds(java.awt.Graphics g,
                                  ObjectBounds bounds)
Adds focus feedback to the given object bounds. The method will draw small red arrows above, below, to the left, and to the right of the object bounds. The icons used are looked up from the IconRegistry via the following IDs:

Parameters:
g - the graphics context into which to draw
bounds - the focused object bounds
Since:
1.0

paintLasso

protected void paintLasso(java.awt.Graphics g,
                          int x1,
                          int y1,
                          int x2,
                          int y2)
Draws the actual lasso. The values passed to this method ensure that the point (x1, y1) is always the upper left corner of the lasso and (x2, y2) is always the lower right corner of the lasso.

Parameters:
g - the graphics context into which to draw
x1 - the x-coordinate of the upper left corner
y1 - the y-coordinate of the upper left corner
x2 - the x-coordinate of the lower right corner
y2 - the y-coordinate of the lower right corner
Since:
1.0

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

getSelectionColor

public java.awt.Color getSelectionColor()
Returns the color used for filling the selection color.

Returns:
the color used for filling the selection color
Since:
1.0

setSelectionColor

public void setSelectionColor(java.awt.Color color)
Sets the color used for filling the selection rectangle.

Parameters:
color - the color used for filling the selection rectangle
Since:
1.0

getLassoMode

public LassoLayer.LassoMode getLassoMode()
Returns the lasso mode used by the lasso layer (selecting timeline objects or selecting time spans).

Returns:
the mode for the next lasso operation
Since:
1.0

setLassoMode

public void setLassoMode(LassoLayer.LassoMode mode)
Sets the lasso mode so that the layer can switch between selecting timeline objects and selecting time spans and creating timeline objects.

Parameters:
mode - the mode to use for the next lasso operation
Since:
1.0

isSingleRowObjectCreation

public boolean isSingleRowObjectCreation()
Determines whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.

Returns:
TRUE if timeline objects can only be created one row at a time
Since:
1.0

setSingleRowObjectCreation

public void setSingleRowObjectCreation(boolean single)
Specifies whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.

Parameters:
single - if TRUE timeline objects can only be created one row at a time
Since:
1.0

getLinkingLineColor

public java.awt.Color getLinkingLineColor()
Returns the color used for the line drawn while linking two timeline objects / creating a relationship.

Returns:
the line color used for linking
Since:
1.0

setLinkingLineColor

public void setLinkingLineColor(java.awt.Color color)
Sets the color used for the line drawn while linking two timeline objects / creating a relationship.

Parameters:
color - the line color used for linking
Since:
1.0

createLassoCursor

protected java.awt.Cursor createLassoCursor(LassoLayer.LassoMode mode,
                                            boolean multi)
Creates a cursor that will be used for the given lasso mode. This method looks up its cursor from the IconRegistry with the following IDs:

Parameters:
mode - the lasso mode for which to create a cursor
multi - determines if the cursor is needed for a 'multi' operation (multi timeline object selection, multi time span selection)
Returns:
a cursor for the given lasso mode
Since:
1.0

dispatchKeyEvent

public boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
Intercepts key events from the KeyboardFocusManager in order to temporarily change the edit mode. Pressing the SHIFT key will turn on the multi selection mode. Pressing the CTRL key will change from timeline object selection to time span selection. Pressing the ALT key will switch to the timeline object creation mode. Key events will only be processed if the mouse cursor is currently on top of the layer container.

Specified by:
dispatchKeyEvent in interface java.awt.KeyEventDispatcher
Since:
1.0

getSupportedLassoModes

public LassoLayer.LassoMode[] getSupportedLassoModes()
Returns the supported lasso modes. By default the lasso layer supports all lasso modes defined in LassoLayer.LassoMode.

Returns:
the supported lasso modes
Since:
1.0
See Also:
setSupportedLassoModes(LassoMode[])

setSupportedLassoModes

public void setSupportedLassoModes(LassoLayer.LassoMode... modes)
Sets the supported lasso modes. By default the lasso layer supports all lasso modes defined in LassoLayer.LassoMode.

Parameters:
modes - the supported lasso modes
Since:
1.0
See Also:
getSupportedLassoModes()

isSupportedLassoMode

public boolean isSupportedLassoMode(LassoLayer.LassoMode mode)
Checks whether the given lasso mode is supported by the lasso layer.

Parameters:
mode - the mode to check
Returns:
TRUE if the given lasso mode is supported by the layer
Since:
1.0
See Also:
setSupportedLassoModes(com.dlsc.flexgantt.swing.layer.system.LassoLayer.LassoMode[]), getSupportedLassoModes()