edu.jhu.ece.iacl.jist.pipeline.parameter
Class ParamModel<T>

java.lang.Object
  extended by edu.jhu.ece.iacl.jist.pipeline.PipePort<T>
      extended by edu.jhu.ece.iacl.jist.pipeline.parameter.ParamModel<T>
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<ParamModel>
Direct Known Subclasses:
ParamBoolean, ParamCollection, ParamColor, ParamFile, ParamFileCollection, ParamHidden, ParamInformation, ParamMatrix, ParamMipavDialog, ParamMultiOption, ParamNumber, ParamNumberCollection, ParamOption, ParamPerformance, ParamPointDouble, ParamPointFloat, ParamPointInteger, ParamString

public abstract class ParamModel<T>
extends PipePort<T>
implements java.lang.Comparable<ParamModel>, java.lang.Cloneable

Generic Parameter with a bridge to interface with methods in the parameter getFactory(). The parameter factory is not serialized when exporting the parameter to XML

Author:
Blake Lucas

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.jhu.ece.iacl.jist.pipeline.PipePort
PipePort.PortListener, PipePort.type
 
Field Summary
protected  java.lang.String cliTag
           
protected  java.lang.String description
          Description of parameter.
protected  ParamFactory factory
          The factory.
protected  boolean hidden
          The hidden.
protected  java.lang.String label
          The label.
protected  boolean loadAndSaveOnValidate
          Should the parameter be validated on load.
protected  boolean mandatory
          The mandatory.
protected  java.lang.String shortLabel
          The shortLabel --- "command line flag"
 
Fields inherited from class edu.jhu.ece.iacl.jist.pipeline.PipePort
connectible, gport, incomingConnectors, listeners, maxIncoming, maxOutgoing, outgoingConnectors, owner, portType, useWire
 
Constructor Summary
ParamModel()
          Default constructor.
 
Method Summary
 void clean()
          Clean resources that maybe out-of-date with the system
abstract  ParamModel<T> clone()
          Clone parameter.
 int compareTo(ParamModel mod)
          Compare specificity of parameters.
 void createMipavParameter(AlgorithmParameters scriptParams)
          Create MIPAV parameter that represents this parameter.
 javax.swing.tree.MutableTreeNode createTreeNode()
          Create tree node that represents this parameter.
 void dispose()
          Release as much memory as possible from this object without setting the entire object to null.
 boolean equals(ParamModel<T> model)
           
 java.lang.String getCliTag()
           
 java.lang.String getDescription()
          Get port description.
 ParamFactory getFactory()
          Get parameter factory.
abstract  java.lang.String getHumanReadableDataType()
           
 ParamInputView getInputView()
          Get the input view to specify the parameter value.
 java.lang.String getLabel()
          Get the text label for this parameter.
 java.lang.String getName()
          Get the parameter's name, which should be unique.
 ParamOutputView getOutputView()
          Get the output view to specify the output parameter.
 java.lang.String getShortLabel()
          Get the short text label for this parameter.
abstract  T getValue()
          Get the value stored in the parameter.
 javax.swing.JPanel getView()
          Get panel that represents this parameter, depending on whether it is an input or output parameter.
abstract  java.lang.String getXMLValue()
           
 void hide()
          Hide this parameter.
 void importMipavParameter(ParameterTable paramTable)
          Import value from MIPAV script parameter.
 boolean importParameter(ParamModel model)
          Import the contents of a foreign parameter into this parameter.
 boolean isCompatible(PipePort model)
          Check for compatibility between parameters.
 boolean isConnectible()
          returns true if connector can connect to this parameter.
 boolean isHidden()
          Returns true if parameter is hidden.
 boolean isMandatory()
          File field is mandatory.
 boolean loadResources(ParamModel param)
          Load resources.
 boolean loadResources(ParamModel param, javax.swing.ProgressMonitor monitor)
          Load external resources specified in foreign parameter.
abstract  java.lang.String probeDefaultValue()
           
 boolean read(java.io.File f)
          Read parameter information from file.
 boolean read(java.lang.String text, boolean loadResources)
          Read parameter information from string.
 void replacePath(java.io.File originalDir, java.io.File replaceDir)
          Replace path in all file type objects with this path.
 boolean saveResources(java.io.File dir, boolean saveSubDirectoryOverride)
          Save external resources associated with the parameter to the specified directory.
 void setCliTag(java.lang.String tag)
           
 void setDescription(java.lang.String description)
           
 void setFactory(ParamFactory factory)
          Use a different factory for manipulating this parameter model.
 void setHidden(boolean b)
          Set hidden status.
 void setInputView(ParamInputView view)
          Set the input view used to specify the parameter value.
 void setLabel(java.lang.String label)
          Set the label to be displayed in the input and output views.
 void setLoadAndSaveOnValidate(boolean flag)
          Allow memory saving operations by reducing the level of validation performed.
 void setMandatory(boolean mandatory)
          Set the mandatory field.
 void setName(java.lang.String name)
          Set the name of the parameter, which will appear as the label if the label is not specified.
 void setOutputView(ParamOutputView view)
          Set the output view used to display the parameter value.
 void setShortLabel(java.lang.String shortLabel)
          Set the shortLabel to be used as a command line switch.
