|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.gui.visualize.JComponentWriter
public abstract class JComponentWriter
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()
setScalingEnabled(boolean)
Constructor Summary | |
---|---|
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 |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 inMethod Detail |
---|
public 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_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 Exception
Note: this method calls generateOutput()
which needs
to be overriden in subclasses!
Exception
- if either the file or the component is null
public 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 in
Exception
- if component of file are null
public 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 one
Exception
- if component or file are null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |