Search in sources :

Example 11 with Node

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;
}
Also used : Node(prefuse.data.Node)

Example 12 with Node

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;
}
Also used : Node(prefuse.data.Node)

Example 13 with Node

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);
    }
}
Also used : TupleSet(prefuse.data.tuple.TupleSet) Graph(prefuse.data.Graph) Node(prefuse.data.Node)

Example 14 with 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;
}
Also used : Node(prefuse.data.Node) Edge(prefuse.data.Edge)

Example 15 with Node

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Node(prefuse.data.Node)

Aggregations

Node (prefuse.data.Node)19 Edge (prefuse.data.Edge)5 TupleSet (prefuse.data.tuple.TupleSet)4 VisualItem (prefuse.visual.VisualItem)4 LinkedHashSet (java.util.LinkedHashSet)3 Point (java.awt.Point)2 HashSet (java.util.HashSet)2 LayerDetailDescriptor (org.qi4j.tools.model.descriptor.LayerDetailDescriptor)2 MouseEvent (java.awt.event.MouseEvent)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 IComboBoxSelectionBluePrint (org.jowidgets.api.widgets.blueprint.IComboBoxSelectionBluePrint)1 IInputFieldBluePrint (org.jowidgets.api.widgets.blueprint.IInputFieldBluePrint)1 ModuleDetailDescriptor (org.qi4j.tools.model.descriptor.ModuleDetailDescriptor)1 DragControl (prefuse.controls.DragControl)1 FocusControl (prefuse.controls.FocusControl)1 NeighborHighlightControl (prefuse.controls.NeighborHighlightControl)1 PanControl (prefuse.controls.PanControl)1 ToolTipControl (prefuse.controls.ToolTipControl)1 WheelZoomControl (prefuse.controls.WheelZoomControl)1