Package org.jgraph.graph
Class EdgeView
java.lang.Object
org.jgraph.graph.AbstractCellView
org.jgraph.graph.EdgeView
- All Implemented Interfaces:
Serializable
,CellView
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.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionDrawing attributes that are created on the flyprotected Rectangle2D
Drawing attributes that are created on the flyprotected Point2D[]
protected Point2D
Cached label position of the edge.protected Point2D
static boolean
Whether or not pre 5.12.3.3 disconnectable behaviour is to be used.Drawing attributes that are created on the flyprotected List
List of points of the edge.static EdgeRenderer
Renderer for the class.Shared-path tune-up.protected CellView
Cached source and target portview of the edge.protected CellView
protected CellView
Cached source and target portview of the edge.protected CellView
Fields inherited from class org.jgraph.graph.AbstractCellView
allAttributes, attributes, cell, cellEditor, childViews, groupBounds, parent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtraLabel
(Point2D location, Object label) Adds an extra label.void
Addsp
at positionindex
.protected void
Hook for subclassers to avoid default label positions.protected Point2D
Converts an relative label position (x is distance along edge and y is distance above/below edge vector) into an absolute co-ordination pointprotected Point2D
getAbsoluteExtraLabelPosition
(int index) Returns the absolute position of the specified extra labelprotected Point2D
Returns the absolute position of the main labelprotected Point2D
getAbsoluteLabelPositionFromRelative
(Point2D geometry) Converts relative label position to absolute and allows for any label offset.Returns the location for this edgeview.getExtraLabelPosition
(int index) Returns a point that describes the position of the label.int
Utility method that returns the first point of the pair that forms the segment that is relativeX along the edge as a proportiongetHandle
(GraphContext context) Returns a cell handle for the view.Returns a point that describes the position of the label.Hook to return the vector that is taken as the base vector to compute relative label positions.static double
protected Point2D
getNearestPoint
(boolean source) Returns the nearest point wrt to the source or target.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.getPoint
(int index) Returns the cached points for this edge.int
Returns the number of point for this edge.protected Point2D
getPointLocation
(int index) Returns the point ofedge
atindex
.Returns the points.Returns a renderer for the class.getShape()
Returns the shape of the view according to the last rendering stateReturns the CellView that represents the source of the edge.Returns the CellView that represents the target of the edge.protected CellView
getVisibleParent
(GraphModel model, CellMapper mapper, Object port) boolean
intersects
(JGraph graph, Rectangle2D rect) Returns true if this view intersects the given rectangle.protected void
Resets the cached values of the edge viewboolean
isLoop()
Returns true if the edge is a loop.void
refresh
(GraphLayoutCache cache, CellMapper mapper, boolean createDependentViews) Overrides the parent method to udpate the cached points, source and target port.void
removeExtraLabel
(int index) Removes the point at positionindex
.void
removePoint
(int index) Removes the point at positionindex
.void
setExtraLabelPosition
(int index, Point2D pos) Sets the description of the label position.void
setLabelPosition
(Point2D pos) Sets the description of the label position.void
Sets the point atindex
top
.void
Sets thesourceView
of the edge.void
Sets thetargetView
of the edge.void
update
(GraphLayoutCache cache) Update attributes and recurse children.Methods inherited from class org.jgraph.graph.AbstractCellView
changeAttributes, childUpdated, createAttributeMap, getAllAttributes, getAttributes, getBounds, getCell, getCellAttributes, getCenterPoint, getChildViews, getDescendantViews, getEditor, getParentView, getRendererComponent, includeInGroupBounds, isLeaf, mergeAttributes, removeFromParent, scale, setAttributes, setBounds, setCell, translate, updateGroupBounds
-
Field Details
-
renderer
Renderer for the class. -
points
List of points of the edge. May contain ports. -
source
Cached source and target portview of the edge. -
target
Cached source and target portview of the edge. -
sourceParentView
-
targetParentView
-
labelPosition
Cached label position of the edge. -
extraLabelPositions
-
labelVector
-
beginShape
Drawing attributes that are created on the fly -
endShape
Drawing attributes that are created on the fly -
lineShape
Drawing attributes that are created on the fly -
cachedBounds
-
LEGACY_DISCONNECTABLE
public static boolean LEGACY_DISCONNECTABLEWhether 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.
-
-
Constructor Details
-
EdgeView
public EdgeView()Constructs an empty edge view. -
EdgeView
Constructs an edge view for the specified model object.- Parameters:
cell
- reference to the model object
-
-
Method Details
-
refresh
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.- Specified by:
refresh
in interfaceCellView
- Overrides:
refresh
in classAbstractCellView
- Parameters:
cache
- the graph model to be usedmapper
- the cell mapper to be usedcreateDependentViews
- whether or not to create a view if one does not already exist
-
getVisibleParent
-
update
Update attributes and recurse children.- Specified by:
update
in interfaceCellView
- Overrides:
update
in classAbstractCellView
- Parameters:
cache
- TODO
-
checkDefaultLabelPosition
protected void checkDefaultLabelPosition()Hook for subclassers to avoid default label positions. -
invalidate
protected void invalidate()Resets the cached values of the edge view -
getShape
Returns the shape of the view according to the last rendering state -
intersects
Returns true if this view intersects the given rectangle.- Specified by:
intersects
in interfaceCellView
- Overrides:
intersects
in classAbstractCellView
- Parameters:
graph
- theJGraph
instance of the viewrect
- the rectangle within which intersection is being checked for- Returns:
- whether or not the rectangle specified intersects the view
-
getBounds
Returns the location for this edgeview.- Specified by:
getBounds
in interfaceCellView
- Overrides:
getBounds
in classAbstractCellView
-
getRenderer
Returns a renderer for the class.- Specified by:
getRenderer
in classAbstractCellView
- Returns:
- the renderer instance for this view
-
getHandle
Returns a cell handle for the view.- Specified by:
getHandle
in interfaceCellView
- Specified by:
getHandle
in classAbstractCellView
- Parameters:
context
- the context of this cell view (cells indirectly affected by it)- Returns:
- the cell handle for this view
-
getSource
Returns the CellView that represents the source of the edge. -
getSourceParentView
-
setSource
Sets thesourceView
of the edge. -
getTarget
Returns the CellView that represents the target of the edge. -
getTargetParentView
-
setTarget
Sets thetargetView
of the edge. -
getExtraLabelPosition
Returns a point that describes the position of the label. -
getLabelPosition
Returns a point that describes the position of the label. -
setLabelPosition
Sets the description of the label position. -
setExtraLabelPosition
Sets the description of the label position. -
isLoop
public boolean isLoop()Returns true if the edge is a loop. -
getPoints
Returns the points.- Returns:
- List
-
getPointCount
public int getPointCount()Returns the number of point for this edge. -
getPoint
Returns the cached points for this edge. -
getNearestPoint
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. -
getPointLocation
Returns the point ofedge
atindex
. Avoids callinggetLocation
on any ports ofedge
.
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. -
setPoint
Sets the point atindex
top
. -
addPoint
Addsp
at positionindex
. -
removePoint
public void removePoint(int index) Removes the point at positionindex
. -
addExtraLabel
Adds an extra label. -
removeExtraLabel
public void removeExtraLabel(int index) Removes the point at positionindex
. -
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
-
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. -
getAbsoluteLabelPosition
Returns the absolute position of the main label- Returns:
- the absolute position of the main label
-
getAbsoluteExtraLabelPosition
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
-
getAbsoluteLabelPositionFromRelative
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
-
convertRelativeLabelPositionToAbsolute
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
-
getLength
-
getPerimeterPoint
Description copied from class:AbstractCellView
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.- Specified by:
getPerimeterPoint
in interfaceCellView
- Overrides:
getPerimeterPoint
in classAbstractCellView
-