com.dlsc.flexgantt.model.gantt
Class DefaultTimelineObject<T>

java.lang.Object
  extended by com.dlsc.flexgantt.model.AbstractPropertiesOwner
      extended by com.dlsc.flexgantt.model.gantt.DefaultTimelineObject<T>
Type Parameters:
T - the type of the user / business object wrapped by the timeline object
All Implemented Interfaces:
ITimelineObject, IPropertiesOwner, java.lang.Comparable<ITimelineObject>
Direct Known Subclasses:
DefaultActivityObject, DefaultCapacityObject, DefaultEventlineObject, DefaultEventObject

public class DefaultTimelineObject<T>
extends AbstractPropertiesOwner
implements ITimelineObject

The default implementation of the ITimelineObject interface. This class provides all the information that is required to visualize the usage of a time span via a horizontal bar. The object can be decorated with a label and additional information about the object can be displayed in a popup / annotation window. Most decisions made by policies are based on information provided by this class.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
DefaultTimelineObjectRenderer, DefaultTimelineObjectEditor

Constructor Summary
DefaultTimelineObject()
          Constructs a new timeline object with an undefined time span.
DefaultTimelineObject(ITimeSpan timeSpan)
          Constructs a new timeline object.
DefaultTimelineObject(java.lang.String name)
          Constructs a new timeline object with an undefined time span.
DefaultTimelineObject(java.lang.String name, ITimeSpan timeSpan)
          Constructs a new timeline object.
 
Method Summary
 void addChild(ITimelineObject child)
          Adds another timeline object as a child to this timeline object.
 int compareTo(ITimelineObject tlo)
           
 java.util.Iterator<ITimelineObject> getChildren()
          Returns an iterator over all children timeline objects of this timeline object.
 int getDragActions()
          Returns the drag actions that can be performed on the timeline object.
 java.lang.String getLabel(LabelType type)
          Returns labels for various purposes depending on the given label type identifier.
 int getLineIndex()
          Returns the object's line index.
 java.lang.Object getPopupObject(boolean extended)
          Returns the object for the popup window.
 java.lang.Object getStatus()
          Returns an object that represents some kind of status that the timeline object is in.
 ITimeSpan getTimeSpan()
          Returns the time allocation of the timeline object.
 T getUserObject()
          Returns the user object wrapped by the timeline object.
 boolean isDeletable()
          Determines whether the timeline object can be deleted or not.
 boolean isDurationChangeable()
          Returns TRUE if the duration of the object can be modified.
 boolean isInPlaceEditable()
          Returns TRUE if the object can be edited via a timeline object editor.
 boolean isParent()
          Determines whether the timeline object is a parent timeline object.
 boolean isSelectable()
          Returns TRUE if the timeline object can be selected.
 boolean isStartTimeChangeable()
          Returns TRUE if the start time of the object can be modified.
 void removeChild(ITimelineObject child)
          Removes the given timeline object from the list of children of this timeline object.
 void setChildren(java.util.Collection<ITimelineObject> children)
          Sets the given timeline objects as the children of this timeline object.
 void setChildren(ITimelineObject... children)
          Sets the given timeline objects as the children of this timeline object.
 void setDeletable(boolean deletable)
          Specifies whether the timeline object can be deleted by the user or not.
 void setDragActions(int actions)
          Specifies the drag actions that can be performed on the timeline object.
 void setDurationChangeable(boolean changeable)
          Determines whether or not the duration of the timeline object can be edited by the user.
 void setInPlaceEditable(boolean editable)
          Specifies whether or not the timeline object can be edited with the help of an ITimelineObjectEditor instance.
 void setLabel(java.lang.String label, LabelType type)
          Sets a new label for the given label type.
 void setLineIndex(int index)
          Specifies a line index.
 void setPopupObject(java.lang.Object object, boolean extended)
          Sets an object on the timeline object that will be used as input for the popup renderer.
 void setSelectable(boolean b)
          Specifies whether the timeline object can be selected.
 void setStartTimeChangeable(boolean changeable)
          Determines whether or not the start time of the timeline object can be edited by the user.
 void setStatus(java.lang.Object status)
          Sets an object that represents some kind of status that the timeline object is in.
 void setTimeSpan(ITimeSpan span)
          Sets the time allocation of the timeline object.
 void setUserObject(T obj)
          Sets the user object on the timeline object.
 java.lang.String toString()
           
 
