public void performLayout(LayoutAction layout) { if (layout != null) { layout.runLayout(); } }
public void addLayoutListener(ProgressListener listener) { for(LayoutAction layout : layouts) { layout.addProgressListener(listener); } }
public CajunAction(String name, Icon icon, String tooltip) { super(name, icon); setTooltip(tooltip); }
private void initializeToolBar() { // Home addToolBarAction(new FocusOnHomeAction(graph.getAnimationHandler())); addToolBarAction(new ClearOrphansAction(graph.getModel(), graph)); getToolBar().addSeparator(); // Layouts for (LayoutAction action : graph.getLayouts()) { addToolBarAction(action); } getToolBar().addSeparator(); // zoom addToolBarAction(new ZoomInAction(graph.getCamera())); addToolBarAction(new NoZoomAction(graph.getCamera())); addToolBarAction(new ZoomOutAction(graph.getCamera())); getToolBar().addSeparator(); // node and arc filter actions final JToggleButton nodesToggle = addToolBarToggleAction(new ShowFilterPanelAction(getNodeFilterPanel())); final JToggleButton arcsToggle = addToolBarToggleAction(new ShowFilterPanelAction(getArcFilterPanel())); // listen for panel close events - keep the toggle buttons in sync getNodeFilterPanel().getCloseButton().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nodesToggle.setSelected(false); } }); getArcFilterPanel().getCloseButton().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { arcsToggle.setSelected(false); } }); }
public LayoutAction getLayout(String name) { for (LayoutAction layout : layouts) { if (layout.getName().equals(name)) { return layout; } } return null; }
public void setTooltip(String tooltip) { putValue(SHORT_DESCRIPTION, tooltip); }
public String getName() { return (String) getValue(NAME); }
public String toString() { return getName(); }
public int hashCode() { return toString().hashCode(); }
public void actionPerformed(ActionEvent e) { doAction(); }
private void initialize() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new BorderLayout()); DefaultFlatGraphView view = new DefaultFlatGraphView(graph); getContentPane().add(view, BorderLayout.CENTER); graph.getNodeContextMenu().add(new CajunAction("Test #1")); graph.getNodeContextMenu().add(new CajunAction("Test #2")); JPanel buttonsPanel = new JPanel(); buttonsPanel.add(new JButton(new AbstractAction(" Close ") { public void actionPerformed(ActionEvent e) { MainFrame.this.dispose(); } })); pack(); Dimension d = new Dimension(800, 600); setPreferredSize(d); setSize(d); setLocation(100, 50); setVisible(true); }
protected void addDefaultLayouts() { int style = LayoutStyles.NO_LAYOUT_NODE_RESIZING; addLayout(new LayoutAction(LayoutConstants.LAYOUT_GRID_BY_ALPHA, ResourceHandler.getIcon("icon_grid_layout.gif"), new GridLayoutAlgorithm(style), this)); addLayout(new LayoutAction(LayoutConstants.LAYOUT_RADIAL, ResourceHandler.getIcon("icon_radial_layout.gif"), new RadialLayoutAlgorithm(style), this)); addLayout(new LayoutAction(LayoutConstants.LAYOUT_SPRING, ResourceHandler.getIcon("icon_spring_layout.gif"), new SpringLayoutAlgorithm(style), this)); addLayout(new LayoutAction(LayoutConstants.LAYOUT_TREE_VERTICAL, ResourceHandler.getIcon("icon_tree_layout.gif"), new TreeLayoutAlgorithm(style), this)); addLayout(new LayoutAction(LayoutConstants.LAYOUT_TREE_HORIZONTAL, ResourceHandler.getIcon("icon_tree_layout_horizontal.gif"), new HorizontalTreeLayoutAlgorithm(style), this)); addLayout(new LayoutAction(LayoutConstants.LAYOUT_DIRECTED_VERTICAL, ResourceHandler.getIcon("icon_tree_layout.gif"), new DirectedGraphLayoutAlgorithm(style), this)); addLayout(new LayoutAction(LayoutConstants.LAYOUT_DIRECTED_HORIZONTAL, ResourceHandler.getIcon("icon_tree_layout_horizontal.gif"), new HorizontalDirectedGraphLayoutAlgorithm(style), this)); // important - set the last layout this.lastLayout = getLayout(LayoutConstants.LAYOUT_DIRECTED_VERTICAL); }
public void doAction() { // save this action as the last executed action ((AbstractGraph) graph).setLastLayout(this); runLayout(); }
public void setName(String name) { putValue(NAME, name); }
public String getTooltip() { return (String) getValue(SHORT_DESCRIPTION); }
/** * Sets the expansion menu options enabled/disabled flag based on the current state of the * node. If the node has already been expanded, everything is disabled. Otherwise, all the * non-filtered arc types are enabled. * @param node */ private void initNodeActionConditions(GraphNode node) { if (model.isExpanded(node)) { expandAction.setEnabled(false); for (Action action : expandBasedOnActions) { action.setEnabled(false); } } else { expandAction.setEnabled(true); for (Action action : expandBasedOnActions) { if(graph.getFilterManager().isArcTypeVisible(((CajunAction)action).getName())) { action.setEnabled(true); } else { action.setEnabled(false); } } } }
public boolean equals(Object o) { return toString().equals(o.toString()); }
public void performLayout() { if (getLastLayout() != null) { filterManager.applyFilters(model); getLastLayout().runLayout(); } }
public void setIcon(Icon icon) { putValue(SMALL_ICON, icon); }
public Icon getIcon() { return (Icon) getValue(SMALL_ICON); }