本文整理汇总了Java中org.graphstream.graph.Node.changeAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Node.changeAttribute方法的具体用法?Java Node.changeAttribute怎么用?Java Node.changeAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.graphstream.graph.Node
的用法示例。
在下文中一共展示了Node.changeAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupNode
import org.graphstream.graph.Node; //导入方法依赖的package包/类
@Override
public void setupNode(final Node node, final int batt, final long now,
final int net, final NodeAddress addr) {
super.setupNode(node, batt, now, net, addr);
node.addAttribute("ui.label", node.getId());
if (net < NetworkPacket.THRES) {
node.changeAttribute("ui.style", "fill-color: rgb(0," + batt
+ ",0),rgb(0,0,0);");
} else {
node.changeAttribute("ui.style", "fill-color: rgb(" + batt
+ ",0,0),rgb(0,0,0);");
}
}
示例2: updateNode
import org.graphstream.graph.Node; //导入方法依赖的package包/类
@Override
public void updateNode(final Node node, final int batt, final long now) {
super.updateNode(node, batt, now);
if (node.getAttribute("net") != null) {
int net = node.getAttribute("net");
if (net < NetworkPacket.THRES) {
node.changeAttribute("ui.style", "fill-color: rgb(0,"
+ batt + ",0),rgb(0,0,0);");
} else {
node.changeAttribute("ui.style", "fill-color: rgb("
+ batt + ",0,0),rgb(0,0,0);");
}
}
}
示例3: buttonReleased
import org.graphstream.graph.Node; //导入方法依赖的package包/类
@Override
/* (non-Javadoc)
* @see org.graphstream.ui.view.ViewerListener#buttonReleased(java.lang.String)
*/
public void buttonReleased(String id) {
Node node = graphDisplay.getNode(id);
// If node color is black or node color is red, change the color to purple and display
// Closeness Centrality.
if (!node.hasAttribute("ui.style") || node.getAttribute("ui.style")
.toString().equals("fill-color: black;") || node.getAttribute("ui.style")
.toString().equals("fill-color: red;")) {
// Round the Closeness Centrality to two decimals.
String closeness = df.format(graph.closeness(new Vertex(Integer.parseInt(id))));
node.addAttribute("ui.style", "fill-color: purple;");
node.addAttribute("ui.label", closeness);
// else if the node color is purple (already clicked node) and its original color is
// black and change its color to black.
}else if (node.getAttribute("ui.style").toString().equals("fill-color: purple;")
&& !node.hasAttribute("ui.class")){
node.changeAttribute("ui.style", "fill-color: black;");
node.changeAttribute("ui.label", id);
// else (if the node is purple and its original color is red) then change node
// color to red and label it with its ID.
}else{
node.changeAttribute("ui.style", "fill-color: red;");
node.changeAttribute("ui.label", id);
}
}