uci.gef
Class FigEdgePoly

java.lang.Object
  |
  +--uci.gef.Fig
        |
        +--uci.gef.FigEdge
              |
              +--uci.gef.FigEdgePoly
Direct Known Subclasses:
FigEdgeModelElement

public class FigEdgePoly
extends FigEdge

A Fig that paints edges between ports. This version automatically routes a rectilinear edge. The routing is not very good. It avoids the source and sink nodes and no other nodes. It is basically case-analysis, and some of the cases are wrong or missing. Anyway, the user can edit the edge by dragging handles. The 0th and last handles are fixed in position so that they stay connected to ports. If the user drags a handle next to a fixed handle, a new vertex is automatically inserted.

See Also:
FigPoly, Serialized Form

Inner classes inherited from class uci.gef.FigEdge
FigEdge.PathItem
 
Field Summary
protected  boolean _initiallyLaidOut
          True if the edge has been laid out automatically once.
 
Fields inherited from class uci.gef.FigEdge
_arrowHeadEnd, _arrowHeadStart, _destFigNode, _destPortFig, _fig, _highlight, _pathItems, _sourceFigNode, _sourcePortFig, _useNearest
 
Fields inherited from class uci.gef.Fig
_dashes, _fillColor, _filled, _group, _h, _layer, _lineColor, _lineWidth, _locked, _w, _x, _y, BORDER, DASH_ARRAYS, DASHED_CHOICES, MIN_SIZE
 
Constructor Summary
FigEdgePoly()
           
 
Method Summary
protected  void computeRoute()
          Find the route that the edge should follow.
protected  Point findAvoidPt(int fx, int fy, int x, int y, Rectangle avoid1, Rectangle avoid2)
          Find a point on the corner of one of the avoid rectangles that is a good intermediate point for the edge layout.
 void insertPoint(int i, int x, int y)
          Add a point to this polygon.
protected  void layoutEdge()
          Internal function to actually compute the layout of the line if it has never been done on that line before.
protected  Fig makeEdgeFig()
          Instanciate a FigPoly with its rectilinear flag set.
 void moveVertex(Handle h, int x, int y, boolean ov)
           
 void paint(Graphics g)
           
protected  Point routingRectPoint(Point p, Rectangle r, int sector)
          Reply a point on the given routing rect that is "straight out" from the connection point in the proper direction.
protected  boolean segOK(int x1, int y1, int x2, int y2, Rectangle avoid1, Rectangle avoid2)
          Reply true if the line segment from (x1, y1) to (x2, y2) does not intersect the given avoid rectangles.
 void setEndPoints(Point start, Point end)
          Set the end points of this polygon, regardless of the number of fixed handles.
 void setInitiallyLaidOut(boolean b)
           
 void setPoints(Handle h, int mX, int mY)
          When the user drags the handles, move individual points
protected  int tryRoute(int x, int y, int np, int[] xs, int[] ys, Rectangle avoid1, Rectangle avoid2, int srcSector, int dstSector)
          Try to find a route from the last point in (xs, ys) to point (x, y).
 
Methods inherited from class uci.gef.FigEdge
addPathItem, calcBounds, cleanUp, contains, delete, getBetweenNearestPoints, getBounds, getDashed, getDestArrowHead, getDestFigNode, getDestPortFig, getFig, getFirstPoint, getHighlight, getLastPoint, getLineColor, getLineWidth, getNumPoints, getPathItem, getPathItemsRaw, getPerimeterLength, getPoints, getPoints, getSourceArrowHead, getSourceFigNode, getSourcePortFig, getXs, getYs, hit, hitFig, intersects, isReshapable, isResizable, isRotatable, paintArrowHeads, paintHighlightLine, paintPathItems, postLoad, propertyChange, removePathItem, setBetweenNearestPoints, setDashed, setDestArrowHead, setDestFigNode, setDestPortFig, setFig, setHighlight, setLineColor, setLineWidth, setNumPoints, setOwner, setPoints, setPoints, setSourceArrowHead, setSourceFigNode, setSourcePortFig, setXs, setYs, stuffPointAlongPerimeter, translateEdge, updatePathItemLocations
 
