类 JComponentWriter

java.lang.Object
weka.gui.visualize.JComponentWriter
直接已知子类:
BMPWriter, JPEGWriter, PNGWriter, PostscriptWriter

public abstract class JComponentWriter extends Object
This class takes any JComponent and outputs it to a file. Scaling is by default enabled. Derived classes only need to override the following methods:
  • getDescription()
  • getExtension()
  • generateOutput()
版本:
$Revision: 7059 $
作者:
FracPete (fracpete at waikato dot ac dot nz)
另请参阅:
  • 构造器详细资料

    • JComponentWriter

      public JComponentWriter()
      initializes the object
    • JComponentWriter

      public JComponentWriter(JComponent c)
      initializes the object with the given Component
      参数:
      c - the component to print in the output format
    • JComponentWriter

      public JComponentWriter(JComponent c, File f)
      initializes the object with the given Component and filename
      参数:
      c - the component to print in the output format
      f - the file to store the output in
  • 方法详细资料

    • setComponent

      public void setComponent(JComponent c)
      sets the component to print to an output format
      参数:
      c - the component to print
    • getComponent

      public JComponent getComponent()
      returns the component that is stored in the output format
      返回:
      the component to print
    • setFile

      public void setFile(File f)
      sets the file to store the output in
      参数:
      f - the file to store the output in
    • getFile

      public File getFile()
      returns the file being used for storing the output
      返回:
      the file to store the output in
    • getDescription

      public abstract String getDescription()
      returns the name of the writer, to display in the FileChooser. must be overridden in the derived class.
      返回:
      the name of the writer
    • getExtension

      public abstract String getExtension()
      returns the extension (incl. ".") of the output format, to use in the FileChooser. must be overridden in the derived class.
      返回:
      the file extension
    • getScalingEnabled

      public boolean getScalingEnabled()
      whether scaling is enabled or ignored
      返回:
      true if scaling is enabled
    • setScalingEnabled

      public void setScalingEnabled(boolean enabled)
      sets whether to enable scaling
      参数:
      enabled - whether scaling is enabled
    • setScale

      public void setScale(double x, double y)
      sets the scale factor - is ignored since we always create a screenshot!
      参数:
      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
      返回:
      the scale scale factor for the x-axis
    • getYScale

      public double getYScale()
      returns the scale factor for the y-axis
      返回:
      the scale scale factor for the y-axis
    • getUseCustomDimensions

      public boolean getUseCustomDimensions()
      whether custom dimensions are to used for the size of the image
      返回:
      true if custom dimensions are used
    • setUseCustomDimensions

      public void setUseCustomDimensions(boolean value)
      sets whether to use custom dimensions for the image
      参数:
      value - whether custom dimensions are used
    • setCustomWidth

      public void setCustomWidth(int value)
      sets the custom width to use
      参数:
      value - the width to use
      另请参阅:
      • m_UseCustomDimensions
    • getCustomWidth

      public int getCustomWidth()
      gets the custom width currently used
      返回:
      the custom width currently used
      另请参阅:
      • m_UseCustomDimensions
    • setCustomHeight

      public void setCustomHeight(int value)
      sets the custom height to use
      参数:
      value - the height to use
      另请参阅:
      • m_UseCustomDimensions
    • getCustomHeight

      public int getCustomHeight()
      gets the custom height currently used
      返回:
      the custom height currently used
      另请参阅:
      • m_UseCustomDimensions
    • toOutput

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

      Note: this method calls generateOutput() which needs to be overriden in subclasses!

      抛出:
      Exception - if either the file or the component is null
    • toOutput

      public static void toOutput(JComponentWriter writer, JComponent comp, File file) throws Exception
      outputs the given component with the given writer in the specified file
      参数:
      writer - the writer to use
      comp - the component to output
      file - the file to store the output in
      抛出:
      Exception - if component of file are null
    • toOutput

      public static void toOutput(JComponentWriter writer, JComponent comp, File file, int width, int height) throws Exception
      outputs the given component with the given writer in the specified file. If width and height are different from -1 then these sizes are used, otherwise the current ones of the component
      参数:
      writer - the writer to use
      comp - the component to output
      file - the file to store the output in
      width - custom width, -1 uses the component's one
      height - custom height, -1 uses the component's one
      抛出:
      Exception - if component or file are null