weka.gui.visualize
Class JComponentWriter

java.lang.Object
  extended by weka.gui.visualize.JComponentWriter
Direct Known Subclasses:
JPEGWriter, PostscriptWriter

public abstract class JComponentWriter
extends java.lang.Object

This class takes any JComponent and outputs it to a file. Scaling is by default enabled.

Version:
$Revision: 1.1.2.1 $
Author:
FracPete (fracpete at waikato dot ac dot nz)
See Also:
#setScalingEnabled()

Constructor Summary
JComponentWriter()
          initializes the object
JComponentWriter(javax.swing.JComponent c)
          initializes the object with the given Component
JComponentWriter(javax.swing.JComponent c, java.io.File f)
          initializes the object with the given Component and filename
 
Method Summary
 javax.swing.JComponent getComponent()
          returns the component that is stored in the output format
 java.lang.String getDescription()
          returns the name of the writer, to display in the FileChooser.
 java.lang.String getExtension()
          returns the extension (incl.
 java.io.File getFile()
          returns the file being used for storing the output
 boolean getScalingEnabled()
          whether scaling is enabled or ignored
 double getXScale()
          returns the scale factor for the x-axis
 double getYScale()
          returns the scale factor for the y-axis
 void setComponent(javax.swing.JComponent c)
          sets the component to print to an output format
 void setFile(java.io.File f)
          sets the file to store the output in
 void setScale(double x, double y)
          sets the scale factor - is ignored since we always create a screenshot!
 void setScalingEnabled(boolean enabled)
          sets whether to enable scaling
 void toOutput()
          saves the current component to the currently set file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JComponentWriter

public JComponentWriter()
initializes the object


JComponentWriter

public JComponentWriter(javax.swing.JComponent c)
initializes the object with the given Component

Parameters:
c - the component to print in the output format

JComponentWriter

public JComponentWriter(javax.swing.JComponent c,
                        java.io.File f)
initializes the object with the given Component and filename

Parameters:
c - the component to print in the output format
f - the file to store the output in
Method Detail

setComponent

public void setComponent(javax.swing.JComponent c)
sets the component to print to an output format


getComponent

public javax.swing.JComponent getComponent()
returns the component that is stored in the output format


setFile

public void setFile(java.io.File f)
sets the file to store the output in


getFile

public java.io.File getFile()
returns the file being used for storing the output


getDescription

public java.lang.String getDescription()
returns the name of the writer, to display in the FileChooser. must be overridden in the derived class.


getExtension

public java.lang.String getExtension()
returns the extension (incl. ".") of the output format, to use in the FileChooser. must be overridden in the derived class.


getScalingEnabled

public boolean getScalingEnabled()
whether scaling is enabled or ignored


setScalingEnabled

public void setScalingEnabled(boolean enabled)
sets whether to enable scaling


setScale

public void setScale(double x,
                     double y)
sets the scale factor - is ignored since we always create a screenshot!

Parameters:
x - the scale factor for the x-axis
y - the scale factor for the y-axis

getXScale

public double getXScale()
returns the scale factor for the x-axis


getYScale

public double getYScale()
returns the scale factor for the y-axis


toOutput

public void toOutput()
              throws java.lang.Exception
saves the current component to the currently set file.

Note: this method has to be overriden in subclasses!

Throws:
java.lang.Exception - if either the file or the component is null