jgraph note (5-25)

Chapter 2 

2. Ports are an artificial addition in JGraph used to indicate places on a vertex where an edge may connected to that vertex. The ends of edges connect to vertices by these ports and ports are represented, at least in the default model provided with JGraph, as being children of one vertex.

cells[ 0 =   new  DefaultGraphCell( new  String( " Hello " ));
...
DefaultPort port0 
=   new  DefaultPort();
cells[
0 ].add(port0);
ports0.setParent(cells[
0 ]);
...

Q: cells.add()  VS. ports.seParent()

 add(MutableTreeNode newChild)
          Removes newChild from its parent and makes it a child of this node by adding it to the end of this node's child array.

setParent(MutableTreeNode newParent)
          Sets this node's parent to newParent but does not change the parent's child array.

3. Setting up the vertices and edge to display how we would like them is done by modifying their attributes. All cells, including ports, have what is called an attribute map. AttributeMap is a subclass of java.util.Map.

4. GraphConstants is a utility class designed to allow you to access attribute maps in a type-safe way.

5. All graph cells have a storage map that you can obtain using getAttributes(). When inserting cells you can obtain the attribute map that belongs to that cell and manipulate it before inserting the cell into the graph. This practice is only generally advised for inserting cells, when editing cell the process of using transport maps, not the actual cell's map(the storage mao) should be used.(?)

 6. Edges all have a direction internally within JGraph, it is up to you whether you want to reveal this directed behaviour on the visible graph.

7. Functionality related to the marquee is handled by the BasicMarqueeHandler.

8. when changing a graph, collect your changes together in one nested map and pass it to GraphLayoutCache.edit(). That will sort out the change on your view, pass it to the model, create an undoable edit on your undo command history and refresh everything that needs refreshing. i.e., calling edit() adds that edit to the undo history, so if you want a number of things to be grouped into one undo, make sure they are performed as part of one edit().

Map nested  =   new  Hashtable();                    // transport map
Map attributeMap1 
=   new  Hashtable();       // transport map

GraphConstants.setLabelAlongEdge(attributeMap1, 
true );
nested.put(cell2, attributeMap1);

graph.getgraphLayoutCache().edit(nested, 
null null null );

When an insert, edit or remove call is made, the graph model creates an object---edit that describes the changes that are to be made. This edit is executed on the current state of the graph to determine the resulting graph. The reason for abstracting the change into an actual object is two-fold:

1) to provide listeners of the event that executing the edit fires a means to obtain informations to what happened in the edit.

2) to provide undo support within JGraph by storing the edit on the undo history.

 edit() checks the requested graph state changes requested against the current graph state.If there is found to be no change requested then no action is taken.

9. two items for attribute maps:

1) storage map: the permanent map associated with a cell, requires the use of a specialized attribute map class.

2) transport map :a temporary map used only to indicate an edit change and then discarded, most generic Map implementations can be used for this.

10. the standard way to alter the contents of cells' attribute maps is to pass a new map of attributes with the cell in a Map entry as part of a nested map to he edit() methods.

  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值