com.dlsc.flexgantt.swing.layer.system

## Class GridLayer

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

- All Implemented Interfaces:
    PropertyChangeListener, EventListener

      public class GridLayer
      extends AbstractSystemLayer
      implements PropertyChangeListener

  The grid layer is responsible for drawing the vertical and horizontal grid lines. The number of vertical grid lines depends on the current grid mode (see `AbstractGanttChart.getGridLineMode()`). Depending on the mode the layer might draw no lines, minor lines only, major lines only or a combination of minor and major grid lines. The layer allows for some customization of the drawing. The colors used for the major and minor lines and the thickness of the major lines may be changed.
  Since:
    1.0
  Version:
    $Revision: 1.13 $
  Author:
    Dirk Lemmermann

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PROPERTY_HORIZONTAL_LINE_COLOR` Constant used for those property change events that get fired when the color for horizontal grid lines changes.
    `static String` | `PROPERTY_MAJOR_GRID_COLOR` Constant used for those property change events that get fired when the major grid color changes.
    `static String` | `PROPERTY_MINOR_GRID_COLOR` Constant used for those property change events that get fired when the color for minor grid lines changes.

    - ### Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GridLayer(LayerContainer lc)` Constructs a new grid layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Color` | `getHorizontalLineColor()` Returns the color used for drawing the horizontal grid lines.
    `Color` | `getMajorGridColor()` Returns the color used to draw a vertical line across all rows in all layer containers in order to indicate the end of a major time unit (for example: the end of a year, the end of a month).
    `Color` | `getMinorGridColor()` Returns the color used to draw a vertical line across all rows in all layer containers in order to indicate the end of a minor time unit (for example: the end of a day, the end of an hour).
    `boolean` | `isHorizontalLinesVisible()` Determines if the horizontal grid lines are visible or not.
    `boolean` | `isThickMajorGridLines()` Determines whether the major grid lines will be drawn thick (2 pixels wide).
    `boolean` | `isVerticalLinesOnTop()` Determines whether the vertical lines will be drawn on top of the horizontal lines or vice versa.
    `protected void` | `paintHorizontalLines(Graphics g)` Draws the horizontal lines.
    `protected void` | `paintLayer(Graphics g)`
    `protected void` | `paintVerticalLines(Graphics g)` Draws the vertical grid lines.
    `void` | `propertyChange(PropertyChangeEvent evt)`
    `void` | `setHorizontalLineColor(Color color)` Set the color used for drawing the horizontal grid lines.
    `void` | `setHorizontalLinesVisible(boolean visible)` Specifies whether the horizontal grid lines will be drawn or not.
    `void` | `setMajorGridColor(Color color)` Changes the color used for rendering those vertical grid lines that get drawn when the grid mode is set to `GridLineMode.MAJOR_GRID_LINES`.
    `void` | `setMinorGridColor(Color color)` Changes the color used for rendering those vertical grid lines that get drawn when the grid mode is set to `GridLineMode.MINOR_GRID_LINES`.
    `void` | `setThickMajorGridLines(boolean thickMajorGridLines)` Specifies whether the major grid lines will be drawn thick (2 pixels wide).
    `void` | `setVerticalLinesOnTop(boolean verticalLinesOnTop)` Specifies whether the vertical lines will be drawn on top of the horizontal lines or vice versa.

    - ### 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, setVisible, tearDown`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### PROPERTY_MAJOR_GRID_COLOR

          public static final String PROPERTY_MAJOR_GRID_COLOR

      Constant used for those property change events that get fired when the major grid color changes.
      Since:
        1.0
      See Also:
        `setMajorGridColor(Color)`, Constant Field Values

    - #### PROPERTY_MINOR_GRID_COLOR

          public static final String PROPERTY_MINOR_GRID_COLOR

      Constant used for those property change events that get fired when the color for minor grid lines changes.
      Since:
        1.0
      See Also:
        `setMinorGridColor(Color)`, Constant Field Values

    - #### PROPERTY_HORIZONTAL_LINE_COLOR

          public static final String PROPERTY_HORIZONTAL_LINE_COLOR

      Constant used for those property change events that get fired when the color for horizontal grid lines changes.
      Since:
        1.0
      See Also:
        `setHorizontalLineColor(Color)`, Constant Field Values

  - ### Constructor Detail

    - #### GridLayer

          public GridLayer(LayerContainer lc)

      Constructs a new grid layer.
      Parameters:
        `lc` - the layer container to which the layer belongs
      Since:
        1.0

  - ### Method Detail

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Overrides:
        `paintLayer` in class `AbstractLayer`

    - #### paintVerticalLines

          protected void paintVerticalLines(Graphics g)

      Draws the vertical grid lines.
      Parameters:
        `g` - the graphics context
      Since:
        1.0

    - #### paintHorizontalLines

          protected void paintHorizontalLines(Graphics g)

      Draws the horizontal lines.
      Parameters:
        `g` - the graphics context
      Since:
        1.0

    - #### isThickMajorGridLines

          public boolean isThickMajorGridLines()

      Determines whether the major grid lines will be drawn thick (2 pixels wide).
      Returns:
        TRUE if the major grid lines will be drawn thick
      Since:
        1.0
      See Also:
        `setThickMajorGridLines(boolean)`

    - #### setThickMajorGridLines

          public void setThickMajorGridLines(boolean thickMajorGridLines)

      Specifies whether the major grid lines will be drawn thick (2 pixels wide).
      Parameters:
        `thickMajorGridLines` - if TRUE the major grid lines will be drawn thick
      Since:
        1.0
      See Also:
        `isThickMajorGridLines()`

    - #### isVerticalLinesOnTop

          public boolean isVerticalLinesOnTop()

      Determines whether the vertical lines will be drawn on top of the horizontal lines or vice versa.
      Returns:
        TRUE if the vertical lines are drawn on top
      Since:
        1.0
      See Also:
        `setVerticalLinesOnTop(boolean)`

    - #### setVerticalLinesOnTop

          public void setVerticalLinesOnTop(boolean verticalLinesOnTop)

      Specifies whether the vertical lines will be drawn on top of the horizontal lines or vice versa.
      Parameters:
        `verticalLinesOnTop` - if TRUE the vertical lines will be drawn on top of the horizontal lines
      Since:
        1.0
      See Also:
        `isVerticalLinesOnTop()`

    - #### setMajorGridColor

          public void setMajorGridColor(Color color)

      Changes the color used for rendering those vertical grid lines that get drawn when the grid mode is set to `GridLineMode.MAJOR_GRID_LINES`. Setting a new major grid color will trigger a property change event with the name/id set to the constant `PROPERTY_MAJOR_GRID_COLOR`.
      Parameters:
        `color` - the major grid color
      Since:
        1.0
      See Also:
        `getMajorGridColor()`, `AbstractGanttChart.setGridLineMode(GridLineMode)`

    - #### getMajorGridColor

          public Color getMajorGridColor()

      Returns the color used to draw a vertical line across all rows in all layer containers in order to indicate the end of a major time unit (for example: the end of a year, the end of a month).
      Returns:
        Color the color used for drawing the vertical lines
      Since:
        1.0
      See Also:
        `setMajorGridColor(Color)`, `getMinorGridColor()`

    - #### setMinorGridColor

          public void setMinorGridColor(Color color)

      Changes the color used for rendering those vertical grid lines that get drawn when the grid mode is set to `GridLineMode.MINOR_GRID_LINES`. Setting a new minor grid color will trigger a property change event with the name/id set to the constant `PROPERTY_MINOR_GRID_COLOR`.
      Parameters:
        `color` - the minor grid color
      Since:
        1.0
      See Also:
        `getMinorGridColor()`, `AbstractGanttChart.setGridLineMode(GridLineMode)`

    - #### getMinorGridColor

          public Color getMinorGridColor()

      Returns the color used to draw a vertical line across all rows in all layer containers in order to indicate the end of a minor time unit (for example: the end of a day, the end of an hour).
      Returns:
        Color the color used for drawing the vertical lines
      Since:
        1.0
      See Also:
        `setMinorGridColor(Color)`, `getMajorGridColor()`

    - #### getHorizontalLineColor

          public Color getHorizontalLineColor()

      Returns the color used for drawing the horizontal grid lines.
      Returns:
        the horizontal grid line color
      Since:
        1.0

    - #### setHorizontalLineColor

          public void setHorizontalLineColor(Color color)

      Set the color used for drawing the horizontal grid lines.
      Parameters:
        `color` - the horizontal grid line color
      Since:
        1.0

    - #### isHorizontalLinesVisible

          public boolean isHorizontalLinesVisible()

      Determines if the horizontal grid lines are visible or not.
      Returns:
        TRUE if the horizontal grid lines will be drawn
      Since:
        1.1

    - #### setHorizontalLinesVisible

          public void setHorizontalLinesVisible(boolean visible)

      Specifies whether the horizontal grid lines will be drawn or not.
      Parameters:
        `visible` - if TRUE the horizontal grid lines will be drawn
      Since:
        1.1

    - #### propertyChange

          public void propertyChange(PropertyChangeEvent evt)

      Specified by:
        `propertyChange` in interface `PropertyChangeListener`

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