org.tigris.gef.presentation
Class FigEdge

java.lang.Object
  extended by org.tigris.gef.presentation.Fig
      extended by org.tigris.gef.presentation.FigEdge
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Connecter, Highlightable, PopupGenerator
Direct Known Subclasses:
FigEdgeLine, FigEdgePoly, FigEdgeRectiline

public abstract class FigEdge
extends Fig
implements Connecter

Abastract Fig class for representing edges between ports.

See Also:
FigEdgeLine, FigEdgeRectiline, Serialized Form

Field Summary
protected  ArrowHead _arrowHeadEnd
          The ArrowHead at the end of the line
protected  ArrowHead _arrowHeadStart
          The ArrowHead at the start of the line
protected  FigNode _destFigNode
          FigNode presenting the edge's to-port's parent node.
protected  Fig _fig
          Fig that presents the edge.
protected  boolean _highlight
          True when the FigEdgde should be drawn highlighted.
protected  java.util.Vector _pathItems
          The items that are accumulated along the path, a vector.
protected  FigNode _sourceFigNode
          FigNode presenting the edge's from-port's parent node.
protected  boolean _useNearest
          True if the FigEdge should be drawn from the nearest point of each port Fig.
 
Fields inherited from class org.tigris.gef.presentation.Fig
_allowsSaving, _context, _dashes, _dashPeriod, _dashStyle, _filled, _h, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, MIN_SIZE
 
Constructor Summary
FigEdge()
          Contruct a new FigEdge without any underlying edge.
FigEdge(Fig s, Fig d, FigNode sfn, FigNode dfn, java.lang.Object edge)
          Contruct a new FigEdge with the given source and destination port figs and FigNodes.
 
Method Summary
 void addPathItem(Fig newFig, PathConv newPath)
          Add a new path item to this FigEdge.
 void calcBounds()
          Update my bounding box
 void cleanUp()
           
 void computeRoute()
          Method to compute the route a FigEdge should follow.
 boolean contains(int x, int y)
          Reply true if the given point is inside the given Fig.
 boolean getBetweenNearestPoints()
          Get and set the flag about using Fig connection points rather than centers.
 java.awt.Rectangle getBounds()
          Reply the bounding box for this FigEdge.
 java.awt.Rectangle getBounds(java.awt.Rectangle r)
          Reply the bounding box for this FigEdge.
 boolean getDashed()
          Get the dashed attribute
 ArrowHead getDestArrowHead()
          Get the ArrowHead at the end of this FigEdge.
 Fig getDestFigNode()
          USED BY PGML.tee
 Fig getDestPortFig()
          USED BY PGML.tee
 Fig getFig()
          Return the Fig that will be drawn.
 java.awt.Point getFirstPoint()
          The first point ion an edge USED BY PGML.tee
 boolean getHighlight()
           
 java.awt.Point getLastPoint()
           
 java.awt.Color getLineColor()
          USED BY PGML.tee
 int getLineWidth()
          USED BY PGML.tee
 int getNumPoints()
           
 Fig getPathItem(PathConv pointOnPath)
          Return the path item on this FigEdge closest to the given location.
 Fig getPathItemFig(org.tigris.gef.presentation.FigEdge.PathItem pathItem)
          Return the fig of a given path item.
 java.util.Vector getPathItemFigs()
          Return all figs of the path items
 java.util.Vector getPathItemsRaw()
          Return the vector of path items on this FigEdge.
 int getPerimeterLength()
          Return the length of the path around this Fig.
 java.awt.Point getPoint(int i)
           
 java.awt.Point[] getPoints()
           
 java.lang.String getPrivateData()
          TODO document Used in SVG.TEE
 ArrowHead getSourceArrowHead()
          Get the ArrowHead at the start of this FigEdge.
 Fig getSourceFigNode()
          USED BY PGML.tee
 Fig getSourcePortFig()
          USED BY PGML.tee
 int[] getXs()
           
 int[] getYs()
           
 boolean hasFillColor()
          An edge cannot be filled with color
 boolean hit(java.awt.Rectangle r)
          Determine if the given rectangle contains some pixels of the Fig.
 Fig hitFig(java.awt.Rectangle r)
           
 boolean intersects(java.awt.Rectangle r)
          Reply true if the object intersects the given rectangle.
 boolean isReshapable()
          Returns true if this Fig can be reshaped by the user.
 boolean isResizable()
          Determine if this Fig can be resized
 boolean isRotatable()
          Returns true if this Fig can be rotated by the user.
