gumbo.visualize.data.impl.swing
Class SwingGraphEdge

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.util.relation.AbstractTreeNodeDelegator
              |
              +--gumbo.graphic.space.AbstractSpaceNode
                    |
                    +--gumbo.graphic.impl.swing.SwingSpaceNode
                          |
                          +--gumbo.graphic.impl.swing.SwingShape
                                |
                                +--gumbo.visualize.data.impl.swing.SwingDataShape
                                      |
                                      +--gumbo.visualize.data.impl.swing.SwingGraphEdge
All Implemented Interfaces:
AxisBound3Boundable, AxisLayoutGraphic, BoundableGraphic, DataModelListener, Disposable, Graphic, GraphicGeometry, GraphicPresence, GraphicResource, GraphicView, InteractableGraphic, Interactor, IntersectableGraphic, KinkableGraphic, LinkingGraphic, java.io.Serializable, SpaceNode, TransformNode, TranslationNode

public class SwingGraphEdge
extends SwingDataShape
implements KinkableGraphic

A default graph edge implemented using a JComponent. Intended for use with SwingGraphView and a layout engine, such as GraphLayoutEngine, which control layout. The edge will appear as a series of straight line segements, defined by end and kink points, from tail to head, with an arrow head decoration at its head end.

Rendering a linear shape in Swing requires a GeneralPath, which is a dosplay list describing the shape and its decorations. The path is rendered by "stroking" it using a specific line width, which affects the shape bounds. Because of a seeming bug in Swing, pre-stroking the path is adequate for use as the shape bound but not for rendering. As such, a separate path and shape are maintained. Note that the shape points and path are maintained relative to the view space origin, not the shape translation origin (i.e. translating this shape changes the position of its end points and bound, which is consistent with a content transforming node). TODO: Add auto-label support.

Version:
$Revision: 1.1 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.
See Also:
Serialized Form

Field Summary
static java.awt.Color COLOR
          Line and decoration color.
static float DECO_SIZE
          Default line decoration size in pixels (>=0).
static float LINE_WIDTH
          Default line width in pixels (>=0).
 
Constructor Summary
SwingGraphEdge(PartView view)
           
 
Method Summary
 void addGraphicLinkEnd(Point3 point)
           
 void addGraphicLinkKink(Point3 point)
          Adds a kink point to the end of the kink point list.
 void clearGraphicLinkEnds()
           
 void clearGraphicLinkKinks()
          Clears the kink point list.
protected  void drawShape(java.awt.Color color)
          Called by the system to build and realize the graphic's shape.
 Size3 getGraphicLinkDecoSize(Size3 retVal)
          Gets the approximate size of the linking graphic decorations and, indirectly, the line width.
 Point3 getGraphicLinkEnd(int index, Point3 retVal)
          Gets the specified kink point in the kink point list.
 int getGraphicLinkEndCount()
          Gets the number of end points in the end point list.
 Point3 getGraphicLinkKink(int index, Point3 retVal)
          Gets the specified kink point in the kink point list.
 int getGraphicLinkKinkCount()
          Gets the number of kink points in the kink point list.
protected  void implDispose()
          Disposes the super, then self.
 void prepareGraphicPresence()
          Informs this graphic entity that, in anticipation of realization, it should update as needed those aspects of its graphic state (geometry, appearance) and that of any dependents (siblings, descendants) that can affect its presentation.
 void realizeGraphicPresence()
          Informs this graphic entity that external (sibling, ancestor) and internal (self, descendant) state changes that can affect its presentation are complete and assumed valid, and that it should update its presentation as needed to be consistent with its graphic state.
 void removeGraphicLinkEnd(int index)
           
 void removeGraphicLinkKink(int index)
          Removes the specified kink point from the kink point list.
 void setGraphicLinkDecoSize(Size3 size)
          Sets a hint for the size of the linking graphic decorations.
 void setGraphicLinkEnd(int index, Point3 point)
          Sets the specified end point in the end point list.
 void setGraphicLinkKink(int index, Point3 point)
          Sets the specified kink point in the kink point list.
 void setGraphicTranslation(Point3 trans)
          Transforms content, not space, by setting the position of points, shape, and bounds.
