uk.ac.starlink.xdoc.fig
Class FigureIcon

java.lang.Object
  extended by uk.ac.starlink.xdoc.fig.FigureIcon
All Implemented Interfaces:
Icon

public abstract class FigureIcon
extends Object
implements Icon

Base class for drawings. As well as implementing Icon it provides some utility methods for output.

Since:
18 Sep 2007
Author:
Mark Taylor

Constructor Summary
protected FigureIcon(Rectangle bounds)
          Constructor.
 
Method Summary
 void display()
          Displays the figure in a Swing window.
protected abstract  void doDrawing(Graphics2D g2)
          Implement this method to draw the figure content.
 void exportEps(OutputStream out)
          Exports the currently displayed plot to encapsulated postscript.
 void exportImageIO(String formatName, boolean transparent, OutputStream out)
          Exports this figure to an output stream using the ImageIO framework.
 void exportPdf(OutputStream out)
          Exports the currently displayed plot to PDF.
 Rectangle getBounds()
          Returns the bounds for this figure.
 int getIconHeight()
           
 int getIconWidth()
           
static void main(String[] args)
          Main method.
 void paintIcon(Component c, Graphics g, int x, int y)
           
static int runMain(String[] args, FigureIcon fig)
          Does the work for the main(java.lang.String[]) method.
 void setBounds(Rectangle bounds)
          Sets the bounds for this figure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FigureIcon

protected FigureIcon(Rectangle bounds)
Constructor.

Parameters:
bounds - of image
Method Detail

doDrawing

protected abstract void doDrawing(Graphics2D g2)
Implement this method to draw the figure content.

Parameters:
g2 - graphics context

setBounds

public void setBounds(Rectangle bounds)
Sets the bounds for this figure.

Parameters:
bounds - new bounds

getBounds

public Rectangle getBounds()
Returns the bounds for this figure.

Returns:
bounds

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface Icon

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon

display

public void display()
Displays the figure in a Swing window.


exportEps

public void exportEps(OutputStream out)
               throws IOException
Exports the currently displayed plot to encapsulated postscript. Note this method closes the output stream when it's done.

Parameters:
out - destination stream for the EPS
Throws:
IOException

exportPdf

public void exportPdf(OutputStream out)
               throws IOException
Exports the currently displayed plot to PDF.

Parameters:
out - destination stream for the PDF
Throws:
IOException

exportImageIO

public void exportImageIO(String formatName,
                          boolean transparent,
                          OutputStream out)
                   throws IOException
Exports this figure to an output stream using the ImageIO framework.

Parameters:
formatName - ImageIO format name
transparent - true iff image will have a transparent background
out - destination output stream; will not be closed
Throws:
IOException

runMain

public static int runMain(String[] args,
                          FigureIcon fig)
                   throws IOException
Does the work for the main(java.lang.String[]) method.

Parameters:
args - argument vector
fig - optional FigureIcon instance to draw; if null the class name must be supplied on the command line
Returns:
status - zero means success
Throws:
IOException

main

public static void main(String[] args)
                 throws IOException
Main method. Run with -help flag for usage.

Parameters:
args - argument vector
Throws:
IOException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.