# HG changeset patch # User berghofe # Date 1003243674 -7200 # Node ID fbab70de9b0dc2e6e1f1710e6b675c40a377a318 # Parent 1e29b79db3dc4c890a0cdfcf33eb9291a7788b4a Added support for batch mode layout (without X11 connection). diff -r 1e29b79db3dc -r fbab70de9b0d lib/browser/GraphBrowser/GraphBrowser.java --- a/lib/browser/GraphBrowser/GraphBrowser.java Tue Oct 16 00:50:23 2001 +0200 +++ b/lib/browser/GraphBrowser/GraphBrowser.java Tue Oct 16 16:47:54 2001 +0200 @@ -2,7 +2,7 @@ Title: GraphBrowser/GraphBrowser.java ID: $Id$ Author: Stefan Berghofer, TU Muenchen - Copyright 1997 TU Muenchen + License: GPL (GNU GENERAL PUBLIC LICENSE) This is the graph browser's main class. It contains the "main(...)" method, which is used for the stand-alone version, as well as @@ -115,7 +115,7 @@ f.show(); } } catch (Exception exn) { - System.out.println("Can't read file "+fname); + System.err.println("Can't read file "+fname); } } @@ -162,11 +162,11 @@ gridbag.setConstraints(gv2,cnstr); add(gv2); } catch (IOException exn) { - System.out.println("\nI/O error while reading graph file."); + System.err.println("\nI/O error while reading graph file."); } catch (ParseError exn) { - System.out.println("\nParse error in graph file:"); - System.out.println(exn.getMessage()); - System.out.println("\nSyntax:\n [ + ] [ < | > ] [ [ ... [ ] ... ] ] ;"); + System.err.println("\nParse error in graph file:"); + System.err.println(exn.getMessage()); + System.err.println("\nSyntax:\n [ + ] [ < | > ] [ [ ... [ ] ... ] ] ;"); } } @@ -178,9 +178,9 @@ initBrowser(is); is.close(); } catch (MalformedURLException exn) { - System.out.println("Invalid URL: "+gfname); + System.err.println("Invalid URL: "+gfname); } catch (IOException exn) { - System.out.println("I/O error while reading "+gfname+"."); + System.err.println("I/O error while reading "+gfname+"."); } } @@ -188,17 +188,33 @@ isApplet=false; try { GraphBrowser gb=new GraphBrowser(args.length > 0 ? args[0] : ""); - if (args.length>0) { + if (args.length > 0) { InputStream is=new FileInputStream(args[0]); gb.initBrowser(is); is.close(); } - f=new GraphBrowserFrame(gb); - f.setSize(700,500); - f.show(); + if (args.length > 1) { + gb.gv.getGraph().layout(null); + try { + if (args[1].endsWith(".ps")) { + gb.gv.PS(args[1], true); + } else if (args[1].endsWith(".eps")) { + gb.gv.PS(args[1], false); + } else { + System.err.println("Unknown file type: " + args[1]); + } + } catch (IOException exn) { + System.err.println("Unable to write file " + args[1]); + } + } else { + f=new GraphBrowserFrame(gb); + f.setSize(700,500); + f.show(); + } } catch (IOException exn) { - System.out.println("Can't open graph file "+args[0]); + System.err.println("Can't open graph file "+args[0]); } + System.exit(0); } } diff -r 1e29b79db3dc -r fbab70de9b0d lib/browser/GraphBrowser/Vertex.java --- a/lib/browser/GraphBrowser/Vertex.java Tue Oct 16 00:50:23 2001 +0200 +++ b/lib/browser/GraphBrowser/Vertex.java Tue Oct 16 16:47:54 2001 +0200 @@ -69,7 +69,8 @@ public void setID(String s) {} public Dimension getLabelSize(Graphics g) { - FontMetrics fm=g.getFontMetrics(font); + FontMetrics fm = g == null ? + new DefaultFontMetrics(font) : g.getFontMetrics(font); return new Dimension( Math.max(fm.stringWidth("[. . . .]"),fm.stringWidth(getLabel())),