com.dlsc.flexgantt.swing.layer
Class AbstractLayer

java.lang.Object
  extended by com.dlsc.flexgantt.swing.layer.AbstractLayer
Direct Known Subclasses:
AbstractCustomLayer, AbstractSystemLayer, TimelineObjectLayer

public abstract class AbstractLayer
extends java.lang.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
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
protected  float alpha
          An alpha channel value used to control the transparency of the layer.
protected  java.beans.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 java.lang.String PROPERTY_ALPHA
          A constant used for property change events that get fired when the application calls the setAlpha(float) method.
static java.lang.String PROPERTY_VISIBLE
          A constant used for property change events that get fired when the application calls the setVisible(boolean) method.
 
Constructor Summary
protected AbstractLayer(java.lang.String name, LayerContainer lc)
          Constructs a new layer.
 
Method Summary
 void addPropertyChangeListener(java.beans.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.
 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.
 java.lang.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.
 java.lang.String getToolTipText(java.awt.event.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.
 boolean isVisible()
          Determines whether the layer is currently visible or not.
protected  void paintLayer(java.awt.Graphics g)
           
 void removePropertyChangeListener(java.beans.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(java.awt.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 java.lang.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 java.lang.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 java.beans.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(java.lang.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(java.beans.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(java.beans.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 java.lang.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(java.awt.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 java.lang.String getToolTipText(java.awt.event.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(java.awt.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)