|
JGraph |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgraph.graph.GraphLayoutCache
An object that defines the view of a graphmodel. This object maps between model cells and views and provides a set of methods to change these views. The view may also contain its own set of attributes and is therefore an extension of an Observable, which may be observed by the GraphUI. It uses the model to send its changes to the command history.
Nested Class Summary | |
class |
GraphLayoutCache.GraphLayoutCacheEdit
An implementation of GraphLayoutCacheChange. |
Field Summary | |
protected boolean |
allAttributesLocal
Controls if all attributes are local. |
protected boolean |
autoSizeOnValueChange
True if the cells should be auto-sized when their values change. |
protected double |
collapseXScale
Specified the initial x- and y-scaling factor for initial collapsed group bounds. |
protected double |
collapseYScale
Specified the initial x- and y-scaling factor for initial collapsed group bounds. |
protected CellViewFactory |
factory
Factory to create the views. |
protected GraphModel |
graphModel
Reference to the graphModel |
protected Map |
hiddenMapping
Maps cells to views. |
protected boolean |
hidesDanglingConnections
Boolean indicating whether existing connections should be hidden if their source or target port is removed from the model. |
protected boolean |
hidesExistingConnections
Boolean indicating whether existing connections should be hidden if their source or target and no parent of the ports is visible, either by hiding the cell or by changing the source or target of the edge to a hidden cell. |
protected EventListenerList |
listenerList
The list of listeners that listen to the GraphLayoutCache. |
protected Set |
localAttributes
A set containing all attribute keys that are stored in the cell views, in other words, the view-local attributes. |
protected Map |
mapping
Maps cells to views. |
protected boolean |
movesChildrenOnExpand
Boolean indicating whether children should be moved to the parent group's origin on expand. |
protected boolean |
movesParentsOnCollapse
Boolean indicating whether parents should be moved to the child area origin on collapse. |
protected boolean |
partial
Only portions of the model are visible. |
protected PortView[] |
ports
Cached array of all ports for the view. |
protected boolean |
reconnectsEdgesToVisibleParent
Deprecated. edges are moved to parent view and back automatically |
protected boolean |
remembersCellViews
Boolean indicating whether cellviews should be remembered once visible in this GraphLayoutCache. |
protected boolean |
resizesParentsOnCollapse
Boolean indicating whether parents should always be resized to the child area on collapse. |
protected List |
roots
Ordered list of roots for the view. |
protected boolean |
selectsAllInsertedCells
Boolean indicating whether inserted cells should automatically be selected. |
protected boolean |
selectsLocalInsertedCells
Boolean indicating whether cells that are inserted using the local insert method should automatically be selected. |
protected boolean |
showsChangedConnections
Boolean indicating whether connections should be made visible when reconnected and their source and target port is visible. |
protected boolean |
showsExistingConnections
Boolean indicating whether existing connections should me made visible if their sources or targets are made visible, given the opposite end of the edge is already visible or made visible, too. |
protected boolean |
showsInsertedCells
Boolean indicating whether inserted should be made visible if they are inserted via insert(Object[], Map, ConnectionSet, ParentMap, UndoableEdit[]) . |
protected boolean |
showsInsertedConnections
Boolean indicating whether inserted edges should me made visible if their sources or targets are already visible. |
protected boolean |
showsInvisibleEditedCells
Boolean indicating whether edited cells should be made visible if they are changed via edit(Map, ConnectionSet, ParentMap, UndoableEdit[]) . |
protected Set |
visibleSet
The set of visible cells. |
Constructor Summary | |
GraphLayoutCache()
Constructs a graph layout cache. |
|
GraphLayoutCache(GraphModel model,
CellViewFactory factory)
Constructs a view for the specified model that uses factory
to create its views. |
|
GraphLayoutCache(GraphModel model,
CellViewFactory factory,
boolean partial)
Constructs a view for the specified model that uses factory
to create its views. |
|
GraphLayoutCache(GraphModel model,
CellViewFactory factory,
CellView[] cellViews,
CellView[] hiddenCellViews,
boolean partial)
Constructs a view for the specified model that uses factory
to create its views. |
Method Summary | |
void |
addGraphLayoutCacheListener(GraphLayoutCacheListener l)
Adds a listener for the GraphLayoutCacheEvent posted after the graph layout cache changes. |
protected Object[] |
addVisibleDependencies(Object[] cells,
boolean visible)
|
protected UndoableEdit[] |
augment(UndoableEdit[] e,
UndoableEdit edit)
|
protected void |
augmentNestedMapForValueChange(Map nested,
Object cell,
Object newValue)
Hook for subclassers to add more stuff for value changes. |
protected void |
cellExpanded(Object cell)
Called when a child has been made visible by expanding its parent. |
void |
cellViewsChanged(CellView[] cellViews)
Invoke this method after you've changed how the cells are to be represented in the graph. |
protected void |
cellWillCollapse(Object cell)
|
void |
collapse(Object[] groups)
Collapses all groups by hiding all their descendants. |
protected GraphLayoutCache.GraphLayoutCacheEdit |
createLocalEdit(Object[] inserted,
Map nested,
Object[] visible,
Object[] invisible)
Creates a local edit for the specified change. |
Map |
createNestedMap()
Returns a nested map of (cell, map) pairs that represent all attributes of all cell views in this view. |
void |
edit(Map attributes)
A shortcut method that takes a nested map and passes it to the edit method. |
void |
edit(Map attributes,
ConnectionSet cs,
ParentMap pm,
UndoableEdit[] e)
Applies the propertyMap and the connection changes to the
model. |
void |
edit(Object[] cells,
Map attributes)
Applies the attributes to all cells by
creating a map that contains the attributes for each cell and passing it
to edit on this layout cache. |
void |
editCell(Object cell,
Map attributes)
Applies the attributes to a single cell by
creating a map that contains the attributes for this cell and passing it
to edit on this layout cache. |
void |
expand(Object[] cells)
Expands all groups by showing all children. |
protected void |
fireGraphLayoutCacheChanged(Object source,
GraphLayoutCacheEvent.GraphLayoutCacheChange edit)
|
CellView[] |
getAllDescendants(CellView[] views)
Returns all views, including descendants that have a parent in views , especially the PortViews. |
CellView[] |
getAllViews()
Returns all views, shortcut to getAllDescendants(getRoots()) |
static Rectangle2D |
getBounds(CellView[] views)
Returns the bounding box for the specified cell views. |
Object[] |
getCells(boolean groups,
boolean vertices,
boolean ports,
boolean edges)
A helper method to return various arrays of cells that are visible in this cache. |
Object[] |
getCells(CellView[] views)
Takes an array of views and returns the array of the corresponding cells by using getCell for each view. |
CellView[] |
getCellViews()
|
protected Object |
getChildPort(Object edge,
boolean source)
Hook for subclassers to return the port to be used for edges that have been connected to the group. |
double |
getCollapseXScale()
|
double |
getCollapseYScale()
|
protected Object[] |
getContext(GraphModelEvent.GraphModelChange change)
Hook for subclassers to augment the context for a graphChange. |
protected List |
getEdges(Object cell,
Set exclude,
boolean visibleCells,
boolean selfLoops,
boolean incoming)
Returns the incoming or outgoing edges for cell. |
CellViewFactory |
getFactory()
Returns the factory that was passed to the constructor. |
GraphLayoutCacheListener[] |
getGraphLayoutCacheListeners()
Return an array of all GraphLayoutCacheListener that were added to this model. |
CellView[] |
getHiddenCellViews()
|
Map |
getHiddenMapping()
Returns the hiddenMapping. |
List |
getIncomingEdges(Object cell,
Set exclude,
boolean visibleCells,
boolean selfLoops)
Returns the incoming edges for cell. |
Set |
getLocalAttributes()
|
CellView[] |
getMapping(Object[] cells)
Returns the views for the specified array of cells without creating these views on the fly. |
CellView[] |
getMapping(Object[] cells,
boolean create)
Returns the views for the specified array of cells. |
CellView |
getMapping(Object cell,
boolean create)
Returns the view for the specified cell. |
GraphModel |
getModel()
Returns the current model. |
List |
getNeighbours(Object cell,
Set exclude,
boolean directed,
boolean visibleCells)
Returns a collection of cells that are connected to the specified cell by edges. |
List |
getOutgoingEdges(Object cell,
Set exclude,
boolean visibleCells,
boolean selfLoops)
Returns the outgoing edges for cell. |
protected Object |
getParentPort(Object edge,
boolean source)
Hook for subclassers to return the first or last visible port to replace the current source or target port of the edge. |
protected Collection |
getParentPorts(Object cell)
|
boolean |
getPartial()
Required for XML persistence |
PortView[] |
getPorts()
Returns the ports of the view. |
protected Collection |
getPorts(Object cell)
|
CellView[] |
getRoots()
Returns the roots of the view. |
CellView[] |
getRoots(Rectangle2D clip)
Return all root cells that intersect the given rectangle. |
Object[] |
getVisibleCells(Object[] cells)
Returns a an array with the visible cells in cells . |
Set |
getVisibleSet()
Returns the set of visible sets in this view. |
void |
graphChanged(GraphModelEvent.GraphModelChange change)
Called from BasicGraphUI.ModelHandler to update the view based on the specified GraphModelEvent. |
protected Map |
handleAttributes(Map attributes)
Attention: Undo will not work for routing-change if ROUTING and POINTS are stored in different locations. |
protected boolean |
hasVisibleParent(Object cell,
Set invisible)
Checks if the port or one of its parents is visible. |
void |
hideCells(Object[] cells,
boolean descandants)
Hides the specified cells with all children if descandants
is true. |
protected void |
hideCellsForChange(GraphModelEvent.GraphModelChange change)
|
void |
insert(Object cell)
Inserts the specified vertex into the graph model. |
void |
insert(Object[] cells)
Inserts the specified cells into the graph model. |
void |
insert(Object[] cells,
Map nested,
ConnectionSet cs,
ParentMap pm)
Variant of the insert method that allows to pass a default connection set and parent map and nested map. |
void |
insert(Object[] roots,
Map attributes,
ConnectionSet cs,
ParentMap pm,
UndoableEdit[] e)
Inserts the cells and connections into the model, and
absorbs the local attributes. |
Object[] |
insertClones(Object[] cells,
Map clones,
Map nested,
ConnectionSet cs,
ParentMap pm,
double dx,
double dy)
Inserts the cloned cells from the clone map and clones the passed-in arguments according to the clone map before insertion and returns the clones in order of the cells. |
void |
insertEdge(Object edge,
Object source,
Object target)
Inserts the specified edge into the graph model. |
void |
insertGroup(Object group,
Object[] children)
Inserts the specified cell as a parent of children. |
void |
insertViews(CellView[] views)
Adds the specified model root cells to the view. |
boolean |
isAllAttributesLocal()
|
boolean |
isAutoSizeOnValueChange()
Returns true if cells should be auto-sized when their values change |
protected boolean |
isControlAttribute(Object cell,
Object key,
Object value)
Returns true if key is a control attribute |
boolean |
isHidesDanglingConnections()
Returns the hidesDanglingConnections. |
boolean |
isHidesExistingConnections()
Returns the hidesExistingConnections. |
protected boolean |
isLocalAttribute(Object cell,
Object key,
Object value)
Returns true if the set of local attributes contains key |
boolean |
isMovesChildrenOnExpand()
|
boolean |
isMovesParentsOnCollapse()
|
boolean |
isPartial()
|
boolean |
isReconnectsEdgesToVisibleParent()
Deprecated. edges are moved to parent view and back automatically |
boolean |
isRemembersCellViews()
Returns the remembersCellViews. |
boolean |
isResizesParentsOnCollapse()
|
boolean |
isSelectsAllInsertedCells()
|
boolean |
isSelectsLocalInsertedCells()
|
boolean |
isShowsChangedConnections()
|
boolean |
isShowsExistingConnections()
Returns the showsExistingConnections. |
boolean |
isShowsInsertedConnections()
Returns the showsInsertedConnections. |
boolean |
isShowsInvisibleEditedCells()
|
boolean |
isVisible(Object cell)
Whether or not the specified cell is visible. |
void |
putMapping(Object cell,
CellView view)
Associates the specified model cell with the specified view. |
void |
refresh(CellView[] views,
boolean create)
|
void |
refresh(CellView view,
boolean create)
|
void |
reload()
Remaps all existing views using the CellViewFactory and replaces the respective root views. |
protected void |
reloadRoots()
Completely reloads all roots from the model in the order returned by DefaultGraphModel.getAll. |
void |
remove(Object[] cells)
Removes cells from the model. |
void |
remove(Object[] cells,
boolean descendants,
boolean edges)
Removes cells from the model, including all children and connected edges if children or edges is true, respectively. |
CellView[] |
removeCells(Object[] cells)
Removes the specified model root cells from the view by removing the mapping between the cell and its view and makes the cells invisible. |
void |
removeGraphLayoutCacheListener(GraphLayoutCacheListener l)
Removes a listener previously added with addGraphLayoutCacheListener() . |
CellView |
removeMapping(Object cell)
Removes the association for the specified model cell and returns the view that was previously associated with the cell. |
boolean |
removeViewLocalAttribute(Object key,
boolean addToModel,
boolean override)
Handles the removal of view local attributes. |
void |
setAllAttributesLocal(boolean allAttributesLocal)
|
void |
setAutoSizeOnValueChange(boolean flag)
Determines whether cells should be auto-sized when their values change. |
void |
setCollapsedState(Object[] collapse,
Object[] expand)
Collapses and/or expands the specified cell(s) NOTE: Your GraphLayoutCache must be partial (set
partial to true in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc. |
void |
setCollapseXScale(double collapseXScale)
|
void |
setCollapseYScale(double collapseYScale)
|
void |
setFactory(CellViewFactory factory)
Sets the factory that creates the cell views. |
void |
setHiddenSet(Map hiddenSet)
Sets the hiddenSet. |
void |
setHidesDanglingConnections(boolean hidesDanglingConnections)
Sets the hidesDanglingConnections |
void |
setHidesExistingConnections(boolean hidesExistingConnections)
Sets the hidesExistingConnections |
void |
setLocalAttributes(Set localAttributes)
|
void |
setModel(GraphModel model)
Sets the current model. |
void |
setMovesChildrenOnExpand(boolean moveChildrenOnExpand)
|
void |
setMovesParentsOnCollapse(boolean movesParentsOnCollapse)
|
void |
setReconnectsEdgesToVisibleParent(boolean reconnectsEdgesToVisibleParent)
Deprecated. edges are moved to parent view and back automatically |
void |
setRemembersCellViews(boolean rememberCellViews)
Sets the rememberCellViews. |
void |
setResizesParentsOnCollapse(boolean resizesParentsOnCollapse)
|
void |
setSelectsAllInsertedCells(boolean selectsAllInsertedCells)
|
void |
setSelectsLocalInsertedCells(boolean selectsLocalInsertedCells)
|
void |
setShowsChangedConnections(boolean showsChangedConnections)
|
void |
setShowsExistingConnections(boolean showsExistingConnections)
Sets the showsExistingConnections |
void |
setShowsInsertedConnections(boolean showsInsertedConnections)
Sets the showsInsertedConnections |
void |
setShowsInvisibleEditedCells(boolean showsInvisibleEditedCells)
|
void |
setVisible(Object[] cells,
boolean visible)
Makes the specified cells visible or invisible depending on the flag passed in. |
void |
setVisible(Object[] visible,
Object[] invisible)
Changes the visibility state of the cells passed in. |
void |
setVisible(Object[] visible,
Object[] invisible,
ConnectionSet cs)
Changes the visibility state of the cells passed in. |
void |
setVisible(Object[] visible,
Object[] invisible,
Map attributes,
ConnectionSet cs)
Changes the visibility state of the cells passed in. |
void |
setVisible(Object cell,
boolean visible)
Makes the specified cell visible or invisible depending on the flag passed in. |
boolean |
setVisibleImpl(Object[] cells,
boolean visible)
The actual implementation of changing cells' visibility state. |
void |
setVisibleSet(Set visible)
Applies the specified set of cells as being those visible |
void |
showCells(Object[] cells,
boolean descandants)
Shows the specified cells with all children if descandants
is true. |
protected void |
showCellsForChange(GraphModelEvent.GraphModelChange change)
|
void |
toBack(Object[] cells)
Sends cells to back. |
void |
toFront(Object[] cells)
Brings cells to front. |
void |
toggleCollapsedState(Object[] cells,
boolean collapseOnly,
boolean expandOnly)
Toggles the collapsed state of the specified cells. |
static void |
translateViews(CellView[] views,
double dx,
double dy)
Translates the specified views by the given amount. |
Object[] |
ungroup(Object[] cells)
Ungroups all groups in cells and returns the children that are not ports. |
void |
update()
Sets the current model. |
void |
update(CellView view)
|
void |
update(CellView[] views)
|
protected void |
updatePorts()
Updates the cached array of ports. |
void |
valueForCellChanged(Object cell,
Object newValue)
Messaged when the user has altered the value for the item identified by cell to newValue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean autoSizeOnValueChange
protected boolean showsExistingConnections
protected boolean showsChangedConnections
protected boolean showsInvisibleEditedCells
edit(Map, ConnectionSet, ParentMap, UndoableEdit[])
. Default is
false.
protected boolean showsInsertedCells
insert(Object[], Map, ConnectionSet, ParentMap, UndoableEdit[])
.
Default is true.
protected boolean showsInsertedConnections
protected boolean hidesExistingConnections
protected boolean hidesDanglingConnections
protected boolean remembersCellViews
protected boolean selectsAllInsertedCells
protected boolean selectsLocalInsertedCells
protected boolean movesChildrenOnExpand
protected boolean movesParentsOnCollapse
protected boolean resizesParentsOnCollapse
protected double collapseXScale
protected double collapseYScale
protected boolean reconnectsEdgesToVisibleParent
protected EventListenerList listenerList
protected GraphModel graphModel
protected Map mapping
protected transient Map hiddenMapping
protected CellViewFactory factory
protected Set visibleSet
protected List roots
protected PortView[] ports
protected boolean partial
protected boolean allAttributesLocal
protected Set localAttributes
Constructor Detail |
public GraphLayoutCache()
public GraphLayoutCache(GraphModel model, CellViewFactory factory)
factory
to create its views.
model
- the model that constitues the data sourcepublic GraphLayoutCache(GraphModel model, CellViewFactory factory, boolean partial)
factory
to create its views.
model
- the model that constitues the data sourcepublic GraphLayoutCache(GraphModel model, CellViewFactory factory, CellView[] cellViews, CellView[] hiddenCellViews, boolean partial)
factory
to create its views.
model
- the model that constitues the data sourceMethod Detail |
public void addGraphLayoutCacheListener(GraphLayoutCacheListener l)
l
- the listener to addremoveGraphLayoutCacheListener(org.jgraph.event.GraphLayoutCacheListener)
public void removeGraphLayoutCacheListener(GraphLayoutCacheListener l)
l
- the listener to removeaddGraphLayoutCacheListener(org.jgraph.event.GraphLayoutCacheListener)
public void cellViewsChanged(CellView[] cellViews)
protected void fireGraphLayoutCacheChanged(Object source, GraphLayoutCacheEvent.GraphLayoutCacheChange edit)
public GraphLayoutCacheListener[] getGraphLayoutCacheListeners()
public void setFactory(CellViewFactory factory)
public CellViewFactory getFactory()
public void setModel(GraphModel model)
public void update()
public CellView[] getCellViews()
public static Rectangle2D getBounds(CellView[] views)
public Object[] getCells(boolean groups, boolean vertices, boolean ports, boolean edges)
graph.getSelectionCells(graph.getGraphLayoutCache().getCells(false, true,
false, false));
public Map createNestedMap()
getCellViews()
public CellView[] getHiddenCellViews()
public void reload()
public GraphModel getModel()
public CellView[] getRoots()
public CellView[] getRoots(Rectangle2D clip)
public Object[] getVisibleCells(Object[] cells)
cells
.
public PortView[] getPorts()
protected void updatePorts()
public void refresh(CellView[] views, boolean create)
public void refresh(CellView view, boolean create)
public void update(CellView[] views)
public void update(CellView view)
public void graphChanged(GraphModelEvent.GraphModelChange change)
protected void reloadRoots()
protected Object[] getContext(GraphModelEvent.GraphModelChange change)
protected void hideCellsForChange(GraphModelEvent.GraphModelChange change)
protected boolean hasVisibleParent(Object cell, Set invisible)
protected void showCellsForChange(GraphModelEvent.GraphModelChange change)
public void insertViews(CellView[] views)
public CellView[] removeCells(Object[] cells)
public Object[] getCells(CellView[] views)
getCell
for each view.
public CellView getMapping(Object cell, boolean create)
getMapping
in interface CellMapper
create
- whether a new view should created if a view does not already
existpublic CellView[] getMapping(Object[] cells)
public CellView[] getMapping(Object[] cells, boolean create)
create
is false
.
public void putMapping(Object cell, CellView view)
putMapping
in interface CellMapper
cell
- the cell that constitutes the model elementview
- the view that constitutes the view elementpublic CellView removeMapping(Object cell)
public boolean isVisible(Object cell)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
null is always visible
cell
- the whose visibility to determine
public Set getVisibleSet()
public void setVisibleSet(Set visible)
visible
- the set of visible cellspublic void setVisible(Object cell, boolean visible)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
cell
- the cell whose visibility is to be changedvisible
- true
if cell is to be made visiblepublic void setVisible(Object[] cells, boolean visible)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
cells
- the cells whose visibility is to be changedvisible
- true
if the cells are to be made visiblepublic void setVisible(Object[] visible, Object[] invisible)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
visible
- cells to be made visibleinvisible
- cells to be made invisiblepublic void setVisible(Object[] visible, Object[] invisible, ConnectionSet cs)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
visible
- cells to be made visibleinvisible
- cells to be made invisiblecs
- a ConnectionSet
describing the new state of
edge connections in the graphpublic void setVisible(Object[] visible, Object[] invisible, Map attributes, ConnectionSet cs)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
visible
- cells to be made visibleinvisible
- cells to be made invisibleattributes
- a nested attribute map of cells/attribute mapscs
- a ConnectionSet
describing the new state of
edge connections in the graphprotected Object[] addVisibleDependencies(Object[] cells, boolean visible)
public boolean setVisibleImpl(Object[] cells, boolean visible)
setVisible
methods in this
class are intended to be the main public way to change visiblilty.
However, if you do not require the undo to be formed, this method is much
quicker, just note that you must call updatePorts
if this
method returns true.
NOTE: Your GraphLayoutCache must be partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
cells
- visible
-
protected Collection getParentPorts(Object cell)
protected Collection getPorts(Object cell)
public boolean isPartial()
public boolean getPartial()
public void valueForCellChanged(Object cell, Object newValue)
protected void augmentNestedMapForValueChange(Map nested, Object cell, Object newValue)
public void insert(Object[] roots, Map attributes, ConnectionSet cs, ParentMap pm, UndoableEdit[] e)
cells
and connections into the model, and
absorbs the local attributes. This implementation sets the inserted cells
visible and selects the new roots depending on graph.selectNewCells.
public Object[] insertClones(Object[] cells, Map clones, Map nested, ConnectionSet cs, ParentMap pm, double dx, double dy)
Object[] cells = graph.getDescendants(graph.order(graph.getSelectionCells())); ConnectionSet cs = ConnectionSet.create(graphModel, cells, false); ParentMap pm = ParentMap.create(graphModel, cells, false, true); cells = graphLayoutCache.insertClones(cells, graph.cloneCells(cells), attributes, cs, pm, 0, 0);
public void insert(Object cell)
DefaultGraphCell vertex = new DefaultGraphCell("Hello, world!"); Map attrs = vertex.getAttributes(); GraphConstants.setOpaque(attrs, false); GraphConstants.setBorderColor(attrs, Color.black); DefaultPort port = new DefaultPort(); vertex.add(port); port.setParent(vertex); graph.getGraphLayoutCache().insert(vertex);
cell
- inserts the specified cell in the cachepublic void insertEdge(Object edge, Object source, Object target)
edge
- the edge to be insertedsource
- the source port this edge is connected totarget
- the target port this edge is connected topublic void insert(Object[] cells)
Object source = graph.getDefaultPortForCell(sourceVertex).getCell(); Object target = graph.getDefaultPortForCell(targetVertex).getCell(); DefaultEdge edge = new DefaultEdge("Hello, world!"); edge.setSource(source); edge.setTarget(target); Map attrs = edge.getAttributes(); GraphConstants.setLineEnd(attrs, GraphConstants.ARROW_TECHNICAL); graph.getGraphLayoutCache().insert(edge);
public void insert(Object[] cells, Map nested, ConnectionSet cs, ParentMap pm)
public void insertGroup(Object group, Object[] children)
DefaultGraphCell group = new DefaultGraphCell("Hello, world!"); Object[] cells = DefaultGraphModel.order(graph.getModel(), graph .getSelectionCells()); Rectangle2D bounds = graph.getCellBounds(cells); if (bounds != null) { bounds = new Rectangle2D.Double(bounds.getX() + bounds.getWidth() / 4, bounds.getY() + bounds.getHeight() / 4, bounds.getWidth() / 2, bounds.getHeight() / 2); GraphConstants.setBounds(group.getAttributes(), bounds); } graph.getGraphLayoutCache().insertGroup(group, cells);
public void remove(Object[] cells)
cells
from the model.
public void remove(Object[] cells, boolean descendants, boolean edges)
children
or edges
is true, respectively.
cells
- The cells to remove.descendants
- Whether to remove all descendants as well.edges
- Whether to remove all connected edges as well.public void hideCells(Object[] cells, boolean descandants)
descandants
is true.
NOTE: Your GraphLayoutCache must be partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
public void showCells(Object[] cells, boolean descandants)
descandants
is true.
NOTE: Your GraphLayoutCache must be partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
public Object[] ungroup(Object[] cells)
public void toggleCollapsedState(Object[] cells, boolean collapseOnly, boolean expandOnly)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
cells
- The cells to toggle the collapsed state for.collapseOnly
- Whether cells should only be collapsed.expandOnly
- Whether cells should only be expanded.public void collapse(Object[] groups)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
groups
- public void expand(Object[] cells)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
public void setCollapsedState(Object[] collapse, Object[] expand)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
collapse
- the cells to be collapsedexpand
- the cells to be expandedprotected Object getParentPort(Object edge, boolean source)
protected Object getChildPort(Object edge, boolean source)
source
.
public void edit(Map attributes, ConnectionSet cs, ParentMap pm, UndoableEdit[] e)
propertyMap
and the connection changes to the
model. The initial edits
that triggered the call are
considered to be part of this transaction. Notifies the model- and undo
listeners of the change. Note: The passed in attributes may contain
PortViews.
public void edit(Map attributes)
public void edit(Object[] cells, Map attributes)
attributes
to all cells
by
creating a map that contains the attributes for each cell and passing it
to edit on this layout cache. Example:
Map attrs = new java.util.Hashtable(); GraphConstants.setBackground(attrs, Color.RED); graph.getGraphLayoutCache().edit(graph.getSelectionCells(), attrs);
public void editCell(Object cell, Map attributes)
attributes
to a single cell
by
creating a map that contains the attributes for this cell and passing it
to edit on this layout cache. Example:
Map attrs = new java.util.Hashtable(); GraphConstants.setBackground(attrs, Color.RED); graph.getGraphLayoutCache().editCell(graph.getSelectionCell(), attrs);
protected UndoableEdit[] augment(UndoableEdit[] e, UndoableEdit edit)
public void toBack(Object[] cells)
cells
to back. Note: This expects an array of cells!
public void toFront(Object[] cells)
cells
to front. Note: This expects an array of
cells!
protected GraphLayoutCache.GraphLayoutCacheEdit createLocalEdit(Object[] inserted, Map nested, Object[] visible, Object[] invisible)
protected boolean isLocalAttribute(Object cell, Object key, Object value)
key
protected boolean isControlAttribute(Object cell, Object key, Object value)
key
is a control attribute
public boolean removeViewLocalAttribute(Object key, boolean addToModel, boolean override)
key
- the key of the view local attributeaddToModel
- whether or not to move the attribute values to the graph modeloverride
- whether or not to override the key's value in the model cell's
attribute map if it exists
protected void cellExpanded(Object cell)
movesChildrenOnExpand
).
protected void cellWillCollapse(Object cell)
protected Map handleAttributes(Map attributes)
public static void translateViews(CellView[] views, double dx, double dy)
views
- an array of cell view to each be translateddx
- the amount to translate the views in the x-axisdy
- the amount to translate the views in the x-axispublic List getNeighbours(Object cell, Set exclude, boolean directed, boolean visibleCells)
cell
- The cell from which the neighbours will be determinedexclude
- The set of cells to ignore when searchingdirected
- whether or not direction of edges should be taken into accountvisibleCells
- whether or not to only consider visible cells
cell
public List getOutgoingEdges(Object cell, Set exclude, boolean visibleCells, boolean selfLoops)
cell
- The cell from which the outgoing edges will be determinedexclude
- The set of edges to ignore when searchingvisibleCells
- whether or not only visible cells should be processedselfLoops
- whether or not to include self loops in the returned list
cell
public List getIncomingEdges(Object cell, Set exclude, boolean visibleCells, boolean selfLoops)
cell
- The cell from which the incoming edges will be determinedexclude
- The set of edges to ignore when searchingvisibleCells
- whether or not only visible cells should be processedselfLoops
- whether or not to include self loops in the returned list
cell
protected List getEdges(Object cell, Set exclude, boolean visibleCells, boolean selfLoops, boolean incoming)
cell
- The cell from which the edges will be determinedexclude
- The set of edges to ignore when searchingvisibleCells
- whether or not only visible cells should be processedselfLoops
- whether or not to include self loops in the returned listincoming
- true
if incoming edges are to be obtained,
false
if outgoing edges are to be obtained
cell
public CellView[] getAllViews()
public CellView[] getAllDescendants(CellView[] views)
views
, especially the PortViews. Note: Iterative
Implementation using model.getChild and getMapping on this cell mapper.
public Map getHiddenMapping()
public void setShowsExistingConnections(boolean showsExistingConnections)
showsExistingConnections
- public boolean isShowsExistingConnections()
public void setShowsInsertedConnections(boolean showsInsertedConnections)
showsInsertedConnections
- public boolean isShowsInsertedConnections()
public void setHidesExistingConnections(boolean hidesExistingConnections)
hidesExistingConnections
- public boolean isHidesExistingConnections()
public void setHidesDanglingConnections(boolean hidesDanglingConnections)
hidesDanglingConnections
- public boolean isHidesDanglingConnections()
public void setRemembersCellViews(boolean rememberCellViews)
rememberCellViews
- The rememberCellViews to setpublic boolean isRemembersCellViews()
public void setHiddenSet(Map hiddenSet)
partial
(set
partial
to true
in the constructor)
in order to use the visibility functionality of expand/collapse,
setVisible, etc.
hiddenSet
- The hiddenSet to setpublic Set getLocalAttributes()
public void setLocalAttributes(Set localAttributes)
localAttributes
- The localAttributes to set.public boolean isAllAttributesLocal()
public void setAllAttributesLocal(boolean allAttributesLocal)
allAttributesLocal
- The allAttributesLocal to set.public boolean isAutoSizeOnValueChange()
public void setAutoSizeOnValueChange(boolean flag)
flag
- a boolean value, true if cells should be auto-sized when their
values changepublic boolean isSelectsAllInsertedCells()
public void setSelectsAllInsertedCells(boolean selectsAllInsertedCells)
selectsAllInsertedCells
- The selectsAllInsertedCells to set.public boolean isSelectsLocalInsertedCells()
public void setSelectsLocalInsertedCells(boolean selectsLocalInsertedCells)
selectsLocalInsertedCells
- The selectsLocalInsertedCells to set.public boolean isReconnectsEdgesToVisibleParent()
public void setReconnectsEdgesToVisibleParent(boolean reconnectsEdgesToVisibleParent)
reconnectsEdgesToVisibleParent
- The reconnectsEdgesToVisibleParent to set.public boolean isShowsChangedConnections()
public void setShowsChangedConnections(boolean showsChangedConnections)
showsChangedConnections
- The showsChangedConnections to set.public boolean isMovesChildrenOnExpand()
public void setMovesChildrenOnExpand(boolean moveChildrenOnExpand)
moveChildrenOnExpand
- The moveChildrenOnExpand to set.public boolean isShowsInvisibleEditedCells()
public void setShowsInvisibleEditedCells(boolean showsInvisibleEditedCells)
public double getCollapseXScale()
public void setCollapseXScale(double collapseXScale)
collapseXScale
- The collapseXScale to set.public double getCollapseYScale()
public void setCollapseYScale(double collapseYScale)
collapseYScale
- The collapseYScale to set.public boolean isMovesParentsOnCollapse()
public void setMovesParentsOnCollapse(boolean movesParentsOnCollapse)
movesParentsOnCollapse
- The movesParentsOnCollapse to set.public boolean isResizesParentsOnCollapse()
public void setResizesParentsOnCollapse(boolean resizesParentsOnCollapse)
resizesParentsOnCollapse
- The resizesParentsOnCollapse to set.
|
JGraph |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |