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,WatermarkPaintlet
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 booleanm_Enabledwhether the paintlet is enabled.protected booleanm_Initializingwhether the paintlet is currently being initialized and should ignore repaint requests.protected PaintablePanelm_Panelthe panel this paintlet is for.protected booleanm_RepaintOnChangewhether 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 booleancanPaint(PaintEvent.PaintMoment moment)Checks whether the paintlet is supposed to paint for thisPaintEvent.PaintMoment.protected voidfinishInit()Finishes the initialization in the constructor.static PaintletforCommandLine(String cmdline)Instantiates the paintlet from the given commandline (i.e., classname and optional options).static PaintletforName(String classname, String[] options)Instantiates the paintlet with the given options.static String[]getPaintlets()Returns a list with classnames of paintlets.abstract PaintEvent.PaintMomentgetPaintMoment()Returns when this paintlet is to be executed.PaintablePanelgetPanel()Returns the panel currently in use.PlotPanelgetPlot()Returns the plot panel of the panel, null if no panel present.booleangetRepaintOnChange()Returns whether the paintlet reacts with repaints to changes of its members.booleanhasPanel()Returns whether a panel has been set.protected voidinitialize()Initializes the members.booleanisEnabled()Returns whether the paintlet is currently enabled.protected booleanisInitializing()Whether the paintlet is currently being initialized.voidmemberChanged()Executes a repaints only if the changes to members are not ignored.voidmemberChanged(boolean updatePanel)Executes a repaints only if the changes to members are not ignored.voidpaint(Graphics g)The paint routine of the paintlet.abstract voidperformPaint(Graphics g, PaintEvent.PaintMoment moment)The paint routine of the paintlet.voidrepaint()Repaints if possible (and enabled!).voidsetEnabled(boolean value)Sets whether the paintlet is enabled or not.voidsetPanel(PaintablePanel value)Sets the panel to use, null to disable painting.voidsetPanel(PaintablePanel value, boolean register)Sets the panel to use, null to disable painting.voidsetRepaintOnChange(boolean value)Sets whether the paintlet reacts with repaints to changes of its members.PaintletshallowCopy()Returns a shallow copy of itself, i.e., based on the commandline options.PaintletshallowCopy(boolean expand)Returns a shallow copy of itself, i.e., based on the commandline options.protected voidupdatePanel()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:
initializein classAbstractOptionHandler
-
finishInit
protected void finishInit()
Finishes the initialization in the constructor.
Calls memberChanged.- Overrides:
finishInitin 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:
setEnabledin 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:
setRepaintOnChangein 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:
getRepaintOnChangein 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:
getPaintMomentin 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:
canPaintin 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:
performPaintin interfacePaintlet- Parameters:
g- the graphics context to use for paintingmoment- whatPaintEvent.PaintMomentis currently being painted
-
paint
public void paint(Graphics g)
The paint routine of the paintlet.- Specified by:
paintin 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:
shallowCopyin 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:
shallowCopyin 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
-
-