Package adams.gui.visualization.core
Class AbstractPaintlet
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.visualization.core.AbstractPaintlet
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<Paintlet>
,SizeOfHandler
,Paintlet
,Serializable
- Direct Known Subclasses:
AbstractDataContainerZoomOverviewPaintlet
,AbstractDataPoolPaintlet
,AbstractStrokePaintlet
,BackgroundImagePaintlet
,MultiMouseMovementTracker
,MultiPaintlet
,MultiPaintlet
,ReportDateFieldPaintlet
,ReportDateFieldRangePaintlet
,TextOverlayPaintlet
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 PaintablePanel
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 boolean
canPaint(PaintEvent.PaintMoment moment)
Checks whether the paintlet is supposed to paint for thisPaintEvent.PaintMoment
.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.abstract PaintEvent.PaintMoment
getPaintMoment()
Returns when this paintlet is to be executed.PaintablePanel
getPanel()
Returns the panel currently in use.PlotPanel
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.abstract void
performPaint(Graphics g, PaintEvent.PaintMoment moment)
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(PaintablePanel value)
Sets the panel to use, null to disable painting.void
setPanel(PaintablePanel 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.protected void
updatePanel()
Calls the update() method of the associated panel.-
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 PaintablePanel 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(PaintablePanel value)
Sets the panel to use, null to disable painting.
-
setPanel
public void setPanel(PaintablePanel value, boolean register)
Sets the panel to use, null to disable painting.
-
getPanel
public PaintablePanel getPanel()
Returns the panel currently in use.
-
hasPanel
public boolean hasPanel()
Returns whether a panel has been set.
-
getPlot
public PlotPanel getPlot()
Returns the plot panel of the panel, null if no panel present.
-
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
-
getPaintMoment
public abstract PaintEvent.PaintMoment getPaintMoment()
Returns when this paintlet is to be executed.- Specified by:
getPaintMoment
in interfacePaintlet
- Returns:
- when this paintlet is to be executed
-
canPaint
public boolean canPaint(PaintEvent.PaintMoment moment)
Checks whether the paintlet is supposed to paint for thisPaintEvent.PaintMoment
. Returns always true ifPaintEvent.PaintMoment.MULTIPLE
.- Specified by:
canPaint
in interfacePaintlet
- Returns:
- true if painting should occur
- See Also:
getPaintMoment()
-
performPaint
public abstract void performPaint(Graphics g, PaintEvent.PaintMoment moment)
The paint routine of the paintlet.- Specified by:
performPaint
in interfacePaintlet
- Parameters:
g
- the graphics context to use for paintingmoment
- whatPaintEvent.PaintMoment
is currently being painted
-
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()
-
updatePanel
protected void updatePanel()
Calls the update() method of the associated panel.
-
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
-
-