Package adams.data.jai.transformer
Class Scripted
- java.lang.Object
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,FileBasedScripting
,FileBasedScriptingWithOptions
,SizeOfHandler
,ImageTransformer<BufferedImageContainer>
,FlowContextHandler
,Serializable
,Comparable
public class Scripted extends AbstractScriptedTransformer
An image transformer that uses any scripting handler for processing the data with a script located in the specified file.
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
-script <adams.core.io.PlaceholderFile> (property: scriptFile) The script file to load and execute. default: ${CWD}
-options <java.lang.String> (property: scriptOptions) The options for the script; must consist of 'key=value' pairs separated by blanks; the value of 'key' can be accessed via the 'getAdditionalOptions ().getXYZ("key")' method in the script actor. default:
-handler <adams.core.scripting.AbstractScriptingHandler> (property: handler) The handler to use for scripting. default: adams.core.scripting.Dummy
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractScriptingHandler
m_Handler
the scripting handler to use.protected AbstractJAITransformer
m_TransformerObject
the loaded script object.-
Fields inherited from class adams.data.jai.transformer.AbstractScriptedTransformer
m_ScriptFile, m_ScriptObject, m_ScriptOptions
-
Fields inherited from class adams.data.image.AbstractImageTransformer
m_FlowContext
-
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 Scripted()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkImage(BufferedImageContainer img)
Optional checks of the image.protected String
checkScriptObject()
Checks the script object.void
defineOptions()
Adds options to the internal list of options.void
destroy()
Frees up memory in a "destructive" non-reversible way.BufferedImageContainer[]
doTransform(BufferedImageContainer img)
Performs the actual transforming of the image.AbstractScriptingHandler
getHandler()
Gets the handler to use for scripting.String
globalInfo()
Returns a string describing the object.String
handlerTipText()
Returns the tip text for this property.protected String
loadScriptObject()
Loads the scripts object and sets its options.String
scriptOptionsTipText()
Returns the tip text for this property.void
setHandler(AbstractScriptingHandler value)
Sets the handler to use for scripting.-
Methods inherited from class adams.data.jai.transformer.AbstractScriptedTransformer
getScriptFile, getScriptOptions, initScriptObject, reset, scriptFileTipText, setScriptFile, setScriptOptions
-
Methods inherited from class adams.data.image.transformer.AbstractBufferedImageTransformer
forCommandLine, forName, getTransformations
-
Methods inherited from class adams.data.image.AbstractImageTransformer
cleanUp, compareTo, equals, getFlowContext, getQuickInfo, initialize, setFlowContext, shallowCopy, shallowCopy, transform
-
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
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_TransformerObject
protected transient AbstractJAITransformer m_TransformerObject
the loaded script object.
-
m_Handler
protected AbstractScriptingHandler m_Handler
the scripting handler to use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractScriptedTransformer
-
scriptOptionsTipText
public String scriptOptionsTipText()
Returns the tip text for this property.- Specified by:
scriptOptionsTipText
in interfaceFileBasedScriptingWithOptions
- Overrides:
scriptOptionsTipText
in classAbstractScriptedTransformer
- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setHandler
public void setHandler(AbstractScriptingHandler value)
Sets the handler to use for scripting.- Parameters:
value
- the handler
-
getHandler
public AbstractScriptingHandler getHandler()
Gets the handler to use for scripting.- Returns:
- the handler
-
handlerTipText
public String handlerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
loadScriptObject
protected String loadScriptObject()
Loads the scripts object and sets its options.- Specified by:
loadScriptObject
in classAbstractScriptedTransformer
- Returns:
- null if OK, otherwise the error message
-
checkScriptObject
protected String checkScriptObject()
Checks the script object.- Specified by:
checkScriptObject
in classAbstractScriptedTransformer
- Returns:
- null if OK, otherwise the error message
-
checkImage
protected void checkImage(BufferedImageContainer img)
Optional checks of the image.- Overrides:
checkImage
in classAbstractScriptedTransformer
- Parameters:
img
- the image to check
-
doTransform
public BufferedImageContainer[] doTransform(BufferedImageContainer img)
Performs the actual transforming of the image.- Specified by:
doTransform
in classAbstractImageTransformer<BufferedImageContainer>
- Parameters:
img
- the image to transform (can be modified, since it is a copy)- Returns:
- the generated image(s)
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classAbstractScriptedTransformer
- See Also:
AbstractOptionHandler.cleanUpOptions()
-
-