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); }
private void initialize(Container parentContainer) { // setup the layouts List<Object> layoutRelTypes = new ArrayList<Object>(); layoutRelTypes.add(ProtegeGraphModel.DIRECT_SUBCLASS_SLOT_TYPE); layoutRelTypes.add(ProtegeGraphModel.DIRECT_INDIVIDUAL_SLOT_TYPE); for (LayoutAction layoutAction : graph.getLayouts()) { if (layoutAction.getName().equals(LayoutConstants.LAYOUT_TREE_HORIZONTAL)) { layoutAction.setLayout(new HorizontalDirectedGraphLayoutAlgorithm()); this.graph.setLastLayout(layoutAction); layoutAction.setLayoutRelTypes(layoutRelTypes); } else if (layoutAction.getName().equals(LayoutConstants.LAYOUT_TREE_VERTICAL)) { layoutAction.setLayout(new DirectedGraphLayoutAlgorithm()); layoutAction.setLayoutRelTypes(layoutRelTypes); } } view = new DefaultFlatGraphView(graph); parentContainer.add(view, BorderLayout.CENTER); initNodeMenu(graph.getNodeContextMenu()); graph.addInputEventListener(new ProtegeInputEventHandler(model, graph)); }