本文整理汇总了Java中org.graphstream.graph.Node.removeAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Node.removeAttribute方法的具体用法?Java Node.removeAttribute怎么用?Java Node.removeAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.graphstream.graph.Node
的用法示例。
在下文中一共展示了Node.removeAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterGraphNodes
import org.graphstream.graph.Node; //导入方法依赖的package包/类
/**
* Filters and highlights the graph by setting the {@code uiClassForFilteredNodes} class on the filtered nodes based on the boolean value {@code selection} and also pans the view to the last filtered node based on the value of {@code panToNode}.
* @param nodes - nodes to be filtered
* @param selection - flag to determine whether the nodes have to be highlighted
* @param panToNode - flag to determine whether to pan the graph to the last filtered node
* @param uiClassForFilteredNodes - class name to be set on filtered nodes, defaults to <b>filter</b> if the passed in value is null
* @author Shashank B S
*/
private void filterGraphNodes(List<VFNode> nodes, boolean selection, boolean panToNode, String uiClassForFilteredNodes) {
boolean panned = false;
if (uiClassForFilteredNodes == null) {
uiClassForFilteredNodes = "filter";
}
Iterable<? extends Node> graphNodes = graph.getEachNode();
for (Node node : graphNodes) {
if (node.hasAttribute("ui.class")) {
node.removeAttribute("ui.class");
}
for (VFNode vfNode : nodes) {
if (node.getAttribute("unit").toString().contentEquals(vfNode.getUnit().toString())) {
if (selection) {
node.removeAttribute("ui.color");
node.addAttribute("ui.class", uiClassForFilteredNodes);
}
if (!panned && panToNode) {
this.panToNode(node.getId());
panned = true;
}
}
}
}
}
示例2: setCustomAttribute
import org.graphstream.graph.Node; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void setCustomAttribute(VFUnit selectedVF, Node curr) {
JPanel panel = new JPanel(new GridLayout(0, 2));
JTextField attributeName = new JTextField("");
JTextField attributeValue = new JTextField("");
panel.add(attributeName);
panel.add(new JLabel("Attribute: "));
panel.add(attributeValue);
panel.add(new JLabel("Attribute value: "));
int result = JOptionPane.showConfirmDialog(null, panel, "Setting custom attribute", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
Map<String, String> hmCustAttr = new HashMap<>();
// Get actual customized attributes
Set set = selectedVF.getHmCustAttr().entrySet();
Iterator i = set.iterator();
String attributeString = "";
if(curr.hasAttribute(nodeAttributesString))
{
attributeString += curr.getAttribute(nodeAttributesString) + "<br>";
curr.removeAttribute(nodeAttributesString);
}
else
attributeString += "";
// Display elements
while (i.hasNext()) {
Map.Entry me = (Map.Entry) i.next();
hmCustAttr.put((String) me.getKey(), (String) me.getValue());
}
if ((attributeName.getText().length() > 0) && (attributeValue.getText().length() > 0)) {
try {
hmCustAttr.put(attributeName.getText(), attributeValue.getText());
selectedVF.setHmCustAttr(hmCustAttr);
ArrayList<VFUnit> units = new ArrayList<>();
units.add(selectedVF);
attributeString += attributeName.getText() + ":" + attributeValue.getText();
curr.setAttribute(nodeAttributesString, attributeString);
curr.addAttribute("ui.color", Color.red.getRGB());
} catch (Exception e) {
e.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(new JPanel(), "Please make sure all fields are correctly filled out", "Warning", JOptionPane.WARNING_MESSAGE);
}
}
}