Methods inherited from class com.dlsc.flexgantt.model.AbstractPropertiesOwner
getProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.dlsc.flexgantt.model.IPropertiesOwner
getProperty, setProperty
 

Constructor Detail

DefaultTimelineObject

public DefaultTimelineObject(java.lang.String name,
                             ITimeSpan timeSpan)
Constructs a new timeline object.

Parameters:
name - the name of the timeline object gets displayed in the status bar, the tooltip and in the title section of the popup window (except if separate values for those places have been specified via the setLabel(String, LabelType) method
timeSpan - the time span that is assigned to the timeline object (may be undefined, see TimeSpan.UNDEFINED).
Since:
1.0

DefaultTimelineObject

public DefaultTimelineObject(java.lang.String name)
Constructs a new timeline object with an undefined time span.

Parameters:
name - the name of the timeline object gets displayed in the status bar, the tooltip and in the title section of the popup window (except if separate values for those places have been specified via the setLabel(String, LabelType) method
Since:
1.0
See Also:
TimeSpan.UNDEFINED

DefaultTimelineObject

public DefaultTimelineObject(ITimeSpan timeSpan)
Constructs a new timeline object.

Parameters:
timeSpan - the time span that is assigned to the timeline object (may be undefined, see TimeSpan.UNDEFINED).
Since:
1.0

DefaultTimelineObject

public DefaultTimelineObject()
Constructs a new timeline object with an undefined time span.

Since:
1.0
See Also:
TimeSpan.UNDEFINED
Method Detail

setUserObject

public void setUserObject(T obj)
Sets the user object on the timeline object. User objects are often the actual business objects that are represented visually by the timeline object.

Parameters:
obj - the user object represented by the timeline object
Since:
1.0
See Also:
getUserObject()

getUserObject

public T getUserObject()
Returns the user object wrapped by the timeline object. User objects are often the actual business objects that are represented visually by the timeline object.

Returns:
the wrapped user object
Since:
1.0

getTimeSpan

public ITimeSpan getTimeSpan()
Description copied from interface: ITimelineObject
Returns the time allocation of the timeline object.

Specified by:
getTimeSpan in interface ITimelineObject
Returns:
the timeline's object time span
See Also:
ITimelineObject.setTimeSpan(ITimeSpan)

setTimeSpan

public void setTimeSpan(ITimeSpan span)
Description copied from interface: ITimelineObject
Sets the time allocation of the timeline object.

Specified by:
setTimeSpan in interface ITimelineObject
Parameters:
span - the object's time allocation
See Also:
ITimelineObject.getTimeSpan()

compareTo

public int compareTo(ITimelineObject tlo)
Specified by:
compareTo in interface java.lang.Comparable<ITimelineObject>

setLabel

public void setLabel(java.lang.String label,
                     LabelType type)
Sets a new label for the given label type. The LabelType enumerator specifies the context in which the label gets used: tooltip, popup, status bar.

Parameters:
label - the new label used for the given label type
type - the label type designating where the label will be used
Since:
1.0

getLabel

public java.lang.String getLabel(LabelType type)
Description copied from interface: ITimelineObject
Returns labels for various purposes depending on the given label type identifier.

Specified by:
getLabel in interface ITimelineObject
Parameters:
type - the type of label requested
Returns:
a label for the given purpose
See Also:
ILabelPolicy.getLabel(Object, Object, IGanttChartModel, LabelType)

isStartTimeChangeable

public boolean isStartTimeChangeable()
Description copied from interface: ITimelineObject
Returns TRUE if the start time of the object can be modified.

Specified by:
isStartTimeChangeable in interface ITimelineObject
Returns:
TRUE if the object can be modified
See Also:
IEditTimelineObjectPolicy.isStartTimeChangeable(Object, Object, IGanttChartModel)

setStartTimeChangeable

public void setStartTimeChangeable(boolean changeable)
Determines whether or not the start time of the timeline object can be edited by the user.

Parameters:
changeable - if TRUE the start time can be modified interactively by the user
Since:
1.0
See Also:
isStartTimeChangeable()

isDurationChangeable

public boolean isDurationChangeable()
Description copied from interface: ITimelineObject
Returns TRUE if the duration of the object can be modified.

Specified by:
isDurationChangeable in interface ITimelineObject
Returns:
TRUE if the object can be modified
See Also:
IEditTimelineObjectPolicy.isDurationChangeable(Object, Object, IGanttChartModel)

setDurationChangeable

public void setDurationChangeable(boolean changeable)
Determines whether or not the duration of the timeline object can be edited by the user.

Parameters:
changeable - if TRUE the duration can be modified interactively by the user
Since:
1.0
See Also:
isDurationChangeable(), IEditTimelineObjectPolicy.isDurationChangeable(Object, Object, IGanttChartModel), DefaultEditTimelineObjectPolicy, DefaultChangeTimelineObjectTimeSpanCommand

getPopupObject

public java.lang.Object getPopupObject(boolean extended)
Description copied from interface: ITimelineObject
Returns the object for the popup window.

Specified by:
getPopupObject in interface ITimelineObject
Parameters:
extended - a flag that signals whether the user wants to see the standard popup information or the extended version
Returns:
a title text for the poup
See Also:
PopupLayer, IPopupRenderer, DefaultPopupRenderer, IPopupPolicy.getPopupValue(Object, Object, IGanttChartModel, boolean)

setPopupObject

public void setPopupObject(java.lang.Object object,
                           boolean extended)
Sets an object on the timeline object that will be used as input for the popup renderer.

Parameters:
extended - a flag used to determine if the given object will be used as for the standard or the extended popup
object - the popup object that will be visualized by the popup layer and renderer
Since:
1.0
See Also:
IPopupRenderer, PopupLayer, IPopupPolicy

isSelectable

public boolean isSelectable()
Description copied from interface: ITimelineObject
Returns TRUE if the timeline object can be selected.

Specified by:
isSelectable in interface ITimelineObject
Returns:
TRUE if the timeline object can be selected
See Also:
ISelectionPolicy.isSelectable(Object, Object, IGanttChartModel)

setSelectable

public void setSelectable(boolean b)
Specifies whether the timeline object can be selected. Selected objects are added to the ITimelineObjectLayerSelectionModel of the layer on which they are displayed at the time of their selection.

Parameters:
b - if TRUE the timeline object can be selected by the user
Since:
1.0
See Also:
ITimelineObjectLayerSelectionModel.isSelected(TimelineObjectPath), ISelectionPolicy.isSelectable(Object, Object, IGanttChartModel)

isInPlaceEditable

public boolean isInPlaceEditable()
Description copied from interface: ITimelineObject
Returns TRUE if the object can be edited via a timeline object editor.

Specified by:
isInPlaceEditable in interface ITimelineObject
Returns:
TRUE if the object can be edited
See Also:
IEditTimelineObjectPolicy.isInPlaceEditable(Object, Object, IGanttChartModel), ITimelineObjectEditor

setInPlaceEditable

public void setInPlaceEditable(boolean editable)
Specifies whether or not the timeline object can be edited with the help of an ITimelineObjectEditor instance. These are user interface components that are added directly to the layer container so that no additional dialogs have to be opened.

Parameters:
editable - if TRUE the timeline object can be edited with an user interface component directly inside the layer container
Since:
1.0
See Also:
LayerContainer.setTimelineObjectEditor(Class, ITimelineObjectEditor), EditingLayer

setLineIndex

public void setLineIndex(int index)
Specifies a line index. This index gets only used if the hierarchy node uses lines within its row. Lines are used to display timeline objects without overlapping each other even if their time spans intersect. A row might use lines but still use its entire height to renderer timeline objects that use the row's full height. Those timeline objects have to use the value -1 as their line index.

Parameters:
index - the timeline object's line index, use -1 to have the object not use a line but the hierarchy node's entire row height
Since:
1.0
See Also:
getLineIndex(), ILinePolicy.getLineIndex(Object, ITreeTableModel, Object), IGanttChartNode.getLineCount(), IGanttChartNode.getLineLocation(int, int), IGanttChartNode.getLineHeight(int, int)

getLineIndex

public int getLineIndex()
Returns the object's line index. This index gets only used if the hierarchy node uses lines within its row. Lines are used to display timeline objects without overlapping each other even if their time spans intersect. A row might use lines but still use its entire height to renderer timeline objects that use the row's full height. Those timeline objects have to use the value -1 as their line index.

Specified by:
getLineIndex in interface ITimelineObject
Returns:
the index of the line on which the timeline object gets displayed (-1 if entire row height shall be used)
Since:
1.0
See Also:
setLineIndex(int), ILinePolicy.getLineIndex(Object, ITreeTableModel, Object), IGanttChartNode.getLineCount(), IGanttChartNode.getLineLocation(int, int), IGanttChartNode.getLineHeight(int, int)

setDeletable

public void setDeletable(boolean deletable)
Specifies whether the timeline object can be deleted by the user or not.

Parameters:
deletable - if TRUE the object can be deleted by the user
Since:
1.0
See Also:
IEditTimelineObjectPolicy.isDeletable(Object, Object, IGanttChartModel)

isDeletable

public boolean isDeletable()
Description copied from interface: ITimelineObject
Determines whether the timeline object can be deleted or not.

Specified by:
isDeletable in interface ITimelineObject
Returns:
TRUE if the object can be deleted
See Also:
IEditTimelineObjectPolicy.isDeletable(Object, Object, IGanttChartModel)

getStatus

public java.lang.Object getStatus()
Returns an object that represents some kind of status that the timeline object is in. The status can be used by the UI to control the appearance of the timeline objects. The OverviewPalette for example uses it to color the timeline objects in different colors depending on their current status.

Specified by:
getStatus in interface ITimelineObject
Returns:
the application-specific status of the timeline object
Since:
1.0

setStatus

public void setStatus(java.lang.Object status)
Sets an object that represents some kind of status that the timeline object is in. The status can be used by the UI to control the appearance of the timeline objects. The OverviewPalette for example uses it to color the timeline objects in different colors depending on their current status.

Parameters:
status - the application-specific status of the timeline object
Since:
1.0

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addChild

public void addChild(ITimelineObject child)
Adds another timeline object as a child to this timeline object. This will automatically turn this timeline object into a parent timeline object.

Parameters:
child - the child timeline object
Since:
1.0
See Also:
isParent()

removeChild

public void removeChild(ITimelineObject child)
Removes the given timeline object from the list of children of this timeline object. This timeline object is no longer a parent when all children have been removed.

Parameters:
child - the child to remove
Since:
1.0
See Also:
isParent()

setChildren

public void setChildren(ITimelineObject... children)
Sets the given timeline objects as the children of this timeline object. This timeline object will automatically become a parent timeline object.

Parameters:
children - the children timeline objects
Since:
1.0

setChildren

public void setChildren(java.util.Collection<ITimelineObject> children)
Sets the given timeline objects as the children of this timeline object. This timeline object will automatically become a parent timeline object.

Parameters:
children - the children timeline objects
Since:
1.0

isParent

public boolean isParent()
Description copied from interface: ITimelineObject
Determines whether the timeline object is a parent timeline object. A parent timeline object is associated with a list of children timeline objects. The time span of a parent is based on the overall time span of all of its children. Parent timeline objects often get visualized differently than their children.

Specified by:
isParent in interface ITimelineObject
Returns:
TRUE if the timeline object is a parent / contains children timeline objects
See Also:
ITimelineObject.getChildren()

getChildren

public java.util.Iterator<ITimelineObject> getChildren()
Description copied from interface: ITimelineObject
Returns an iterator over all children timeline objects of this timeline object. This method will only get called on those timeline objects that are parent timeline objects. It is used to calculate the overall time span used by the parent.

Specified by:
getChildren in interface ITimelineObject
Returns:
an iterator over all children timeline objects
See Also:
ITimelineObject.isParent()

setDragActions

public void setDragActions(int actions)
Specifies the drag actions that can be performed on the timeline object. Timeline objects can either be moved or copied. The desired behaviour can be specified by using the constants defined in DnDConstants. Possible values are: Declaring the drag actions is only half of the work needed for correct drag and drop behaviour. A timeline object might be draggable but it also needs a place where it can be dropped. The drop places are defined by IGanttChartNode.getDropActions(Object, long).

Parameters:
actions - the supported drag actions (move, copy, or both)
Since:
1.0
See Also:
DefaultDragAndDropCommand, IDragAndDropPolicy.getDragActions(Object, Object, IGanttChartModel)

getDragActions

public int getDragActions()
Description copied from interface: ITimelineObject
Returns the drag actions that can be performed on the timeline object. Timeline objects can either be moved or copied or both. The desired behaviour can be specified by using the constants defined in DnDConstants. Possible values are: Declaring the drag actions is only half of the work needed for correct drag and drop behaviour. A timeline object might be draggable but it also needs a place where it can be dropped. The drop places are defined by IGanttChartNode.getDropActions(Object, long).

Specified by:
getDragActions in interface ITimelineObject
Returns:
the supported drag actions (move, copy, or both)
See Also:
DefaultDragAndDropCommand, IDragAndDropPolicy.getDragActions(Object, Object, IGanttChartModel)