private JScrollPane dagWorkbenchScroll(Graph dag) { GraphWorkbench dagWorkbench = new GraphWorkbench(dag); dagWorkbench.setAllowDoubleClickActions(false); dagWorkbench.setAllowNodeEdgeSelection(true); JScrollPane dagWorkbenchScroll = new JScrollPane(dagWorkbench); dagWorkbenchScroll.setPreferredSize(new Dimension(450, 450)); dagWorkbench.addMouseListener( new MouseAdapter() { public void mouseExited(MouseEvent e) { storeLatestWorkbenchGraph(); } }); return dagWorkbenchScroll; }
/** Constructs a new GraphEditor for the given EdgeListGraph. */ public TimeLagGraphEditor(TimeLagGraph graph) { setLayout(new BorderLayout()); this.workbench = new TimeLagGraphWorkbench(graph); DagGraphToolbar toolbar = new DagGraphToolbar(getWorkbench()); JMenuBar menuBar = createGraphMenuBar(); JScrollPane scroll = new JScrollPane(getWorkbench()); scroll.setPreferredSize(new Dimension(450, 450)); add(scroll, BorderLayout.CENTER); add(toolbar, BorderLayout.WEST); add(menuBar, BorderLayout.NORTH); JLabel label = new JLabel("Double click variable to change name."); label.setFont(new Font("SansSerif", Font.PLAIN, 12)); Box b = Box.createHorizontalBox(); b.add(Box.createHorizontalStrut(2)); b.add(label); b.add(Box.createHorizontalGlue()); b.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); add(b, BorderLayout.SOUTH); this.getWorkbench() .addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("graph".equals(propertyName)) { TimeLagGraph _graph = (TimeLagGraph) evt.getNewValue(); if (getWorkbench() != null) { getGraphWrapper().setGraph(_graph); } } } }); }