public class JGraph
extends javax.swing.JComponent
implements javax.swing.Scrollable, javax.accessibility.Accessible, java.io.Serializable
A JGraph object doesn't actually contain your data; it simply provides a view of the data. Like any non-trivial Swing component, the graph gets data by querying its data model.
JGraph displays its data by drawing individual elements. Each element displayed by the graph contains exactly one item of data, which is called a cell. A cell may either be a vertex or an edge. Vertices may have neighbours or not, and edges may have source and target vertices or not, depending on whether they are connected.
Creating a Graph
The following code creates a JGraph object:
JGraph graph = new JGraph();
...
JScrollPane graphLayoutCache = new JScrollPane(graph)
The code creates an instance of JGraph and puts it in a scroll pane. JGraphs constructor is called with no arguments in this example, which causes the constructor to create a sample model.
Editing
Outmoved, cloned, resized, and shaped, or connected/disconnected to or from other cells.
Keyboard Bindings
JGraph defines the following set of keyboard bindings:
Customization
There are a number of additional methods that customize JGraph. For example, setMinimumMove() defines the minimum amount of pixels before a move operation is initiated. setSnapSize() defines the maximum distance for a cell to be selected. setFloatEnabled() enables/disables port floating.
With setDisconnectOnMove() you can indicate if the selected subgraph should be disconnected from the unselected rest when a move operation is initiated. setDragEnabled() enables/disables the use of Drag And Drop, and setDropEnabled() sets if the graph accepts Drops from external sources.
Customizing a graphs display
JGraph performs some look-and-feel specific painting. You can customize this painting in a limited way. For example, you can modify the grid using setGridColor() and setGridSize(), and you can change the handle colors using setHandleColor() and setLockedHandleColor().
If you want finer control over the rendering, you can subclass one of the default renderers, and extend its paint()-method. A renderer is a Component-extension that paints a cell based on its attributes. Thus, neither the JGraph nor its look-and-feel-specific implementation actually contain the code that paints the cell. Instead, the graph uses the cell renderers painting code.
Selection
Apart from the single-cell and marquee-selection, JGraphs selection model also allows to "step-into" groups, and select children. This feature can be disabled using the setAllowsChildSelection() method of the selection model instance.
If you are interested in knowing when the selection changes implement the
GraphSelectionListener
interface and add the instance using
the method addGraphSelectionListener
.
valueChanged
will be invoked when the selection changes, that
is if the user clicks twice on the same vertex valueChanged
will only be invoked once.
Change Notification
For detection of double-clicks or when a user clicks on a cell, regardless of
whether or not it was selected, I recommend you implement a MouseListener and
use getFirstCellForLocation
.
Undo Support
To enable Undo-Support, a GraphUndoManager
must be added using
addGraphSelectionListener
. The GraphUndoManager is an
extension of Swing's GraphUndoManager
that maintains a command
history in the context of multiple views. In this setup, a cell may have a
set of attributes in each view attached to the model.
For example, consider a position that is stored separately in each view. If a node is inserted, the change will be visible in all attached views, resulting in a new node that pops-up at the initial position. If the node is subsequently moved, say, in view1, this does not constitute a change in view2. If view2 does an "undo", the move and the insertion must be undone, whereas an "undo" in view1 will only undo the previous move operation.
Like all JComponent
classes, you can use
InputMap
and ActionMap
to associate
an Action
object with a KeyStroke
and
execute the action under specified conditions.
Modifier and Type | Class and Description |
---|---|
static class |
JGraph.EmptySelectionModel
EmptySelectionModel is a GraphSelectionModel
that does not allow anything to be selected. |
protected class |
JGraph.GraphSelectionRedirector
Handles creating a new
GraphSelectionEvent with the
JGraph as the source and passing it off to all the
listeners. |
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected boolean |
antiAliased
True if the graph is anti-aliased.
|
static java.lang.String |
ANTIALIASED_PROPERTY
Bound property name for
antiAliased . |
protected boolean |
autoResizeGraph
True if the graph should be auto resized when cells are moved below the
bottom right corner.
|
protected java.awt.Component |
backgroundComponent
A Component responsible for drawing the background image, if any
|
protected javax.swing.ImageIcon |
backgroundImage
Holds the background image.
|
protected boolean |
backgroundScaled
Whether or not the background image is scaled on zooming
|
protected boolean |
bendable
True if the graph allows points to be modified/added/removed.
|
protected boolean |
cloneable
True if the graph allows "ctrl-drag" operations.
|
protected boolean |
connectable
True if the graph allows new connections to be established.
|
static int |
CROSS_GRID_MODE |
protected boolean |
disconnectable
True if the graph allows existing connections to be removed.
|
protected boolean |
disconnectOnMove
True if selected edges are disconnected from unselected vertices on move.
|
static int |
DOT_GRID_MODE |
protected boolean |
dragEnabled
True if Drag-and-Drop should be used for move operations.
|
protected boolean |
dropEnabled
True if the graph accepts transfers from other components (graphs).
|
protected boolean |
edgeLabelsMovable
True if the labels on edges may be moved.
|
protected boolean |
editable
True if the graph allows editing the value of a cell.
|
static java.lang.String |
EDITABLE_PROPERTY
Bound property name for
editable . |
protected int |
editClickCount
Number of clicks for editing to start.
|
protected boolean |
enabled
True if the graph allows interactions.
|
static java.lang.String |
GRAPH_LAYOUT_CACHE_PROPERTY
Bound property name for
graphModel . |
static java.lang.String |
GRAPH_MODEL_PROPERTY
Bound property name for
graphModel . |
protected GraphLayoutCache |
graphLayoutCache
The view that defines the display properties of the model.
|
protected GraphModel |
graphModel
The model that defines the graph displayed by this object.
|
static java.lang.String |
GRID_COLOR_PROPERTY
Bound property name for
gridColor . |
static java.lang.String |
GRID_SIZE_PROPERTY
Bound property name for
gridSize . |
static java.lang.String |
GRID_VISIBLE_PROPERTY
Bound property name for
gridVisible . |
protected java.awt.Color |
gridColor
The color of the grid.
|
protected boolean |
gridEnabled
True if the snap method should be active (snap to grid).
|
protected int |
gridMode
The style of the grid.
|
protected double |
gridSize
The size of the grid in points.
|
protected boolean |
gridVisible
True if the grid is visible.
|
protected boolean |
groupsEditable
True if the graph allows editing of non-leaf cells.
|
static java.lang.String |
HANDLE_COLOR_PROPERTY
Bound property name for
gridColor . |
static java.lang.String |
HANDLE_SIZE_PROPERTY
Bound property name for
gridColor . |
protected java.awt.Color |
handleColor
Color of the handles and locked handles.
|
protected int |
handleSize
Size of a handle.
|
protected java.awt.Color |
highlightColor
Highlight Color.
|
static java.lang.String |
INVOKES_STOP_CELL_EDITING_PROPERTY
Bound property name for
messagesStopCellEditing . |
protected boolean |
invokesStopCellEditing
If true, when editing is to be stopped by way of selection changing, data
in graph changing or other means
stopCellEditing is
invoked, and changes are saved. |
static boolean |
IS_MAC |
protected boolean |
isJumpToDefaultPort
True if getPortViewAt should return the default port if no other port is
found.
|
protected boolean |
isMoveIntoGroups
Specifies if cells should be added to a group when moved over the group's
area.
|
protected boolean |
isMoveOutOfGroups
Specifies if cells should be removed from groups when removed from the
group area.
|
protected boolean |
lastBufferAllocated
Stores whether the last double buffer allocation worked or not
|
static int |
LINE_GRID_MODE |
static java.lang.String |
LOCKED_HANDLE_COLOR_PROPERTY
Bound property name for
gridColor . |
protected java.awt.Color |
lockedHandleColor
Color of the handles and locked handles.
|
protected BasicMarqueeHandler |
marquee
Handler for marquee selection.
|
static java.lang.String |
MARQUEE_HANDLER_PROPERTY
Bound property name for
graphModel . |
protected java.awt.Color |
marqueeColor
Color of the marquee.
|
protected int |
minimumMove
Minimum amount of pixels to start a move transaction.
|
protected boolean |
moveable
True if the graph allows move operations.
|
protected boolean |
moveBelowZero
True if the graph allows to move cells below zero.
|
protected boolean |
moveBeyondGraphBounds
True if the graph allows to move cells beyond the graph bounds
|
protected java.awt.Graphics |
offgraphics
Graphics object of off screen image
|
protected java.awt.Image |
offscreen
Off screen image for double buffering
|
protected java.awt.geom.Rectangle2D |
offscreenBounds
The bounds of the offscreen buffer
|
protected int |
offscreenBuffer
The buffer around the offscreen graphics object that provides the
specified distance of scrolling before the buffer has to be recreated.
|
protected java.awt.geom.Rectangle2D |
offscreenDirty
Whether or not the current background image is correct
|
protected java.awt.geom.Point2D |
offscreenOffset
The offset of the offscreen buffer
|
static java.lang.String |
PORTS_SCALED_PROPERTY
Bound property name for
portsScaled . |
static java.lang.String |
PORTS_VISIBLE_PROPERTY
Bound property name for
gridVisible . |
protected boolean |
portsOnTop
True if port are painted above all other cells.
|
protected boolean |
portsScaled
True if the ports are scaled.
|
protected boolean |
portsVisible
True if the ports are visible.
|
protected boolean |
previewInvalidNullPorts
True if the graph allows invalid null ports during previews (aka flip
back edges).
|
static java.lang.String |
PROPERTY_BACKGROUNDIMAGE
Bound property name for
backgroundImage . |
protected double |
scale
Scale of the graph.
|
static java.lang.String |
SCALE_PROPERTY
Bound property name for
scale . |
static java.lang.String |
SELECTION_MODEL_PROPERTY
Bound property name for
selectionModel . |
protected boolean |
selectionEnabled
True if the graph allows selection of cells.
|
static java.lang.String |
SELECTIONENABLED_PROPERTY
Bound property name for
selectionEnabled . |
protected GraphSelectionModel |
selectionModel
Models the set of selected objects in this graph.
|
protected JGraph.GraphSelectionRedirector |
selectionRedirector
Creates a new event and passes it off the
selectionListeners . |
protected boolean |
sizeable
True if the graph allows cells to be resized.
|
protected int |
tolerance
Maximum distance between a cell and the mousepointer.
|
static java.lang.String |
VERSION |
protected boolean |
volatileOffscreen
Whether or not to try to use a volatile offscreen buffer for double
buffering.
|
protected boolean |
wholeOffscreenDirty |
protected double |
wholeOffscreenDirtyProportion |
protected boolean |
xorEnabled
True if the graph accepts transfers from other components (graphs).
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
JGraph()
Returns a
JGraph with a sample model. |
JGraph(GraphLayoutCache cache)
Returns an instance of
JGraph which displays the data
model using the specified view. |
JGraph(GraphModel model)
Returns an instance of
JGraph which displays the the
specified data model. |
JGraph(GraphModel model,
BasicMarqueeHandler mh)
Returns an instance of
JGraph which displays the specified
data model and assigns the specified marquee handler |
JGraph(GraphModel model,
GraphLayoutCache cache)
Returns an instance of
JGraph which displays the specified
data model using the specified view. |
JGraph(GraphModel model,
GraphLayoutCache layoutCache,
BasicMarqueeHandler mh)
Returns an instance of
JGraph which displays the specified
data model using the specified view and assigns the specified marquee
handler |
Modifier and Type | Method and Description |
---|---|
void |
addGraphSelectionListener(GraphSelectionListener tsl)
Adds a listener for
GraphSelection events. |
void |
addOffscreenDirty(java.awt.geom.Rectangle2D offscreenDirty)
Adds the specified area to the region deemed dirty for the next double
buffered redraw
|
static void |
addSampleData(GraphModel model)
Creates and returns a sample
GraphModel . |
void |
addSelectionCell(java.lang.Object cell)
Adds the cell identified by the specified
Object to the
current selection. |
void |
addSelectionCells(java.lang.Object[] cells)
Adds each cell in the array of cells to the current selection.
|
void |
cancelEditing()
Cancels the current editing session.
|
void |
clearOffscreen()
Invalidate the offscreen region, do not just delete it, since if the new
region is smaller than the old you may not wish to re-create the buffer
|
void |
clearOffscreenDirty()
Clears the region deemed dirty for the next double buffered redraw
|
void |
clearSelection()
Clears the selection.
|
java.util.Map |
cloneCells(java.lang.Object[] cells)
Returns a map of (cell, clone)-pairs for all
cells and
their children. |
java.lang.String |
convertValueToString(java.lang.Object value)
Converts the specified value to string.
|
static java.util.Map |
createBounds(AttributeMap map,
int x,
int y,
java.awt.Color c)
Returns an attributeMap for the specified position and color.
|
protected void |
createBufferedImage(int width,
int height)
Utility method to create a standard buffered image
|
boolean |
drawImage(java.awt.Graphics g) |
boolean |
drawImage(int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2)
Utility method to draw the off screen buffer
|
protected void |
fireValueChanged(GraphSelectionEvent e)
Notifies all listeners that have registered interest for notification on
this event type.
|
java.awt.geom.Point2D |
fromScreen(java.awt.geom.Point2D p)
Downscale the given point in place, using the given instance.
|
java.awt.geom.Rectangle2D |
fromScreen(java.awt.geom.Rectangle2D rect)
Downscale the given rectangle in place, using the given instance.
|
AttributeMap |
getAttributes(java.lang.Object cell)
Returns the attributes for the specified cell.
|
java.awt.Component |
getBackgroundComponent() |
javax.swing.ImageIcon |
getBackgroundImage()
Returns the background image.
|
java.awt.geom.Rectangle2D |
getCellBounds(java.lang.Object cell)
Returns the bounding rectangle of the specified cell.
|
java.awt.geom.Rectangle2D |
getCellBounds(java.lang.Object[] cells)
Returns the bounding rectangle of the specified cells.
|
java.awt.geom.Point2D |
getCenterPoint()
Returns the center of the component relative to the parent viewport's
position.
|
java.awt.geom.Rectangle2D |
getClipRectangle(GraphLayoutCacheEvent.GraphLayoutCacheChange change)
Calculates the clip
|
PortView |
getDefaultPortForCell(java.lang.Object cell)
Returns the default portview for the specified cell.
|
java.lang.Object[] |
getDescendants(java.lang.Object[] cells)
Returns all
cells including all descendants in the passed
in order of cells. |
boolean |
getEdgeLabelsMovable()
Returns true if edge labels may be dragged and dropped.
|
int |
getEditClickCount()
Returns the number of clicks for editing to start.
|
java.lang.Object |
getEditingCell()
Returns the cell that is currently being edited.
|
java.lang.Object |
getFirstCellForLocation(double x,
double y)
Returns the topmost cell at the specified location.
|
GraphLayoutCache |
getGraphLayoutCache()
Returns the
GraphLayoutCache that is providing the
view-data. |
java.awt.Color |
getGridColor()
Returns the current grid color.
|
int |
getGridMode()
Returns the current grid view mode.
|
double |
getGridSize()
Returns the size of the grid in pixels.
|
java.awt.Color |
getHandleColor()
Returns the current handle color.
|
int |
getHandleSize()
Returns the size of the handles.
|
java.awt.Color |
getHighlightColor()
Returns the current highlight color.
|
java.awt.image.BufferedImage |
getImage(java.awt.Color bg,
int inset)
Returns a
BufferedImage for the graph using inset as an empty
border around the cells of the graph. |
boolean |
getInvokesStopCellEditing()
Returns the indicator that tells what happens when editing is
interrupted.
|
CellView |
getLeafViewAt(double x,
double y)
Returns the next view at the specified location wrt.
|
java.awt.Color |
getLockedHandleColor()
Returns the current second handle color.
|
java.awt.Color |
getMarqueeColor()
Returns the current marquee color.
|
BasicMarqueeHandler |
getMarqueeHandler()
Returns the
MarqueeHandler that will handle marquee
selection. |
int |
getMinimumMove()
Returns the miminum amount of pixels for a move operation.
|
GraphModel |
getModel()
Returns the
GraphModel that is providing the data. |
java.lang.Object |
getNextCellForLocation(java.lang.Object current,
double x,
double y)
Returns the cell at the specified location that is "behind" the
current cell. |
CellView |
getNextSelectableViewAt(CellView current,
double x,
double y)
Note: Arguments are not expected to be scaled (they are scaled in here).
|
CellView |
getNextViewAt(CellView[] cells,
CellView c,
double x,
double y)
Returns the next view at the specified location wrt.
|
CellView |
getNextViewAt(CellView[] cells,
CellView c,
double x,
double y,
boolean leafsOnly)
Returns the next view at the specified location wrt.
|
CellView |
getNextViewAt(CellView current,
double x,
double y)
Returns the next view at the specified location wrt.
|
CellView |
getNextViewAt(CellView current,
double x,
double y,
boolean leafsOnly)
Returns the next view at the specified location wrt.
|
java.awt.Graphics |
getOffgraphics()
Returns the current double buffering graphics object.
|
java.awt.Image |
getOffscreen() |
java.awt.geom.Rectangle2D |
getOffscreenDirty()
Returns the area that is deemed dirty for the next double buffered redraw
|
java.awt.geom.Point2D |
getOffscreenOffset() |
java.lang.Object |
getPortForLocation(double x,
double y)
Convenience method to return the port at the specified location.
|
PortView |
getPortViewAt(double x,
double y)
Returns the portview at the specified location.
|
PortView |
getPortViewAt(double x,
double y,
int tolerance)
Returns the portview at the specified location.
|
java.awt.Dimension |
getPreferredScrollableViewportSize()
Returns the preferred display size of a
JGraph . |
java.lang.Object[] |
getRoots()
Returns all root cells (cells that have no parent) that the model
contains.
|
java.lang.Object[] |
getRoots(java.awt.Rectangle clip)
Returns all cells that intersect the given rectangle.
|
double |
getScale()
Returns the current scale.
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Returns the amount for a block increment, which is the height or width of
visibleRect , based on orientation . |
boolean |
getScrollableTracksViewportHeight()
Returns false to indicate that the height of the viewport does not
determine the height of the graph, unless the preferred height of the
graph is smaller than the viewports height.
|
boolean |
getScrollableTracksViewportWidth()
Returns false to indicate that the width of the viewport does not
determine the width of the graph, unless the preferred width of the graph
is smaller than the viewports width.
|
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
Returns the amount to increment when scrolling.
|
java.lang.Object |
getSelectionCell()
Returns the first selected cell.
|
java.lang.Object |
getSelectionCellAt(java.awt.geom.Point2D pt)
Returns the selection cell at the specified location.
|
java.lang.Object[] |
getSelectionCells()
Returns all selected cells.
|
java.lang.Object[] |
getSelectionCells(java.lang.Object[] cells)
Returns all selected cells in
cells . |
int |
getSelectionCount()
Returns the number of cells selected.
|
GraphSelectionModel |
getSelectionModel()
Returns the model for selections.
|
int |
getTolerance()
Returns the maximum distance between the mousepointer and a cell to be
selected.
|
java.lang.String |
getToolTipText(java.awt.event.MouseEvent e)
Overrides
JComponent 'sgetToolTipText
method in order to allow the graph to create a tooltip for the topmost
cell under the mousepointer. |
CellView |
getTopmostViewAt(double x,
double y,
boolean reverse,
boolean leafsOnly)
Returns the topmost cell view at the specified location using the view's
bounds on non-leafs to check for containment.
|
GraphUI |
getUI()
Returns the L&F object that renders this component.
|
java.lang.String |
getUIClassID()
Returns the name of the L&F class that renders this component.
|
java.awt.geom.Rectangle2D |
getViewPortBounds()
Return the bounds of the parent viewport, if one exists.
|
void |
graphDidChange()
Messaged when the graph has changed enough that we need to resize the
bounds, but not enough that we need to remove the cells (e.g cells were
inserted into the graph).
|
boolean |
isAntiAliased()
Returns true if the graph will be anti aliased.
|
boolean |
isAutoResizeGraph()
Returns true if the graph should be automatically resized when cells are
being moved below the bottom right corner.
|
boolean |
isBackgroundScaled() |
boolean |
isBendable()
Returns true if the graph allows adding/removing/modifying points.
|
boolean |
isCellEditable(java.lang.Object cell)
Returns
true if the graph and the cell are editable. |
boolean |
isCellSelected(java.lang.Object cell)
Returns true if the cell is currently selected.
|
boolean |
isCloneable()
Returns true if cells are cloned on CTRL-Drag operations.
|
boolean |
isConnectable()
Returns true if the graph allows new connections to be established.
|
boolean |
isDisconnectable()
Returns true if the graph allows existing connections to be removed.
|
boolean |
isDisconnectOnMove()
Returns true if selected edges should be disconnected from unselected
vertices when they are moved.
|
boolean |
isDragEnabled()
Returns true if the graph uses Drag-and-Drop to move cells.
|
boolean |
isDropEnabled()
Returns true if the graph accepts drops/pastes from external sources.
|
boolean |
isEditable()
Returns true if the graph is editable (if it allows cells to be edited).
|
boolean |
isEditing()
Returns true if the graph is being edited.
|
boolean |
isGridEnabled()
Returns true if the grid is active.
|
boolean |
isGridVisible()
Returns true if the grid will be visible.
|
boolean |
isGroupsEditable() |
boolean |
isJumpToDefaultPort()
Returns true if getPortViewAt should return the default port if no other
port is found.
|
boolean |
isMoveable() |
boolean |
isMoveBelowZero()
Returns true if the graph allows to move cells below zero.
|
boolean |
isMoveBeyondGraphBounds() |
boolean |
isMoveIntoGroups()
Returns true if cells should be added to groups when moved over the
group's area.
|
boolean |
isMoveOutOfGroups()
Returns true if cells should be removed from groups when removed from the
group's area.
|
boolean |
isPortsOnTop() |
boolean |
isPortsScaled()
Returns true if the ports will be scaled.
|
boolean |
isPortsVisible()
Returns true if the ports will be visible.
|
boolean |
isPreviewInvalidNullPorts()
Returns true if graph allows invalid null ports during previews
|
boolean |
isSelectionEmpty()
Returns true if the selection is currently empty.
|
boolean |
isSelectionEnabled()
Returns true if the cell selection is enabled
|
boolean |
isSizeable()
Returns true if the graph allows cells to be resized.
|
boolean |
isVolatileOffscreen() |
boolean |
isXorEnabled()
Returns true if the graph accepts drops/pastes from external sources.
|
static void |
main(java.lang.String[] args) |
java.lang.Object[] |
order(java.lang.Object[] cells)
Returns all
cells including all descendants ordered using
the current layering data stored by the model. |
protected java.lang.String |
paramString()
Returns a string representation of this
JGraph . |
void |
refresh()
Repaints the entire graph, regardless of what is marked dirty
|
void |
releaseOffscreenResources()
Schedules the offscreen resources taken by the offscreen buffer to
be reclaimed.
|
void |
removeGraphSelectionListener(GraphSelectionListener tsl)
Removes a
GraphSelection listener. |
void |
removeSelectionCell(java.lang.Object cell)
Removes the cell identified by the specified Object from the current
selection.
|
void |
scrollCellToVisible(java.lang.Object cell)
Scrolls to the specified cell.
|
void |
scrollPointToVisible(java.awt.geom.Point2D p)
Makes sure the specified point is visible.
|
void |
setAntiAliased(boolean newValue)
Sets antialiasing on or off based on the boolean value.
|
void |
setAutoResizeGraph(boolean autoResizeGraph)
Sets whether or not the graph should be automatically resize when cells
are being moved below the bottom right corner
|
void |
setBackground(java.awt.Color bg)
Override parent to clear offscreen double buffer
|
void |
setBackgroundComponent(java.awt.Component backgroundComponent) |
void |
setBackgroundImage(javax.swing.ImageIcon backgroundImage)
Sets the background image.
|
void |
setBackgroundScaled(boolean backgroundScaled) |
void |
setBendable(boolean flag)
Sets if the graph allows adding/removing/modifying points.
|
void |
setCloneable(boolean flag)
Sets if cells are cloned on CTRL-Drag operations.
|
void |
setConnectable(boolean flag)
Setse if the graph allows new connections to be established.
|
void |
setDisconnectable(boolean flag)
Sets if the graph allows existing connections to be removed.
|
void |
setDisconnectOnMove(boolean flag)
Sets if selected edges should be disconnected from unselected vertices
when they are moved.
|
void |
setDragEnabled(boolean flag)
Sets if the graph uses Drag-and-Drop to move cells.
|
void |
setDropEnabled(boolean flag)
Sets if the graph accepts drops/pastes from external sources.
|
void |
setEdgeLabelsMovable(boolean edgeLabelsMovable)
Set if edge labels may be moved with the mouse or not.
|
void |
setEditable(boolean flag)
Determines whether the graph is editable.
|
void |
setEditClickCount(int count)
Sets the number of clicks for editing to start.
|
void |
setGraphLayoutCache(GraphLayoutCache newLayoutCache)
Sets the
GraphLayoutCache that will provide the view-data. |
void |
setGridColor(java.awt.Color newColor)
Sets the current grid color.
|
void |
setGridEnabled(boolean flag)
If set to true, the grid will be active.
|
void |
setGridMode(int mode)
Sets the current grid view mode.
|
void |
setGridSize(double newSize)
Sets the size of the grid.
|
void |
setGridVisible(boolean flag)
If set to true, the grid will be visible.
|
void |
setGroupsEditable(boolean groupsEditable) |
void |
setHandleColor(java.awt.Color newColor)
Sets the current handle color.
|
void |
setHandleSize(int size)
Sets the size of the handles.
|
void |
setHighlightColor(java.awt.Color newColor)
Sets the current selection highlight color.
|
void |
setInvokesStopCellEditing(boolean newValue)
Determines what happens when editing is interrupted by selecting another
cell in the graph, a change in the graph's data, or by some other means.
|
void |
setJumpToDefaultPort(boolean flag)
Sets if getPortViewAt should return the default port if no other port is
found.
|
void |
setLockedHandleColor(java.awt.Color newColor)
Sets the current second handle color.
|
void |
setMarqueeColor(java.awt.Color newColor)
Sets the current marquee color.
|
void |
setMarqueeHandler(BasicMarqueeHandler newMarquee)
Sets the
MarqueeHandler that will handle marquee
selection. |
void |
setMinimumMove(int pixels)
Sets the miminum amount of pixels for a move operation.
|
void |
setModel(GraphModel newModel)
Sets the
GraphModel that will provide the data. |
void |
setMoveable(boolean flag)
Sets if the graph allows movement of cells.
|
void |
setMoveBelowZero(boolean moveBelowZero)
Sets if the graph should auto resize when cells are being moved below the
bottom right corner.
|
void |
setMoveBeyondGraphBounds(boolean moveBeyondGraphBounds) |
void |
setMoveIntoGroups(boolean flag)
Specifies if cells should be added to groups when moved over the group's
area.
|
void |
setMoveOutOfGroups(boolean flag)
Specifies if cells should be removed from groups when removed from the
group's area.
|
void |
setOffscreenOffset(java.awt.geom.Point2D offscreenOffset) |
void |
setOpaque(boolean opaque) |
void |
setPortsOnTop(boolean portsOnTop) |
void |
setPortsScaled(boolean flag)
If set to true, the ports will be scaled.
|
void |
setPortsVisible(boolean flag)
If set to true, the ports will be visible.
|
void |
setPreviewInvalidNullPorts(boolean flag)
Determines whether the graph allows invalid null ports during previews
|
void |
setScale(double newValue)
Sets the current scale.
|
void |
setScale(double newValue,
java.awt.geom.Point2D center)
Sets the current scale and centers the graph to the specified point
|
void |
setSelectionCell(java.lang.Object cell)
Selects the specified cell.
|
void |
setSelectionCells(java.lang.Object[] cells)
Selects the specified cells.
|
void |
setSelectionEnabled(boolean flag)
Determines whether cell selection is enabled.
|
void |
setSelectionModel(GraphSelectionModel selectionModel)
Sets the graph's selection model.
|
void |
setSizeable(boolean flag)
Sets if the graph allows cells to be resized.
|
void |
setTolerance(int size)
Sets the maximum distance between the mousepointer and a cell to be
selected.
|
void |
setUI(GraphUI ui)
Sets the L&F object that renders this component.
|
protected void |
setupOffScreen(int x,
int y,
int width,
int height,
java.awt.geom.Rectangle2D newOffscreenBuffer)
Utility method that initialises the offscreen graphics area
|
void |
setVolatileOffscreen(boolean volatileOffscreen) |
void |
setXorEnabled(boolean flag)
Sets if the graph accepts drops/pastes from external sources.
|
java.awt.geom.Dimension2D |
snap(java.awt.geom.Dimension2D d)
Returns the given dimension applied to the grid.
|
java.awt.geom.Point2D |
snap(java.awt.geom.Point2D p)
Returns the given point applied to the grid.
|
java.awt.geom.Rectangle2D |
snap(java.awt.geom.Rectangle2D r)
Returns the given rectangle applied to the grid.
|
void |
startEditingAtCell(java.lang.Object cell)
Selects the specified cell and initiates editing.
|
boolean |
stopEditing()
Ends the current editing session.
|
java.awt.geom.Point2D |
toScreen(java.awt.geom.Point2D p)
Upscale the given point in place, using the given instance.
|
java.awt.geom.Rectangle2D |
toScreen(java.awt.geom.Rectangle2D rect)
Upscale the given rectangle in place, using the given instance.
|
void |
updateAutoSize(CellView view)
Computes and updates the size for
view . |
void |
updateUI()
Notification from the
UIManager that the L&F has changed. |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final java.lang.String VERSION
public static final int DOT_GRID_MODE
public static final int CROSS_GRID_MODE
public static final int LINE_GRID_MODE
public static boolean IS_MAC
protected transient JGraph.GraphSelectionRedirector selectionRedirector
selectionListeners
.protected transient GraphModel graphModel
protected transient GraphLayoutCache graphLayoutCache
protected transient GraphSelectionModel selectionModel
protected transient BasicMarqueeHandler marquee
protected transient java.awt.Image offscreen
protected transient java.awt.geom.Rectangle2D offscreenBounds
protected transient java.awt.geom.Point2D offscreenOffset
protected transient java.awt.Graphics offgraphics
protected transient java.awt.geom.Rectangle2D offscreenDirty
protected transient boolean wholeOffscreenDirty
protected transient double wholeOffscreenDirtyProportion
protected transient int offscreenBuffer
protected boolean volatileOffscreen
protected boolean lastBufferAllocated
protected javax.swing.ImageIcon backgroundImage
protected java.awt.Component backgroundComponent
protected boolean backgroundScaled
protected double scale
protected boolean antiAliased
protected boolean editable
protected boolean groupsEditable
protected boolean selectionEnabled
protected boolean previewInvalidNullPorts
protected boolean gridVisible
protected double gridSize
protected int gridMode
protected boolean portsVisible
protected boolean portsScaled
protected boolean portsOnTop
protected boolean moveBelowZero
protected boolean moveBeyondGraphBounds
protected boolean edgeLabelsMovable
protected boolean autoResizeGraph
protected java.awt.Color highlightColor
protected java.awt.Color handleColor
protected java.awt.Color lockedHandleColor
protected java.awt.Color marqueeColor
protected java.awt.Color gridColor
protected boolean dragEnabled
protected boolean dropEnabled
protected boolean xorEnabled
protected int editClickCount
protected boolean enabled
protected boolean gridEnabled
protected int handleSize
protected int tolerance
protected int minimumMove
protected boolean isJumpToDefaultPort
protected boolean isMoveIntoGroups
protected boolean isMoveOutOfGroups
protected boolean disconnectOnMove
protected boolean moveable
protected boolean cloneable
protected boolean sizeable
protected boolean bendable
protected boolean connectable
protected boolean disconnectable
protected boolean invokesStopCellEditing
stopCellEditing
is
invoked, and changes are saved. If false, cancelCellEditing
is invoked, and changes are discarded.public static final java.lang.String GRAPH_MODEL_PROPERTY
graphModel
.public static final java.lang.String GRAPH_LAYOUT_CACHE_PROPERTY
graphModel
.public static final java.lang.String MARQUEE_HANDLER_PROPERTY
graphModel
.public static final java.lang.String EDITABLE_PROPERTY
editable
.public static final java.lang.String SELECTIONENABLED_PROPERTY
selectionEnabled
.public static final java.lang.String SCALE_PROPERTY
scale
.public static final java.lang.String ANTIALIASED_PROPERTY
antiAliased
.public static final java.lang.String GRID_SIZE_PROPERTY
gridSize
.public static final java.lang.String GRID_VISIBLE_PROPERTY
gridVisible
.public static final java.lang.String GRID_COLOR_PROPERTY
gridColor
.public static final java.lang.String HANDLE_COLOR_PROPERTY
gridColor
.public static final java.lang.String HANDLE_SIZE_PROPERTY
gridColor
.public static final java.lang.String LOCKED_HANDLE_COLOR_PROPERTY
gridColor
.public static final java.lang.String PORTS_VISIBLE_PROPERTY
gridVisible
.public static final java.lang.String PORTS_SCALED_PROPERTY
portsScaled
.public static final java.lang.String SELECTION_MODEL_PROPERTY
selectionModel
.public static final java.lang.String INVOKES_STOP_CELL_EDITING_PROPERTY
messagesStopCellEditing
.public static final java.lang.String PROPERTY_BACKGROUNDIMAGE
backgroundImage
.public JGraph()
JGraph
with a sample model.public JGraph(GraphModel model)
JGraph
which displays the the
specified data model.model
- the GraphModel
to use as the data modelpublic JGraph(GraphLayoutCache cache)
JGraph
which displays the data
model using the specified view.cache
- the GraphLayoutCache
to use as the viewpublic JGraph(GraphModel model, GraphLayoutCache cache)
JGraph
which displays the specified
data model using the specified view.model
- the GraphModel
to use as the data modelcache
- the GraphLayoutCache
to use as the cachepublic JGraph(GraphModel model, BasicMarqueeHandler mh)
JGraph
which displays the specified
data model and assigns the specified marquee handlermodel
- the GraphModel
to use as the data modelmh
- the BasicMarqueeHandler
to use as the marquee
handlerpublic JGraph(GraphModel model, GraphLayoutCache layoutCache, BasicMarqueeHandler mh)
JGraph
which displays the specified
data model using the specified view and assigns the specified marquee
handlermodel
- the GraphModel
to use as the data modellayoutCache
- the GraphLayoutCache
to use as the cachemh
- the BasicMarqueeHandler
to use as the marquee
handlerpublic static void addSampleData(GraphModel model)
GraphModel
. Used primarily
for beanbuilders to show something interesting.public static java.util.Map createBounds(AttributeMap map, int x, int y, java.awt.Color c)
public GraphUI getUI()
public void setUI(GraphUI ui)
ui
- the GraphUI L&F objectUIDefaults.getUI(JComponent)
public void updateUI()
UIManager
that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager
. Subclassers can override this to support
different GraphUIs.updateUI
in class javax.swing.JComponent
JComponent.updateUI()
public java.lang.String getUIClassID()
getUIClassID
in class javax.swing.JComponent
JComponent.getUIClassID()
public java.lang.Object[] getRoots()
public java.lang.Object[] getRoots(java.awt.Rectangle clip)
public java.lang.Object[] getDescendants(java.lang.Object[] cells)
cells
including all descendants in the passed
in order of cells.public java.lang.Object[] order(java.lang.Object[] cells)
cells
including all descendants ordered using
the current layering data stored by the model.public java.util.Map cloneCells(java.lang.Object[] cells)
cells
and
their children. Special care is taken to replace the anchor references
between ports. (Iterative implementation.)public CellView getTopmostViewAt(double x, double y, boolean reverse, boolean leafsOnly)
public java.lang.Object getFirstCellForLocation(double x, double y)
x
- an integer giving the number of pixels horizontally from the
left edge of the display area, minus any left marginy
- an integer giving the number of pixels vertically from the top
of the display area, minus any top marginpublic java.lang.Object getNextCellForLocation(java.lang.Object current, double x, double y)
current
cell. Returns the topmost cell if there are no
more cells behind current
. Note: This does only return
visible cells.public java.awt.geom.Rectangle2D getCellBounds(java.lang.Object cell)
public java.awt.geom.Rectangle2D getCellBounds(java.lang.Object[] cells)
public CellView getNextViewAt(CellView current, double x, double y)
current
.
This is used to iterate overlapping cells, and cells that are grouped.
The current selection affects this method. public CellView getNextViewAt(CellView current, double x, double y, boolean leafsOnly)
current
.
This is used to iterate overlapping cells, and cells that are grouped.
The current selection affects this method. public CellView getNextSelectableViewAt(CellView current, double x, double y)
public CellView getNextViewAt(CellView[] cells, CellView c, double x, double y)
c
in
the specified array of views. The views must be in order, as returned,
for example, by GraphLayoutCache.order(Object[]).public CellView getNextViewAt(CellView[] cells, CellView c, double x, double y, boolean leafsOnly)
c
in
the specified array of views. The views must be in order, as returned,
for example, by GraphLayoutCache.order(Object[]).public CellView getLeafViewAt(double x, double y)
c
in
the specified array of views. The views must be in order, as returned,
for example, by GraphLayoutCache.order(Object[]).public java.lang.Object getPortForLocation(double x, double y)
public PortView getPortViewAt(double x, double y)
public PortView getPortViewAt(double x, double y, int tolerance)
public PortView getDefaultPortForCell(java.lang.Object cell)
cell
- the cell whose port is to be obtainedpublic java.lang.String convertValueToString(java.lang.Object value)
public java.awt.geom.Point2D snap(java.awt.geom.Point2D p)
p
- a point in screen coordinates.public java.awt.geom.Rectangle2D snap(java.awt.geom.Rectangle2D r)
r
- a rectangle in screen coordinates.public java.awt.geom.Dimension2D snap(java.awt.geom.Dimension2D d)
d
- a dimension in screen coordinates to snap to.public java.awt.geom.Point2D toScreen(java.awt.geom.Point2D p)
p
- the point to be upscaledpublic java.awt.geom.Point2D fromScreen(java.awt.geom.Point2D p)
p
- the point to be downscaledpublic java.awt.geom.Rectangle2D toScreen(java.awt.geom.Rectangle2D rect)
rect
- the rectangle to be upscaledpublic java.awt.geom.Rectangle2D fromScreen(java.awt.geom.Rectangle2D rect)
rect
- the rectangle to be downscaledpublic void updateAutoSize(CellView view)
view
.public AttributeMap getAttributes(java.lang.Object cell)
public int getEditClickCount()
public void setEditClickCount(int count)
public boolean isDropEnabled()
public void setDropEnabled(boolean flag)
public boolean isXorEnabled()
public void setXorEnabled(boolean flag)
public boolean isDragEnabled()
public void setDragEnabled(boolean flag)
public boolean isMoveable()
public void setMoveable(boolean flag)
public boolean isBendable()
public void setBendable(boolean flag)
public boolean isConnectable()
public void setConnectable(boolean flag)
public boolean isDisconnectable()
public void setDisconnectable(boolean flag)
public boolean isCloneable()
public void setCloneable(boolean flag)
public boolean isSizeable()
public void setSizeable(boolean flag)
public void setDisconnectOnMove(boolean flag)
public boolean isDisconnectOnMove()
public void setJumpToDefaultPort(boolean flag)
public boolean isJumpToDefaultPort()
public void setMoveIntoGroups(boolean flag)
public boolean isMoveIntoGroups()
public void setMoveOutOfGroups(boolean flag)
public boolean isMoveOutOfGroups()
public boolean isGridEnabled()
snap(Point2D)
public void setGridEnabled(boolean flag)
snap(Point2D)
public boolean isMoveBelowZero()
public void setMoveBelowZero(boolean moveBelowZero)
public boolean isMoveBeyondGraphBounds()
public void setMoveBeyondGraphBounds(boolean moveBeyondGraphBounds)
moveBeyondGraphBounds
- the moveBeyondGraphBounds to setpublic boolean getEdgeLabelsMovable()
public void setEdgeLabelsMovable(boolean edgeLabelsMovable)
edgeLabelsMovable
- true if edge labels may be draggedpublic boolean isAutoResizeGraph()
moveBeyondGraphBounds
if false
auto resizing
is automatically disabledpublic void setAutoResizeGraph(boolean autoResizeGraph)
public int getTolerance()
public void setTolerance(int size)
public int getHandleSize()
public void setHandleSize(int size)
public int getMinimumMove()
public void setMinimumMove(int pixels)
public java.awt.Color getGridColor()
public void setGridColor(java.awt.Color newColor)
public java.awt.Color getHandleColor()
public void setHandleColor(java.awt.Color newColor)
public java.awt.Color getLockedHandleColor()
public void setLockedHandleColor(java.awt.Color newColor)
public java.awt.Color getMarqueeColor()
public void setMarqueeColor(java.awt.Color newColor)
public java.awt.Color getHighlightColor()
public void setHighlightColor(java.awt.Color newColor)
public double getScale()
public void setScale(double newValue)
Fires a property change for the SCALE_PROPERTY.
newValue
- the new scalepublic void setScale(double newValue, java.awt.geom.Point2D center)
newValue
- the new scalecenter
- the center of the graphpublic void clearOffscreen()
public java.awt.geom.Point2D getCenterPoint()
public java.awt.geom.Rectangle2D getViewPortBounds()
public double getGridSize()
public int getGridMode()
public void setGridSize(double newSize)
Fires a property change for the GRID_SIZE_PROPERTY.
newSize
- the new size of the grid in pixelspublic void setGridMode(int mode)
mode
- The current grid view mode. Valid values are
DOT_GRID_MODE
,CROSS_GRID_MODE
, and
LINE_GRID_MODE
.public boolean isGridVisible()
public void setGridVisible(boolean flag)
Fires a property change for the GRID_VISIBLE_PROPERTY.
public boolean isPortsVisible()
public void setPortsVisible(boolean flag)
Fires a property change for the PORTS_VISIBLE_PROPERTY.
public boolean isPortsScaled()
public void setPortsScaled(boolean flag)
Fires a property change for the PORTS_SCALED_PROPERTY.
public boolean isPortsOnTop()
public void setPortsOnTop(boolean portsOnTop)
public boolean isAntiAliased()
public void setAntiAliased(boolean newValue)
Fires a property change for the ANTIALIASED_PROPERTY.
newValue
- whether to turn antialiasing on or offpublic boolean isEditable()
public void setEditable(boolean flag)
Note: Editable determines whether the graph allows editing. This is not to be confused with enabled, which allows the graph to handle mouse events (including editing).
flag
- a boolean value, true if the graph is editablepublic boolean isGroupsEditable()
public void setGroupsEditable(boolean groupsEditable)
groupsEditable
- the groupsEditable to setpublic boolean isSelectionEnabled()
public void setSelectionEnabled(boolean flag)
flag
- a boolean value, true if cell selection is enabledpublic boolean isPreviewInvalidNullPorts()
public void setPreviewInvalidNullPorts(boolean flag)
flag
- a boolean value, true if the graph allows invalid null ports
during previewspublic java.awt.Graphics getOffgraphics()
protected void createBufferedImage(int width, int height)
width
- height
- protected void setupOffScreen(int x, int y, int width, int height, java.awt.geom.Rectangle2D newOffscreenBuffer)
x
- y
- width
- height
- newOffscreenBuffer
- public java.awt.Image getOffscreen()
public java.awt.geom.Rectangle2D getOffscreenDirty()
public void addOffscreenDirty(java.awt.geom.Rectangle2D offscreenDirty)
offscreenDirty
- the region to addpublic void clearOffscreenDirty()
public void releaseOffscreenResources()
public boolean drawImage(int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2)
dx1
- the x coordinate of the first corner of the
destination rectangle.dy1
- the y coordinate of the first corner of the
destination rectangle.dx2
- the x coordinate of the second corner of the
destination rectangle.dy2
- the y coordinate of the second corner of the
destination rectangle.sx1
- the x coordinate of the first corner of the source
rectangle.sy1
- the y coordinate of the first corner of the source
rectangle.sx2
- the x coordinate of the second corner of the source
rectangle.sy2
- the y coordinate of the second corner of the source
rectangle.true
if the current output representation is
complete; false
otherwise.public boolean drawImage(java.awt.Graphics g)
public javax.swing.ImageIcon getBackgroundImage()
public void setBackgroundImage(javax.swing.ImageIcon backgroundImage)
PROPERTY_BACKGROUNDIMAGE
.backgroundImage
- The backgroundImage to set.public void setBackground(java.awt.Color bg)
setBackground
in class javax.swing.JComponent
public boolean isBackgroundScaled()
public java.awt.geom.Point2D getOffscreenOffset()
public void setOffscreenOffset(java.awt.geom.Point2D offscreenOffset)
offscreenOffset
- the offscreenOffset to setpublic boolean isVolatileOffscreen()
public void setVolatileOffscreen(boolean volatileOffscreen)
volatileOffscreen
- the volatileOffscreen to setpublic void setBackgroundScaled(boolean backgroundScaled)
backgroundScaled
- the backgroundScaled to setpublic java.awt.Component getBackgroundComponent()
public void setBackgroundComponent(java.awt.Component backgroundComponent)
backgroundComponent
- the backgroundComponent to setpublic void setOpaque(boolean opaque)
setOpaque
in class javax.swing.JComponent
public GraphModel getModel()
GraphModel
that is providing the data.public void setModel(GraphModel newModel)
GraphModel
that will provide the data. Note:
Updates the current GraphLayoutCache's model using setModel if the
GraphLayoutCache points to a different model.
Fires a property change for the GRAPH_MODEL_PROPERTY.
newModel
- the GraphModel
that is to provide the datapublic GraphLayoutCache getGraphLayoutCache()
GraphLayoutCache
that is providing the
view-data.public void setGraphLayoutCache(GraphLayoutCache newLayoutCache)
GraphLayoutCache
that will provide the view-data.
Note: Updates the graphs's model using using the model from the layout cache.
Fires a property change for the GRAPH_LAYOUT_CACHE_PROPERTY.
newLayoutCache
- the GraphLayoutCache
that is to provide the
view-datapublic BasicMarqueeHandler getMarqueeHandler()
MarqueeHandler
that will handle marquee
selection.public void setMarqueeHandler(BasicMarqueeHandler newMarquee)
MarqueeHandler
that will handle marquee
selection.newMarquee
- the BasicMarqueeHandler
that is to provide
marquee handlingpublic void setInvokesStopCellEditing(boolean newValue)
true
causes the changes to be
automatically saved when editing is interrupted.
Fires a property change for the INVOKES_STOP_CELL_EDITING_PROPERTY.
newValue
- true means that stopCellEditing
is invoked when
editing is interruped, and data is saved; false means that
cancelCellEditing
is invoked, and changes are
lostpublic boolean getInvokesStopCellEditing()
setInvokesStopCellEditing(boolean)
public boolean isCellEditable(java.lang.Object cell)
true
if the graph and the cell are editable. This
is invoked from the UI before editing begins to ensure that the given
cell can be edited.isEditable()
public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
JComponent
'sgetToolTipText
method in order to allow the graph to create a tooltip for the topmost
cell under the mousepointer. This differs from JTree where the renderers
tooltip is used.
NOTE: For JGraph
to properly display tooltips of its
renderers, JGraph
must be a registered component with the
ToolTipManager
. This can be done by invoking
ToolTipManager.sharedInstance().registerComponent(graph)
.
This is not done automatically!
getToolTipText
in class javax.swing.JComponent
e
- the MouseEvent
that initiated the
ToolTip
displaynull
if
event
is nullpublic void setSelectionModel(GraphSelectionModel selectionModel)
null
value is
specified an emtpy selectionModel
is used, which does not
allow selections.selectionModel
- the GraphSelectionModel
to use, or
null
to disable selectionsGraphSelectionModel
public GraphSelectionModel getSelectionModel()
null
value. If you don't want to allow anything to be
selected set the selection model to null
, which forces an
empty selection model to be used.setSelectionModel(org.jgraph.graph.GraphSelectionModel)
public void clearSelection()
public boolean isSelectionEmpty()
public void addGraphSelectionListener(GraphSelectionListener tsl)
GraphSelection
events.tsl
- the GraphSelectionListener
that will be
notified when a cell is selected or deselected (a "negative
selection")public void removeGraphSelectionListener(GraphSelectionListener tsl)
GraphSelection
listener.tsl
- the GraphSelectionListener
to removeprotected void fireValueChanged(GraphSelectionEvent e)
e
- the GraphSelectionEvent
generated by the
GraphSelectionModel
when a cell is selected or
deselectedEventListenerList
public void setSelectionCell(java.lang.Object cell)
cell
- the Object
specifying the cell to selectpublic void setSelectionCells(java.lang.Object[] cells)
cells
- an array of objects that specifies the cells to selectpublic void addSelectionCell(java.lang.Object cell)
Object
to the
current selection.cell
- the cell to be added to the selectionpublic void addSelectionCells(java.lang.Object[] cells)
cells
- an array of objects that specifies the cells to addpublic void removeSelectionCell(java.lang.Object cell)
cell
- the cell to be removed from the selectionpublic java.lang.Object getSelectionCell()
Object
for the first selected cell, or
null
if nothing is currently selectedpublic java.lang.Object[] getSelectionCells()
null
if nothing is currently selectedpublic java.lang.Object[] getSelectionCells(java.lang.Object[] cells)
cells
.public java.lang.Object getSelectionCellAt(java.awt.geom.Point2D pt)
pt
.public int getSelectionCount()
public boolean isCellSelected(java.lang.Object cell)
cell
- an object identifying a cellpublic void scrollCellToVisible(java.lang.Object cell)
JGraph
is contained in a JScrollPane
.cell
- the object identifying the cell to bring into viewpublic void scrollPointToVisible(java.awt.geom.Point2D p)
p
- the point that should be visiblepublic boolean isEditing()
getEditingCell
.getSelectionCell()
public boolean stopEditing()
DefaultGraphCellEditor
object saves any edits that are
currently in progress on a cell. Other implementations may operate
differently.) Has no effect if the tree isn't being edited. Note:
To make edit-saves automatic whenever the user changes their position in the graph, usesetInvokesStopCellEditing(boolean)
.
public void cancelEditing()
public void startEditingAtCell(java.lang.Object cell)
CellEditor
does not allow editing for the specified
item.public java.lang.Object getEditingCell()
public void graphDidChange()
public void refresh()
public java.awt.image.BufferedImage getImage(java.awt.Color bg, int inset)
BufferedImage
for the graph using inset as an empty
border around the cells of the graph. If bg is null then a transparent
background is applied to the image, else the background is filled with
the bg color. Therefore, one should only use a null background if the
fileformat support transparency, eg. GIF and PNG. For JPG, you can use
Color.WHITE
for example.public java.awt.geom.Rectangle2D getClipRectangle(GraphLayoutCacheEvent.GraphLayoutCacheChange change)
change
- public java.awt.Dimension getPreferredScrollableViewportSize()
JGraph
. The
height is determined from getPreferredWidth
.getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
visibleRect
- the view area visible within the viewportorientation
- either SwingConstants.VERTICAL
or
SwingConstants.HORIZONTAL
direction
- less than zero to scroll up/left, greater than zero for
down/rightJScrollBar.setUnitIncrement(int)
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
visibleRect
, based on orientation
.getScrollableBlockIncrement
in interface javax.swing.Scrollable
visibleRect
- the view area visible within the viewportorientation
- either SwingConstants.VERTICAL
or
SwingConstants.HORIZONTAL
direction
- less than zero to scroll up/left, greater than zero for
down/right.JScrollBar.setBlockIncrement(int)
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
Scrollable.getScrollableTracksViewportWidth()
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
Scrollable.getScrollableTracksViewportHeight()
protected java.lang.String paramString()
JGraph
. This
method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null
.paramString
in class javax.swing.JComponent
JGraph
.public static void main(java.lang.String[] args)
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.