Package weka.gui.visualize
Class PrintableComponent
- java.lang.Object
-
- weka.gui.visualize.PrintableComponent
-
- All Implemented Interfaces:
PrintableHandler
public class PrintableComponent extends java.lang.Object implements 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: 7059 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
getWriters(),getWriter(String)
-
-
Constructor Summary
Constructors Constructor Description PrintableComponent(javax.swing.JComponent component)initializes the panel.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.swing.JComponentgetComponent()returns the GUI component this print dialog is part of.java.lang.StringgetSaveDialogTitle()returns the title for the save dialog.static java.lang.StringgetToolTipText(PrintableComponent component)Returns a tooltip only if the user wants it.JComponentWritergetWriter(java.lang.String name)returns the JComponentWriter associated with the given name, isnullif not found.java.util.HashtablegetWriters()returns a Hashtable with the current available JComponentWriters in the save dialog.doublegetXScale()returns the scale factor for the x-axis.doublegetYScale()returns the scale factor for the y-axis.voidsaveComponent()displays a save dialog for saving the panel to a file.voidsetSaveDialogTitle(java.lang.String title)sets the title for the save dialog.voidsetScale(double x, double y)sets the scale factor.
-
-
-
Method Detail
-
getComponent
public javax.swing.JComponent getComponent()
returns the GUI component this print dialog is part of.- Returns:
- the GUI component
-
getToolTipText
public static java.lang.String getToolTipText(PrintableComponent component)
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
public java.util.Hashtable 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:
getWritersin interfacePrintableHandler- Returns:
- all currently available JComponentWriters
- See Also:
JComponentWriter.getDescription()
-
getWriter
public JComponentWriter getWriter(java.lang.String name)
returns the JComponentWriter associated with the given name, isnullif not found.- Specified by:
getWriterin interfacePrintableHandler- Parameters:
name- the name of the writer- Returns:
- the writer associated with the given name
- See Also:
JComponentWriter.getDescription()
-
setSaveDialogTitle
public void setSaveDialogTitle(java.lang.String title)
sets the title for the save dialog.- Specified by:
setSaveDialogTitlein interfacePrintableHandler- Parameters:
title- the title of the save dialog
-
getSaveDialogTitle
public java.lang.String getSaveDialogTitle()
returns the title for the save dialog.- Specified by:
getSaveDialogTitlein interfacePrintableHandler- Returns:
- the title of the save dialog
-
setScale
public void setScale(double x, double y)sets the scale factor.- Specified by:
setScalein 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:
getXScalein interfacePrintableHandler- Returns:
- the scale factor
-
getYScale
public double getYScale()
returns the scale factor for the y-axis.- Specified by:
getYScalein 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 thegetSelectedFilemethod returnsnullinstead 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:
saveComponentin interfacePrintableHandler
-
-