com.dlsc.flexgantt.swing.layer.timeline
Class TimelineObjectLayer

java.lang.Object
  extended by com.dlsc.flexgantt.swing.layer.AbstractLayer
      extended by com.dlsc.flexgantt.swing.layer.timeline.TimelineObjectLayer
All Implemented Interfaces:
ITimelineObjectLayerSelectionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener

public class TimelineObjectLayer
extends AbstractLayer
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, ITimelineObjectLayerSelectionListener

The timeline object layer is responsible for rendering the timeline objects returned by the Gantt chart model. The layer container will create one instance of a timeline object layer for each layer defined by the model. Timeline objects get rendered by the layer via the help of so-called timeline object renderers (see ITimelineObjectRenderer).

The timeline object layer uses its alpha value to determine the transparency of the timeline objects that it renders. This feature is especially useful in situations where timeline objects overlap each other (then again, consider using inner lines, see ILinePolicy).

Each timeline object layer uses its own selection model to keep track of the currently selected timeline objects. Applications need to register listeners with these selection models for every layer that they are interested in.

Timeline object layers are capable of returning ObjectBounds for timeline objects. These bounds contain various information about the object itself, its location, the layer it is on and the model it belongs to.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
IGanttChartModel.getLayers(), ILayerFactory

Field Summary
 
Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer
alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE
 
Constructor Summary
TimelineObjectLayer(LayerContainer lc, ILayer layer)
          Constructs a new timeline object layer.
 
Method Summary
 java.util.Collection<ObjectBounds> getAllObjectBoundsAt(int x, int y)
          Returns the object bounds for all timeline objects found at the given coordinate.
 ILayer getLayer()
          Returns the model layer visualized by the timeline object layer.
 ObjectBounds getObjectBounds(TimelineObjectPath path)
          Returns the object bounds for the given timeline object (path).
 ObjectBounds getObjectBoundsAt(int x, int y)
          Returns the object bounds for the timeline object found at the given coordinate.
 ObjectBounds getObjectBoundsAt(java.awt.event.MouseEvent evt)
          Returns the object bounds for the timeline object found at the location of the given mouse event.
 ObjectBounds getObjectBoundsAt(java.awt.Point p)
          Returns the object bounds for the timeline object found at the given location.
 ITimeSpan getTimeSpanUsed()
          Returns the time span that is used by the layer.
 boolean isDebuggingObjectBounds()
          Determines whether the layer will draw red rectangles showing the individual object bounds of the timeline objects.
 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)
           
protected  void paintLayer(java.awt.Graphics g)
           
 void setDebuggingObjectBounds(boolean debug)
          Specifies whether the layer will draw red rectangles showing the individual object bounds of the timeline objects.
 void setVisible(boolean b)
          Specifies whether the layer is visible or not.
 void tearDown()
          Performs tear down operations when the layer is no longer needed (removing listeners, etc...).
 void valueChanged(TimelineObjectSelectionEvent evt)
          Callback method that gets invoked when the selection within the observed TimelineObjectLayer changes.
 
Methods inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer
addPropertyChangeListener, getAlpha, getDateline, getEventline, getGanttChart, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getToolTipText, getTreeTable, getTreeTablePolicyProvider, isVisible, removePropertyChangeListener, repaint, repaint, repaint, setAlpha
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimelineObjectLayer

public TimelineObjectLayer(LayerContainer lc,
                           ILayer layer)
Constructs a new timeline object layer.

Parameters:
lc - the parent layer container
layer - the model layer that will be visualized by the UI layer
Since:
1.0
Method Detail

tearDown

public void tearDown()
Description copied from class: AbstractLayer
Performs tear down operations when the layer is no longer needed (removing listeners, etc...).

Overrides:
tearDown in class AbstractLayer

setVisible

public void setVisible(boolean b)
Description copied from class: AbstractLayer
Specifies whether the layer is visible or not.

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

getObjectBounds

public ObjectBounds getObjectBounds(TimelineObjectPath path)
Returns the object bounds for the given timeline object (path). The bounds provide detailed information about the visual representation of the timeline object (the location, the width, the height, the layer, etc...).

Parameters:
path - the path for which to return the bounds
Returns:
the object bounds for the given timeline object (path)
Since:
1.0

getObjectBoundsAt

public ObjectBounds getObjectBoundsAt(java.awt.event.MouseEvent evt)
Returns the object bounds for the timeline object found at the location of the given mouse event. The bounds provide detailed information about the visual representation of the timeline object (the location, the width, the height, the layer, etc...).

Parameters:
evt - the mouse event for which to return object bounds
Returns:
the object bounds found at the location of the given mouse event
Since:
1.0

getObjectBoundsAt

public ObjectBounds getObjectBoundsAt(java.awt.Point p)
Returns the object bounds for the timeline object found at the given location. The bounds provide detailed information about the visual representation of the timeline object (the location, the width, the height, the layer, etc...).

Parameters:
p - the location within the layer
Returns:
the object bounds for the timeline object at the given location
Since:
1.0

getObjectBoundsAt

public ObjectBounds getObjectBoundsAt(int x,
                                      int y)
Returns the object bounds for the timeline object found at the given coordinate. The bounds provide detailed information about the visual representation of the timeline object (the location, the width, the height, the layer, etc...).

Parameters:
x - the x-coordinate of the location to check
y - the y-coordinate of the location to check
Returns:
the object bounds for the given timeline object (path)
Since:
1.0

getAllObjectBoundsAt

public java.util.Collection<ObjectBounds> getAllObjectBoundsAt(int x,
                                                               int y)
Returns the object bounds for all timeline objects found at the given coordinate. The bounds provide detailed information about the visual representation of the timeline objects (the location, the width, the height, the layer, etc...).

Parameters:
x - the x-coordinate of the location to check
y - the y-coordinate of the location to check
Returns:
the object bounds for all timeline objects located at the given coordinates
Since:
1.0

paintLayer

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

getTimeSpanUsed

public ITimeSpan getTimeSpanUsed()
Description copied from class: AbstractLayer
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.

Overrides:
getTimeSpanUsed in class AbstractLayer
Returns:
the time span that is 'used' by the layer

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

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

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

valueChanged

public void valueChanged(TimelineObjectSelectionEvent evt)
Description copied from interface: ITimelineObjectLayerSelectionListener
Callback method that gets invoked when the selection within the observed TimelineObjectLayer changes.

Specified by:
valueChanged in interface ITimelineObjectLayerSelectionListener
Parameters:
evt - the event with detailed information about the change that occured

getLayer

public ILayer getLayer()
Returns the model layer visualized by the timeline object layer.

Returns:
the model layer
Since:
1.0

isDebuggingObjectBounds

public boolean isDebuggingObjectBounds()
Determines whether the layer will draw red rectangles showing the individual object bounds of the timeline objects. This is very useful for debugging purposes.

Returns:
TRUE if the layer draws the object bounds
Since:
1.0
See Also:
ITimelineObjectRenderer.getTimelineObjectRendererInsets(int, int, int, int)

setDebuggingObjectBounds

public void setDebuggingObjectBounds(boolean debug)
Specifies whether the layer will draw red rectangles showing the individual object bounds of the timeline objects. This is very useful for debugging purposes.

Parameters:
debug - if TRUE the layer draws the object bounds
Since:
1.0
See Also:
ITimelineObjectRenderer.getTimelineObjectRendererInsets(int, int, int, int)