ucar.visad
Class Plotter

java.lang.Object
  extended by ucar.visad.Plotter

public class Plotter
extends Object

Plot a Plottable object to file. This is roughly analoguous to java printing which provides a Graphics2D to a Printable object, which the Printable can then render itself to, before being printed


Nested Class Summary
static interface Plotter.Plottable
          Interface for classes which create charts capable of being plotted via a third party rendering library to a vector based graphics format
 
Field Summary
static int DIFAX
          Specifies a format of DIFAX
static String[] FORMATS
          The different file formats supported
static int JPG
          Specifies a format of JPG
static int PDF
          Specifies a format of PDF
static int PNG
          Specifies a format of PNG
static int PS
          Specifies a format of Postscript
static int SVG
          Specifies a format of SVG
static int TIFF
          Specifies a format of PS2
 
Constructor Summary
Plotter(int format, String filename)
          Create a plotter
Plotter(int format, String filename, boolean monochrome)
          Create a plotter
Plotter(String filename)
          ctor
 
Method Summary
 int getFormat()
          Find out which format the plotter is plotting to
 JComponent getPreview(Plotter.Plottable plottable)
          Get the preview of the given plot
 void handleError(Exception exc)
          handle the error.
 void plot(Plotter.Plottable plottable)
          Plot a plottable object to the file specified in the constructor
 void setColourDepth(int colourDepth)
          Set color depth
 void setFilename(String filename)
          Set the filename
 void setMonochrome(boolean monochrome)
          set monochrome
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SVG

public static final int SVG
Specifies a format of SVG

See Also:
Constant Field Values

PNG

public static final int PNG
Specifies a format of PNG

See Also:
Constant Field Values

JPG

public static final int JPG
Specifies a format of JPG

See Also:
Constant Field Values

PS

public static final int PS
Specifies a format of Postscript

See Also:
Constant Field Values

PDF

public static final int PDF
Specifies a format of PDF

See Also:
Constant Field Values

TIFF

public static final int TIFF
Specifies a format of PS2

See Also:
Constant Field Values

DIFAX

public static final int DIFAX
Specifies a format of DIFAX

See Also:
Constant Field Values

FORMATS

public static final String[] FORMATS
The different file formats supported

Constructor Detail

Plotter

public Plotter(int format,
               String filename)
Create a plotter

Parameters:
format - The format of the distination file SVG, PNG or PS
filename - The filename to plot to

Plotter

public Plotter(String filename)
ctor

Parameters:
filename - file to write to

Plotter

public Plotter(int format,
               String filename,
               boolean monochrome)
Create a plotter

Parameters:
format - The format of the distination file SVG, PNG or PS
filename - The filename to plot to
monochrome - Set to true if all colours are to be plotted as either pure black or pure white
Method Detail

handleError

public void handleError(Exception exc)
                 throws Exception
handle the error. THis just throws the error but can be overwritten

Parameters:
exc - The error.
Throws:
Exception - On badness

setFilename

public void setFilename(String filename)
Set the filename

Parameters:
filename - the filename

setMonochrome

public void setMonochrome(boolean monochrome)
set monochrome

Parameters:
monochrome - is monochrome

setColourDepth

public void setColourDepth(int colourDepth)
Set color depth

Parameters:
colourDepth - the depth

getFormat

public int getFormat()
Find out which format the plotter is plotting to

Returns:
format

plot

public void plot(Plotter.Plottable plottable)
          throws FileNotFoundException,
                 IOException,
                 Exception
Plot a plottable object to the file specified in the constructor

Parameters:
plottable - The object to be plotted
Throws:
Exception - On badness
FileNotFoundException - On badness
IOException - On badness

getPreview

public JComponent getPreview(Plotter.Plottable plottable)
                      throws FileNotFoundException,
                             IOException
Get the preview of the given plot

Parameters:
plottable - plot to preview
Returns:
preview component
Throws:
FileNotFoundException - On badness
IOException - On badness