protected abstract  Fig makeEdgeFig()
          Abstract method to make the Fig that will be drawn for this FigEdge.
 void paint(java.awt.Graphics g)
          Paint this FigEdge.
protected  void paintArrowHeads(java.awt.Graphics g)
          Paint ArrowHeads on this FigEdge.
 void paintHighlightLine(java.awt.Graphics g, int x1, int y1, int x2, int y2)
           
protected  void paintPathItems(java.awt.Graphics g)
          Paint any labels that are located relative to this FigEdge.
 void postLoad()
          After the file is loaded, re-establish any connections from the model to the Figs
 void propertyChange(java.beans.PropertyChangeEvent pce)
          By default just pass it up to enclosing groups.
 void removeFromDiagram()
          Remove this Fig from the Layer it belongs to.
 void removePathItem(Fig goneFig)
           
 void removePathItem(org.tigris.gef.presentation.FigEdge.PathItem goneItem)
          Removes the given path item.
 void setBetweenNearestPoints(boolean un)
           
 void setDashed(boolean d)
          Set line to be dashed or not
 void setDestArrowHead(ArrowHead newArrow)
          Set the ArrowHead at the end of this FigEdge.
 void setDestFigNode(FigNode fn)
          Set the FigNode reprenting this FigEdge's to-node.
 void setDestPortFig(Fig fig)
          Set the Fig reprenting this FigEdge's to-port.
 void setFig(Fig f)
           
 void setHighlight(boolean b)
           
 void setLineColor(java.awt.Color c)
          Sets the line color of the edge and of soure/destination arrows.
 void setLineWidth(int w)
          Set the line width.
 void setNumPoints(int npoints)
           
 void setOwner(java.lang.Object own)
          Set the edge (some object in an underlying model) that this FigEdge should represent.
 void setPoint(Handle h, int x, int y)
           
 void setPoint(int i, int x, int y)
           
 void setPoints(java.awt.Point[] ps)
          Get and set the points along a path for Figs that are path-like.
 void setSourceArrowHead(ArrowHead newArrow)
          Set the ArrowHead at the start of this FigEdge.
 void setSourceFigNode(FigNode fn)
          Set the FigNode reprenting this FigEdge's from-node.
 void setSourcePortFig(Fig fig)
          Get the Fig reprenting this FigEdge's from-port.
 void setXs(int[] xs)
           
 void setYs(int[] ys)
           
 void stuffPointAlongPerimeter(int dist, java.awt.Point res)
           
 void translateEdge(int dx, int dy)
           
 void updatePathItemLocations()
           
 
Methods inherited from class org.tigris.gef.presentation.Fig
addAnnotation, addPoint, addPropertyChangeListener, align, center, classNameAndBounds, clone, connectionPoint, contains, contains, countCornersContained, createDrag, damage, deleteFromModel, drawDashedLine, drawDashedPerimeter, endTrans, firePropChange, firePropChange, firePropChange, getAnnotationOwner, getAnnotationStrategy, getClosestPoint, getContext, getDashed01, getDashedString, getEnclosedFigs, getEnclosingFig, getFillColor, getFilled, getFilled01, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHandleBox, getHeight, getId, getLayer, getLocation, getLocked, getMinimumSize, getOwner, getPopUpActions, getPreferredSize, getResource, getSingle, getSize, getTipString, getTrapRect, getUseTrapRect, getVisState, getWidth, getX, getY, hasLineColor, initAnnotations, insertPoint, intersectsPerimeter, isAnnotation, isCopyable, isCutable, isLowerRightResizable, isMovable, isSelected, isVisible, makeSelection, OK, pointAlongPerimeter, postSave, preSave, print, redraw, removeAnnotation, removeAnnotation, removePoint, removePropertyChangeListener, reorder, routingRect, savingAllowed, setAnnotationOwner, setAnnotationStatus, setAnnotationStrategy, setBounds, setBounds, setCenter, setContext, setDashedString, setEnclosingFig, setFillColor, setFilled, setGroup, setHandleBox, setHeight, setLayer, setLocation, setLocation, setLocked, setMovable, setPoint, setPoint, setPrivateData, setResizable, setResource, setSavingAllowed, setSingle, setSize, setSize, setVisible, setVisState, setWidth, setX, setY, stuffBounds, translate, translateAnnotations, unsetAnnotationOwner, updateAnnotationPositions, updateVisState, within
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tigris.gef.ui.Highlightable
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

