public class PrintableComponent extends Object implements PrintableHandler
The individual JComponentWriter-descendants can be accessed by the
getWriter(String)
method, if the parameters need to be changed.
getWriters()
,
getWriter(String)
Modifier and Type | Class and Description |
---|---|
protected class |
PrintableComponent.JComponentWriterFileFilter
a specialized filter that also contains the associated filter class.
|
Modifier and Type | Field and Description |
---|---|
protected double |
m_AspectRatio
the aspect ratio.
|
protected static JCheckBox |
m_AspectRatioCheckBox
the checkbox for keeping the aspect ration.
|
protected JComponent |
m_Component
the parent component of this print dialog.
|
protected static JCheckBox |
m_CustomDimensionsCheckBox
the checkbox for the custom dimensions.
|
protected static JTextField |
m_CustomHeightText
the edit field for the custom height.
|
protected static JTextField |
m_CustomWidthText
the edit field for the custom width.
|
protected static JFileChooser |
m_FileChooserPanel
the filechooser for saving the panel.
|
protected boolean |
m_IgnoreChange
whether to ignore the update of the text field (in case of "keep ratio").
|
protected String |
m_SaveDialogTitle
the title of the save dialog.
|
protected static boolean |
m_ShowToolTip
whether to display the tooltip or not.
|
protected static boolean |
m_ToolTipUserAsked
whether the user was already asked about the tooltip behavior.
|
protected double |
m_xScale
the x scale factor.
|
protected double |
m_yScale
the y scale factor.
|
protected static String |
PROPERTY_SHOW
the property name for showing the tooltip.
|
protected static String |
PROPERTY_USERASKED
the property name whether the user was already asked.
|
Constructor and Description |
---|
PrintableComponent(JComponent component)
initializes the panel.
|
Modifier and Type | Method and Description |
---|---|
JComponent |
getComponent()
returns the GUI component this print dialog is part of.
|
String |
getSaveDialogTitle()
returns the title for the save dialog.
|
static String |
getToolTipText(PrintableComponent component)
Returns a tooltip only if the user wants it.
|
JComponentWriter |
getWriter(String name)
returns the JComponentWriter associated with the given name, is
null if not found. |
Hashtable |
getWriters()
returns a Hashtable with the current available JComponentWriters in the
save dialog.
|
double |
getXScale()
returns the scale factor for the x-axis.
|
double |
getYScale()
returns the scale factor for the y-axis.
|
protected void |
initFileChooser()
initializes the filechooser, i.e.
|
void |
saveComponent()
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.
|
protected void |
updateDimensions(JTextField sender)
updates the dimensions if necessary (i.e., if aspect ratio is to be kept).
|
protected JComponent m_Component
protected static JFileChooser m_FileChooserPanel
protected static JCheckBox m_CustomDimensionsCheckBox
protected static JTextField m_CustomWidthText
protected static JTextField m_CustomHeightText
protected static JCheckBox m_AspectRatioCheckBox
protected String m_SaveDialogTitle
protected double m_xScale
protected double m_yScale
protected double m_AspectRatio
protected boolean m_IgnoreChange
protected static boolean m_ToolTipUserAsked
protected static final String PROPERTY_SHOW
protected static final String PROPERTY_USERASKED
protected static boolean m_ShowToolTip
public PrintableComponent(JComponent component)
component
- the component to enhance with printing functionalitypublic JComponent getComponent()
public static String getToolTipText(PrintableComponent component)
component
- the PrintableComponent to ask forprotected void initFileChooser()
protected void updateDimensions(JTextField sender)
sender
- the JTextField which send the notification to updatepublic Hashtable getWriters()
getWriters
in interface PrintableHandler
JComponentWriter.getDescription()
public JComponentWriter getWriter(String name)
null
if not found.getWriter
in interface PrintableHandler
name
- the name of the writerJComponentWriter.getDescription()
public void setSaveDialogTitle(String title)
setSaveDialogTitle
in interface PrintableHandler
title
- the title of the save dialogpublic String getSaveDialogTitle()
getSaveDialogTitle
in interface PrintableHandler
public void setScale(double x, double y)
setScale
in interface PrintableHandler
x
- the scale factor for the x-axisy
- the scale factor for the y-axispublic double getXScale()
getXScale
in interface PrintableHandler
public double getYScale()
getYScale
in interface PrintableHandler
public void saveComponent()
getSelectedFile
method returns null
instead of the filename.saveComponent
in interface PrintableHandler
Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.