Package adams.flow.sink
Class DisplayPanelGrid
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,VariablesInspectionHandler,VariableChangeListener,Actor,DisplayTypeSupporter,ErrorHandler,FlowControlSubMenuSupporter,HeadlessExecutionSupporter,InputConsumer,ComponentSupplier,MenuBarProvider,SendToActionSupporter,Serializable,Comparable
public class DisplayPanelGrid extends AbstractDisplay implements MenuBarProvider, ComponentSupplier, SendToActionSupporter, FlowControlSubMenuSupporter
Sink that places a panel in the grid for each each arriving token.
Uses the user-defined panel provider for creating the panels.
Input/output:
- accepts:
java.lang.String
java.io.File
java.awt.image.BufferedImage
adams.data.image.AbstractImage
Valid options are:
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-name <java.lang.String> (property: name) The name of the actor. default: DisplayPanelGrid
-annotation <adams.core.base.BaseText> (property: annotations) The annotations to attach to this actor. default:
-skip (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is.
-stop-flow-on-error (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors.
-short-title (property: shortTitle) If enabled uses just the name for the title instead of the actor's full name.
-width <int> (property: width) The width of the dialog. default: 800 minimum: -1
-height <int> (property: height) The height of the dialog. default: 600 minimum: -1
-x <int> (property: x) The X position of the dialog (>=0: absolute, -1: left, -2: center, -3: right ). default: -1 minimum: -3
-y <int> (property: y) The Y position of the dialog (>=0: absolute, -1: top, -2: center, -3: bottom ). default: -1 minimum: -3
-provider <adams.flow.sink.DisplayPanelProvider> (property: panelProvider) The actor for generating the display panels. default: adams.flow.sink.ImageViewer -writer adams.gui.print.NullWriter
-num-columns <int> (property: numColumns) The number of columns to use in the grid. default: 2 minimum: 1
-panel-width <int> (property: panelWidth) The width of the individual panels. default: 400 minimum: 1
-panel-height <int> (property: panelHeight) The height of the individual panels. default: 300 minimum: 1
-title-variable <adams.core.VariableNameNoUpdate> (property: titleVariable) The variable to use for the panel title; gets ignored if variable not available and the index of the panel is used instead. default: titleVariable
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected JComponentWriterFileChooserm_ComponentFileChooserthe filedialog for loading/saving flows.protected List<DisplayPanel>m_DisplayPanelsthe panels to display.protected JMenuBarm_MenuBarthe menu bar, if used.protected JMenuItemm_MenuItemFileClosethe "exit" menu item.protected JMenuItemm_MenuItemFileSaveAsthe "save as" menu item.protected JMenuItemm_MenuItemFlowPauseResumethe "pause/resume" menu item.protected JMenuItemm_MenuItemFlowStopthe "stop" menu item.protected intm_NumColumnsthe number of columns to use.protected AdjustableGridPanelm_PanelGridfor displaying the panels.protected intm_PanelHeightthe height of the individual panels.protected DisplayPanelProviderm_PanelProviderthe actor to use for generating panels.protected intm_PanelWidththe width of the individual panels.protected booleanm_ShowFlowControlSubMenuwhether to show flow control sub-menu.protected VariableNameNoUpdatem_TitleVariablethe variable to use for naming the entries.-
Fields inherited from class adams.flow.core.AbstractDisplay
BACKUP_INPUT, m_CreateFrame, m_DisplayType, m_Frame, m_Height, m_InputToken, m_KeepOpen, m_Panel, m_ResetGUIWaiting, m_ShortTitle, m_Updating, m_Width, m_X, m_Y
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description DisplayPanelGrid()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]accepts()Returns the class that the consumer accepts.protected booleancanPauseOrResume()Returns whether the flow can be paused/resumed.protected voidcleanUpGUI()Removes all graphical components.voidclearPanel()Clears the content of the panel.protected voidclose()Closes the dialog or frame.protected JMenuBarcreateMenuBar()Assembles the menu bar.voiddefineOptions()Adds options to the internal list of options.protected voiddisplay(Token token)Displays the token (the panel and dialog have already been created at this stage).protected JComponentWriterFileChoosergetComponentFileChooser()Returns (and initializes if necessary) the file chooser for the components.protected intgetDefaultHeight()Returns the default height for the dialog.protected intgetDefaultWidth()Returns the default width for the dialog.JMenuBargetMenuBar()Creates a menu bar (singleton per panel object).intgetNumColumns()Returns the number of columns in the grid.intgetPanelHeight()Returns the currently set height of the individual panels.DisplayPanelProvidergetPanelProvider()Returns the panel provider in use for generating the panels.intgetPanelWidth()Returns the currently set width of the individual panels.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.Class[]getSendToClasses()Returns the classes that the supporter generates.ObjectgetSendToItem(Class[] cls)Returns the object to send.booleangetShowFlowControlSubMenu()Returns whether to show a flow control sub-menu in the menubar.VariableNameNoUpdategetTitleVariable()Returns the variable name which value gets used to name the entries.StringglobalInfo()Returns a string describing the object.booleanhasSendToItem(Class[] cls)Checks whether something to send is available.protected voidinitialize()Initializes the members.protected booleanisPaused()Returns whether the flow is currently paused.protected BasePanelnewPanel()Creates the panel to display in the dialog.StringnumColumnsTipText()Returns the tip text for this property.StringpanelHeightTipText()Returns the tip text for this property.StringpanelProviderTipText()Returns the tip text for this property.StringpanelWidthTipText()Returns the tip text for this property.protected voidpauseResumeFlow()Pauses or resumes the flow.protected voidsaveAs()Saves the setups.voidsetNumColumns(int value)Sets the number of columns in the grid.voidsetPanelHeight(int value)Sets the height of the individual panels.voidsetPanelProvider(DisplayPanelProvider value)Sets the panel provider to use for generating the panels.voidsetPanelWidth(int value)Sets the width of the individual panels.voidsetShowFlowControlSubMenu(boolean value)Sets whether to show a flow control sub-menu in the menubar.voidsetTitleVariable(VariableNameNoUpdate value)Sets the variable name which value gets used to name the entries.StringshowFlowControlSubMenuTipText()Returns the tip text for this property.protected voidstopFlow()Stops the flow.JComponentsupplyComponent()Returns the current panel.StringtitleVariableTipText()Returns the tip text for this property.protected voidupdateMenu()updates the enabled state of the menu items.voidwrapUp()Cleans up after the execution has finished.-
Methods inherited from class adams.flow.sink.AbstractDisplay
newDisplayRunnable, postDisplay, preDisplay
-
Methods inherited from class adams.flow.core.AbstractDisplay
backupState, cleanUp, cleanUpGUIKeepOpen, closeDisplay, createFrame, createTitle, currentInput, deregisterInWrapUp, deregisterWindow, deregisterWithEditor, displayTypeTipText, doCreateFrame, doExecute, doExecuteHeadless, getCreateFrame, getDefaultDisplayType, getDefaultShortTitle, getDefaultX, getDefaultY, getDisplayType, getFrame, getFrameDefaultCloseOperation, getHeight, getKeepOpen, getPanel, getShortTitle, getWidth, getX, getY, hasInput, heightTipText, input, postCreateFrame, preCreateFrame, registerWindow, registerWithEditor, reset, restoreState, setCreateFrame, setDisplayType, setHeight, setKeepOpen, setShortTitle, setWidth, setX, setY, shortTitleTipText, stopExecution, supportsHeadlessExecution, widthTipText, xTipText, yTipText
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, compareTo, configureLogger, destroy, equals, execute, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, preExecute, pruneBackup, pruneBackup, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.flow.core.InputConsumer
currentInput, hasInput, input
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
m_NumColumns
protected int m_NumColumns
the number of columns to use.
-
m_PanelProvider
protected DisplayPanelProvider m_PanelProvider
the actor to use for generating panels.
-
m_PanelWidth
protected int m_PanelWidth
the width of the individual panels.
-
m_PanelHeight
protected int m_PanelHeight
the height of the individual panels.
-
m_TitleVariable
protected VariableNameNoUpdate m_TitleVariable
the variable to use for naming the entries.
-
m_ShowFlowControlSubMenu
protected boolean m_ShowFlowControlSubMenu
whether to show flow control sub-menu.
-
m_MenuBar
protected JMenuBar m_MenuBar
the menu bar, if used.
-
m_MenuItemFileSaveAs
protected JMenuItem m_MenuItemFileSaveAs
the "save as" menu item.
-
m_MenuItemFileClose
protected JMenuItem m_MenuItemFileClose
the "exit" menu item.
-
m_MenuItemFlowPauseResume
protected JMenuItem m_MenuItemFlowPauseResume
the "pause/resume" menu item.
-
m_MenuItemFlowStop
protected JMenuItem m_MenuItemFlowStop
the "stop" menu item.
-
m_ComponentFileChooser
protected transient JComponentWriterFileChooser m_ComponentFileChooser
the filedialog for loading/saving flows.
-
m_PanelGrid
protected AdjustableGridPanel m_PanelGrid
for displaying the panels.
-
m_DisplayPanels
protected List<DisplayPanel> m_DisplayPanels
the panels to display.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractDisplay
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractDisplay
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractDisplay- Returns:
- null if no info available, otherwise short string
-
getDefaultWidth
protected int getDefaultWidth()
Returns the default width for the dialog.- Overrides:
getDefaultWidthin classAbstractDisplay- Returns:
- the default width
-
getDefaultHeight
protected int getDefaultHeight()
Returns the default height for the dialog.- Overrides:
getDefaultHeightin classAbstractDisplay- Returns:
- the default height
-
setPanelProvider
public void setPanelProvider(DisplayPanelProvider value)
Sets the panel provider to use for generating the panels.- Parameters:
value- the panel provider to use
-
getPanelProvider
public DisplayPanelProvider getPanelProvider()
Returns the panel provider in use for generating the panels.- Returns:
- the panel provider in use
-
panelProviderTipText
public String panelProviderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumColumns
public void setNumColumns(int value)
Sets the number of columns in the grid.- Parameters:
value- the number of columns
-
getNumColumns
public int getNumColumns()
Returns the number of columns in the grid.- Returns:
- the number of columns
-
numColumnsTipText
public String numColumnsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPanelWidth
public void setPanelWidth(int value)
Sets the width of the individual panels.- Parameters:
value- the width
-
getPanelWidth
public int getPanelWidth()
Returns the currently set width of the individual panels.- Returns:
- the width
-
panelWidthTipText
public String panelWidthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPanelHeight
public void setPanelHeight(int value)
Sets the height of the individual panels.- Parameters:
value- the height
-
getPanelHeight
public int getPanelHeight()
Returns the currently set height of the individual panels.- Returns:
- the height
-
panelHeightTipText
public String panelHeightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTitleVariable
public void setTitleVariable(VariableNameNoUpdate value)
Sets the variable name which value gets used to name the entries. Gets ignored if variable does not exist.- Parameters:
value- the variable name
-
getTitleVariable
public VariableNameNoUpdate getTitleVariable()
Returns the variable name which value gets used to name the entries. Gets ignored if variable does not exist.- Returns:
- the variable name
-
titleVariableTipText
public String titleVariableTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setShowFlowControlSubMenu
public void setShowFlowControlSubMenu(boolean value)
Sets whether to show a flow control sub-menu in the menubar.- Specified by:
setShowFlowControlSubMenuin interfaceFlowControlSubMenuSupporter- Parameters:
value- true if to show
-
getShowFlowControlSubMenu
public boolean getShowFlowControlSubMenu()
Returns whether to show a flow control sub-menu in the menubar.- Specified by:
getShowFlowControlSubMenuin interfaceFlowControlSubMenuSupporter- Returns:
- true if to show
-
showFlowControlSubMenuTipText
public String showFlowControlSubMenuTipText()
Returns the tip text for this property.- Specified by:
showFlowControlSubMenuTipTextin interfaceFlowControlSubMenuSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
acceptsin interfaceInputConsumer- Returns:
- java.lang.String.class, java.io.File.class, java.awt.image.BufferedImage.class, adams.data.image.AbstractImage.class
-
clearPanel
public void clearPanel()
Clears the content of the panel.- Specified by:
clearPanelin classAbstractDisplay
-
newPanel
protected BasePanel newPanel()
Creates the panel to display in the dialog.- Specified by:
newPanelin classAbstractDisplay- Returns:
- the panel
-
display
protected void display(Token token)
Displays the token (the panel and dialog have already been created at this stage).- Specified by:
displayin classAbstractDisplay- Parameters:
token- the token to display
-
createMenuBar
protected JMenuBar createMenuBar()
Assembles the menu bar.- Returns:
- the menu bar
-
getMenuBar
public JMenuBar getMenuBar()
Creates a menu bar (singleton per panel object). Can be used in frames.- Specified by:
getMenuBarin interfaceMenuBarProvider- Returns:
- the menu bar
-
updateMenu
protected void updateMenu()
updates the enabled state of the menu items.
-
getComponentFileChooser
protected JComponentWriterFileChooser getComponentFileChooser()
Returns (and initializes if necessary) the file chooser for the components.- Returns:
- the file chooser
-
close
protected void close()
Closes the dialog or frame.
-
saveAs
protected void saveAs()
Saves the setups.
-
canPauseOrResume
protected boolean canPauseOrResume()
Returns whether the flow can be paused/resumed.- Returns:
- true if pause/resume available
-
isPaused
protected boolean isPaused()
Returns whether the flow is currently paused.- Returns:
- true if currently paused
-
pauseResumeFlow
protected void pauseResumeFlow()
Pauses or resumes the flow.
-
stopFlow
protected void stopFlow()
Stops the flow.
-
cleanUpGUI
protected void cleanUpGUI()
Removes all graphical components.- Overrides:
cleanUpGUIin classAbstractDisplay
-
supplyComponent
public JComponent supplyComponent()
Returns the current panel.- Specified by:
supplyComponentin interfaceComponentSupplier- Returns:
- the current panel, can be null
-
getSendToClasses
public Class[] getSendToClasses()
Returns the classes that the supporter generates.- Specified by:
getSendToClassesin interfaceSendToActionSupporter- Returns:
- the classes
-
hasSendToItem
public boolean hasSendToItem(Class[] cls)
Checks whether something to send is available.- Specified by:
hasSendToItemin interfaceSendToActionSupporter- Parameters:
cls- the classes to retrieve the item for- Returns:
- true if an object is available for sending
-
getSendToItem
public Object getSendToItem(Class[] cls)
Returns the object to send.- Specified by:
getSendToItemin interfaceSendToActionSupporter- Parameters:
cls- the classes to retrieve the item for- Returns:
- the item to send
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished.- Specified by:
wrapUpin interfaceActor- Overrides:
wrapUpin classAbstractDisplay
-
-