The default implementation of an edge view. The getEdgeRenderer method
assumes a renderer of type EdgeRenderer. If you provide a custom renderer to
a subclass, you must also override the methods that call this method, namely:
getShape, getLabelBounds, getExtraLabelBounds, intersects and getBounds.
beginShape
public Shape beginShape
Drawing attributes that are created on the fly
cachedBounds
protected Rectangle2D cachedBounds
endShape
public Shape endShape
Drawing attributes that are created on the fly
extraLabelPositions
protected Point2D[] extraLabelPositions
labelPosition
protected Point2D labelPosition
Cached label position of the edge.
labelVector
protected Point2D labelVector
lineShape
public Shape lineShape
Drawing attributes that are created on the fly
points
protected List points
List of points of the edge. May contain ports.
renderer
public static EdgeRenderer renderer
Renderer for the class.
sharedPath
public GeneralPath sharedPath
Shared-path tune-up.
source
protected CellView source
Cached source and target portview of the edge.
sourceParentView
protected CellView sourceParentView
target
protected CellView target
Cached source and target portview of the edge.
targetParentView
protected CellView targetParentView
addExtraLabel
public void addExtraLabel(Point2D location,
Object label)
Adds an extra label.
addPoint
public void addPoint(int index,
Point2D p)
Adds p
at position index
.
checkDefaultLabelPosition
protected void checkDefaultLabelPosition()
Hook for subclassers to avoid default label positions.
getExtraLabelPosition
public Point2D getExtraLabelPosition(int index)
Returns a point that describes the position of the label.
getLabelPosition
public Point2D getLabelPosition()
Returns a point that describes the position of the label.
getLabelVector
public Point2D getLabelVector()
Hook to return the vector that is taken as the base vector to compute
relative label positions. Normally, the vector goes from the first to the
last point on the edge, unless these points are equal, in which case the
average distance of all points to the source point is used.
getLength
public static double getLength(CellView view)
getNearestPoint
protected Point2D getNearestPoint(boolean source)
Returns the nearest point wrt to the source or target. This method
returns the next or previous point or port in the points list, eg. if
source is true it returns the location of the point or port at index 1
without calling the getLocation method on any ports.
Likewise, the method returns the location at index getPointCount()-2 if
source is false.
getPerimeterPoint
public Point2D getPerimeterPoint(EdgeView edge,
Point2D source,
Point2D p)
Returns the intersection of the bounding rectangle and the straight line
between the source and the specified point p. The specified point is
expected not to intersect the bounds. Note: You must override this method
if you use a different renderer. This is because this method relies on
the VertexRenderer interface, which can not be safely assumed for
subclassers.
- getPerimeterPoint in interface CellView
- getPerimeterPoint in interface AbstractCellView
getPoint
public Point2D getPoint(int index)
Returns the cached points for this edge.
getPointCount
public int getPointCount()
Returns the number of point for this edge.
getPointLocation
protected Point2D getPointLocation(int index)
Returns the point of edge
at index
. Avoids
calling getLocation
on any ports of edge
.
This is used from within getPoint to pass the nearest point to the
portview to find it's location. This uses the center point of the parent
view to determine the port view's location to avoid infinite recursion.
getPoints
public List getPoints()
Returns the points.
getShape
public Shape getShape()
Returns the shape of the view according to the last rendering state
getSource
public CellView getSource()
Returns the CellView that represents the source of the edge.
getSourceParentView
public CellView getSourceParentView()
getTarget
public CellView getTarget()
Returns the CellView that represents the target of the edge.
getTargetParentView
public CellView getTargetParentView()
invalidate
protected void invalidate()
Resets the cached values of the edge view
isLoop
public boolean isLoop()
Returns true if the edge is a loop.
refresh
public void refresh(GraphLayoutCache cache,
CellMapper mapper,
boolean createDependentViews)
Overrides the parent method to udpate the cached points, source and
target port. If the source or target is removed, a point is inserted into
the array of points.
- refresh in interface CellView
- refresh in interface AbstractCellView
removeExtraLabel
public void removeExtraLabel(int index)
Removes the point at position index
.
removePoint
public void removePoint(int index)
Removes the point at position index
.
setExtraLabelPosition
public void setExtraLabelPosition(int index,
Point2D pos)
Sets the description of the label position.
setLabelPosition
public void setLabelPosition(Point2D pos)
Sets the description of the label position.
setPoint
public void setPoint(int index,
Point2D p)
Sets the point at index
to p
.
setSource
public void setSource(CellView sourceView)
Sets the sourceView
of the edge.
setTarget
public void setTarget(CellView targetView)
Sets the targetView
of the edge.