Methods inherited from class uci.gef.Fig
addPoint, addPropertyChangeListener, align, center, classNameAndBounds, clone, connectionPoint, contains, contains, countCornersContained, createDrag, damage, dispose, drawDashedLine, drawDashedPerimeter, endTrans, firePropChange, firePropChange, firePropChange, getClosestPoint, getDashed01, getDashedString, getEnclosedFigs, getEnclosingFig, getFillColor, getFilled, getFilled01, getGravityPoints, getGroup, getHalfHeight, getHalfWidth, getHeight, getId, getLayer, getLocation, getLocked, getMinimumSize, getOwner, getPopUpActions, getPreferedSize, getSize, getTipString, getTrapRect, getUseTrapRect, getWidth, getX, getY, isLowerRightResizable, isMovable, makeSelection, OK, pointAlongPerimeter, postSave, preSave, print, removePoint, removePropertyChangeListener, reorder, routingRect, setBounds, setBounds, setDashedString, setEnclosingFig, setFillColor, setFilled, setGroup, setHeight, setLayer, setLocation, setLocation, setLocked, setPoints, setPoints, setSize, setSize, setWidth, setX, setY, startTrans, stuffBounds, translate, within
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_initiallyLaidOut

protected boolean _initiallyLaidOut
True if the edge has been laid out automatically once. It will not be done automatically again since the user may have edited the edge and I dont want to undo that work.
Constructor Detail

FigEdgePoly

public FigEdgePoly()
Method Detail

makeEdgeFig

protected Fig makeEdgeFig()
Instanciate a FigPoly with its rectilinear flag set. By default the FigPoly is black and the FigEdge has now ArrowHeads.
Overrides:
makeEdgeFig in class FigEdge

setInitiallyLaidOut

public void setInitiallyLaidOut(boolean b)

computeRoute

protected void computeRoute()
Find the route that the edge should follow. Basically case analysis to route around source and destination nodes. Needs-More-Work: A better algorithm would really be useful. Needs-More-Work: Sometimes the edge can get non-rectilinear.
Overrides:
computeRoute in class FigEdge

layoutEdge

protected void layoutEdge()
Internal function to actually compute the layout of the line if it has never been done on that line before.

routingRectPoint

protected Point routingRectPoint(Point p,
                                 Rectangle r,
                                 int sector)
Reply a point on the given routing rect that is "straight out" from the connection point in the proper direction.

tryRoute

protected int tryRoute(int x,
                       int y,
                       int np,
                       int[] xs,
                       int[] ys,
                       Rectangle avoid1,
                       Rectangle avoid2,
                       int srcSector,
                       int dstSector)
Try to find a route from the last point in (xs, ys) to point (x, y). Try to avoid the given rectangles along the way. Needs-More-Work: should allow a vector of rectangles to avoid.

findAvoidPt

protected Point findAvoidPt(int fx,
                            int fy,
                            int x,
                            int y,
                            Rectangle avoid1,
                            Rectangle avoid2)
Find a point on the corner of one of the avoid rectangles that is a good intermediate point for the edge layout.

segOK

protected boolean segOK(int x1,
                        int y1,
                        int x2,
                        int y2,
                        Rectangle avoid1,
                        Rectangle avoid2)
Reply true if the line segment from (x1, y1) to (x2, y2) does not intersect the given avoid rectangles.

moveVertex

public void moveVertex(Handle h,
                       int x,
                       int y,
                       boolean ov)

setPoints

public void setPoints(Handle h,
                      int mX,
                      int mY)
When the user drags the handles, move individual points
Overrides:
setPoints in class FigEdge

insertPoint

public void insertPoint(int i,
                        int x,
                        int y)
Add a point to this polygon. Fires PropertyChange with "bounds".
Overrides:
insertPoint in class Fig

setEndPoints

public void setEndPoints(Point start,
                         Point end)
Set the end points of this polygon, regardless of the number of fixed handles. This is used when nodes move.

paint

public void paint(Graphics g)
Overrides:
paint in class FigEdge