abstract  void setValue(T value)
          Set the parameter value.
abstract  void setXMLValue(java.lang.String arg)
           
abstract  java.lang.String toString()
          Get description of parameter.
 java.lang.String toXML()
          Serialize parameter as XML.
abstract  void validate()
          Validate parameter associated with this port.
 boolean write(java.io.File f)
          Write this parameter to an XML file.
 void write(java.io.ObjectOutputStream out)
          Write parameter to byte serialized output stream.
 void writeAndFreeNow(ProcessingAlgorithm src)
          Attempt to export the current parameter now, and, if possible, free associated memory.
 
Methods inherited from class edu.jhu.ece.iacl.jist.pipeline.PipePort
addListener, disconnect, disconnect, disconnect, disconnect, getGraphPort, getIncomingConnector, getIncomingConnectors, getIncomingPorts, getListeners, getMaxIncoming, getMaxOutgoing, getOutgoingConnector, getOutgoingConnectors, getOutgoingPorts, getOwner, getPortType, init, isConnected, isConnectedTo, isInputPort, isOutputPort, notifyListenersOfConnection, notifyListenersOfDisconnection, removeAllListeners, removeListener, setConnectable, setGraphPort, setMaxIncoming, setMaxOutgoing, setOwner, setPortType, setUseConnector, usingConnector
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

factory

protected transient ParamFactory factory
The factory.


shortLabel

protected java.lang.String shortLabel
The shortLabel --- "command line flag"


label

protected java.lang.String label
The label.


hidden

protected boolean hidden
The hidden.


mandatory

protected boolean mandatory
The mandatory.


description

protected java.lang.String description
Description of parameter.


loadAndSaveOnValidate

protected transient boolean loadAndSaveOnValidate
Should the parameter be validated on load. True = default behavior.


cliTag

protected java.lang.String cliTag
Constructor Detail

ParamModel

public ParamModel()
Default constructor.

Method Detail

clone

public abstract ParamModel<T> clone()
Description copied from class: PipePort
Clone parameter.

Specified by:
clone in class PipePort<T>
Returns:
the pipe port

compareTo

public int compareTo(ParamModel mod)
Compare specificity of parameters. Zero indicates both parameters have the same level of specificity. Negative one indicates this parameter is less specific than the foreign one. Positive one indicates this parameter is more specific than the foreign one.

Specified by:
compareTo in interface java.lang.Comparable<ParamModel>
Parameters:
mod - the mod
Returns:
the int

createMipavParameter

public void createMipavParameter(AlgorithmParameters scriptParams)
                          throws ParserException
Create MIPAV parameter that represents this parameter.

Parameters:
scriptParams - script parameter
Throws:
ParserException - the parser exception

createTreeNode

public final javax.swing.tree.MutableTreeNode createTreeNode()
Create tree node that represents this parameter.

Returns:
the mutable tree node

clean

public void clean()
Clean resources that maybe out-of-date with the system


replacePath

public void replacePath(java.io.File originalDir,
                        java.io.File replaceDir)
Replace path in all file type objects with this path. This is used for JUnit testing

Parameters:
replaceDir -

getFactory

public ParamFactory getFactory()
Get parameter factory.

Returns:
parameter factory

getInputView

public final ParamInputView getInputView()
Get the input view to specify the parameter value.

Returns:
input view

getShortLabel

public java.lang.String getShortLabel()
Get the short text label for this parameter. Useful for command line flag.

Returns:
suggested command line flag for parameter

getLabel

public java.lang.String getLabel()
Get the text label for this parameter. If none is specified, the text name is used

Specified by:
getLabel in class PipePort<T>
Returns:
label

getName

public java.lang.String getName()
Get the parameter's name, which should be unique.

Specified by:
getName in class PipePort<T>
Returns:
name

getOutputView

public final ParamOutputView getOutputView()
Get the output view to specify the output parameter.

Returns:
output view

getValue

public abstract T getValue()
Get the value stored in the parameter.

Specified by:
getValue in class PipePort<T>
Returns:
this the default value stored by the parameter. Although, parameters could potentially store more than one type of value.

getView

public javax.swing.JPanel getView()
Get panel that represents this parameter, depending on whether it is an input or output parameter.

Specified by:
getView in class PipePort<T>
Returns:
the view

hide

public void hide()
Hide this parameter.


importMipavParameter

public void importMipavParameter(ParameterTable paramTable)
                          throws ParameterException
Import value from MIPAV script parameter.

Parameters:
paramTable - parameter table
Throws:
ParameterException - the parameter exception

importParameter

public final boolean importParameter(ParamModel model)
Import the contents of a foreign parameter into this parameter.

Parameters:
model - foreign parameter
Returns:
true if success

isCompatible

public boolean isCompatible(PipePort model)
Check for compatibility between parameters.

Specified by:
isCompatible in class PipePort<T>
Parameters:
model - foreign parameter
Returns:
true if compatible

