org.jgraph.graph

Class PortView

public class PortView extends AbstractCellView

The default implementation of a port view.
Field Summary
static booleanallowPortMagic
Controls if port magic should be allowed.
protected CellViewlastParent
Cache of the last valid parent.
static PortRendererrenderer
Renderer for the class.
static intSIZE
Default size for all ports is 6.
Constructor Summary
PortView()
Constructs an empty portview.
PortView(Object cell)
Constructs a view that holds a reference to the specified cell, anchor and parent vertex.
Method Summary
Rectangle2DgetBounds()
Returns the bounds for the port view.
CellHandlegetHandle(GraphContext context)
Returns null.
Point2DgetLocation()
Shortcut method to getLocation(null, null)
Point2DgetLocation(EdgeView edge)
For backwards compatibility.
Point2DgetLocation(EdgeView edge, Point2D nearest)
Returns the point that the port represents with respect to edge and point, which is the nearest point to this port view on the edge.
CellViewgetParentView()
This method ensures a non-null value.
intgetPortSize()
CellViewRenderergetRenderer()
Returns a renderer for the class.
voidsetPortSize(int size)
protected booleanshouldInvokePortMagic(EdgeView edge)
Subclassers can override this to decide whether or not "port magic" should appear on a given edge.

Field Detail

allowPortMagic

public static boolean allowPortMagic
Controls if port magic should be allowed. Default is true. This is an easy switch to disable port magic for all instances of graphs.

lastParent

protected transient CellView lastParent
Cache of the last valid parent. //FIX: Better solution?

renderer

public static transient PortRenderer renderer
Renderer for the class.

SIZE

public static transient int SIZE
Default size for all ports is 6.

Constructor Detail

PortView

public PortView()
Constructs an empty portview.

PortView

public PortView(Object cell)
Constructs a view that holds a reference to the specified cell, anchor and parent vertex.

Parameters: cell reference to the cell in the model

Method Detail

getBounds

public Rectangle2D getBounds()
Returns the bounds for the port view.

getHandle

public CellHandle getHandle(GraphContext context)
Returns null.

getLocation

public Point2D getLocation()
Shortcut method to getLocation(null, null)

getLocation

public Point2D getLocation(EdgeView edge)
For backwards compatibility.

getLocation

public Point2D getLocation(EdgeView edge, Point2D nearest)
Returns the point that the port represents with respect to edge and point, which is the nearest point to this port view on the edge. edge and point may be null.

getParentView

public CellView getParentView()
This method ensures a non-null value. If the super method returns null then the last valid parent is returned. Note: If a vertex is removed, all ports will be replaced in connected edges. The ports are replaced by the center point of the last valid vertex view.

getPortSize

public int getPortSize()

Returns: the port size

getRenderer

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

setPortSize

public void setPortSize(int size)

Parameters: size the port size to set

shouldInvokePortMagic

protected boolean shouldInvokePortMagic(EdgeView edge)
Subclassers can override this to decide whether or not "port magic" should appear on a given edge. (Port magic means the port tries to make the edge horizontal or vertical if the closest control point lies within the bounds of the parent vertex.)
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.