com.dlsc.flexgantt.swing.layer

## Class AbstractLayer

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.AbstractLayer

- Direct Known Subclasses:
    AbstractCustomLayer, AbstractSystemLayer, TimelineObjectLayer

      public abstract class AbstractLayer
      extends Object

  The abstract superclass of all layers inside a layer container. The visual appearance of a layer container is composed of the rendering operations of several layers. The FlexGantt framework differentiates between three different types of layers: system, timeline and custom layers.
  Since:
    1.0
  Version:
    $Revision: 1.15 $
  Author:
    Dirk Lemmermann
  See Also:
    `IGanttChartModel.getLayers()`, `LayerContainer.getSystemLayer(Class)`, `LayerContainer.getTimelineObjectLayer(com.dlsc.flexgantt.model.gantt.ILayer)`, `LayerContainer.getCustomLayer(com.dlsc.flexgantt.model.gantt.ILayer)`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected float` | `alpha` An alpha channel value used to control the transparency of the layer.
    `protected PropertyChangeSupport` | `changeSupport` A property change support object on which property change event listeners can be registered and property change events can be fired.
    `protected AbstractGanttChart` | `ganttChart` The parent Gantt chart.
    `protected LayerContainer` | `layerContainer` The parent container.
    `static String` | `PROPERTY_ALPHA` A constant used for property change events that get fired when the application calls the `setAlpha(float)` method.
    `static String` | `PROPERTY_VISIBLE` A constant used for property change events that get fired when the application calls the `setVisible(boolean)` method.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractLayer(String name, LayerContainer lc)` Constructs a new layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPropertyChangeListener(PropertyChangeListener l)` Adds a property change listener to the layer.
    `float` | `getAlpha()` Returns the alpha channel value used by the layer for rendering operations.
    `Dateline` | `getDateline()` Returns the timeline's dateline
    `Eventline` | `getEventline()` Returns the timeline's eventline.
    `AbstractGanttChart` | `getGanttChart()` Returns the Gantt chart to which the layer belongs.
    `int` | `getHeight()` Convenience method to access `JComponent.getHeight()`.
    `LayerContainer` | `getLayerContainer()` Returns the parent container, the layer container.
    `IPolicyProvider` | `getLayerPolicyProvider()` Returns the policy provider of the layer container.
    `IGanttChartModel` | `getModel()` Returns the Gantt chart model.
    `String` | `getName()` Returns the name of the layer.
    `int` | `getStartRow()` Returns the start row of the tree table.
    `long` | `getTimeAt(int x)` Returns the time at the given location.
    `Timeline` | `getTimeline()` Returns the Gantt chart's timeline.
    `int` | `getTimeLocation(long time)` Returns the x-coordinate for the given time point.
    `ITimeSpan` | `getTimeSpanUsed()` Returns the time span that is used by the layer.
    `String` | `getToolTipText(MouseEvent e)` Returns a tooltip text for the given mouse event (mouse location).
    `TreeTable` | `getTreeTable()` Returns the tree table that is shown to the left of the layer (container).
    `IPolicyProvider` | `getTreeTablePolicyProvider()` Returns the policy provider of the tree table.
    `int` | `getWidth()` Convenience method to access `JComponent.getWidth()`.
    `boolean` | `isVisible()` Determines whether the layer is currently visible or not.
    `protected void` | `paintLayer(Graphics g)`
    `void` | `removePropertyChangeListener(PropertyChangeListener l)` Removes a property change listener from the layer.
    `void` | `repaint()` Repaints the layer by repainting the layer container, which will result in all layers been repainted.
    `void` | `repaint(int x, int y, int width, int height)` Repaints the given bounds of the layer by repainting the same bounds on the layer container, which will result in all layers been repainted.
    `void` | `repaint(Rectangle r)` Repaints the given bounds of the layer by repainting the same bounds on the layer container, which will result in all layers been repainted.
    `void` | `setAlpha(float alpha)` Sets the alpha channel value used by the layer for rendering operations.
    `void` | `setVisible(boolean visible)` Specifies whether the layer is visible or not.
    `void` | `tearDown()` Performs tear down operations when the layer is no longer needed (removing listeners, etc...).

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

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

- - ### Field Detail

    - #### PROPERTY_ALPHA

          public static final String PROPERTY_ALPHA

      A constant used for property change events that get fired when the application calls the `setAlpha(float)` method.
      Since:
        1.0
      See Also:
        Constant Field Values

    - #### PROPERTY_VISIBLE

          public static final String PROPERTY_VISIBLE

      A constant used for property change events that get fired when the application calls the `setVisible(boolean)` method.
      Since:
        1.0
      See Also:
        Constant Field Values

    - #### layerContainer

          protected LayerContainer layerContainer

      The parent container.
      Since:
        1.0

    - #### ganttChart

          protected AbstractGanttChart ganttChart

      The parent Gantt chart.
      Since:
        1.0

    - #### alpha

          protected float alpha

      An alpha channel value used to control the transparency of the layer.
      Since:
        1.0
      See Also:
        `setAlpha(float)`

    - #### changeSupport

          protected PropertyChangeSupport changeSupport

      A property change support object on which property change event listeners can be registered and property change events can be fired.
      Since:
        1.0
      See Also:
        `addPropertyChangeListener(PropertyChangeListener)`, `removePropertyChangeListener(PropertyChangeListener)`

  - ### Constructor Detail

    - #### AbstractLayer

          protected AbstractLayer(String name,
                                  LayerContainer lc)

      Constructs a new layer.
      Parameters:
        `name` - the layer name
        `lc` - the parent container
      Since:
        1.0

  - ### Method Detail

    - #### addPropertyChangeListener

          public void addPropertyChangeListener(PropertyChangeListener l)

      Adds a property change listener to the layer. Depending on the layer different property change events can get fired when setter methods get invoked.
      Parameters:
        `l` - the listener that will be added
      Since:
        1.0
      See Also:
        `removePropertyChangeListener(PropertyChangeListener)`

    - #### removePropertyChangeListener

          public void removePropertyChangeListener(PropertyChangeListener l)

      Removes a property change listener from the layer.
      Parameters:
        `l` - the listener that will be removed
      Since:
        1.0
      See Also:
        `addPropertyChangeListener(PropertyChangeListener)`

    - #### tearDown

          public void tearDown()

      Performs tear down operations when the layer is no longer needed (removing listeners, etc...).
      Since:
        1.0

    - #### getTimeSpanUsed

          public ITimeSpan getTimeSpanUsed()

      Returns the time span that is used by the layer. Useful for various operations (e.g. to make all timeline objects become visible). The default implementation returns `TimeSpan.UNDEFINED`.
      Returns:
        the time span that is 'used' by the layer
      Since:
        1.0

    - #### getName

          public String getName()

      Returns the name of the layer.
      Returns:
        the layer name
      Since:
        1.0

    - #### getLayerContainer

          public LayerContainer getLayerContainer()

      Returns the parent container, the layer container.
      Returns:
        the layer container
      Since:
        1.0

    - #### getGanttChart

          public AbstractGanttChart getGanttChart()

      Returns the Gantt chart to which the layer belongs.
      Returns:
        the layer's Gantt chart
      Since:
        1.0

    - #### getTreeTable

          public TreeTable getTreeTable()

      Returns the tree table that is shown to the left of the layer (container).
      Returns:
        the tree table
      Since:
        1.0

    - #### getStartRow

          public int getStartRow()

      Returns the start row of the tree table. This is the row at the top of the visible rectangle.
      Returns:
        the first visible row / node
      Since:
        1.0

    - #### getModel

          public IGanttChartModel getModel()

      Returns the Gantt chart model.
      Returns:
        the Gantt chart model
      Since:
        1.0

    - #### getTimeline

          public Timeline getTimeline()

      Returns the Gantt chart's timeline.
      Returns:
        the timeline
      Since:
        1.0
      See Also:
        `getDateline()`, `getEventline()`

    - #### getDateline

          public Dateline getDateline()

      Returns the timeline's dateline
      Returns:
        the dateline
      Since:
        1.0
      See Also:
        `getTimeline()`, `getEventline()`

    - #### getEventline

          public Eventline getEventline()

      Returns the timeline's eventline.
      Returns:
        the eventline
      Since:
        1.0
      See Also:
        `getTimeline()`, `getEventline()`

    - #### getLayerPolicyProvider

          public IPolicyProvider getLayerPolicyProvider()

      Returns the policy provider of the layer container.
      Returns:
        the layer container's policy provider
      Since:
        1.0

    - #### getTreeTablePolicyProvider

          public IPolicyProvider getTreeTablePolicyProvider()

      Returns the policy provider of the tree table.
      Returns:
        the tree table's policy provider
      Since:
        1.0

    - #### getTimeAt

          public long getTimeAt(int x)

      Returns the time at the given location.
      Parameters:
        `x` - the x-coordinate inside the layer (container) for which to return a time point
      Returns:
        the time point at the given location
      Since:
        1.0
      See Also:
        `Dateline.getTimeAt(int)`

    - #### getTimeLocation

          public int getTimeLocation(long time)

      Returns the x-coordinate for the given time point.
      Parameters:
        `time` - the time point for which to return a coordinate
      Returns:
        the x-coordinate of the given time point
      Since:
        1.0

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Parameters:
        `g` -
      Since:
        1.0

    - #### getAlpha

          public float getAlpha()

      Returns the alpha channel value used by the layer for rendering operations. Note: not all layers actually use this value. Layers that use it are: the timeline object layer (see `TimelineObjectLayer`), the grid layer (see `GridLayer`) and the calendar layer (see `CalendarLayer`).
      Returns:
        the alpha channel value that controls the transparency of objects rendered by the layer
      Since:
        1.0

    - #### setAlpha

          public void setAlpha(float alpha)

      Sets the alpha channel value used by the layer for rendering operations. The alpha value must be within the interval [0,1]. Calling this method will cause a property change event with the ID `PROPERTY_ALPHA`. Note: not all layers actually use this value. Layers that do use it are: the timeline object layer (see `TimelineObjectLayer`), the grid layer (see `GridLayer`) and the calendar layer (see `CalendarLayer`).
      Parameters:
        `alpha` - the alpha channel value that controls the transparency of objects rendered by the layer
      Since:
        1.0

    - #### isVisible

          public boolean isVisible()

      Determines whether the layer is currently visible or not.
      Returns:
        TRUE if the layer is currently visible
      Since:
        1.0
      See Also:
        `setVisible(boolean)`

    - #### setVisible

          public void setVisible(boolean visible)

      Specifies whether the layer is visible or not.
      Parameters:
        `visible` - if TRUE the layer will be visible
      Since:
        1.0
      See Also:
        `isVisible()`

    - #### getToolTipText

          public String getToolTipText(MouseEvent e)

      Returns a tooltip text for the given mouse event (mouse location).
      Parameters:
        `e` - the mouse event for which to return a tooltip text
      Returns:
        a tooltip text for the given mouse event (mouse location)
      Since:
        1.0

    - #### repaint

          public void repaint()

      Repaints the layer by repainting the layer container, which will result in all layers been repainted. This is a convenience methode so that subclasses do not have to call `Component.repaint()`.
      Since:
        1.0
      See Also:
        `repaint(Rectangle)`, `repaint(int, int, int, int)`

    - #### repaint

          public void repaint(int x,
                              int y,
                              int width,
                              int height)

      Repaints the given bounds of the layer by repainting the same bounds on the layer container, which will result in all layers been repainted. This is a convenience methode so that subclasses do not have to call `Component.repaint(int, int, int, int)`.
      Parameters:
        `x` - the x-coordinate of the bounds that will be repainted
        `y` - the y-coordinate of the bounds that will be repainted
        `width` - the width of the bounds that will be repainted
        `height` - the height of the bounds that will be repainted
      Since:
        1.0
      See Also:
        `repaint()`, `repaint(Rectangle)`

    - #### repaint

          public void repaint(Rectangle r)

      Repaints the given bounds of the layer by repainting the same bounds on the layer container, which will result in all layers been repainted. This is a convenience methode so that subclasses do not have to call `JComponent.repaint(Rectangle)`.
      Parameters:
        `r` - the bounds that will be repainted
      Since:
        1.0
      See Also:
        `repaint()`, `repaint(int, int, int, int)`

    - #### getWidth

          public int getWidth()

      Convenience method to access `JComponent.getWidth()`.
      Returns:
        the width of the layer container
      Since:
        2.1

    - #### getHeight

          public int getHeight()

      Convenience method to access `JComponent.getHeight()`.
      Returns:
        the height of the layer container
      Since:
        2.1

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