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

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.CrosshairLayer
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

public class CrosshairLayer
extends AbstractSystemLayer
implements java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.MouseListener

The crosshair layer renders the crosshair cursor, which can be used to take a closer look at the timeline objects. The crosshair can be customized via the ICrosshairPolicy, which returns labels that are shown in the four corners of the crosshair.

Since:
1.0
Author:
Dirk Lemmermann

Field Summary
 
Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer
alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE
 
Constructor Summary
CrosshairLayer(LayerContainer lc)
          Constructs a new crosshair layer.
 
Method Summary
 int getCircleRadius()
          Returns the radius / size used for drawing the crosshair circle.
 java.awt.Color getFillColor()
          Returns the color that will be used to fill out the crosshair circle.
 java.awt.Color getLineColor()
          Returns the color used to draw the horizontal and vertical crosshair lines.
 java.awt.BasicStroke getStroke()
          Returns the stroke used to draw the crosshair lines.
 java.awt.Color getTextColor()
          Returns the color used to draw the text in the four corners of the crosshair.
 boolean isHorizontalLineVisible()
          Determines whether the horizontal line will be drawn.
 boolean isVerticalLineVisible()
          Determines whether the vertical line will be drawn.
 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)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
protected  void paintLayer(java.awt.Graphics g)
           
 void setCircleRadius(int radius)
          Sets the radius / size for drawing the crosshair circle.
 void setFillColor(java.awt.Color color)
          Sets the color that will be used to fill out the crosshair circle.
 void setHorizontalLineVisible(boolean visible)
          Specifies whether the horizontal crosshair line will be drawn or not.
 void setLineColor(java.awt.Color color)
          Sets the color used to draw the vertical and horizontal crosshair lines.
 void setStroke(java.awt.BasicStroke stroke)
          Sets the stroke used to draw the crosshair lines.
 void setTextColor(java.awt.Color color)
          Sets the color used to draw the text in the four corners of the crosshair.
 void setVerticalLineVisible(boolean visible)
          Specifies whether the vertical crosshair line will be drawn or not.
 void setVisible(boolean visible)
          Overriden to add / remove mouse listeners to / from the layer container.
 
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, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrosshairLayer

public CrosshairLayer(LayerContainer lc)
Constructs a new crosshair layer.

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

setVisible

public void setVisible(boolean visible)
Overriden to add / remove mouse listeners to / from the layer container. If the layer is not visible then there is no need to listen to mouse events.

Overrides:
setVisible in class AbstractLayer
Parameters:
visible - if TRUE the layer will be visible
See Also:
AbstractLayer.isVisible()

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

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

paintLayer

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

getStroke

public java.awt.BasicStroke getStroke()
Returns the stroke used to draw the crosshair lines.

Returns:
a stroke object used for drawing the crosshair
Since:
1.0

setStroke

public void setStroke(java.awt.BasicStroke stroke)
Sets the stroke used to draw the crosshair lines.

Parameters:
stroke - the stroke used for drawing the crosshair lines
Since:
1.0

isHorizontalLineVisible

public boolean isHorizontalLineVisible()
Determines whether the horizontal line will be drawn.

Returns:
TRUE if the horizontal crosshair line will be drawn
Since:
1.0

setHorizontalLineVisible

public void setHorizontalLineVisible(boolean visible)
Specifies whether the horizontal crosshair line will be drawn or not.

Parameters:
visible - if TRUE the horizontal line will be drawn
Since:
1.0

isVerticalLineVisible

public boolean isVerticalLineVisible()
Determines whether the vertical line will be drawn.

Returns:
TRUE if the vertical crosshair line will be drawn
Since:
1.0

setVerticalLineVisible

public void setVerticalLineVisible(boolean visible)
Specifies whether the vertical crosshair line will be drawn or not.

Parameters:
visible - if TRUE the vertical line will be drawn
Since:
1.0

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked 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

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

getCircleRadius

public int getCircleRadius()
Returns the radius / size used for drawing the crosshair circle.

Returns:
the crosshair circle size
Since:
1.0

setCircleRadius

public void setCircleRadius(int radius)
Sets the radius / size for drawing the crosshair circle.

Parameters:
radius - the size of the crosshair circle
Since:
1.0

getFillColor

public java.awt.Color getFillColor()
Returns the color that will be used to fill out the crosshair circle.

Returns:
the crosshair circle fill color
Since:
1.0

setFillColor

public void setFillColor(java.awt.Color color)
Sets the color that will be used to fill out the crosshair circle.

Parameters:
color - the crosshair circle fill color
Since:
1.0

getLineColor

public java.awt.Color getLineColor()
Returns the color used to draw the horizontal and vertical crosshair lines.

Returns:
the crosshair line color
Since:
1.0

setLineColor

public void setLineColor(java.awt.Color color)
Sets the color used to draw the vertical and horizontal crosshair lines.

Parameters:
color - the crosshair line color
Since:
1.0

getTextColor

public java.awt.Color getTextColor()
Returns the color used to draw the text in the four corners of the crosshair.

Returns:
the crosshair text color
Since:
1.0

setTextColor

public void setTextColor(java.awt.Color color)
Sets the color used to draw the text in the four corners of the crosshair.

Parameters:
color - the crosshair text color
Since:
1.0