Package weka.gui.visualize
Class PrintableComponent
java.lang.Object
weka.gui.visualize.PrintableComponent
- All Implemented Interfaces:
PrintableHandler
This class extends the component which is handed over in the constructor by a
print dialog. The Print dialog is accessible via Alt+Shift+LeftMouseClick.
The individual JComponentWriter-descendants can be accessed by the
getWriter(String)
method, if the parameters need to be changed.
- Version:
- $Revision: 15294 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionreturns the GUI component this print dialog is part of.returns the title for the save dialog.static String
getToolTipText
(PrintableComponent component) Returns a tooltip only if the user wants it.returns the JComponentWriter associated with the given name, isnull
if not found.returns a Hashtable with the current available JComponentWriters in the save dialog.double
returns the scale factor for the x-axis.double
returns the scale factor for the y-axis.void
displays a save dialog for saving the panel to a file.void
setSaveDialogTitle
(String title) sets the title for the save dialog.void
setScale
(double x, double y) sets the scale factor.
-
Constructor Details
-
PrintableComponent
initializes the panel.- Parameters:
component
- the component to enhance with printing functionality
-
-
Method Details
-
getComponent
returns the GUI component this print dialog is part of.- Returns:
- the GUI component
-
getToolTipText
Returns a tooltip only if the user wants it. If retrieved for the first, a dialog pops up and asks the user whether the tooltip should always appear or not. The weka/gui/visualize/Visualize.props is then written in the user's home directory.- Parameters:
component
- the PrintableComponent to ask for- Returns:
- null if the user doesn't want the tooltip, otherwise the text
-
getWriters
returns a Hashtable with the current available JComponentWriters in the save dialog. the key of the Hashtable is the description of the writer.- Specified by:
getWriters
in interfacePrintableHandler
- Returns:
- all currently available JComponentWriters
- See Also:
-
getWriter
returns the JComponentWriter associated with the given name, isnull
if not found.- Specified by:
getWriter
in interfacePrintableHandler
- Parameters:
name
- the name of the writer- Returns:
- the writer associated with the given name
- See Also:
-
setSaveDialogTitle
sets the title for the save dialog.- Specified by:
setSaveDialogTitle
in interfacePrintableHandler
- Parameters:
title
- the title of the save dialog
-
getSaveDialogTitle
returns the title for the save dialog.- Specified by:
getSaveDialogTitle
in interfacePrintableHandler
- Returns:
- the title of the save dialog
-
setScale
public void setScale(double x, double y) sets the scale factor.- Specified by:
setScale
in interfacePrintableHandler
- Parameters:
x
- the scale factor for the x-axisy
- the scale factor for the y-axis
-
getXScale
public double getXScale()returns the scale factor for the x-axis.- Specified by:
getXScale
in interfacePrintableHandler
- Returns:
- the scale factor
-
getYScale
public double getYScale()returns the scale factor for the y-axis.- Specified by:
getYScale
in interfacePrintableHandler
- Returns:
- the scale factor
-
saveComponent
public void saveComponent()displays a save dialog for saving the panel to a file. Fixes a bug with the Swing JFileChooser: if you entered a new filename in the save dialog and press Enter thegetSelectedFile
method returnsnull
instead of the filename.
To solve this annoying behavior we call the save dialog once again s.t. the filename is set. Might look a little bit strange to the user, but no NullPointerException! ;-)- Specified by:
saveComponent
in interfacePrintableHandler
-