JGraph 5.3

Automatic Selection

The graph layout cache offers the setSelectsLocalInsertedCells and setSelectsAllInsertedCells methods for automatic selection. The first method will select all cells which are inserted through the local cache, while the latter will select all inserted cells that are visible. (Therefore it is not possible to select cells in all but the local layout cache.)

Attribute Maps

The AttributeMap had quite some changes over time. For migration it is important to understand that we have split the use of such maps into transport and storage. The transport objects are normal maps, as they do not need to override certain methods. The storage maps are AttributeMaps, which are no longer created with a static or non-static hook. The storage maps are only used when replacing the cell's or cellview's attributes field, otherwise one should use a transport map, such as a Hashtable.

Storage Maps

Here is how to set a storage map for a cell:

DefaultGraphCell cell = new DefaultGraphCell(); 
cell.setAttributes(new MyAttributeMap());

Transport Maps

This changes the vertex background color to blue:

Hashtable map = new Hashtable(); 
GraphConstants.setBackground(map, Color.BLUE); 
graph.getGraphLayoutCache().edit(new Object[]{vertex}, map);

Note that by using the edit(Object[], Map) method we do no longer require a nested map.

New Methods

Many of the methods found in JGraphUtilities (JGraphAddons) have been moved to the DefaultGraphModel and GraphLayoutCache including:

  • GraphLayoutCache.insertEdge: Inserts an edge

  • GraphLayoutCache.insertVertex: Inserts a vertex

  • GraphLayoutCache.insertGroup: Inserts a group