protected  void updateFeedback()
          Default implementation: Calls drawShape(), with the color determined by DataFeedback.INSTANCE.feedbackColor().
 
Methods inherited from class gumbo.visualize.data.impl.swing.SwingDataShape
clientDataChanged, getAutoLabel, getDataView, initSwingDataShape
 
Methods inherited from class gumbo.graphic.impl.swing.SwingShape
getInteractorState, initSwingShape, newTreeNodeDelegate
 
Methods inherited from class gumbo.graphic.impl.swing.SwingSpaceNode
canIntersectGraphic, getGraphic, getGraphicAxisBound3, getGraphicLocalSpace, getGraphicTransform, getGraphicTranslation, initSwingSpaceNode, intersectGraphic, isSpaceTransforming
 
Methods inherited from class gumbo.graphic.space.AbstractSpaceNode
getGraphicSpaceTree
 
Methods inherited from class gumbo.util.relation.AbstractTreeNodeDelegator
getTreeNodeDelegate
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gumbo.graphic.Graphic
getGraphic
 
Methods inherited from interface gumbo.util.Disposable
dispose, isDisposed
 
Methods inherited from interface gumbo.graphic.probe.AxisBound3Boundable
getGraphicAxisBound3
 
Methods inherited from interface gumbo.graphic.space.GraphicGeometry
getGraphicLocalSpace
 
Methods inherited from interface gumbo.graphic.space.TranslationNode
getGraphicTranslation
 
Methods inherited from interface gumbo.graphic.space.TransformNode
getGraphicTransform, isSpaceTransforming
 
Methods inherited from interface gumbo.graphic.space.SpaceNode
getGraphicSpaceTree
 

Field Detail

COLOR

public static final java.awt.Color COLOR
Line and decoration color.


LINE_WIDTH

public static final float LINE_WIDTH
Default line width in pixels (>=0).

See Also:
Constant Field Values

DECO_SIZE

public static final float DECO_SIZE
Default line decoration size in pixels (>=0).

See Also:
Constant Field Values
Constructor Detail

SwingGraphEdge

public SwingGraphEdge(PartView view)
Method Detail

drawShape

protected void drawShape(java.awt.Color color)
Called by the system to build and realize the graphic's shape. By convention, line color is used exclusively for interaction feedback. Default implementation: Sets the graphic's foreground color to the specified color, and then calls prepareGraphicPresence() and realizeGraphicPresence.

Parameters:
color - The dominant line color. Never null.

updateFeedback

protected void updateFeedback()
Default implementation: Calls drawShape(), with the color determined by DataFeedback.INSTANCE.feedbackColor().

Overrides:
updateFeedback in class SwingShape

setGraphicTranslation

public void setGraphicTranslation(Point3 trans)
Transforms content, not space, by setting the position of points, shape, and bounds.

Specified by:
setGraphicTranslation in interface TranslationNode
Overrides:
setGraphicTranslation in class SwingSpaceNode
Parameters:
trans - Value of the transformation. Never null.

prepareGraphicPresence

public void prepareGraphicPresence()
Description copied from interface: GraphicPresence
Informs this graphic entity that, in anticipation of realization, it should update as needed those aspects of its graphic state (geometry, appearance) and that of any dependents (siblings, descendants) that can affect its presentation. Does not actually affect the presentation (see realizeGraphicDisplay()). Allows for efficient batching of graphic state changes.

Specified by:
prepareGraphicPresence in interface GraphicPresence
Overrides:
prepareGraphicPresence in class SwingSpaceNode

realizeGraphicPresence

public void realizeGraphicPresence()
Description copied from interface: GraphicPresence
Informs this graphic entity that external (sibling, ancestor) and internal (self, descendant) state changes that can affect its presentation are complete and assumed valid, and that it should update its presentation as needed to be consistent with its graphic state. Allows for efficient batching of graphic state realizations.

Specified by:
realizeGraphicPresence in interface GraphicPresence
Overrides:
realizeGraphicPresence in class SwingSpaceNode

getGraphicLinkEndCount

public int getGraphicLinkEndCount()
Description copied from interface: LinkingGraphic
Gets the number of end points in the end point list.

Specified by:
getGraphicLinkEndCount in interface LinkingGraphic
Returns:
End point count.

setGraphicLinkEnd

public void setGraphicLinkEnd(int index,
                              Point3 point)
Description copied from interface: LinkingGraphic
Sets the specified end point in the end point list.

Specified by:
setGraphicLinkEnd in interface LinkingGraphic
Parameters:
index - Index of the point to set.
point - Value of the point. Never null.

getGraphicLinkEnd

public Point3 getGraphicLinkEnd(int index,
                                Point3 retVal)
Description copied from interface: LinkingGraphic
Gets the specified kink point in the kink point list.

Specified by:
getGraphicLinkEnd in interface LinkingGraphic
Parameters:
index - Index of the point to get.
retVal - Return value object. Value of the point. Never null.
Returns:
Reference to retVal. Never null.

addGraphicLinkEnd

public void addGraphicLinkEnd(Point3 point)

removeGraphicLinkEnd

public void removeGraphicLinkEnd(int index)

clearGraphicLinkEnds

public void clearGraphicLinkEnds()

setGraphicLinkDecoSize

public void setGraphicLinkDecoSize(Size3 size)
Description copied from interface: LinkingGraphic
Sets a hint for the size of the linking graphic decorations. Typically set to less than one half the size of the gap between linkable shapes. Depending on the graphic, it may ignore the size or only use the smallest dimension, etc.

Specified by:
setGraphicLinkDecoSize in interface LinkingGraphic
Parameters:
size - Value of the size (>=0). Never null.

getGraphicLinkDecoSize

public Size3 getGraphicLinkDecoSize(Size3 retVal)
Description copied from interface: LinkingGraphic
Gets the approximate size of the linking graphic decorations and, indirectly, the line width. (See setGraphicLinkSize()).

Specified by:
getGraphicLinkDecoSize in interface LinkingGraphic
Parameters:
retVal - Return value object. Value of the size. Never null.

getGraphicLinkKinkCount

public int getGraphicLinkKinkCount()
Description copied from interface: KinkableGraphic
Gets the number of kink points in the kink point list.

Specified by:
getGraphicLinkKinkCount in interface KinkableGraphic
Returns:
Kink point count.

setGraphicLinkKink

public void setGraphicLinkKink(int index,
                               Point3 point)
Description copied from interface: KinkableGraphic
Sets the specified kink point in the kink point list.

Specified by:
setGraphicLinkKink in interface KinkableGraphic
Parameters:
index - Index of the point to set.
point - Value of the point. Never null.

getGraphicLinkKink

public Point3 getGraphicLinkKink(int index,
                                 Point3 retVal)
Description copied from interface: KinkableGraphic
Gets the specified kink point in the kink point list.

Specified by:
getGraphicLinkKink in interface KinkableGraphic
Parameters:
index - Index of the point to get.
retVal - Return value object. Value of the point. Never null.
Returns:
Reference to retVal. Never null.

addGraphicLinkKink

public void addGraphicLinkKink(Point3 point)
Description copied from interface: KinkableGraphic
Adds a kink point to the end of the kink point list.

Specified by:
addGraphicLinkKink in interface KinkableGraphic
Parameters:
point - Value of the point position. Never null.

removeGraphicLinkKink

public void removeGraphicLinkKink(int index)
Description copied from interface: KinkableGraphic
Removes the specified kink point from the kink point list.

Specified by:
removeGraphicLinkKink in interface KinkableGraphic
Parameters:
index - Index of the point to remove.

clearGraphicLinkKinks

public void clearGraphicLinkKinks()
Description copied from interface: KinkableGraphic
Clears the kink point list.

Specified by:
clearGraphicLinkKinks in interface KinkableGraphic

implDispose

protected void implDispose()
Disposes the super, then self.

Overrides:
implDispose in class SwingDataShape