public FlatGraph() { this(new DefaultGraphModel()); this.showNodeTooltips = true; }
public GraphArc addArc(Object userObject, GraphNode src, GraphNode dest, Object type) { return addArc(userObject, src, dest, type, null); }
public GraphNode addNode(Object userObject, String text) { return addNode(userObject, text, null, null); }
public GraphArc addArc(Object userObject, GraphNode src, GraphNode dest, Object type, Icon icon) { if (userObject == null) { throw new NullPointerException("All graph arcs must have a user object."); } if (!arcs.containsKey(userObject)) { addNodeInternal(src); addNodeInternal(dest); DefaultGraphArc arc = new DefaultGraphArc(userObject, src, dest, icon, type); addArcInternal(arc); arrangeArcs(arc.getSource(), arc.getDestination()); } return arcs.get(userObject); }
protected void addArcInternal(DefaultGraphArc arc) { // this is the ONLY place where arcs are added arcs.put(arc.getUserObject(), arc); if (!arcTypes.contains(arc.getType())) { arcTypes.add(arc.getType()); fireArcTypeAddedEvent(arc.getType()); } // add this arc to the source and destination nodes arc.getSource().addArc(arc); arc.getDestination().addArc(arc); fireArcAddedEvent(arc); }
public void clear() { if ((nodes.size() > 0) || (arcs.size() > 0)) { nodes.clear(); arcs.clear(); nodeTypes.clear(); arcTypes.clear(); fireGraphClearedEvent(); } }
public GraphNode addNode(Object userObject, String text, Icon icon, Object type) { if (userObject == null) { throw new NullPointerException("All graph nodes must have a user object."); } if (!nodes.containsKey(userObject)) { if (type == null) { type = GraphItem.UNKNOWN_TYPE; } DefaultGraphNode node = new DefaultGraphNode(userObject, text, icon, type); addNodeInternal(node); } return nodes.get(userObject); }
/** * Clears the arc types, then iterates through all the arcs and adds the * arc types back in. */ public void recalculateArcTypes() { arcTypes.clear(); for (GraphArc arc: arcs.values()) { Object arcType = arc.getType(); if (!arcTypes.contains(arcType)) { arcTypes.add(arcType); fireArcTypeAddedEvent(arcType); } } }
protected void removeArcInternal(GraphArc arc) { if ((arc != null) && arcs.containsKey(arc.getUserObject())) { // remove this arc from the source and destination nodes arc.getSource().removeArc(arc); arc.getDestination().removeArc(arc); // now remove the arc from the model and fire the event arcs.remove(arc.getUserObject()); fireArcRemovedEvent(arc); } }
public void setModel(GraphModel model) { GraphModel oldModel = this.model; oldModel.removeGraphModelListener(modelListener); // now remove any of "our" graph model listeners for (GraphModelListener gml : graphModelListeners) { oldModel.removeGraphModelListener(gml); } // don't allow null models if (model == null) { model = new DefaultGraphModel(); } this.model = model; this.model.addGraphModelListener(modelListener); // now add "our" graph model listeners back for (GraphModelListener gml : graphModelListeners) { this.model.addGraphModelListener(gml); } loadModel(); firePropertyChange(GRAPH_MODEL_PROPERTY, oldModel, this.model); }
public GraphNode addNode(Object userObject, String text, Icon icon) { return addNode(userObject, text, icon, null); }
public AbstractGraph() { super(); this.model = new DefaultGraphModel(); this.graphModelListeners = new ArrayList<GraphModelListener>(); this.layouts = new ArrayList<LayoutAction>(); addDefaultLayouts(); this.graphPopupListener = new GraphPopupListener(); getCamera().addInputEventListener(graphPopupListener); this.filterManager = new FilterManager(this); this.filterManager.addFilterChangedListener(filterListener); this.selectedNodes = new NodeCollection(); selectedNodes.addCollectionListener(selectionListener); this.matchingNodes = new NodeCollection(); matchingNodes.addCollectionListener(matchingListener); this.nodeStyle = new DefaultGraphNodeStyle(); this.arcStyle = new DefaultGraphArcStyle(); addFocusListener(focusListener); // register to use our custom tooltips CustomToolTipManager.sharedInstance().registerComponent(this); initializeLayers(); // this is needed to handle keyboard events getRoot().getDefaultInputManager().setKeyboardFocus(new KeyHandlerDelegate(getCamera())); }
public GraphNode addNode(Object userObject) { return addNode(userObject, String.valueOf(userObject), null, null); }