_sourceFigNode

protected FigNode _sourceFigNode
FigNode presenting the edge's from-port's parent node.


_destFigNode

protected FigNode _destFigNode
FigNode presenting the edge's to-port's parent node.


_fig

protected Fig _fig
Fig that presents the edge.


_useNearest

protected boolean _useNearest
True if the FigEdge should be drawn from the nearest point of each port Fig.


_highlight

protected boolean _highlight
True when the FigEdgde should be drawn highlighted.


_arrowHeadStart

protected ArrowHead _arrowHeadStart
The ArrowHead at the start of the line


_arrowHeadEnd

protected ArrowHead _arrowHeadEnd
The ArrowHead at the end of the line


_pathItems

protected java.util.Vector _pathItems
The items that are accumulated along the path, a vector.

Constructor Detail

FigEdge

public FigEdge()
Contruct a new FigEdge without any underlying edge.


FigEdge

public FigEdge(Fig s,
               Fig d,
               FigNode sfn,
               FigNode dfn,
               java.lang.Object edge)
Contruct a new FigEdge with the given source and destination port figs and FigNodes. The new FigEdge will represent the given edge (an object from some underlying model).

Method Detail

addPathItem

public void addPathItem(Fig newFig,
                        PathConv newPath)
Add a new path item to this FigEdge. newPath indicates both the location and the Fig (usually FigText) that should be drawn.


calcBounds

public void calcBounds()
Update my bounding box

Overrides:
calcBounds in class Fig
See Also:
FigText.calcBounds()

cleanUp

public void cleanUp()
Overrides:
cleanUp in class Fig

computeRoute

public void computeRoute()
Method to compute the route a FigEdge should follow. By defualt this does nothing. Sublcasses, like FigEdgeRectiline override this method.


contains

public boolean contains(int x,
                        int y)
Description copied from class: Fig
Reply true if the given point is inside the given Fig. By default reply true if the point is in my bounding box. Subclasses like FigCircle and FigEdge do more specific checks.

Overrides:
contains in class Fig
See Also:
FigCircle, FigEdge

removeFromDiagram

public void removeFromDiagram()
Description copied from class: Fig
Remove this Fig from the Layer it belongs to.

Overrides:
removeFromDiagram in class Fig

getBetweenNearestPoints

public boolean getBetweenNearestPoints()
Get and set the flag about using Fig connection points rather than centers.


getBounds

public java.awt.Rectangle getBounds()
Reply the bounding box for this FigEdge.

Overrides:
getBounds in class Fig

getBounds

public java.awt.Rectangle getBounds(java.awt.Rectangle r)
Reply the bounding box for this FigEdge.

Overrides:
getBounds in class Fig
Parameters:
r - the return value, modified to the components bounds
Returns:
r

getDashed

public boolean getDashed()
Description copied from class: Fig
Get the dashed attribute

Overrides:
getDashed in class Fig

getDestArrowHead

public ArrowHead getDestArrowHead()
Get the ArrowHead at the end of this FigEdge.


getDestFigNode

public Fig getDestFigNode()
USED BY PGML.tee


getDestPortFig

public Fig getDestPortFig()
USED BY PGML.tee


