org.jgraph.graph

Class PortView

Implemented Interfaces:
CellView, Serializable

public class PortView
extends AbstractCellView

The default implementation of a port view.

Field Summary

static int
SIZE
Default size for all ports is 6.
static boolean
allowPortMagic
Controls if port magic should be allowed.
protected CellView
lastParent
Cache of the last valid parent.
static PortRenderer
renderer
Renderer for the class.

Fields inherited from class org.jgraph.graph.AbstractCellView

allAttributes, attributes, cell, cellEditor, childViews, groupBounds, parent

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

Rectangle2D
getBounds()
Returns the bounds for the port view.
CellHandle
getHandle(GraphContext context)
Returns null.
Point2D
getLocation()
Shortcut method to getLocation(null, null)
Point2D
getLocation(EdgeView edge)
For backwards compatibility.
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.
CellView
getParentView()
This method ensures a non-null value.
int
getPortSize()
CellViewRenderer
getRenderer()
Returns a renderer for the class.
void
setPortSize(int size)
protected boolean
shouldInvokePortMagic(EdgeView edge)
Subclassers can override this to decide whether or not "port magic" should appear on a given edge.

Methods inherited from class org.jgraph.graph.AbstractCellView

changeAttributes, childUpdated, createAttributeMap, getAllAttributes, getAttributes, getBounds, getBounds, getCell, getCellAttributes, getCenterPoint, getChildViews, getDescendantViews, getEditor, getHandle, getParentView, getPerimeterPoint, getRenderer, getRendererComponent, includeInGroupBounds, intersects, isLeaf, mergeAttributes, refresh, removeFromParent, scale, setAttributes, setBounds, setCell, translate, update, updateGroupBounds

Field Details

SIZE

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

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 CellView lastParent
Cache of the last valid parent. //FIX: Better solution?

renderer

public static PortRenderer renderer
Renderer for the class.

Constructor Details

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 Details

getBounds

public Rectangle2D getBounds()
Returns the bounds for the port view.
Specified by:
getBounds in interface CellView
Overrides:
getBounds in interface AbstractCellView

getHandle

public CellHandle getHandle(GraphContext context)
Returns null.
Specified by:
getHandle in interface CellView
Overrides:
getHandle in interface AbstractCellView

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.
Specified by:
getParentView in interface CellView
Overrides:
getParentView in interface AbstractCellView

getPortSize

public int getPortSize()
Returns:
the port size

getRenderer

public CellViewRenderer getRenderer()
Returns a renderer for the class.
Overrides:
getRenderer in interface AbstractCellView

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-2006 Gaudenz Alder. All rights reserved.