use of prefuse.data.Node in project qi4j-sdk by Qi4j.
the class GraphBuilder method buildApplicationNode.
private Graph buildApplicationNode(ApplicationDetailDescriptor descriptor) {
Node node = addChild(null, descriptor.descriptor().name(), descriptor);
buildLayersNode(node, descriptor.layers());
buildUsesNode(node, descriptor.layers());
return graph;
}
use of prefuse.data.Node in project qi4j-sdk by Qi4j.
the class GraphBuilder method addChild.
private Node addChild(Node parent, String name, Object object) {
Node childNode = graph.addNode();
childNode.set(GraphDisplay.NAME_LABEL, name);
childNode.set(GraphDisplay.USER_OBJECT, object);
// check for application node
if (parent != null) {
graph.addEdge(parent, childNode);
}
return childNode;
}
use of prefuse.data.Node in project jo-client-platform by jo-source.
the class TreeRootAction method run.
@Override
public void run(final double frac) {
final TupleSet focus = vis.getGroup(Visualization.FOCUS_ITEMS);
if (focus == null || focus.getTupleCount() == 0) {
return;
}
final Graph g = (Graph) vis.getGroup(m_group);
final Node node = getFirstContainingNode(g, focus);
if (node != null) {
g.getSpanningTree(node);
}
}
use of prefuse.data.Node in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method addBeanToGraph.
private boolean addBeanToGraph(final IBeanProxy<Object> bean, final int index, final IBeanRelationNodeModel<Object, Object> beanRelationNodeModel) {
final IBeanProxyLabelRenderer<Object> renderer = beanRelationNodeModel.getChildRenderer();
final Node childNode;
boolean runFilter = false;
if (nodeMap.get(bean) == null) {
synchronized (vis) {
childNode = graph.addNode();
nodeMap.put(bean, childNode);
childNode.set("visible", true);
childNode.set("expanded", Expand.NOT);
childNode.set("isParent", false);
childNode.set("marked", false);
childNode.set("position", null);
beanRelationMap.put(bean, beanRelationNodeModel);
runFilter = true;
}
} else {
childNode = nodeMap.get(bean);
}
if (entityGroupMap.get(beanRelationNodeModel.getChildBeanType()) == null) {
entityGroupMap.put(beanRelationNodeModel.getChildBeanType(), GRAPH_NODES_GROUP + groupCount);
groupVisibilityMap.put(beanRelationNodeModel.getChildBeanType().getSimpleName(), true);
groupColorMap.put(beanRelationNodeModel.getChildBeanType().getSimpleName(), NODE_COLORS[groupCount]);
groupCount = (groupCount < NODE_COLORS.length - 1) ? ++groupCount : 0;
}
childNode.set("beanrelation", beanRelationNodeModel.getChildBeanType().getSimpleName());
final String nodeGroup = entityGroupMap.get(beanRelationNodeModel.getChildBeanType());
final Node parentNode = nodeMap.get(beanRelationNodeModel.getParentBean());
if (parentNode != null && (!bean.isDummy())) {
parentNode.set("visible", true);
synchronized (vis) {
if (graph.getEdge(parentNode, childNode) == null && graph.getEdge(childNode, parentNode) == null) {
final Edge edge = graph.addEdge(parentNode, childNode);
edge.set("visible", false);
edge.set("name", beanRelationNodeModel.getText());
} else {
if (graph.getEdge(childNode, parentNode) != null) {
final String previousString = (String) graph.getEdge(childNode, parentNode).get("name");
if (!previousString.contains("/") && !previousString.equals(beanRelationNodeModel.getText())) {
graph.getEdge(childNode, parentNode).set("name", previousString + " / " + beanRelationNodeModel.getText());
}
} else if (graph.getEdge(parentNode, childNode) != null) {
final String previousString = (String) graph.getEdge(parentNode, childNode).get("name");
if (!previousString.contains("/") && !previousString.equals(beanRelationNodeModel.getText())) {
graph.getEdge(parentNode, childNode).set("name", previousString + " / " + beanRelationNodeModel.getText());
}
}
}
}
}
if ((Boolean) childNode.get("visible")) {
synchronized (vis) {
renderNodeShape(nodeGroup, childNode);
renderNode(childNode, bean, renderer);
}
}
if (parentNode != null) {
if (getOutlinedNodes(parentNode).size() >= 1) {
parentNode.set("isParent", true);
} else {
parentNode.set("isParent", false);
}
}
for (final IEntityTypeId<Object> childEntityTypeId : beanRelationNodeModel.getChildRelations()) {
final IBeanRelationNodeModel<Object, Object> childRelationNodeModel = relationTreeModel.getNode(beanRelationNodeModel.getChildEntityTypeId(), bean, childEntityTypeId);
final ChildModelListener childModelListener = new ChildModelListener(childRelationNodeModel);
if (!childModelListenerSet.contains(childRelationNodeModel)) {
childRelationNodeModel.addBeanListModelListener(childModelListener);
childModelListenerSet.add(childRelationNodeModel);
}
}
return runFilter;
}
use of prefuse.data.Node in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method getOutlinedNodes.
private Set<Node> getOutlinedNodes(final Node node) {
final Iterator<?> outNode = node.outNeighbors();
final Iterator<?> children = node.children();
final Set<Node> outNodeSet = new LinkedHashSet<Node>();
Set<Node> childrenSet = new LinkedHashSet<Node>();
while (outNode.hasNext()) {
final Node out = (Node) outNode.next();
outNodeSet.add(out);
}
while (children.hasNext()) {
final Node child = (Node) children.next();
childrenSet.add(child);
}
outNodeSet.addAll(childrenSet);
childrenSet.clear();
childrenSet = null;
return outNodeSet;
}
Aggregations