org.tigris.gef.presentation
Class FigEdgeRectiline

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

public class FigEdgeRectiline
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

Field Summary
protected  boolean _initiallyLaidOut
          True if the edge has been laid out automatically once.
 
Fields inherited from class org.tigris.gef.presentation.FigEdge
_arrowHeadEnd, _arrowHeadStart, _destFigNode, _fig, _highlight, _pathItems, _sourceFigNode, _useNearest
 
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
FigEdgeRectiline()
           
 
Method Summary
 void computeRoute()
          Find the route that the edge should follow.
protected  java.awt.Point findAvoidPt(int fx, int fy, int x, int y, java.awt.Rectangle avoid1, java.awt.Rectangle avoid2)
          Find a point on the corner of one of the avoid rectangles that is a good intermediate point for the edge layout.
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.
protected  java.awt.Point routingRectPoint(java.awt.Point p, java.awt.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, java.awt.Rectangle avoid1, java.awt.Rectangle avoid2)
          Reply true if the line segment from (x1, y1) to (x2, y2) does not intersect the given avoid rectangles.
protected  int tryRoute(int x, int y, int np, int[] xs, int[] ys, java.awt.Rectangle avoid1, java.awt.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 org.tigris.gef.presentation.FigEdge
addPathItem, calcBounds, cleanUp, contains, getBetweenNearestPoints, getBounds, getBounds, getDashed, getDestArrowHead, getDestFigNode, getDestPortFig, getFig, getFirstPoint, getHighlight, getLastPoint, getLineColor, getLineWidth, getNumPoints, getPathItem, getPathItemFig, getPathItemFigs, getPathItemsRaw, getPerimeterLength, getPoint, getPoints, getPrivateData, getSourceArrowHead, getSourceFigNode, getSourcePortFig, getXs, getYs, hasFillColor, hit, hitFig, intersects, isReshapable, isResizable, isRotatable, paint, paintArrowHeads, paintHighlightLine, paintPathItems, postLoad, propertyChange, removeFromDiagram, removePathItem, removePathItem, setBetweenNearestPoints, setDashed, setDestArrowHead, setDestFigNode, setDestPortFig, setFig, setHighlight, setLineColor, setLineWidth, setNumPoints, setOwner, setPoint, setPoint, setPoints, setSourceArrowHead, setSourceFigNode, setSourcePortFig, setXs, setYs, stuffPointAlongPerimeter, translateEdge, 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

_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

FigEdgeRectiline

public FigEdgeRectiline()
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.

Specified by:
makeEdgeFig in class FigEdge

computeRoute

public 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 java.awt.Point routingRectPoint(java.awt.Point p,
                                          java.awt.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,
                       java.awt.Rectangle avoid1,
                       java.awt.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 java.awt.Point findAvoidPt(int fx,
                                     int fy,
                                     int x,
                                     int y,
                                     java.awt.Rectangle avoid1,
                                     java.awt.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,
                        java.awt.Rectangle avoid1,
                        java.awt.Rectangle avoid2)
Reply true if the line segment from (x1, y1) to (x2, y2) does not intersect the given avoid rectangles.