com.dlsc.flexgantt.swing.layer.system
Class DefaultRelationshipRenderer

java.lang.Object
  extended by com.dlsc.flexgantt.swing.layer.system.DefaultRelationshipRenderer
All Implemented Interfaces:
IRelationshipRenderer

public class DefaultRelationshipRenderer
extends java.lang.Object
implements IRelationshipRenderer

The default relationship renderer draws a multi edge line from the source to the target timeline object. The renderer can be customized to use different line strokes and paints. These differently colored relationship renderers can then be mapped to different types of relationships.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
RelationshipLayer.setRelationshipRenderer(Class, IRelationshipRenderer)

Nested Class Summary
static class DefaultRelationshipRenderer.TargetLocation
          An enumerator of possible locations that the target object can have relative to the source object.
 
Constructor Summary
DefaultRelationshipRenderer()
          Constructs a new relationship renderer.
 
Method Summary
 void drawRelationship(RelationshipLayer layer, java.awt.Graphics g, IRelationship relationship)
          Draws a relationship between two timeline objects.
 int getArrowSize()
           
 int getCornerSize()
           
 int getGap()
           
 java.awt.Paint getLinePaint()
          Returns the default line paint that will be used to draw the lines of a relationship.
protected  java.awt.Paint getLinePaint(IRelationship rel, IGanttChartModel model)
          Returns the paint that will be used for drawing the given relationship.
 java.awt.BasicStroke getLineStroke()
          Returns the default line stroke that will be used to draw the lines of a relationship.
protected  java.awt.Stroke getLineStroke(IRelationship rel, IGanttChartModel model)
          Returns the stroke that will be used for drawing the given relationship.
 int getOffset()
           
protected  void paintArrowHead(java.awt.Graphics g, IRelationship rel, int x, int y)
          Draws an arrow at the end of the relationship line.
protected  void paintRelationshipLine(java.awt.Graphics g, IRelationship rel, int[] x, int[] y)
          Draws the relationship by taking the incoming x- and y-coordinates to draw a polyline.
 void setArrowSize(int arrowSize)
           
 void setCornerSize(int cornerSize)
           
 void setGap(int gap)
           
 void setLinePaint(java.awt.Paint paint)
          Sets the default line paint that will be used to draw the lines of a relationship.
 void setLineStroke(java.awt.BasicStroke stroke)
          Sets the default line stroke that will be used to draw the lines of a relationship.
 void setOffset(int offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRelationshipRenderer

public DefaultRelationshipRenderer()
Constructs a new relationship renderer.

Since:
1.0
Method Detail

drawRelationship

public void drawRelationship(RelationshipLayer layer,
                             java.awt.Graphics g,
                             IRelationship relationship)
Description copied from interface: IRelationshipRenderer
Draws a relationship between two timeline objects. This is usually a line that starts at the source object and ends at the target object (with an arrow head pointing towards the target).

Specified by:
drawRelationship in interface IRelationshipRenderer
Parameters:
layer - the relationship layer in which the drawing takes place
g - the graphics context into which to draw
relationship - the relationship object in need of rendering

paintRelationshipLine

protected void paintRelationshipLine(java.awt.Graphics g,
                                     IRelationship rel,
                                     int[] x,
                                     int[] y)
Draws the relationship by taking the incoming x- and y-coordinates to draw a polyline.

Parameters:
g - the graphics context into which to draw
rel - the relationship that gets drawn
x - the x-coordinates array of the line
y - the y-coordinates array of the line
Since:
1.0

paintArrowHead

protected void paintArrowHead(java.awt.Graphics g,
                              IRelationship rel,
                              int x,
                              int y)
Draws an arrow at the end of the relationship line.

Parameters:
g - the graphics context to use for the drawing operations
rel - the relationship to draw
x - the starting x coordinate
y - the starting y coordinate
Since:
1.0

getLinePaint

public java.awt.Paint getLinePaint()
Returns the default line paint that will be used to draw the lines of a relationship.

Returns:
a paint object used for drawing the relationship lines
Since:
1.0

setLinePaint

public void setLinePaint(java.awt.Paint paint)
Sets the default line paint that will be used to draw the lines of a relationship.

Parameters:
paint - the paint object that will be used as a default for drawing the lines of a relationship
Since:
1.0

getLineStroke

public java.awt.BasicStroke getLineStroke()
Returns the default line stroke that will be used to draw the lines of a relationship.

Returns:
a stroke object used for drawing the relationship lines
Since:
1.0

setLineStroke

public void setLineStroke(java.awt.BasicStroke stroke)
Sets the default line stroke that will be used to draw the lines of a relationship.

Parameters:
stroke - the stroke object that will be used as a default for drawing the lines of a relationship
Since:
1.0

getArrowSize

public int getArrowSize()
Returns:
the arrowSize
Since:
1.0

setArrowSize

public void setArrowSize(int arrowSize)
Parameters:
arrowSize - the arrowSize to set
Since:
1.0

getCornerSize

public int getCornerSize()
Returns:
the cornerSize
Since:
1.0

setCornerSize

public void setCornerSize(int cornerSize)
Parameters:
cornerSize - the cornerSize to set
Since:
1.0

getOffset

public int getOffset()
Returns:
the offset
Since:
1.0

setOffset

public void setOffset(int offset)
Parameters:
offset - the offset to set
Since:
1.0

getGap

public int getGap()
Returns:
the gap
Since:
1.0

setGap

public void setGap(int gap)
Parameters:
gap - the gap to set
Since:
1.0

getLineStroke

protected java.awt.Stroke getLineStroke(IRelationship rel,
                                        IGanttChartModel model)
Returns the stroke that will be used for drawing the given relationship.

Parameters:
rel - the relationship for which a stroke gets looked up
model - the Gantt chart model to which the relationship belongs
Returns:
a stroke used for drawing the relationship lines
Since:
1.0

getLinePaint

protected java.awt.Paint getLinePaint(IRelationship rel,
                                      IGanttChartModel model)
Returns the paint that will be used for drawing the given relationship.

Parameters:
rel - the relationship for which a paint gets looked up
model - the Gantt chart model to which the relationship belongs
Returns:
a paint used for drawing the relationship lines
Since:
1.0