Added support for batch mode layout (without X11 connection).
authorberghofe
Tue Oct 16 16:47:54 2001 +0200 (2001-10-16)
changeset 11798fbab70de9b0d
parent 11797 1e29b79db3dc
child 11799 533a95523f61
Added support for batch mode layout (without X11 connection).
lib/browser/GraphBrowser/GraphBrowser.java
lib/browser/GraphBrowser/Vertex.java
     1.1 --- a/lib/browser/GraphBrowser/GraphBrowser.java	Tue Oct 16 00:50:23 2001 +0200
     1.2 +++ b/lib/browser/GraphBrowser/GraphBrowser.java	Tue Oct 16 16:47:54 2001 +0200
     1.3 @@ -2,7 +2,7 @@
     1.4    Title:      GraphBrowser/GraphBrowser.java
     1.5    ID:         $Id$
     1.6    Author:     Stefan Berghofer, TU Muenchen
     1.7 -  Copyright   1997  TU Muenchen
     1.8 +  License:    GPL (GNU GENERAL PUBLIC LICENSE)
     1.9  
    1.10    This is the graph browser's main class. It contains the "main(...)"
    1.11    method, which is used for the stand-alone version, as well as
    1.12 @@ -115,7 +115,7 @@
    1.13  				f.show();
    1.14  			}
    1.15  		} catch (Exception exn) {
    1.16 -			System.out.println("Can't read file "+fname);
    1.17 +			System.err.println("Can't read file "+fname);
    1.18  		}
    1.19  	}
    1.20  				
    1.21 @@ -162,11 +162,11 @@
    1.22  			gridbag.setConstraints(gv2,cnstr);
    1.23  			add(gv2);
    1.24  		} catch (IOException exn) {
    1.25 -			System.out.println("\nI/O error while reading graph file.");
    1.26 +			System.err.println("\nI/O error while reading graph file.");
    1.27  		} catch (ParseError exn) {
    1.28 -			System.out.println("\nParse error in graph file:");
    1.29 -			System.out.println(exn.getMessage());
    1.30 -			System.out.println("\nSyntax:\n<vertexname> <vertexID> <dirname> [ + ] <path> [ < | > ] [ <vertexID> [ ... [ <vertexID> ] ... ] ] ;");
    1.31 +			System.err.println("\nParse error in graph file:");
    1.32 +			System.err.println(exn.getMessage());
    1.33 +			System.err.println("\nSyntax:\n<vertexname> <vertexID> <dirname> [ + ] <path> [ < | > ] [ <vertexID> [ ... [ <vertexID> ] ... ] ] ;");
    1.34  		}
    1.35  	}		
    1.36  
    1.37 @@ -178,9 +178,9 @@
    1.38  			initBrowser(is);
    1.39  			is.close();
    1.40  		} catch (MalformedURLException exn) {
    1.41 -			System.out.println("Invalid URL: "+gfname);
    1.42 +			System.err.println("Invalid URL: "+gfname);
    1.43  		} catch (IOException exn) {
    1.44 -			System.out.println("I/O error while reading "+gfname+".");
    1.45 +			System.err.println("I/O error while reading "+gfname+".");
    1.46  		}
    1.47  	}
    1.48  
    1.49 @@ -188,17 +188,33 @@
    1.50  		isApplet=false;
    1.51  		try {
    1.52  			GraphBrowser gb=new GraphBrowser(args.length > 0 ? args[0] : "");
    1.53 -			if (args.length>0) {
    1.54 +			if (args.length > 0) {
    1.55  				InputStream is=new FileInputStream(args[0]);
    1.56  				gb.initBrowser(is);
    1.57  				is.close();
    1.58  			}
    1.59 -			f=new GraphBrowserFrame(gb);
    1.60 -			f.setSize(700,500);
    1.61 -			f.show();
    1.62 +			if (args.length > 1) {
    1.63 +			    gb.gv.getGraph().layout(null);
    1.64 +                            try {
    1.65 +			      if (args[1].endsWith(".ps")) {
    1.66 +                                gb.gv.PS(args[1], true);
    1.67 +                              } else if (args[1].endsWith(".eps")) {
    1.68 +                                gb.gv.PS(args[1], false);
    1.69 +                              } else {
    1.70 +                                System.err.println("Unknown file type: " + args[1]);
    1.71 +                              }
    1.72 +                            } catch (IOException exn) {
    1.73 +                              System.err.println("Unable to write file " + args[1]);
    1.74 +                            }
    1.75 +                        } else {
    1.76 +			    f=new GraphBrowserFrame(gb);
    1.77 +			    f.setSize(700,500);
    1.78 +			    f.show();
    1.79 +                        }
    1.80  		} catch (IOException exn) {
    1.81 -			System.out.println("Can't open graph file "+args[0]);
    1.82 +			System.err.println("Can't open graph file "+args[0]);
    1.83  		}
    1.84 +		System.exit(0);
    1.85  	}
    1.86  }
    1.87  
     2.1 --- a/lib/browser/GraphBrowser/Vertex.java	Tue Oct 16 00:50:23 2001 +0200
     2.2 +++ b/lib/browser/GraphBrowser/Vertex.java	Tue Oct 16 16:47:54 2001 +0200
     2.3 @@ -69,7 +69,8 @@
     2.4  	public void setID(String s) {}
     2.5  
     2.6  	public Dimension getLabelSize(Graphics g) {
     2.7 -		FontMetrics fm=g.getFontMetrics(font);
     2.8 +		FontMetrics fm = g == null ? 
     2.9 +		    new DefaultFontMetrics(font) : g.getFontMetrics(font);
    2.10  		
    2.11  		return new Dimension(
    2.12  		        Math.max(fm.stringWidth("[. . . .]"),fm.stringWidth(getLabel())),