getFig

public Fig getFig()
Return the Fig that will be drawn. USED BY PGML.tee


getFirstPoint

public java.awt.Point getFirstPoint()
The first point ion an edge USED BY PGML.tee

Overrides:
getFirstPoint in class Fig

getHighlight

public boolean getHighlight()
Specified by:
getHighlight in interface Highlightable

getLastPoint

public java.awt.Point getLastPoint()
Overrides:
getLastPoint in class Fig

getLineColor

public java.awt.Color getLineColor()
USED BY PGML.tee

Overrides:
getLineColor in class Fig

hasFillColor

public boolean hasFillColor()
An edge cannot be filled with color

Overrides:
hasFillColor in class Fig
Returns:
false

getLineWidth

public int getLineWidth()
USED BY PGML.tee

Overrides:
getLineWidth in class Fig

getNumPoints

public int getNumPoints()
Overrides:
getNumPoints in class Fig

getPathItem

public Fig getPathItem(PathConv pointOnPath)
Return the path item on this FigEdge closest to the given location. needs-more-work: not implemented yet.


getPathItemFig

public Fig getPathItemFig(org.tigris.gef.presentation.FigEdge.PathItem pathItem)
Return the fig of a given path item.


getPathItemFigs

public java.util.Vector getPathItemFigs()
Return all figs of the path items


getPathItemsRaw

public java.util.Vector getPathItemsRaw()
Return the vector of path items on this FigEdge.


getPerimeterLength

public int getPerimeterLength()
Description copied from class: Fig
Return the length of the path around this Fig. By default, returns the perimeter of the Fig's bounding box. Subclasses like FigPoly have more specific logic.

Overrides:
getPerimeterLength in class Fig

getPoints

public java.awt.Point[] getPoints()
Overrides:
getPoints in class Fig

getPoint

public java.awt.Point getPoint(int i)
Overrides:
getPoint in class Fig

getPrivateData

public java.lang.String getPrivateData()
TODO document Used in SVG.TEE

Overrides:
getPrivateData in class Fig

getSourceArrowHead

public ArrowHead getSourceArrowHead()
Get the ArrowHead at the start of this FigEdge.


getSourceFigNode

public Fig getSourceFigNode()
USED BY PGML.tee


getSourcePortFig

public Fig getSourcePortFig()
USED BY PGML.tee


getXs

public int[] getXs()
Overrides:
getXs in class Fig

getYs

public int[] getYs()
Overrides:
getYs in class Fig

hit

public boolean hit(java.awt.Rectangle r)
Description copied from class: Fig
Determine if the given rectangle contains some pixels of the Fig. This is used to determine if the user is trying to select this Fig. Rather than ask if the mouse point is in the Fig, I use a small rectangle around the mouse point so that small objects and lines are easier to select. If the fig is invisible this method always returns false.

Overrides:
hit in class Fig
Parameters:
r - the rectangular hit area
Returns:
true if the hit rectangle strikes this fig

hitFig

public Fig hitFig(java.awt.Rectangle r)

intersects

public boolean intersects(java.awt.Rectangle r)
Description copied from class: Fig
Reply true if the object intersects the given rectangle. Used for selective redrawing and by ModeSelect to select all Figs that are partly within the selection rectangle. Note: comparisons are strict (e.g. '<' instead of '<='), so that figs with zero height or width are handled correctly.

Overrides:
intersects in class Fig

isReshapable

public boolean isReshapable()
Description copied from class: Fig
Returns true if this Fig can be reshaped by the user.

Overrides:
isReshapable in class Fig

isResizable

public boolean isResizable()
Description copied from class: Fig
Determine if this Fig can be resized

Overrides:
isResizable in class Fig
Returns:
true if this Fig can be resized by the user.

isRotatable

public boolean isRotatable()
Description copied from class: Fig
Returns true if this Fig can be rotated by the user.

Overrides:
isRotatable in class Fig

makeEdgeFig

protected abstract Fig makeEdgeFig()
Abstract method to make the Fig that will be drawn for this FigEdge. In FigEdgeLine this method constructs a FigLine. In FigEdgeRectiline, this method constructs a FigPoly.


