Download JGraph User Manual
Transcript
JGraph User Manual localAttributes. allAttributesLocal is a boolean flag that determines whether or not to make all attributes view-local, so the all attributes set in the GraphLayoutCache are stored locally in the cell views and those are the attributes used for the visualization. localAttributes is a Set of attribute keys ( e.g. GraphConstants.BOUNDS, GraphConstants.FONT, etc. ) that use the value in the cell view attribute map over that in the graph model cell. You can set all attributes to view-local using: setAllAttributesLocal(true); and set the value of localAttributes using: setLocalAttributes(attributeSet); Note the setting of the local attribute set overwrite the current set, it does not add to it. Therefore, if you wish to add to it, call getLocalAttributes() and add to the set obtained in-place. Note, if you wish to remove a view-local attribute this requires more than simply removing the key from the local attributes set. The attribute value should also be removed from all cell view that have that attribute set. Depending on application requirements, you will either leave the attributes deleted or re-add them to the equivalent graph model cells' attribute maps. From JGraph 5.6.3 onwards the method removeLocalAttribute(Object attribute, boolean addToModel) is available in the GraphLayoutCache to assist this process. The attribute is the key to be removed and the flag indicates whether or not to re-add the deleted attribute to the model cells. As previously mentioned, if you perform an insert call to the model with a partial layout cache, the cell is invisible to start with in the layout cache. If you perform an edit on the model and you change an attribute which is view-local in a graph layout cache, the value does not get passed to the cell views' attribute maps. Similarly, if you perform an edit directly on a graph layout cache any view-local attributes are not passed onto the model cells. This means you can have colors, cell positions and size, text font, any of the attributes in GraphConstants display differently in one view to another by using partial layout caches, setting the appropriate attributes to be view-local and editing those attributes using the edit call on the partial layout cache. In the examples directory of the package you received with this user manual you will find the file org.jgraph.example.GraphEdMV.java. This is an example implementation of a simple multi-view application. The following code in the constructor of GraphEdMV sets the view-local attributes: Set localAttributes = new HashSet(); localAttributes.add(GraphConstants.BOUNDS); localAttributes.add(GraphConstants.POINTS); localAttributes.add(GraphConstants.LABELPOSITION); localAttributes.add(GraphConstants.ROUTING); graph.getGraphLayoutCache().setLocalAttributes(localAttributes); Page 81