public LayoutAction(String name, Icon icon, LayoutAlgorithm layout, Graph graph, boolean animate) { super(name, icon); this.layout = layout; this.graph = graph; this.animate = animate; this.resizeNodes = false; this.layoutRelTypes = new ArrayList<Object>(); this.manager = new ActivityManager(graph.getCanvas(), graph.getCanvas().getRoot().getActivityScheduler()); }
protected void updateNodeTypes() { GraphModel model = graph.getModel(); // ensure that the new node types match the old ones, // preserving the original node type visibilities Collection<Object> newNodeTypes = model.getNodeTypes(); if (newNodeTypes.isEmpty()) { nodeTypesVisibilityMap.clear(); } else { // first remove any node types that no longer exist for (Iterator<Object> iter = nodeTypesVisibilityMap.keySet().iterator(); iter.hasNext();) { Object oldNodeType = iter.next(); if (!newNodeTypes.contains(oldNodeType)) { iter.remove(); } } // now add any that don't already exist (visible by default) for (Object nodeType : newNodeTypes) { if (!nodeTypesVisibilityMap.containsKey(nodeType)) { nodeTypesVisibilityMap.put(nodeType, true); } } } }
public FilterManager(Graph graph) { this.graph = graph; NodeAndArcTypeListener listener = new NodeAndArcTypeListener(); // this listens for when a new model is set this.graph.addPropertyChangeListener(listener); // this listens for changes to the model (node/arc types added etc) // by adding it to the graph it will always be attached to the current model even when a new model is set this.graph.addGraphModelListener(listener); this.listeners = new ArrayList<FilterChangedListener>(); this.filters = new ArrayList<GraphFilter>(); this.nodeTypesVisibilityMap = new HashMap<Object, Boolean>(); this.arcTypesVisibilityMap = new HashMap<Object, Boolean>(); // populate the node and arc types map (all visible by default) updateNodeAndArcTypes(); // add the node and arc type filters filters.add(new NodeTypeFilter()); filters.add(new ArcTypeFilter()); }
@Override public void doAction() { boolean graphChanged = false; GraphNode nodes[] = model.getAllNodes().toArray(new GraphNode[model.getAllNodes().size()]); // goes through all nodes and hides any that have no arcs or have no visible arcs for(GraphNode node : nodes) { if(node.getArcs().size() == 0) { graphChanged = true; model.removeNode(node.getUserObject()); } else { boolean found = false; for(GraphArc arc : node.getArcs()) { if(arc.isVisible()) { found = true; } } if(!found) { graphChanged = true; model.removeNode(node.getUserObject()); } } } // re-layout the graph if it changed if(graphChanged) graph.performLayout(); } }
graphController.getGraph().addNodeSelectionListener(new GraphNodeCollectionListener() { public void collectionChanged(GraphNodeCollectionEvent arg0) { syncNodeSelection();
protected void updateArcTypes() { GraphModel model = graph.getModel(); Collection<Object> newArcTypes = model.getArcTypes(); if (newArcTypes.isEmpty()) { arcTypesVisibilityMap.clear(); } else { // first remove any node types that no longer exist for (Iterator<Object> iter = arcTypesVisibilityMap.keySet().iterator(); iter.hasNext();) { Object oldArcType = iter.next(); if (!newArcTypes.contains(oldArcType)) { iter.remove(); } } // now add any that don't already exist (visible by default) for (Object arcType : newArcTypes) { if (!arcTypesVisibilityMap.containsKey(arcType)) { arcTypesVisibilityMap.put(arcType, true); } } } }
private void initToolbar() { JToolBar toolBar = graphController.getToolBar(); JFrame mainWindow = (javax.swing.JFrame)SwingUtilities.windowForComponent(this); toolBar.addSeparator(); toolBar.add(new ExportImageAction(mainWindow, graphController.getGraph().getCanvas())); toolBar.add(new ConfigTooltipsAction(mainWindow, graphController.getGraph().getCanvas())); toolBar.addSeparator(); toolBar.add(new SaveGraphAction(mainWindow, graphController)); toolBar.add(new OpenGraphAction(mainWindow, graphController)); toolBar.addSeparator(); toolBar.add(new ExportAsDotAction(mainWindow, graphController)); Action action = new PinTooltipsAction(mainWindow, graphController); JToggleButton btn = new JToggleButton(action); btn.setText(null); btn.setToolTipText((String) action.getValue(Action.NAME)); toolBar.add(btn); }
PrintStream out = new PrintStream(file); GraphModel model = controller.getGraph().getModel();
PrintStream out = new PrintStream(file); GraphModel model = controller.getGraph().getModel(); OWLModelManager owlModelManager = controller.getModel().getOwlModelManager();