paint

public void paint(java.awt.Graphics g)
Paint this FigEdge. Needs-more-work: take Highlight into account

Overrides:
paint in class Fig

paintArrowHeads

protected void paintArrowHeads(java.awt.Graphics g)
Paint ArrowHeads on this FigEdge. Called from paint(). Determines placement and orientation by using pointAlongPerimeter().


paintHighlightLine

public void paintHighlightLine(java.awt.Graphics g,
                               int x1,
                               int y1,
                               int x2,
                               int y2)

paintPathItems

protected void paintPathItems(java.awt.Graphics g)
Paint any labels that are located relative to this FigEdge.


postLoad

public void postLoad()
After the file is loaded, re-establish any connections from the model to the Figs

Overrides:
postLoad in class Fig

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent pce)
Description copied from class: Fig
By default just pass it up to enclosing groups. Subclasses of FigNode may want to override this method.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class Fig

removePathItem

public void removePathItem(org.tigris.gef.presentation.FigEdge.PathItem goneItem)
Removes the given path item.


removePathItem

public void removePathItem(Fig goneFig)

setBetweenNearestPoints

public void setBetweenNearestPoints(boolean un)

setDashed

public void setDashed(boolean d)
Description copied from class: Fig
Set line to be dashed or not

Overrides:
setDashed in class Fig

setDestArrowHead

public void setDestArrowHead(ArrowHead newArrow)
Set the ArrowHead at the end of this FigEdge.


setDestFigNode

public void setDestFigNode(FigNode fn)
Set the FigNode reprenting this FigEdge's to-node.


setDestPortFig

public void setDestPortFig(Fig fig)
Set the Fig reprenting this FigEdge's to-port.


setFig

public void setFig(Fig f)

setHighlight

public void setHighlight(boolean b)
Specified by:
setHighlight in interface Highlightable

setLineColor

public void setLineColor(java.awt.Color c)
Sets the line color of the edge and of soure/destination arrows.

Overrides:
setLineColor in class Fig
Parameters:
c -

setLineWidth

public void setLineWidth(int w)
Description copied from class: Fig
Set the line width. Zero means lines are not drawn. One draws them one pixel wide. Larger widths are in experimental support stadium (hendrik@freiheit.com, 2003-02-05). Fires PropertyChangeEvent "lineWidth".

Overrides:
setLineWidth in class Fig
Parameters:
w - The new lineWidth value

setNumPoints

public void setNumPoints(int npoints)
Overrides:
setNumPoints in class Fig

setOwner

public void setOwner(java.lang.Object own)
Set the edge (some object in an underlying model) that this FigEdge should represent.

Overrides:
setOwner in class Fig

setPoints

public void setPoints(java.awt.Point[] ps)
Description copied from class: Fig
Get and set the points along a path for Figs that are path-like.

Overrides:
setPoints in class Fig

setPoint

public void setPoint(int i,
                     int x,
                     int y)
Overrides:
setPoint in class Fig

setPoint

public void setPoint(Handle h,
                     int x,
                     int y)
Overrides:
setPoint in class Fig

setSourceArrowHead

public void setSourceArrowHead(ArrowHead newArrow)
Set the ArrowHead at the start of this FigEdge.


setSourceFigNode

public void setSourceFigNode(FigNode fn)
Set the FigNode reprenting this FigEdge's from-node.


setSourcePortFig

public void setSourcePortFig(Fig fig)
Get the Fig reprenting this FigEdge's from-port.


setXs

public void setXs(int[] xs)
Overrides:
setXs in class Fig

setYs

public void setYs(int[] ys)
Overrides:
setYs in class Fig

stuffPointAlongPerimeter

public void stuffPointAlongPerimeter(int dist,
                                     java.awt.Point res)
Overrides:
stuffPointAlongPerimeter in class Fig

translateEdge

public void translateEdge(int dx,
                          int dy)

updatePathItemLocations

public void updatePathItemLocations()