本文整理了Java中org.gephi.graph.api.Graph.addNode()
方法的一些代码示例,展示了Graph.addNode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.addNode()
方法的具体详情如下:
包路径:org.gephi.graph.api.Graph
类名称:Graph
方法名:addNode
[英]Adds a node to this graph.
[中]将节点添加到此图形中。
代码示例来源:origin: org.gephi/datalab-api
@Override
public Node createNode(String label, Graph graph) {
Node newNode = buildNode(graph, label);
graph.addNode(newNode);
return newNode;
}
代码示例来源:origin: org.gephi/graph-api
public void readTreeStructure(XMLStreamReader reader, GraphModel graphModel, GraphFactory factory, LegacyMapHelper mapHelper) throws XMLStreamException {
Graph graph = graphModel.getGraph();
boolean end = false;
while (reader.hasNext() && !end) {
int type = reader.next();
switch (type) {
case XMLStreamReader.START_ELEMENT:
String name = reader.getLocalName();
if (ELEMENT_TREESTRUCTURE_NODE.equalsIgnoreCase(name)) {
String id = reader.getAttributeValue(null, "id");
String pre = reader.getAttributeValue(null, "pre");
mapHelper.preToIdMap.put(pre, id);
Node node = factory.newNode(id);
graph.addNode(node);
}
break;
case XMLStreamReader.END_ELEMENT:
if (ELEMENT_TREESTRUCTURE.equalsIgnoreCase(reader.getLocalName())) {
end = true;
}
break;
}
}
}
代码示例来源:origin: org.gephi/datalab-api
@Override
public Node createNode(String label, String id, Graph graph) {
if (graph.getNode(id) == null) {
Node newNode = buildNode(graph, label, id);
graph.addNode(newNode);
return newNode;
} else {
return null;
}
}
代码示例来源:origin: gephi/gephi-plugins-bootcamp
graph.addNode(n);
代码示例来源:origin: gephi/gephi-plugins-bootcamp
@Override
public void mouseClick(int[] positionViewport, float[] position3d) {
//Get current graph
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getGraphModel().getGraph();
GraphFactory factory = gc.getGraphModel().factory();
//Add node
Node node = factory.newNode();
node.setX(position3d[0]);
node.setY(position3d[1]);
node.setSize(10f);
graph.addNode(node);
}
},
代码示例来源:origin: org.gephi/filters-plugin
graph.addNode(node);
} else if (graph.contains(node)) {
graph.removeNode(node);
代码示例来源:origin: org.gephi/tools-plugin
@Override
public void mouseClick(int[] positionViewport, float[] position3d) {
color = nodePencilPanel.getColor();
size = nodePencilPanel.getNodeSize();
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel gm = gc.getGraphModel();
Graph graph = gm.getGraph();
Node node = gm.factory().newNode();
node.setX(position3d[0]);
node.setY(position3d[1]);
node.setSize(size);
node.setColor(color);
graph.addNode(node);
}
};
代码示例来源:origin: org.gephi/filters-plugin
graph.addNode(n);
代码示例来源:origin: gephi/gephi-plugins-bootcamp
@Override
public void clickNodes(Node[] nodes) {
//Get mouse position
float[] position3d = VizController.getInstance().getGraphIO().getMousePosition3d();
//Get current graph
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getGraphModel().getGraph();
GraphFactory factory = gc.getGraphModel().factory();
//Add node
Node node = factory.newNode();
node.setX(position3d[0]);
node.setY(position3d[1]);
node.setSize(10f);
graph.addNode(node);
//Add edges with the clicked nodes
for (Node n : nodes) {
Edge edge = factory.newEdge(node, n);
graph.addEdge(edge);
}
}
}};
代码示例来源:origin: org.gephi/filters-plugin
@Override
public Graph filter(Subgraph[] graphs) {
if (graphs.length > 1) {
throw new IllegalArgumentException("Not Filter accepts a single graph in parameter");
}
Graph graph = graphs[0];
Graph mainGraph = graph.getView().getGraphModel().getGraph();
for (Node n : mainGraph.getNodes().toArray()) {
if (!graph.contains(n)) {
//The node n is not in graph
graph.addNode(n);
} else {
//The node n is in graph
graph.removeNode(n);
}
}
for (Edge e : mainGraph.getEdges()) {
Node source = e.getSource();
Node target = e.getTarget();
if (graph.contains(source) && graph.contains(target)) {
Edge edgeInGraph = graph.getEdge(source, target, e.getType());
if (edgeInGraph == null) {
graph.addEdge(e);
}
}
}
return graph;
}
代码示例来源:origin: org.gephi/datalab-api
private Node copyNode(Node node, Graph graph) {
Node copy = buildNode(graph, node.getLabel());
//Copy properties (position, size and color):
copy.setX(node.x());
copy.setY(node.y());
copy.setZ(node.z());
copy.setSize(node.size());
copy.setR(node.r());
copy.setG(node.g());
copy.setB(node.b());
copy.setAlpha(node.alpha());
Table nodeTable = graph.getModel().getNodeTable();
//Copy attributes:
for (Column column : nodeTable) {
if (!column.isReadOnly()) {
copy.setAttribute(column, node.getAttribute(column));
}
}
graph.addNode(copy);
return copy;
}
内容来源于网络,如有侵权,请联系作者删除!