isConnectible

public boolean isConnectible()
returns true if connector can connect to this parameter.

Overrides:
isConnectible in class PipePort<T>
Returns:
true, if checks if is connectible

isHidden

public boolean isHidden()
Returns true if parameter is hidden.

Returns:
true if hidden

isMandatory

public boolean isMandatory()
File field is mandatory.

Returns:
true, if checks if is mandatory

loadResources

public final boolean loadResources(ParamModel param)
Load resources.

Parameters:
param - the param
Returns:
true, if successful

loadResources

public final boolean loadResources(ParamModel param,
                                   javax.swing.ProgressMonitor monitor)
Load external resources specified in foreign parameter.

Parameters:
param - foreign parameter
monitor - TODO
Returns:
true if resources successfully loaded or not specified

read

public final boolean read(java.io.File f)
Read parameter information from file.

Parameters:
f - XML file
Returns:
true if parameter information imported correctly

read

public final boolean read(java.lang.String text,
                          boolean loadResources)
Read parameter information from string.

Parameters:
text - the text
loadResources - the load resources
Returns:
true if parameter information imported correctly

saveResources

public final boolean saveResources(java.io.File dir,
                                   boolean saveSubDirectoryOverride)
Save external resources associated with the parameter to the specified directory.

Parameters:
dir - save directory
Returns:
true if success

setFactory

public void setFactory(ParamFactory factory)
Use a different factory for manipulating this parameter model.

Parameters:
factory - the factory

setHidden

public void setHidden(boolean b)
Set hidden status.

Parameters:
b - true if hidden

setInputView

public final void setInputView(ParamInputView view)
Set the input view used to specify the parameter value.

Parameters:
view - the view

setLabel

public void setLabel(java.lang.String label)
Set the label to be displayed in the input and output views.

Specified by:
setLabel in class PipePort<T>
Parameters:
label - the label

setShortLabel

public void setShortLabel(java.lang.String shortLabel)
Set the shortLabel to be used as a command line switch.

Parameters:
shortLabel - the shortLabel

setMandatory

public void setMandatory(boolean mandatory)
Set the mandatory field. The default is true.

Parameters:
mandatory - the mandatory

setName

public void setName(java.lang.String name)
Set the name of the parameter, which will appear as the label if the label is not specified.

Specified by:
setName in class PipePort<T>
Parameters:
name - the name

setOutputView

public final void setOutputView(ParamOutputView view)
Set the output view used to display the parameter value.

Parameters:
view - the view

setValue

public abstract void setValue(T value)
                       throws InvalidParameterValueException
Set the parameter value. A parameter maybe able to support more than one type of value

Specified by:
setValue in class PipePort<T>
Parameters:
value - the value
Throws:
InvalidParameterValueException - object type is not an acceptable value for this parameter
parameter - assigned value of an improper type

toString

public abstract java.lang.String toString()
Get description of parameter.

Overrides:
toString in class PipePort<T>
Returns:
the string

toXML

public final java.lang.String toXML()
Serialize parameter as XML.

Returns:
the string

validate

public abstract void validate()
                       throws InvalidParameterException
Description copied from class: PipePort
Validate parameter associated with this port.

Specified by:
validate in class PipePort<T>
Throws:
InvalidParameterException - the invalid parameter exception

write

public final boolean write(java.io.File f)
Write this parameter to an XML file.

Parameters:
f - file
Returns:
true if success

write

public final void write(java.io.ObjectOutputStream out)
                 throws java.io.IOException
Write parameter to byte serialized output stream.

Parameters:
out - the out
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getDescription

public java.lang.String getDescription()
Description copied from class: PipePort
Get port description.

Overrides:
getDescription in class PipePort<T>
Returns:
the description

setDescription

public void setDescription(java.lang.String description)
Parameters:
description - the description to set

equals

public boolean equals(ParamModel<T> model)

getHumanReadableDataType

public abstract java.lang.String getHumanReadableDataType()

setCliTag

public void setCliTag(java.lang.String tag)

getCliTag

public java.lang.String getCliTag()

setXMLValue

public abstract void setXMLValue(java.lang.String arg)

getXMLValue

public abstract java.lang.String getXMLValue()

probeDefaultValue

public abstract java.lang.String probeDefaultValue()

setLoadAndSaveOnValidate

public void setLoadAndSaveOnValidate(boolean flag)
Allow memory saving operations by reducing the level of validation performed.

Parameters:
flag - - false = do not perform extra validation, true (default) = perform standard valdiation

dispose

public void dispose()
Release as much memory as possible from this object without setting the entire object to null. If this is an input parameter, the data should be able to be retrieved. By default, does nothing.


writeAndFreeNow

public void writeAndFreeNow(ProcessingAlgorithm src)
Attempt to export the current parameter now, and, if possible, free associated memory. Does not apply in cases where the algorithm is being run in process. By default, does nothing. Only possibly active for parameters with setLoadAndSaveOnValidate(false)

Parameters:
src - - Parent ProcessingAlgorithm needed to determine output location