org.jgraph.graph
Class EdgeView
- java.lang.Object
-
- org.jgraph.graph.AbstractCellView
-
- org.jgraph.graph.EdgeView
-
- All Implemented Interfaces:
- java.io.Serializable, CellView
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.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classEdgeView.EdgeHandle
-
Field Summary
Fields Modifier and Type Field and Description java.awt.ShapebeginShapeDrawing attributes that are created on the flyjava.awt.ShapeendShapeDrawing attributes that are created on the flystatic booleanLEGACY_DISCONNECTABLEWhether or not pre 5.12.3.3 disconnectable behaviour is to be used.java.awt.ShapelineShapeDrawing attributes that are created on the flystatic EdgeRendererrendererRenderer for the class.java.awt.geom.GeneralPathsharedPathShared-path tune-up.-
Fields inherited from class org.jgraph.graph.AbstractCellView
cellEditor
-
-
Constructor Summary
Constructors Constructor and Description EdgeView()Constructs an empty edge view.EdgeView(java.lang.Object cell)Constructs an edge view for the specified model object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddExtraLabel(java.awt.geom.Point2D location, java.lang.Object label)Adds an extra label.voidaddPoint(int index, java.awt.geom.Point2D p)Addspat positionindex.java.awt.geom.Rectangle2DgetBounds()Returns the location for this edgeview.java.awt.geom.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 proportionCellHandlegetHandle(GraphContext context)Returns a cell handle for the view.java.awt.geom.Point2DgetLabelPosition()Returns a point that describes the position of the label.java.awt.geom.Point2DgetLabelVector()Hook to return the vector that is taken as the base vector to compute relative label positions.static doublegetLength(CellView view)java.awt.geom.Point2DgetPerimeterPoint(EdgeView edge, java.awt.geom.Point2D source, java.awt.geom.Point2D p)Returns the intersection of the bounding rectangle and the straight line between the source and the specified point p.java.awt.geom.Point2DgetPoint(int index)Returns the cached points for this edge.intgetPointCount()Returns the number of point for this edge.java.util.ListgetPoints()Returns the points.CellViewRenderergetRenderer()Returns a renderer for the class.java.awt.ShapegetShape()Returns the shape of the view according to the last rendering stateCellViewgetSource()Returns the CellView that represents the source of the edge.CellViewgetSourceParentView()CellViewgetTarget()Returns the CellView that represents the target of the edge.CellViewgetTargetParentView()booleanintersects(JGraph graph, java.awt.geom.Rectangle2D rect)Returns true if this view intersects the given rectangle.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 positionindex.voidremovePoint(int index)Removes the point at positionindex.voidsetExtraLabelPosition(int index, java.awt.geom.Point2D pos)Sets the description of the label position.voidsetLabelPosition(java.awt.geom.Point2D pos)Sets the description of the label position.voidsetPoint(int index, java.awt.geom.Point2D p)Sets the point atindextop.voidsetSource(CellView sourceView)Sets thesourceViewof the edge.voidsetTarget(CellView targetView)Sets thetargetViewof the edge.voidupdate(GraphLayoutCache cache)Update attributes and recurse children.-
Methods inherited from class org.jgraph.graph.AbstractCellView
changeAttributes, childUpdated, getAllAttributes, getAttributes, getBounds, getCell, getCenterPoint, getChildViews, getDescendantViews, getEditor, getParentView, getRendererComponent, isLeaf, removeFromParent, scale, setAttributes, setBounds, setCell, translate
-
-
-
-
Field Detail
-
renderer
public static transient EdgeRenderer renderer
Renderer for the class.
-
beginShape
public transient java.awt.Shape beginShape
Drawing attributes that are created on the fly
-
endShape
public transient java.awt.Shape endShape
Drawing attributes that are created on the fly
-
lineShape
public transient java.awt.Shape lineShape
Drawing attributes that are created on the fly
-
sharedPath
public transient java.awt.geom.GeneralPath sharedPath
Shared-path tune-up.
-
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.
-
-
Constructor Detail
-
EdgeView
public EdgeView()
Constructs an empty edge view.
-
EdgeView
public EdgeView(java.lang.Object cell)
Constructs an edge view for the specified model object.- Parameters:
cell- reference to the model object
-
-
Method Detail
-
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.- Specified by:
refreshin interfaceCellView- Overrides:
refreshin 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
-
update
public void update(GraphLayoutCache cache)
Update attributes and recurse children.- Specified by:
updatein interfaceCellView- Overrides:
updatein classAbstractCellView- Parameters:
cache- TODO
-
getShape
public java.awt.Shape getShape()
Returns the shape of the view according to the last rendering state
-
intersects
public boolean intersects(JGraph graph, java.awt.geom.Rectangle2D rect)
Returns true if this view intersects the given rectangle.- Specified by:
intersectsin interfaceCellView- Overrides:
intersectsin classAbstractCellView- Parameters:
graph- theJGraphinstance of the viewrect- the rectangle within which intersection is being checked for- Returns:
- whether or not the rectangle specified intersects the view
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Returns the location for this edgeview.- Specified by:
getBoundsin interfaceCellView- Overrides:
getBoundsin classAbstractCellView
-
getRenderer
public CellViewRenderer getRenderer()
Returns a renderer for the class.- Specified by:
getRendererin classAbstractCellView- Returns:
- the renderer instance for this view
-
getHandle
public CellHandle getHandle(GraphContext context)
Returns a cell handle for the view.- Specified by:
getHandlein interfaceCellView- Specified by:
getHandlein classAbstractCellView- Parameters:
context- the context of this cell view (cells indirectly affected by it)- Returns:
- the cell handle for this view
-
getSource
public CellView getSource()
Returns the CellView that represents the source of the edge.
-
getSourceParentView
public CellView getSourceParentView()
-
setSource
public void setSource(CellView sourceView)
Sets thesourceViewof the edge.
-
getTarget
public CellView getTarget()
Returns the CellView that represents the target of the edge.
-
getTargetParentView
public CellView getTargetParentView()
-
setTarget
public void setTarget(CellView targetView)
Sets thetargetViewof the edge.
-
getExtraLabelPosition
public java.awt.geom.Point2D getExtraLabelPosition(int index)
Returns a point that describes the position of the label.
-
getLabelPosition
public java.awt.geom.Point2D getLabelPosition()
Returns a point that describes the position of the label.
-
setLabelPosition
public void setLabelPosition(java.awt.geom.Point2D pos)
Sets the description of the label position.
-
setExtraLabelPosition
public void setExtraLabelPosition(int index, java.awt.geom.Point2D pos)Sets the description of the label position.
-
isLoop
public boolean isLoop()
Returns true if the edge is a loop.
-
getPoints
public java.util.List getPoints()
Returns the points.- Returns:
- List
-
getPointCount
public int getPointCount()
Returns the number of point for this edge.
-
getPoint
public java.awt.geom.Point2D getPoint(int index)
Returns the cached points for this edge.
-
setPoint
public void setPoint(int index, java.awt.geom.Point2D p)Sets the point atindextop.
-
addPoint
public void addPoint(int index, java.awt.geom.Point2D p)Addspat positionindex.
-
removePoint
public void removePoint(int index)
Removes the point at positionindex.
-
addExtraLabel
public void addExtraLabel(java.awt.geom.Point2D location, java.lang.Object label)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
public java.awt.geom.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)
-
getPerimeterPoint
public java.awt.geom.Point2D getPerimeterPoint(EdgeView edge, java.awt.geom.Point2D source, java.awt.geom.Point2D p)
Description copied from class:AbstractCellViewReturns 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:
getPerimeterPointin interfaceCellView- Overrides:
getPerimeterPointin classAbstractCellView
-
-
DataMelt 3.0 © DataMelt by jWork.ORG