weka.gui.visualize

## Class PNGWriter

- java.lang.Object
- - weka.gui.visualize.JComponentWriter
  - - weka.gui.visualize.PNGWriter

-     public class PNGWriter
      extends JComponentWriter

  This class takes any JComponent and outputs it to a PNG-file. Scaling is by default disabled, since we always take a screenshot.
  Version:
    $Revision: 8034 $
  Author:
    fracpete (fracpete at waikato dot ac dot nz)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PNGWriter()` initializes the object.
    `PNGWriter(javax.swing.JComponent c)` initializes the object with the given Component.
    `PNGWriter(javax.swing.JComponent c, java.io.File f)` initializes the object with the given Component and filename.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `generateOutput()` generates the actual output.
    `java.awt.Color` | `getBackground()` returns the current background color.
    `java.lang.String` | `getDescription()` returns the name of the writer, to display in the FileChooser.
    `java.lang.String` | `getExtension()` returns the extension (incl.
    `void` | `initialize()` further initialization.
    `static void` | `main(java.lang.String[] args)` for testing only.
    `void` | `setBackground(java.awt.Color c)` sets the background color to use in creating the PNG.

    - ### Methods inherited from class weka.gui.visualize.JComponentWriter

      `getComponent, getCustomHeight, getCustomWidth, getFile, getScalingEnabled, getUseCustomDimensions, getXScale, getYScale, setComponent, setCustomHeight, setCustomWidth, setFile, setScale, setScalingEnabled, setUseCustomDimensions, toOutput, toOutput, toOutput`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PNGWriter

          public PNGWriter()

      initializes the object.

    - #### PNGWriter

          public PNGWriter(javax.swing.JComponent c)

      initializes the object with the given Component.
      Parameters:
        `c` - the component to print in the output format

    - #### PNGWriter

          public PNGWriter(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

    - #### initialize

          public void initialize()

      further initialization.

    - #### getDescription

          public java.lang.String getDescription()

      returns the name of the writer, to display in the FileChooser. must be overridden in the derived class.
      Specified by:
        `getDescription` in class `JComponentWriter`
      Returns:
        the name of the writer

    - #### getExtension

          public java.lang.String getExtension()

      returns the extension (incl. ".") of the output format, to use in the FileChooser.
      Specified by:
        `getExtension` in class `JComponentWriter`
      Returns:
        the file extension

    - #### getBackground

          public java.awt.Color getBackground()

      returns the current background color.
      Returns:
        the current background color

    - #### setBackground

          public void setBackground(java.awt.Color c)

      sets the background color to use in creating the PNG.
      Parameters:
        `c` - the color to use for background

    - #### generateOutput

          public void generateOutput()
                              throws java.lang.Exception

      generates the actual output.
      Throws:
        `java.lang.Exception` - if something goes wrong

    - #### main

          public static void main(java.lang.String[] args)
                           throws java.lang.Exception

      for testing only.
      Parameters:
        `args` - the commandline arguments
      Throws:
        `java.lang.Exception` - if something goes wrong