当前位置: 首页>>代码示例>>Java>>正文


Java Node.getAttribute方法代码示例

本文整理汇总了Java中org.graphstream.graph.Node.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getAttribute方法的具体用法?Java Node.getAttribute怎么用?Java Node.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.graphstream.graph.Node的用法示例。


在下文中一共展示了Node.getAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findParentWithHighestLevel

import org.graphstream.graph.Node; //导入方法依赖的package包/类
/**
 * Determine the parent of a node that has the highest level set.
 * @param node
 * @return parent node that has the highest level assigned
 */
static Node findParentWithHighestLevel(Node node) {
	int inDegreeOfNode = node.getInDegree();
	Node parent = null;

	Iterator<Edge> nodeIterator = node.getEachEnteringEdge().iterator();
	if(inDegreeOfNode == 1)
		parent = nodeIterator.next().getOpposite(node);
	else if (inDegreeOfNode > 1) {
		parent = nodeIterator.next().getOpposite(node);
		while (nodeIterator.hasNext()) {
			Node temp = nodeIterator.next().getOpposite(node);
			if (temp.hasAttribute("layoutLayer") && (int) temp.getAttribute("layoutLayer") > (int) parent.getAttribute("layoutLayer")) {
				parent = temp;
			}
		}

	}

	if(parent != null && !parent.hasAttribute("layouted")) {
		parent.setAttribute("layouted", "true");
		positionNode(parent);
	}
	return parent;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:30,代码来源:HierarchicalLayout.java

示例2: positionNode

import org.graphstream.graph.Node; //导入方法依赖的package包/类
/**
 * Assign the coordinates to the node in the graph.
 * @param node
 */
private static void positionNode(Node node) {
	Node parent = findParentWithHighestLevel(node);
	if(parent == null)
		return;

	double[] positionOfParent = Toolkit.nodePosition(parent);
	int outDegreeOfParent = parent.getOutDegree();
	if (outDegreeOfParent == 1) {
		node.setAttribute("xyz", positionOfParent[0], positionOfParent[1] - spacingY, 0.0);
	} else {
		if(node.hasAttribute("directionResolver")) {
			double x = positionOfParent[0] + ((int) node.getAttribute("directionResolver") * spacingX);
			double y = positionOfParent[1] - spacingY;
			node.setAttribute("xyz", x, y, 0.0);
		} else {
			node.setAttribute("xyz", positionOfParent[0], positionOfParent[1] - spacingY, 0.0);
		}
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:24,代码来源:HierarchicalLayout.java

示例3: checkConsistency

import org.graphstream.graph.Node; //导入方法依赖的package包/类
/**
 * Checks if there were modifications in the graph. This method deletes dead
 * nodes.
 *
 * @param now actual time in milliseconds
 * @return true if the graph was changed, false otherwise
 */
private boolean checkConsistency(final long now) {
    boolean modified = false;
    if (now - lastCheck > (timeout * MILLIS_IN_SECOND)) {
        lastCheck = now;
        for (Node n : graph) {
            if (n.getAttribute("net", Integer.class) < NetworkPacket.THRES
                    && n.getAttribute("lastSeen", Long.class) != null
                    && !isAlive(timeout, (long) n.getNumber("lastSeen"),
                            now)) {
                removeNode(n);
                modified = true;
            }

        }
    }
    return modified;
}
 
开发者ID:sdnwiselab,项目名称:sdn-wise-java,代码行数:25,代码来源:NetworkGraph.java

示例4: assignCommunity

import org.graphstream.graph.Node; //导入方法依赖的package包/类
@Override
public void assignCommunity() {
  final String communitMarker = communityComputer.getMarker();
  ArrayList<String> communities = new ArrayList<>();
  for(Node node : graphicGraph.getEachNode()) {
    int nodeId = Integer.valueOf(node.getId());
    SourceLineNode lineNode =  flowGraph.getNode(nodeId);
    Community community = node.getAttribute(communitMarker);
    int communityIndex = communities.indexOf(community.getId());
    if(communityIndex == -1) {
      communities.add(community.getId());
      communityIndex = communities.indexOf(community.getId());
    }
    lineNode.initCommunity("" + communityIndex);
    System.out.println(communityIndex);
  }
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:18,代码来源:GraphStreamCommunityComputer.java

示例5: handleEvent

import org.graphstream.graph.Node; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void handleEvent(Event event) {
	if (event.getTopic().contentEquals(DataModel.EA_TOPIC_DATA_MODEL_CHANGED)) {
		renderICFG((ICFGStructure) event.getProperty("icfg"));
	}
	if (event.getTopic().contentEquals(DataModel.EA_TOPIC_DATA_SELECTION)) {
		VFMethod selectedMethod = (VFMethod) event.getProperty("selectedMethod");
		boolean panToNode = (boolean) event.getProperty("panToNode");
		try {
			renderMethodCFG(selectedMethod.getControlFlowGraph(), panToNode);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	if (event.getTopic().contentEquals(DataModel.EA_TOPIC_DATA_FILTER_GRAPH)) {
		filterGraphNodes((List<VFNode>) event.getProperty("nodesToFilter"), (boolean) event.getProperty("selection"),
				(boolean) event.getProperty("panToNode"), (String) event.getProperty("uiClassName"));
	}
	if (event.getTopic().equals(DataModel.EA_TOPIC_DATA_UNIT_CHANGED)) {
		VFUnit unit = (VFUnit) event.getProperty("unit");

		for (Edge edge : graph.getEdgeSet()) {
			Node src = edge.getSourceNode();
			VFNode vfNode = src.getAttribute("nodeUnit");
			if (vfNode != null) {
				VFUnit currentUnit = vfNode.getVFUnit();
				if (unit.getFullyQualifiedName().equals(currentUnit.getFullyQualifiedName())) {
					String outset = Optional.fromNullable(unit.getOutSet()).or("").toString();
					edge.setAttribute("ui.label", outset);
					edge.setAttribute("edgeData.outSet", outset);
					src.addAttribute("nodeData.inSet", unit.getInSet());
					src.addAttribute("nodeData.outSet", unit.getOutSet());
				}
			}
		}
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:39,代码来源:GraphManager.java

示例6: getIndexWithLabel

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public final Integer getIndexWithLabel(PartitionMap partitionMap, Node n) {
	setupNodes(n.getGraph(), partitionMap);
	int max_ite=5;
	while(!runLabelPropagation(n.getGraph(),n) && (max_ite--)>0);

	int index=n.getAttribute("label");
	if(index==0)
	{
		index=new BalancedHeuristic(parallel).getIndex(partitionMap, n);
	}

	System.out.println(n+" -> "+index);
	return index;
}
 
开发者ID:isislab-unisa,项目名称:streaminggraphpartitioning,代码行数:15,代码来源:AbstractAbsDispersionBased.java

示例7: 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);");
        }
    }
}
 
开发者ID:sdnwiselab,项目名称:sdn-wise-java,代码行数:16,代码来源:VisualNetworkGraph.java

示例8: pinNodesOnDynamicFlowGraph

import org.graphstream.graph.Node; //导入方法依赖的package包/类
private void pinNodesOnDynamicFlowGraph() {
  for(Node node : graphicGraph.getEachNode()) {
    int nodeId = Integer.valueOf(node.getId());
    SourceLineNode lineNode =  flowGraph.getNode(nodeId);
    Object[] xyz = node.getAttribute("xyz");
    System.out.println(Arrays.toString(xyz));
    double x = (double)xyz[0] * 20;
    double y = (double)xyz[1] * 20;
    lineNode.initXY(x, y);
  }
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:12,代码来源:Spine.java

示例9: pinNodesOnDynamicFlowGraph

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public void pinNodesOnDynamicFlowGraph() {
	for(Node node : ggraph.getEachNode()) {
		int nodeId = Integer.valueOf(node.getId());
		SourceLineNode lineNode =  displayedGraph.getNode(nodeId);
		//        int colorGroup = displayedGraph.getNodeClassCode(nodeId);
		//        lineNode.initColorGroup(colorGroup);
		Object[] xyz = node.getAttribute("xyz");
		double x = (double)xyz[0] * 20;
		double y = (double)xyz[1] * 20;
		lineNode.initXY(x, y);
	}
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:13,代码来源:DynamicDisplay.java

示例10: 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);
		}

	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:58,代码来源:GraphManager.java


注:本文中的org.graphstream.graph.Node.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。