org.jgraph.graph

Class EdgeView

public class EdgeView extends AbstractCellView

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.
Nested Class Summary
static classEdgeView.EdgeHandle
Field Summary
ShapebeginShape
Drawing attributes that are created on the fly
protected Rectangle2DcachedBounds
ShapeendShape
Drawing attributes that are created on the fly
protected Point2D[]extraLabelPositions
protected Point2DlabelPosition
Cached label position of the edge.
protected Point2DlabelVector
ShapelineShape
Drawing attributes that are created on the fly
static booleanLEGACY_DISCONNECTABLE
Whether or not pre 5.12.3.3 disconnectable behaviour is to be used.
protected Listpoints
List of points of the edge.
static EdgeRendererrenderer
Renderer for the class.
GeneralPathsharedPath
Shared-path tune-up.
protected CellViewsource
Cached source and target portview of the edge.
protected CellViewsourceParentView
protected CellViewtarget
Cached source and target portview of the edge.
protected CellViewtargetParentView
Constructor Summary
EdgeView()
Constructs an empty edge view.
EdgeView(Object cell)
Constructs an edge view for the specified model object.
Method Summary
voidaddExtraLabel(Point2D location, Object label)
Adds an extra label.
voidaddPoint(int index, Point2D p)
Adds p at position index.
protected voidcheckDefaultLabelPosition()
Hook for subclassers to avoid default label positions.
protected Point2DconvertRelativeLabelPositionToAbsolute(Point2D geometry)
Converts an relative label position (x is distance along edge and y is distance above/below edge vector) into an absolute co-ordination point
protected Point2DgetAbsoluteExtraLabelPosition(int index)
Returns the absolute position of the specified extra label
protected Point2DgetAbsoluteLabelPosition()
Returns the absolute position of the main label
protected Point2DgetAbsoluteLabelPositionFromRelative(Point2D geometry)
Converts relative label position to absolute and allows for any label offset.
Rectangle2DgetBounds()
Returns the location for this edgeview.
Point2DgetExtraLabelPosition(int index)
Returns a point that describes the position of the label.
intgetFirstPointOfSegment()
Utility method that returns the first point of the pair that forms the segment that is relativeX along the edge as a proportion
CellHandlegetHandle(GraphContext context)
Returns a cell handle for the view.
Point2DgetLabelPosition()
Returns a point that describes the position of the label.
Point2DgetLabelVector()
Hook to return the vector that is taken as the base vector to compute relative label positions.
static doublegetLength(CellView view)
protected Point2DgetNearestPoint(boolean source)
Returns the nearest point wrt to the source or target.
Point2DgetPerimeterPoint(EdgeView edge, Point2D source, Point2D p)
Point2DgetPoint(int index)
Returns the cached points for this edge.
intgetPointCount()
Returns the number of point for this edge.
protected Point2DgetPointLocation(int index)
Returns the point of edge at index.
ListgetPoints()
Returns the points.
CellViewRenderergetRenderer()
Returns a renderer for the class.
ShapegetShape()
Returns the shape of the view according to the last rendering state
CellViewgetSource()
Returns the CellView that represents the source of the edge.
CellViewgetSourceParentView()
CellViewgetTarget()
Returns the CellView that represents the target of the edge.
CellViewgetTargetParentView()
protected CellViewgetVisibleParent(GraphModel model, CellMapper mapper, Object port)
booleanintersects(JGraph graph, Rectangle2D rect)
Returns true if this view intersects the given rectangle.
protected voidinvalidate()
Resets the cached values of the edge view
booleanisLoop()
Returns true if the edge is a loop.
voidrefresh(GraphLayoutCache cache, CellMapper mapper, boolean createDependentViews)
Overrides the parent method to udpate the cached points, source and target port.
voidremoveExtraLabel(int index)
Removes the point at position index.
voidremovePoint(int index)
Removes the point at position index.
voidsetExtraLabelPosition(int index, Point2D pos)
Sets the description of the label position.
voidsetLabelPosition(Point2D pos)
Sets the description of the label position.
voidsetPoint(int index, Point2D p)
Sets the point at index to p.
voidsetSource(CellView sourceView)
Sets the sourceView of the edge.
voidsetTarget(CellView targetView)
Sets the targetView of the edge.
voidupdate(GraphLayoutCache cache)
Update attributes and recurse children.

Field Detail

beginShape

public transient Shape beginShape
Drawing attributes that are created on the fly

cachedBounds

protected transient Rectangle2D cachedBounds

endShape

public transient 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 transient Point2D labelVector

lineShape

public transient Shape lineShape
Drawing attributes that are created on the fly

LEGACY_DISCONNECTABLE

public static boolean LEGACY_DISCONNECTABLE
Whether or not pre 5.12.3.3 disconnectable behaviour is to be used. This allowed an edge to reconnect to another vertex ever when isDisconnectable was false for the edge. Set to false with isDisconnectable set to false for the edge forbids any disconnection. Default is true.

points

protected List points
List of points of the edge. May contain ports.

renderer

public static transient EdgeRenderer renderer
Renderer for the class.

sharedPath

public transient 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

Constructor Detail

EdgeView

public EdgeView()
Constructs an empty edge view.

EdgeView

public EdgeView(Object cell)
Constructs an edge view for the specified model object.

Parameters: cell reference to the model object

Method Detail

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.

convertRelativeLabelPositionToAbsolute

protected Point2D convertRelativeLabelPositionToAbsolute(Point2D geometry)
Converts an relative label position (x is distance along edge and y is distance above/below edge vector) into an absolute co-ordination point

Parameters: geometry the relative label position

Returns: the absolute label position

getAbsoluteExtraLabelPosition

protected Point2D getAbsoluteExtraLabelPosition(int index)
Returns the absolute position of the specified extra label

Parameters: index the index of the extra label

Returns: the absolute position of the specified extra label

getAbsoluteLabelPosition

protected Point2D getAbsoluteLabelPosition()
Returns the absolute position of the main label

Returns: the absolute position of the main label

getAbsoluteLabelPositionFromRelative

protected Point2D getAbsoluteLabelPositionFromRelative(Point2D geometry)
Converts relative label position to absolute and allows for any label offset.

Parameters: geometry the relative label position

Returns: the absolute label position including any offset

getBounds

public Rectangle2D getBounds()
Returns the location for this edgeview.

getExtraLabelPosition

public Point2D getExtraLabelPosition(int index)
Returns a point that describes the position of the label.

getFirstPointOfSegment

public int getFirstPointOfSegment()
Utility method that returns the first point of the pair that forms the segment that is relativeX along the edge as a proportion

Returns: the index of the first point. A value of -1 indicate to use the first and last points

getHandle

public CellHandle getHandle(GraphContext context)
Returns a cell handle for the view.

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)

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.

Returns: List

getRenderer

public CellViewRenderer getRenderer()
Returns a renderer for the class.

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()

getVisibleParent

protected CellView getVisibleParent(GraphModel model, CellMapper mapper, Object port)

intersects

public boolean intersects(JGraph graph, Rectangle2D rect)
Returns true if this view intersects the given rectangle.

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.

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.

update

public void update(GraphLayoutCache cache)
Update attributes and recurse children.
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.