public abstract class JComponentWriter extends Object
getDescription()getExtension()generateOutput()setScalingEnabled(boolean)| Constructor and Description |
|---|
JComponentWriter()
initializes the object
|
JComponentWriter(JComponent c)
initializes the object with the given Component
|
JComponentWriter(JComponent c,
File f)
initializes the object with the given Component and filename
|
| Modifier and Type | Method and Description |
|---|---|
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 String |
getDescription()
returns the name of the writer, to display in the FileChooser.
|
abstract String |
getExtension()
returns the extension (incl.
|
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(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(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,
JComponent comp,
File file)
outputs the given component with the given writer in the specified file
|
static void |
toOutput(JComponentWriter writer,
JComponent comp,
File file,
int width,
int height)
outputs the given component with the given writer in the specified file.
|
public JComponentWriter()
public JComponentWriter(JComponent c)
c - the component to print in the output formatpublic JComponentWriter(JComponent c, File f)
c - the component to print in the output formatf - the file to store the output inpublic void setComponent(JComponent c)
c - the component to printpublic JComponent getComponent()
public void setFile(File f)
f - the file to store the output inpublic File getFile()
public abstract String getDescription()
public abstract 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_UseCustomDimensionspublic int getCustomWidth()
m_UseCustomDimensionspublic void setCustomHeight(int value)
value - the height to usem_UseCustomDimensionspublic int getCustomHeight()
m_UseCustomDimensionspublic void toOutput()
throws Exception
Note: this method calls generateOutput() which needs
to be overriden in subclasses!
Exception - if either the file or the component is nullpublic static void toOutput(JComponentWriter writer, JComponent comp, File file) throws Exception
writer - the writer to usecomp - the component to outputfile - the file to store the output inException - if component of file are nullpublic static void toOutput(JComponentWriter writer, JComponent comp, File file, int width, int height) throws 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 oneException - if component or file are nullCopyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.