public abstract class JComponentWriter
extends java.lang.Object
getDescription()
getExtension()
generateOutput()
setScalingEnabled(boolean)
Constructor and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
javax.swing.JComponent |
getComponent()
returns the component that is stored in the output format
|
int |
getCustomHeight()
gets the custom height currently used
|
int |
getCustomWidth()
gets the custom width currently used
|
abstract java.lang.String |
getDescription()
returns the name of the writer, to display in the FileChooser.
|
abstract 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
|
boolean |
getUseCustomDimensions()
whether custom dimensions are to used for the size of the image
|
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 |
setCustomHeight(int value)
sets the custom height to use
|
void |
setCustomWidth(int value)
sets the custom width to use
|
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 |
setUseCustomDimensions(boolean value)
sets whether to use custom dimensions for the image
|
void |
toOutput()
saves the current component to the currently set file.
|
static void |
toOutput(JComponentWriter writer,
javax.swing.JComponent comp,
java.io.File file)
outputs the given component with the given writer in the specified file
|
static void |
toOutput(JComponentWriter writer,
javax.swing.JComponent comp,
java.io.File file,
int width,
int height)
outputs the given component with the given writer in the specified file.
|
public JComponentWriter()
public JComponentWriter(javax.swing.JComponent c)
c
- the component to print in the output formatpublic JComponentWriter(javax.swing.JComponent c, java.io.File f)
c
- the component to print in the output formatf
- the file to store the output inpublic void setComponent(javax.swing.JComponent c)
c
- the component to printpublic javax.swing.JComponent getComponent()
public void setFile(java.io.File f)
f
- the file to store the output inpublic java.io.File getFile()
public abstract java.lang.String getDescription()
public abstract java.lang.String getExtension()
public boolean getScalingEnabled()
public void setScalingEnabled(boolean enabled)
enabled
- whether scaling is enabledpublic void setScale(double x, double y)
x
- the scale factor for the x-axisy
- the scale factor for the y-axispublic double getXScale()
public double getYScale()
public boolean getUseCustomDimensions()
public void setUseCustomDimensions(boolean value)
value
- whether custom dimensions are usedpublic void setCustomWidth(int value)
value
- the width to usem_UseCustomDimensions
public int getCustomWidth()
m_UseCustomDimensions
public void setCustomHeight(int value)
value
- the height to usem_UseCustomDimensions
public int getCustomHeight()
m_UseCustomDimensions
public void toOutput() throws java.lang.Exception
Note: this method calls generateOutput()
which needs
to be overriden in subclasses!
java.lang.Exception
- if either the file or the component is null
public static void toOutput(JComponentWriter writer, javax.swing.JComponent comp, java.io.File file) throws java.lang.Exception
writer
- the writer to usecomp
- the component to outputfile
- the file to store the output injava.lang.Exception
- if component of file are null
public static void toOutput(JComponentWriter writer, javax.swing.JComponent comp, java.io.File file, int width, int height) throws java.lang.Exception
writer
- the writer to usecomp
- the component to outputfile
- the file to store the output inwidth
- custom width, -1 uses the component's oneheight
- custom height, -1 uses the component's onejava.lang.Exception
- if component or file are null