|
JGraph |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
org.jgraph.graph.GraphLayoutCache
public class 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.GraphViewEdit
An implementation of GraphViewChange. |
Field Summary | |
---|---|
protected boolean |
askLocalAttribute
May be used to disable the creation of local edits independently. |
protected CellViewFactory |
factory
Factory to create the views. |
protected JGraph |
graph
Factory to create the views. |
protected GraphModel |
graphModel
Reference to the graphModel |
protected Map |
hiddenSet
Remebered cell views. |
boolean |
hideEdgesOnBecomeInvisible
Boolean indicating whether edges should be made invisible if their connected vertices become invisible (for example when removed). |
boolean |
hideEdgesOnHide
Boolean indicating whether attached edges should be made invisible if their source or target port is hidden. |
protected Set |
localAttributes
A set containing all attribute keys that are stored in the cell views, in other words, the view-local attributes. |
protected CellMapper |
mapper
Reference to the cell mapper, typically this. |
protected Map |
mapping
Maps cells to views. |
protected boolean |
partial
Only portions of the model are visible. |
protected PortView[] |
ports
Cached array of all ports for the view. |
boolean |
rememberCellViews
Boolean indicating whether cellviews should be remembered once visible in this GraphLayoutCache. |
protected List |
roots
Ordered list of roots for the view. |
boolean |
showAllEdgesForVisibleVertices
Boolean indicating whether new or changed edges should be made visible if their source and target vertices are visible. |
boolean |
showEdgesOnShow
Boolean indicating whether edges should be made visible if their connected vertices become visible. |
protected Set |
visibleSet
The set of visible cells. |
Constructor Summary | |
---|---|
GraphLayoutCache(JGraph graph)
Constructs a view for the specified model that uses factory
to create its views. |
|
GraphLayoutCache(JGraph graph,
GraphModel model,
CellViewFactory factory,
boolean partial)
Constructs a view for the specified model that uses factory
to create its views. |
|
GraphLayoutCache(JGraph graph,
GraphModel model,
CellViewFactory factory,
boolean partial,
boolean rememberCellViews,
boolean showAllEdgesForVisibleVertices,
boolean showEdgesOnShow,
boolean hideEdgesOnHide,
boolean hideEdgesOnBecomeInvisible)
Constructs a view for the specified model that uses factory
to create its views. |
|
GraphLayoutCache(JGraph graph,
Set localAttributes)
Constructs a view for the specified model that uses factory
to create its views. |
Method Summary | |
---|---|
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 GraphLayoutCache.GraphViewEdit |
createLocalEdit(Map nested,
Object[] visible,
Object[] invisible)
Creates a local edit for the specified change. |
void |
edit(Map attributes,
ConnectionSet cs,
ParentMap pm,
UndoableEdit[] e)
Applies the propertyMap and the connection changes to the
model. |
CellView[] |
getAllDescendants(CellView[] views)
Returns all views, including descendants that have a parent in views , especially the PortViews. |
Object[] |
getCells(CellView[] views)
Takes an array of views and returns the array of the corresponding cells by using getCell for each view. |
protected Object[] |
getContext(GraphModelEvent.GraphModelChange change)
Hook for subclassers to augment the context for a graphChange. |
CellViewFactory |
getFactory()
Returns the factory that was passed to the constructor. |
JGraph |
getGraph()
Returns the factory that was passed to the constructor. |
Map |
getHiddenSet()
Returns the hiddenSet. |
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. |
protected Collection |
getParentPorts(Object cell)
|
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 cells that intersect the given rectangle. |
Set |
getVisibleSet()
|
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 void |
hideCellsForChange(GraphModelEvent.GraphModelChange change)
|
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. |
void |
insertRoots(CellView[] views)
Adds the specified model root cells to the view. |
boolean |
isAskLocalAttribute()
|
protected boolean |
isControlAttribute(Object cell,
Object key,
Object value)
Returns true if key is a control attribute |
boolean |
isHideEdgesOnBecomeInvisible()
Returns the hideEdgesOnBecomeInvisible. |
boolean |
isHideEdgesOnHide()
Returns the hideEdgesOnHide. |
protected boolean |
isLocalAttribute(Object cell,
Object key,
Object value)
Returns true if the set of local attributes contains key |
boolean |
isPartial()
|
boolean |
isRememberCellViews()
Returns the rememberCellViews. |
boolean |
isShowAllEdgesForVisibleVertices()
Returns the showAllEdgesForVisibleVertices. |
boolean |
isShowEdgesOnShow()
Returns the showEdgesOnShow. |
boolean |
isVisible(Object cell)
|
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()
|
void |
remove(Object[] roots)
Removes cells from the model. |
CellView |
removeMapping(Object cell)
Removes the associaten for the specified model cell and returns the view that was previously associated with the cell. |
CellView[] |
removeRoots(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 |
setAskLocalAttribute(boolean askLocalAttribute)
|
void |
setFactory(CellViewFactory factory)
Sets the factory that creates the cell views. |
void |
setHiddenSet(Map hiddenSet)
Sets the hiddenSet. |
void |
setHideEdgesOnBecomeInvisible(boolean hideEdgesOnBecomeInvisible)
Sets the hideEdgesOnBecomeInvisible. |
void |
setHideEdgesOnHide(boolean hideEdgesOnHide)
Sets the hideEdgesOnHide. |
void |
setLocalAttributes(Set localAttributes)
|
void |
setModel(GraphModel model)
Sets the current model. |
void |
setRememberCellViews(boolean rememberCellViews)
Sets the rememberCellViews. |
void |
setShowAllEdgesForVisibleVertices(boolean showAllEdgesForVisibleVertices)
Sets the showAllEdgesForVisibleVertices. |
void |
setShowEdgesOnShow(boolean showEdgesOnShow)
Sets the showEdgesOnShow. |
void |
setVisible(Object[] cells,
boolean visible)
|
void |
setVisible(Object[] visible,
Object[] invisible)
|
void |
setVisible(Object cell,
boolean visible)
|
boolean |
setVisibleImpl(Object[] cells,
boolean visible)
|
void |
setVisibleSet(Set visible)
|
protected void |
showCellsForChange(GraphModelEvent.GraphModelChange change)
|
void |
toBack(Object[] cells)
Sends cells to back. |
void |
toFront(Object[] cells)
Brings cells to front. |
static void |
translateViews(CellView[] views,
double dx,
double dy)
Translates the specified views by the given amount. |
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.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public boolean showAllEdgesForVisibleVertices
public boolean showEdgesOnShow
public boolean hideEdgesOnHide
public boolean hideEdgesOnBecomeInvisible
public boolean rememberCellViews
protected GraphModel graphModel
protected Map mapping
protected CellMapper mapper
protected CellViewFactory factory
protected JGraph graph
protected Set visibleSet
protected List roots
protected PortView[] ports
protected transient Map hiddenSet
protected boolean partial
protected boolean askLocalAttribute
protected Set localAttributes
Constructor Detail |
---|
public GraphLayoutCache(JGraph graph)
factory
to create its views.
model
- the model that constitues the data sourcepublic GraphLayoutCache(JGraph graph, Set localAttributes)
factory
to create its views.
model
- the model that constitues the data sourcepublic GraphLayoutCache(JGraph graph, GraphModel model, CellViewFactory factory, boolean partial)
factory
to create its views.
model
- the model that constitues the data sourcepublic GraphLayoutCache(JGraph graph, GraphModel model, CellViewFactory factory, boolean partial, boolean rememberCellViews, boolean showAllEdgesForVisibleVertices, boolean showEdgesOnShow, boolean hideEdgesOnHide, boolean hideEdgesOnBecomeInvisible)
factory
to create its views.
model
- the model that constitues the data sourceMethod Detail |
---|
public JGraph getGraph()
public void setFactory(CellViewFactory factory)
public CellViewFactory getFactory()
public void setModel(GraphModel model)
public void reload()
public GraphModel getModel()
public CellView[] getRoots()
public CellView[] getRoots(Rectangle2D clip)
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 Object[] getContext(GraphModelEvent.GraphModelChange change)
protected void hideCellsForChange(GraphModelEvent.GraphModelChange change)
protected void showCellsForChange(GraphModelEvent.GraphModelChange change)
public void insertRoots(CellView[] views)
public CellView[] removeRoots(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 createdpublic 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)
public Set getVisibleSet()
public void setVisibleSet(Set visible)
public void setVisible(Object cell, boolean visible)
public void setVisible(Object[] cells, boolean visible)
public void setVisible(Object[] visible, Object[] invisible)
public Object[] addVisibleDependencies(Object[] cells, boolean visible)
public boolean setVisibleImpl(Object[] cells, boolean visible)
protected Collection getParentPorts(Object cell)
protected Collection getPorts(Object cell)
public boolean isPartial()
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 void remove(Object[] roots)
cells
from the model. If
removeChildren
is true
, the children are
also removed. Notifies the model- and undo listeners of the change.
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.
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.GraphViewEdit createLocalEdit(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
protected Map handleAttributes(Map attributes)
public static void translateViews(CellView[] views, double dx, double dy)
public CellView[] getAllDescendants(CellView[] views)
views
, especially the PortViews. Note: Iterative
Implementation using model.getChild and getMapping on this cell mapper.
public Map getHiddenSet()
public boolean isHideEdgesOnBecomeInvisible()
public boolean isHideEdgesOnHide()
public boolean isRememberCellViews()
public boolean isShowAllEdgesForVisibleVertices()
public boolean isShowEdgesOnShow()
public void setHiddenSet(Map hiddenSet)
hiddenSet
- The hiddenSet to setpublic void setHideEdgesOnBecomeInvisible(boolean hideEdgesOnBecomeInvisible)
hideEdgesOnBecomeInvisible
- The hideEdgesOnBecomeInvisible to setpublic void setHideEdgesOnHide(boolean hideEdgesOnHide)
hideEdgesOnHide
- The hideEdgesOnHide to setpublic void setRememberCellViews(boolean rememberCellViews)
rememberCellViews
- The rememberCellViews to setpublic void setShowAllEdgesForVisibleVertices(boolean showAllEdgesForVisibleVertices)
showAllEdgesForVisibleVertices
- The showAllEdgesForVisibleVertices to setpublic void setShowEdgesOnShow(boolean showEdgesOnShow)
showEdgesOnShow
- The showEdgesOnShow to setpublic Set getLocalAttributes()
public void setLocalAttributes(Set localAttributes)
localAttributes
- The localAttributes to set.public boolean isAskLocalAttribute()
public void setAskLocalAttribute(boolean askLocalAttribute)
askLocalAttribute
- The askLocalAttribute to set.
|
JGraph |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |