public DefaultGraphNode(Object userObject, String text, Icon icon, Object type) { super(); this.userObject = userObject; this.changeListeners = new ArrayList<ChangeListener>(); this.style = new DefaultGraphNodeStyle(); this.selected = false; this.highlighted = false; this.matching = false; this.arcs = new ArrayList<GraphArc>(); this.setPickable(true); this.setChildrenPickable(false); textNode = new GraphTextNode(); // make this node match the text size textNode.setConstrainWidthToTextWidth(true); textNode.setConstrainHeightToTextHeight(true); textNode.setPickable(false); addChild(textNode); setText(text); setIcon(icon); setType(type); }
public MainFrame() { super("Baby Shrimp Test"); SampleGraphModel model = new SampleGraphModel(); this.graph = new FlatGraph(model); // color the nodes based on node type DefaultGraphNodeStyle nodeStyle = new DefaultGraphNodeStyle(); nodeStyle.setNodeTypes(model.getNodeTypes()); this.graph.setGraphNodeStyle(nodeStyle); // color the arcs based on arc type DefaultGraphArcStyle arcStyle = new DefaultGraphArcStyle(); arcStyle.setArcTypes(model.getArcTypes()); this.graph.setGraphArcStyle(arcStyle); initialize(); // run the initial layout on the nodes //SwingUtilities.invokeLater(new Runnable() { // public void run() { // try { // Thread.sleep(100); // } catch (InterruptedException e) { // } // graph.performLayout(); //} //}); }
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())); }