[graphl-cvs] graphl/src/org/mediavirus/graphl GraphlApplication.java
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2004-10-05 07:54:52
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13893/src/org/mediavirus/graphl Modified Files: GraphlApplication.java Log Message: * added command line option support in GraphlApplication * added "Exit" menu entry (for quitting without window decorations) * fixes for LineEdgePainter and ShapeNodePainter * minor documentation updates * more default config tweaking Index: GraphlApplication.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlApplication.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GraphlApplication.java 4 Oct 2004 10:21:03 -0000 1.8 --- GraphlApplication.java 5 Oct 2004 07:54:20 -0000 1.9 *************** *** 57,60 **** --- 57,61 ---- JMenuItem saveItem; JMenuItem saveAsItem; + JMenuItem exitItem; private File currentFile; *************** *** 82,92 **** this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { ! quit(); } }); ! ! // TODO (3) provide own event handling (move, resize, close) to be able to remove decorations ! //this.setUndecorated(true); ! mainPanel = new GraphlPanel(); --- 83,90 ---- this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { ! doExit(); } }); ! mainPanel = new GraphlPanel(); *************** *** 130,133 **** --- 128,133 ---- fileMenu.add(openURLItem); + fileMenu.addSeparator(); + saveItem = new JMenuItem("Save"); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK)); *************** *** 150,153 **** --- 150,165 ---- fileMenu.add(saveAsItem); + fileMenu.addSeparator(); + + exitItem = new JMenuItem("Exit"); + exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_DOWN_MASK)); + exitItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doExit(); + } + }); + exitItem.setFont(menuFont); + fileMenu.add(exitItem); + menuBar.add(fileMenu); *************** *** 169,173 **** * */ ! protected void quit() { if (mainPanel.getGraph().isDirty()) { int choice = JOptionPane.showConfirmDialog(this, "File has been changed. Do you want to save your changes?", "Save Changes?", JOptionPane.YES_NO_CANCEL_OPTION); --- 181,185 ---- * */ ! protected void doExit() { if (mainPanel.getGraph().isDirty()) { int choice = JOptionPane.showConfirmDialog(this, "File has been changed. Do you want to save your changes?", "Save Changes?", JOptionPane.YES_NO_CANCEL_OPTION); *************** *** 384,400 **** GraphlApplication app = new GraphlApplication(); ! app.setSize(1024, 768); app.show(); try { ! app.loadSettings(System.getProperty("user.dir") + "/config/config.rdf"); ! app.mainPanel.getGraph().readFromFile(System.getProperty("user.dir") + "/graphs/default.rdf"); app.setTitle("Graphl - default.rdf"); } catch (IOException ioex) { - ioex.printStackTrace(); JOptionPane.showMessageDialog(app, "Error while loading file:\n" + ioex.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } } --- 396,456 ---- GraphlApplication app = new GraphlApplication(); ! int[] size = {1024, 768}; ! int[] pos = {0,0}; ! boolean decorations = true; ! String filename = System.getProperty("user.dir") + "/graphs/default.rdf"; ! String configfile = System.getProperty("user.dir") + "/config/config.rdf"; ! ! for (int i = 0; i < args.length; i++) { ! if (args[i].startsWith("size=")) { ! size[0] = Integer.parseInt(args[i].substring(5,args[i].indexOf(','))); ! size[1] = Integer.parseInt(args[i].substring(args[i].indexOf(',')+1,args[i].length())); ! } ! else if (args[i].startsWith("pos=")) { ! pos[0] = Integer.parseInt(args[i].substring(4,args[i].indexOf(','))); ! pos[1] = Integer.parseInt(args[i].substring(args[i].indexOf(',')+1,args[i].length())); ! } ! else if (args[i].startsWith("decorations=")) { ! if (args[i].equals("decorations=off")) decorations = false; ! } ! else if (args[i].startsWith("config=")) { ! configfile = args[i].substring(7); ! } ! else if (i == args.length-1) { ! filename = args[i]; ! } ! else { ! usage(true); ! } ! } ! ! app.setSize(size[0], size[1]); ! app.setLocation(pos[0], pos[1]); ! // TODO (3) provide own event handling (move, resize, close) to be able to remove decorations ! app.setUndecorated(!decorations); app.show(); try { ! app.loadSettings(configfile); ! app.mainPanel.getGraph().readFromFile(filename); app.setTitle("Graphl - default.rdf"); } catch (IOException ioex) { JOptionPane.showMessageDialog(app, "Error while loading file:\n" + ioex.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } + public static void usage(boolean exit){ + System.out.println("-------------------------------------------------------------------"); + System.out.println("graphl V 0.0.2 (c) by Flo Ledermann <led...@im...>"); + System.out.println("update, info & download ---> http://www.mediavirus.org/graphl/"); + System.out.println("licensed under the GPL"); + System.out.println("-------------------------------------------------------------------"); + System.out.println("usage:"); + System.out.println("graphl [size=<width>,<height>] [pos=<x>,<y>] [decorations={on|off}]\n" + + " [settings=<filename.rdf>] [<filename.rdf>]"); + System.out.println("-------------------------------------------------------------------"); + if (exit) System.exit(0); + } + } |