com.dlsc.flexgantt.swing.layer.system

## Class CrosshairLayer

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.AbstractLayer
  - - com.dlsc.flexgantt.swing.layer.system.AbstractSystemLayer
    - - com.dlsc.flexgantt.swing.layer.system.CrosshairLayer

- All Implemented Interfaces:
    MouseListener, MouseMotionListener, MouseWheelListener, EventListener

      public class CrosshairLayer
      extends AbstractSystemLayer
      implements MouseMotionListener, MouseWheelListener, 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
  Version:
    $Revision: 1.7 $
  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

    Constructors
    Constructor and Description
    `CrosshairLayer(LayerContainer lc)` Constructs a new crosshair layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getCircleRadius()` Returns the radius / size used for drawing the crosshair circle.
    `Color` | `getFillColor()` Returns the color that will be used to fill out the crosshair circle.
    `Color` | `getLineColor()` Returns the color used to draw the horizontal and vertical crosshair lines.
    `BasicStroke` | `getStroke()` Returns the stroke used to draw the crosshair lines.
    `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(MouseEvent e)`
    `void` | `mouseDragged(MouseEvent e)`
    `void` | `mouseEntered(MouseEvent e)`
    `void` | `mouseExited(MouseEvent e)`
    `void` | `mouseMoved(MouseEvent e)`
    `void` | `mousePressed(MouseEvent e)`
    `void` | `mouseReleased(MouseEvent e)`
    `void` | `mouseWheelMoved(MouseWheelEvent e)`
    `protected void` | `paintLayer(Graphics g)`
    `void` | `setCircleRadius(int radius)` Sets the radius / size for drawing the crosshair circle.
    `void` | `setFillColor(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(Color color)` Sets the color used to draw the vertical and horizontal crosshair lines.
    `void` | `setStroke(BasicStroke stroke)` Sets the stroke used to draw the crosshair lines.
    `void` | `setTextColor(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, getHeight, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getTimeSpanUsed, getToolTipText, getTreeTable, getTreeTablePolicyProvider, getWidth, 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(MouseEvent e)

      Specified by:
        `mouseDragged` in interface `MouseMotionListener`

    - #### mouseMoved

          public void mouseMoved(MouseEvent e)

      Specified by:
        `mouseMoved` in interface `MouseMotionListener`

    - #### mouseWheelMoved

          public void mouseWheelMoved(MouseWheelEvent e)

      Specified by:
        `mouseWheelMoved` in interface `MouseWheelListener`

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Overrides:
        `paintLayer` in class `AbstractLayer`

    - #### getStroke

          public 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(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(MouseEvent e)

      Specified by:
        `mouseClicked` in interface `MouseListener`

    - #### mouseEntered

          public void mouseEntered(MouseEvent e)

      Specified by:
        `mouseEntered` in interface `MouseListener`

    - #### mouseExited

          public void mouseExited(MouseEvent e)

      Specified by:
        `mouseExited` in interface `MouseListener`

    - #### mousePressed

          public void mousePressed(MouseEvent e)

      Specified by:
        `mousePressed` in interface `MouseListener`

    - #### mouseReleased

          public void mouseReleased(MouseEvent e)

      Specified by:
        `mouseReleased` in interface `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 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(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 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(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 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(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

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.