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


Java Node.setAttribute方法代码示例

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


在下文中一共展示了Node.setAttribute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createGraphMethodNode

import org.graphstream.graph.Node; //导入方法依赖的package包/类
/**
 * Creates the graph method node and sets the label, methodName, methodSignature, methodBody and nodeMethod attributes on the node.
 *
 * @param src
 * @author Shashank B S
 */
private void createGraphMethodNode(VFMethod src) {
	if (graph.getNode(src.getId() + "") == null) {
		Node createdNode = graph.addNode(src.getId() + "");
		String methodName = src.getSootMethod().getName();
		String escapedMethodName = StringEscapeUtils.escapeHtml(methodName);
		String escapedMethodSignature = StringEscapeUtils.escapeHtml(src.getSootMethod().getSignature());
		createdNode.setAttribute("ui.label", methodName);
		createdNode.setAttribute("nodeData.methodName", escapedMethodName);
		createdNode.setAttribute("nodeData.methodSignature", escapedMethodSignature);
		String methodBody = src.getBody().toString();
		methodBody = Pattern.compile("^[ ]{4}", Pattern.MULTILINE).matcher(methodBody).replaceAll(""); // remove indentation at line start
		methodBody = methodBody.replaceAll("\n{2,}", "\n"); // replace empty lines
		String escapedMethodBody = StringEscapeUtils.escapeHtml(methodBody);
		String hexColor = getCodeBackgroundColor();
		createdNode.setAttribute("nodeData.methodBody", "<code><pre style=\"color: #000000; background-color: #"+hexColor+"\">" + escapedMethodBody + "</pre></code>");
		createdNode.setAttribute("nodeMethod", src);
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:25,代码来源:GraphManager.java

示例4: setupNodes

import org.graphstream.graph.Node; //导入方法依赖的package包/类
private void setupNodes(Graph g, PartitionMap map)
{
	for(Node u : g.getNodeSet())
	{ 
		u.setAttribute("label",""+getBalancedSetupLabel(u,map));
		u.setAttribute("tmplabel",""+u.getAttribute("label"));
	}
}
 
开发者ID:isislab-unisa,项目名称:streaminggraphpartitioning,代码行数:9,代码来源:LabelPropagation.java

示例5: runConversion

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public void runConversion() throws NumberFormatException, IOException {
		String line ="";
		Integer edgeCount = 0;
		while ((line = reader.readLine()) != null) {
			if (line.startsWith("#")) continue;
			line = line.trim();
			String[] edgePoints = line.split(sep);
//			System.out.print(edgePoints[0] + " : " ) ;
//			System.out.println(edgePoints[1]);
			if (edgePoints.length < 2) continue;
			gr.addNode(edgePoints[0]);
			gr.addNode(edgePoints[1]);
			gr.addEdge((edgeCount++).toString(), edgePoints[0] , edgePoints[1]);
		}
		
		this.writer.println(gr.getNodeCount() + " " + gr.getEdgeCount());
		
		Integer nodeCount = 0;
		Iterator<Node> nIt = gr.getNodeIterator();
		ArrayList<Node> arrNodes = new ArrayList<>();
		while (nIt.hasNext()) {
			Node nx = nIt.next();
			arrNodes.add(nx);
			nx.setAttribute(NODE_ID, ++nodeCount);
		}
	
		arrNodes.stream()
			.forEach(p -> {
				writer.println(getNeigh(p));
				System.out.println("" + p.getAttribute(NODE_ID));
				writer.flush();
			});
		writer.flush();
		writer.close();
		
	}
 
开发者ID:isislab-unisa,项目名称:streaminggraphpartitioning,代码行数:37,代码来源:Converter.java

示例6: setupNodes

import org.graphstream.graph.Node; //导入方法依赖的package包/类
private void setupNodes(Graph g, PartitionMap map)
{
	for(Node u : g.getNodeSet())
	{ 
		u.setAttribute("label",getBalancedSetupLabel(u,map));
		u.setAttribute("tmplabel",u.getAttribute("label"));
	}
}
 
开发者ID:isislab-unisa,项目名称:streaminggraphpartitioning,代码行数:9,代码来源:AbstractAbsDispersionBased.java

示例7: colorNode

import org.graphstream.graph.Node; //导入方法依赖的package包/类
private void colorNode(String[] palette, int colorIndex, Node node) {
	Preconditions.checkNotNull(palette);
	Preconditions.checkElementIndex(colorIndex, palette.length);
	String color = palette[colorIndex % palette.length];
	String colorStyle = "fill-color: " + color + ";";
	node.setAttribute("ui.style", colorStyle);
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:8,代码来源:DynamicDisplay.java

示例8: expandNodes

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public void expandNodes() {
	if(nodeSize < 20) {
		nodeSize += 1;
	}

	for(Node node : graph.getEachNode()) {
		node.setAttribute("ui.style",
				String.format("size: %spx;", nodeSize));
	}
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:11,代码来源:DynamicDisplay.java

示例9: shrinkNodes

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public void shrinkNodes() {
	if(nodeSize > 4) {
		nodeSize -= 1;
	}

	for(Node node : graph.getEachNode()) {
		node.setAttribute("ui.style",
				String.format("size: %spx;", nodeSize));
	}
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:11,代码来源:DynamicDisplay.java

示例10: setStartNode

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public void setStartNode(){
		Node node = graph.getNode(0);
		node.setAttribute("ui.style",
				String.format("shape: %s; fill-color: %s;", "diamond", "white"));

//		n.addAttribute("ui.style", "size: 10px, 10px; shape: diamond; fill-color: blue;");
	}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:8,代码来源:DynamicDisplay.java

示例11: colorCostumizedNode

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public static void colorCostumizedNode(Node n){
	n.setAttribute("ui.color", Color.RED);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:4,代码来源:UnitView.java

示例12: createControlFlowGraphNode

import org.graphstream.graph.Node; //导入方法依赖的package包/类
/**
 * Creates the CFG node and sets the label, unit, escapedHTMLunit, unitType, inSet, outSet, color attributes.
 *
 * @param node
 * @author Shashank B S
 */
private void createControlFlowGraphNode(VFNode node) {
	if (graph.getNode(node.getId() + "") == null) {
		Node createdNode = graph.addNode(node.getId() + "");
		Unit unit = node.getUnit();
		String label = unit.toString();
		try {
			UnitFormatter formatter = UnitFormatterFactory.createFormatter(unit);
			//UnitFormatter formatter = new DefaultFormatter();
			label = formatter.format(unit, maxLength);
		} catch (Exception e) {
			logger.error("Unit formatting failed", e);
		}

		createdNode.setAttribute("ui.label", label);
		String str = unit.toString();
		String escapedNodename = StringEscapeUtils.escapeHtml(str);
		createdNode.setAttribute("unit", str);
		createdNode.setAttribute("nodeData.unit", escapedNodename);

		createdNode.setAttribute("nodeData.unitType", node.getUnit().getClass());
		String str1 = Optional.fromNullable(node.getVFUnit().getInSet()).or("n/a").toString();
		String nodeInSet = StringEscapeUtils.escapeHtml(str1);
		String str2 = Optional.fromNullable(node.getVFUnit().getOutSet()).or("n/a").toString();
		String nodeOutSet = StringEscapeUtils.escapeHtml(str2);

		createdNode.setAttribute("nodeData.inSet", nodeInSet);
		createdNode.setAttribute("nodeData.outSet", nodeOutSet);

		Map<String, String> customAttributes = node.getVFUnit().getHmCustAttr();
		String attributeData = "";
		if(!customAttributes.isEmpty())
		{
			Iterator<Entry<String, String>> customAttributeIterator = customAttributes.entrySet().iterator();
			while(customAttributeIterator.hasNext())
			{
				Entry<String, String> curr = customAttributeIterator.next();
				attributeData += curr.getKey() + " : " + curr.getValue();
				attributeData += "<br />";
			}
			createdNode.setAttribute(nodeAttributesString, attributeData);
		}

		createdNode.setAttribute("nodeUnit", node);
		Color nodeColor = new Color(new ProjectPreferences().getColorForNode(node.getUnit().getClass().getName().toString()));
		createdNode.addAttribute("ui.color", nodeColor);
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:54,代码来源:GraphManager.java

示例13: 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

示例14: decolorNodes

import org.graphstream.graph.Node; //导入方法依赖的package包/类
public void decolorNodes() {
	for(Node node : graph.getEachNode()) {
		node.setAttribute("ui.style", "fill-color:lightyellow;");
	}
}
 
开发者ID:spideruci,项目名称:cerebro-layout,代码行数:6,代码来源:DynamicDisplay.java


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