com.dlsc.flexgantt.model.gantt
Class DefaultResourceNode<T,S extends ITimelineObject>

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by com.dlsc.flexgantt.model.treetable.DefaultMutableTreeTableNode<T>
          extended by com.dlsc.flexgantt.model.gantt.DefaultGanttChartNode<T,S>
              extended by com.dlsc.flexgantt.model.gantt.DefaultResourceNode<T,S>
Type Parameters:
T - the type of the wrapped user / business object
S - the type of the timeline objects returned by the node
All Implemented Interfaces:
IGanttChartNode<S>, IResourceNode<S>, IMutableTreeTableNode, ITreeTableNode, java.io.Serializable, java.lang.Cloneable, java.util.Comparator, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class DefaultResourceNode<T,S extends ITimelineObject>
extends DefaultGanttChartNode<T,S>
implements IResourceNode<S>

The default implementation of a Gantt chart node that represents a resource (e.g. a machine with a minimum and a maximum capacity). It is up to the application to decide whether the values for the minimum and the maximum capacity represent the minimum and maximum capacity used over the entire time horizon or whether these are the the minimum and maximum capacity supported by the machine.

The default configuration of the node is:

Using a maximum capacity of more than 100% allows the resource row renderer to visualize capacity overallocations.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
DefaultResourceNode()
          Constructs a new resource node.
DefaultResourceNode(boolean allowsChildren)
          Constructs a new resource node.
DefaultResourceNode(T userObject)
          Constructs a new resource node.
DefaultResourceNode(T userObject, boolean allowsChildren)
          Constructs a new resource node.
 
Method Summary
 void addMajorCapacityLine(CapacityLine line)
          Adds the given major capacity line to the resource node.
 void addMinorCapacityLine(CapacityLine line)
          Adds the given minor capacity line to the resource node.
 void clearMajorCapacityLines()
          Removes all major capacity lines from the resource node.
 void clearMinorCapacityLines()
          Removes all minor capacity lines from the resource node.
 double getCapacityAt(int rowHeight, int y)
          Returns the capacity value for the given y coordinate.
 java.util.List<CapacityLine> getCapacityLines(int rowHeight, boolean major)
          Returns a list of capacity lines that can be picked up by row renderers to draw a nice scale in the background of the resource row.
 int getCapacityLocation(int rowHeight, double capacity)
          Returns the location / y-coordinate of a given capacity for a given row height.
 double getMaximumCapacity()
          Returns the maximum capacity of the resource node.
 double getMinimumCapacity()
          Returns the minimum capacity of the resource node.
 void removeMajorCapacityLine(CapacityLine line)
          Removes the given major capacity line from the resource node.
 void removeMinorCapacityLine(CapacityLine line)
          Removes the given minor capacity line from the resource node.
 void setMaximumCapacity(double capacity)
          Sets the minimum capacity of the resource node.
 void setMinimumCapacity(double capacity)
          Sets the minimum capacity of the resource node.
 
Methods inherited from class com.dlsc.flexgantt.model.gantt.DefaultGanttChartNode
addTimelineObject, addTimelineObjects, addTimelineObjects, clearTimelineObjects, getDropActions, getLineCount, getLineHeight, getLineLocation, getTimelineObjects, getTimelineObjects, getTimelineObjectsIterator, getTimelineObjectsIterator, isSelectable, removeTimelineObject, removeTimelineObjects, removeTimelineObjects, setLineCount, setTimelineObject, setTimelineObjects, setTimelineObjects, sortTimelineObjects, validateTimelineObjectList
 
Methods inherited from class com.dlsc.flexgantt.model.treetable.DefaultMutableTreeTableNode
add, compare, compare, getColumnValue, getComparator, getDragActions, getDropActions, getKey, getKeyComparator, getRowHeaderValue, getRowHeight, getRowHeightMaximum, getRowHeightMinimum, getToolTipText, getTypedUserObject, getUserObject, insert, isDeletable, isKeyEditable, isResizable, isRowLineVisible, isSelectable, isSorting, isValueEditable, setColumnValue, setComparator, setDeletable, setDragActions, setKey, setKeyComparator, setKeyEditable, setResizable, setRowHeaderValue, setRowHeight, setRowHeightMaximum, setRowHeightMinimum, setRowLineVisible, setSelectable, setToolTipText, setTypedUserObject, setUserObject, setValueEditable, sort
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.dlsc.flexgantt.model.gantt.IGanttChartNode
addTimelineObjects, clearTimelineObjects, getDropActions, getLineCount, getLineHeight, getLineLocation, getTimelineObjects, getTimelineObjects, getTimelineObjectsIterator, isSelectable, removeTimelineObjects
 
