Class AbstractPaintlet
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.visualization.image.paintlet.AbstractPaintlet
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<Paintlet>
,SizeOfHandler
,Paintlet
,Serializable
- Direct Known Subclasses:
Null
public abstract class AbstractPaintlet extends AbstractOptionHandler implements Paintlet
An abstract superclass for paint engines that can be plugged into panels.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Enabled
whether the paintlet is enabled.protected boolean
m_Initializing
whether the paintlet is currently being initialized and should ignore repaint requests.protected ImagePanel
m_Panel
the panel this paintlet is for.protected boolean
m_RepaintOnChange
whether the paintlet reacts with repaints to changes of its members.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractPaintlet()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
finishInit()
Finishes the initialization in the constructor.static Paintlet
forCommandLine(String cmdline)
Instantiates the paintlet from the given commandline (i.e., classname and optional options).static Paintlet
forName(String classname, String[] options)
Instantiates the paintlet with the given options.static String[]
getPaintlets()
Returns a list with classnames of paintlets.ImagePanel.PaintPanel
getPaintPanel()
Returns the paint panel of the panel, null if no panel present.ImagePanel
getPanel()
Returns the panel currently in use.ImagePanel.PaintPanel
getPlot()
Returns the plot panel of the panel, null if no panel present.boolean
getRepaintOnChange()
Returns whether the paintlet reacts with repaints to changes of its members.boolean
hasPanel()
Returns whether a panel has been set.protected void
initialize()
Initializes the members.boolean
isEnabled()
Returns whether the paintlet is currently enabled.protected boolean
isInitializing()
Whether the paintlet is currently being initialized.void
memberChanged()
Executes a repaints only if the changes to members are not ignored.void
memberChanged(boolean updatePanel)
Executes a repaints only if the changes to members are not ignored.void
paint(Graphics g)
The paint routine of the paintlet.protected abstract void
performPaint(Graphics g)
The paint routine of the paintlet.void
repaint()
Repaints if possible (and enabled!).void
setEnabled(boolean value)
Sets whether the paintlet is enabled or not.void
setPanel(ImagePanel value)
Sets the panel to use, null to disable painting.void
setPanel(ImagePanel value, boolean register)
Sets the panel to use, null to disable painting.void
setRepaintOnChange(boolean value)
Sets whether the paintlet reacts with repaints to changes of its members.Paintlet
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.Paintlet
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Panel
protected transient ImagePanel m_Panel
the panel this paintlet is for.
-
m_Enabled
protected boolean m_Enabled
whether the paintlet is enabled.
-
m_RepaintOnChange
protected boolean m_RepaintOnChange
whether the paintlet reacts with repaints to changes of its members.
-
m_Initializing
protected boolean m_Initializing
whether the paintlet is currently being initialized and should ignore repaint requests.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
finishInit
protected void finishInit()
Finishes the initialization in the constructor.
Calls memberChanged.- Overrides:
finishInit
in classAbstractOptionHandler
- See Also:
memberChanged()
-
isInitializing
protected boolean isInitializing()
Whether the paintlet is currently being initialized.- Returns:
- true if the paintlet is currently being initialized
-
setPanel
public void setPanel(ImagePanel value)
Sets the panel to use, null to disable painting.
-
setPanel
public void setPanel(ImagePanel value, boolean register)
Sets the panel to use, null to disable painting.
-
getPanel
public ImagePanel getPanel()
Returns the panel currently in use.
-
getPaintPanel
public ImagePanel.PaintPanel getPaintPanel()
Returns the paint panel of the panel, null if no panel present.- Specified by:
getPaintPanel
in interfacePaintlet
- Returns:
- the paint panel
-
hasPanel
public boolean hasPanel()
Returns whether a panel has been set.
-
getPlot
public ImagePanel.PaintPanel getPlot()
Returns the plot panel of the panel, null if no panel present.- Returns:
- the plot panel
-
setEnabled
public void setEnabled(boolean value)
Sets whether the paintlet is enabled or not. Setting it to true automatically initiates a repaint. Is not affected by m_RepaintOnChange.- Specified by:
setEnabled
in interfacePaintlet
- Parameters:
value
- if true then the paintlet is enabled- See Also:
m_RepaintOnChange
-
isEnabled
public boolean isEnabled()
Returns whether the paintlet is currently enabled.
-
setRepaintOnChange
public void setRepaintOnChange(boolean value)
Sets whether the paintlet reacts with repaints to changes of its members.- Specified by:
setRepaintOnChange
in interfacePaintlet
- Parameters:
value
- if true then the paintlet repaints whenever members get changed
-
getRepaintOnChange
public boolean getRepaintOnChange()
Returns whether the paintlet reacts with repaints to changes of its members.- Specified by:
getRepaintOnChange
in interfacePaintlet
- Returns:
- true if paintlet repaints whenever members get changed
-
performPaint
protected abstract void performPaint(Graphics g)
The paint routine of the paintlet.- Parameters:
g
- the graphics context to use for painting
-
paint
public void paint(Graphics g)
The paint routine of the paintlet.- Specified by:
paint
in interfacePaintlet
- Parameters:
g
- the graphics context to use for painting- See Also:
isEnabled()
-
memberChanged
public void memberChanged()
Executes a repaints only if the changes to members are not ignored.- See Also:
getRepaintOnChange()
,isInitializing()
,repaint()
-
memberChanged
public void memberChanged(boolean updatePanel)
Executes a repaints only if the changes to members are not ignored.- Parameters:
updatePanel
- whether to call the update() method of the associated panel- See Also:
getRepaintOnChange()
,isInitializing()
,repaint()
-
repaint
public void repaint()
Repaints if possible (and enabled!).- See Also:
m_Panel
,isEnabled()
-
shallowCopy
public Paintlet shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<Paintlet>
- Returns:
- the shallow copy
-
shallowCopy
public Paintlet shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<Paintlet>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
getPaintlets
public static String[] getPaintlets()
Returns a list with classnames of paintlets.- Returns:
- the filter classnames
-
forName
public static Paintlet forName(String classname, String[] options)
Instantiates the paintlet with the given options.- Parameters:
classname
- the classname of the paintlet to instantiateoptions
- the options for the paintlet- Returns:
- the instantiated paintlet or null if an error occurred
-
forCommandLine
public static Paintlet forCommandLine(String cmdline)
Instantiates the paintlet from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the paintlet to instantiate- Returns:
- the instantiated paintlet or null if an error occurred
-
-