[英]How to show rectangle shape for a node through PREFUSE visualization toolkit for JAVA?
I have coded the following code(some excerpts of the code) to display a node as rectangle but it is no working. 我已经编码以下代码(代码的某些摘录)以将节点显示为矩形,但它不起作用。 It is just displaying a simple node. 它只是显示一个简单的节点。
Code excerpts: 代码摘录:
...
ShapeAction nodeShape = new NodeShapeAction(treeNodes); // treeNodes is a datagroup representing the tree nodes
m_vis.putAction("nodeShape", nodeShape); // m_vis is referring the visualization object
m_vis.run(nodeShape);
....
/**
* Set node shapes
*/
public static class NodeShapeAction extends ShapeAction {
public NodeShapeAction(String group) {
super(group);
add("type == 'APPLICATION'", Constants.SHAPE_RECTANGLE);
add("type == 'DATABASE'", Constants.SHAPE_STAR);
add("type == 'INTERFACE'", Constants.SHAPE_ELLIPSE);
}
} // end of inner class NodeShapeAction
I got the answer so I am answering it here. 我得到了答案,所以我在这里回答。
In prefuse
, adding the Action
s (in our case ShapeAction
) to a visualization just sets the display properties of the VisualItem
s. 在prefuse
,将Action
(在我们的示例中为ShapeAction
)添加到可视化中只是设置VisualItem
的显示属性。
To display VisualItem
s that reflect those display properties, we need to set appropriate renderers
to the Visualization
. 要显示反映这些显示属性的VisualItem
,我们需要为Visualization
设置适当的renderers
。
ShapeRenderer m_nodeRenderer = new ShapeRenderer();
DefaultRendererFactory rf = new DefaultRendererFactory(m_nodeRenderer);
m_vis.setRendererFactory(rf);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.