Methods inherited from interface com.dlsc.flexgantt.model.treetable.ITreeTableNode
getColumnValue, getDragActions, getDropActions, getKey, getRowHeaderValue, getRowHeight, getRowHeightMaximum, getRowHeightMinimum, getToolTipText, isDeletable, isKeyEditable, isResizable, isRowLineVisible, isSelectable, isValueEditable, setColumnValue, setKey, setRowHeaderValue, setRowHeight, sort
 
Methods inherited from interface javax.swing.tree.TreeNode
children, getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf
 
Methods inherited from interface javax.swing.tree.MutableTreeNode
remove, remove, removeFromParent, setParent
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

DefaultResourceNode

public DefaultResourceNode(T userObject,
                           boolean allowsChildren)
Constructs a new resource node.

Parameters:
userObject - the wrapped user / business object
allowsChildren - a flag signalling whether the node allows child nodes at all
Since:
1.0

DefaultResourceNode

public DefaultResourceNode(T userObject)
Constructs a new resource node.

Parameters:
userObject - the wrapped user / business object
Since:
1.0

DefaultResourceNode

public DefaultResourceNode(boolean allowsChildren)
Constructs a new resource node.

Parameters:
allowsChildren - a flag signalling whether the node allows child nodes at all
Since:
1.0

DefaultResourceNode

public DefaultResourceNode()
Constructs a new resource node.

Since:
1.0
Method Detail

getCapacityLines

public java.util.List<CapacityLine> getCapacityLines(int rowHeight,
                                                     boolean major)
Description copied from interface: IResourceNode
Returns a list of capacity lines that can be picked up by row renderers to draw a nice scale in the background of the resource row.

Specified by:
getCapacityLines in interface IResourceNode<S extends ITimelineObject>
Parameters:
rowHeight - the height of the row in which the resource gets displayed
major - a flag signalling whether the application queries the major or the minor capacity lines
Returns:
a list of capacity lines that can be visualized in the Gantt chart

getCapacityLocation

public int getCapacityLocation(int rowHeight,
                               double capacity)
Description copied from interface: IResourceNode
Returns the location / y-coordinate of a given capacity for a given row height. This method is required for the correct placing of capacity lines.

Specified by:
getCapacityLocation in interface IResourceNode<S extends ITimelineObject>
Parameters:
rowHeight - the current height of the row in which the resource node gets displayed
capacity - the capacity for which to return a location
Returns:
the location of the given capacity (the y-coordinate within the coordinate space / interval [0, rowHeight])

getCapacityAt

public double getCapacityAt(int rowHeight,
                            int y)
Description copied from interface: IResourceNode
Returns the capacity value for the given y coordinate. The y coordinate uses the coordinate space of the row, which means that y = 0 is the bottom of the row.

Specified by:
getCapacityAt in interface IResourceNode<S extends ITimelineObject>
Parameters:
rowHeight - the height of the row
y - the location for which to return a capacity
Returns:
the capacity at the given location

addMajorCapacityLine

public void addMajorCapacityLine(CapacityLine line)
Adds the given major capacity line to the resource node.

Parameters:
line - the capacity line to add
Since:
1.0

removeMajorCapacityLine

public void removeMajorCapacityLine(CapacityLine line)
Removes the given major capacity line from the resource node.

Parameters:
line - the capacity line to remove
Since:
1.0

addMinorCapacityLine

public void addMinorCapacityLine(CapacityLine line)
Adds the given minor capacity line to the resource node.

Parameters:
line - the capacity line to add
Since:
1.0

removeMinorCapacityLine

public void removeMinorCapacityLine(CapacityLine line)
Removes the given minor capacity line from the resource node.

Parameters:
line - the capacity line to remove
Since:
1.0

clearMajorCapacityLines

public void clearMajorCapacityLines()
Removes all major capacity lines from the resource node.

Since:
1.0

clearMinorCapacityLines

public void clearMinorCapacityLines()
Removes all minor capacity lines from the resource node.

Since:
1.0

getMaximumCapacity

public double getMaximumCapacity()
Returns the maximum capacity of the resource node.

Specified by:
getMaximumCapacity in interface IResourceNode<S extends ITimelineObject>
Returns:
the maximum capacity of the resource node
Since:
1.0

setMaximumCapacity

public void setMaximumCapacity(double capacity)
Sets the minimum capacity of the resource node.

Parameters:
capacity - the maximum capacity of the resource node
Since:
1.0

getMinimumCapacity

public double getMinimumCapacity()
Returns the minimum capacity of the resource node.

Specified by:
getMinimumCapacity in interface IResourceNode<S extends ITimelineObject>
Returns:
the minimum capacity of the resource node
Since:
1.0

setMinimumCapacity

public void setMinimumCapacity(double capacity)
Sets the minimum capacity of the resource node.

Parameters:
capacity - the minimum capacity of the resource node
Since:
1.0