uk.ac.essex.ia.media
Class OperatorImpl

java.lang.Object
  extended by uk.ac.essex.ia.media.OperatorImpl
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, Operator
Direct Known Subclasses:
AbsoluteOperator, AddConstOperator, AddOperator, AffineTransformOperator, AndOperator, BandCombineOperator, BandSelectOperator, BoxFilterOperator, CompositeOperator, ConvolutionOperator, DivideOperator, EdgeOperator, ExpOperator, HoughLinesOperator, HSISegmentOperator, MatchCDFOperator, MultiplyOperator, OpenImageOperator, OperatorTemplate, OrConstantOperator, OrOperator, OverlayOperator, PatternOperator, SaveImageOperator, ShowImageOperator, SubtractConstOperator, SubtractOperator, XOrOperator

public class OperatorImpl
extends java.lang.Object
implements Operator, java.io.Externalizable, java.lang.Cloneable

Provides a default implmentation of Operator and some variables/fucntions that are useful for operator Most of the information is obtained from the XML descriptor this class is a castor mapping object where the class OperatorDescriptor mapss to an XML element of the same name. These classes are autogenerated by castor sourceGen. TODO: Make OperatorDescriptor an interface this removes the reliance on the autogenerated xml code??
Date: May 15, 2002
You should have received a copy of GNU public license with this code. If not please visit this site

See Also:
Serialized Form

Field Summary
protected  java.net.URL iconURL
          The url to the icon
protected  java.awt.image.renderable.ParameterBlock inputParameters
          The input parameters for this operator
protected  java.lang.String label
          The label of this operator
protected  OperatorDescriptor operatorDescriptor
          This operators xml representation
protected  OperatorDialog operatorDialog
          The dialog used to get the any input parameters this operator requires
protected  LanguageManager translator
          The translator used to localized strings
 
Constructor Summary
OperatorImpl()
          Deprecated. This is solely for when this object is serialized / unserialized
OperatorImpl(OperatorDescriptor operatorDescriptor)
           
 
Method Summary
 boolean acceptsInputFrom(Operator o)
          Check the operators that are allowed to output data to this operator
 java.lang.Object clone()
           
 java.awt.image.RenderedImage execute(java.awt.image.renderable.ParameterBlock inData)
          Execute this operator with the input data passed as a parameter
 int getAllowedInputs()
           
 int getAllowedOutputs()
           
 java.lang.String getHelpID()
          Return a String that is the full path name to the help file for this operator.
 java.net.URL getIcon()
          Get the URL to the icon for this operator
 java.awt.image.renderable.ParameterBlock getInputParameters()
           
 java.awt.image.renderable.ParameterBlock getInputParametersForWriting()
          Any operator that has special requirements for writing there parameters should override this method.
 OperatorDialog getOperatorDialog()
           
 DataTypeConstant getOutputData()
          Get the type of the data that is output from this operator.
 int getRequiredInputs()
           
protected  java.awt.image.RenderedImage getSingleSource(java.awt.image.renderable.ParameterBlock parameters)
          Checks the parameter block to see if it contains a single source RenderedImage.
protected  java.awt.image.RenderedImage initSingleImageParameterBlock(java.awt.image.renderable.ParameterBlock inData)
           
 void readExternal(java.io.ObjectInput objectInput)
           
 void setInputParameters(java.awt.image.renderable.ParameterBlock inputParameters)
          TODO: Should there be a different method when params have been read??
 void setOperatorDialog(OperatorDialog dialog)
           
 void showOperatorDialog()
          Show a GUI that allows users to modify the parameters for the underlying operation
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput objectOutput)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

operatorDialog

protected OperatorDialog operatorDialog
The dialog used to get the any input parameters this operator requires


operatorDescriptor

protected transient OperatorDescriptor operatorDescriptor
This operators xml representation


inputParameters

protected java.awt.image.renderable.ParameterBlock inputParameters
The input parameters for this operator


translator

protected transient LanguageManager translator
The translator used to localized strings


iconURL

protected java.net.URL iconURL
The url to the icon


label

protected java.lang.String label
The label of this operator

Constructor Detail

OperatorImpl

public OperatorImpl()
Deprecated. This is solely for when this object is serialized / unserialized

Users should not use this constructor since the required variables will not be initialised. Users should use OperatorImpl(OperatorDescriptor) This is solely for when this object is serialized / unserialized


OperatorImpl

public OperatorImpl(OperatorDescriptor operatorDescriptor)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

writeExternal

public void writeExternal(java.io.ObjectOutput objectOutput)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
objectOutput -
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput objectInput)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
objectInput -
Throws:
java.io.IOException
java.lang.ClassNotFoundException

showOperatorDialog

public void showOperatorDialog()
Show a GUI that allows users to modify the parameters for the underlying operation

Specified by:
showOperatorDialog in interface Operator

setOperatorDialog

public void setOperatorDialog(OperatorDialog dialog)
Specified by:
setOperatorDialog in interface Operator
Parameters:
dialog - - The OperatorDialog that handles getting this operators parameters

getOperatorDialog

public OperatorDialog getOperatorDialog()
Specified by:
getOperatorDialog in interface Operator
Returns:
OperatorDialog - The dialog that handles getting this operators parameters

getHelpID

public java.lang.String getHelpID()
Return a String that is the full path name to the help file for this operator. This allows OpViewer to obtain context sensitive help for an Operator.

Specified by:
getHelpID in interface Operator
Returns:
URL - The path to the help file for this operator

getAllowedInputs

public int getAllowedInputs()
Specified by:
getAllowedInputs in interface Operator
Returns:
the number of inputs that this Operator can accept

getAllowedOutputs

public int getAllowedOutputs()
Specified by:
getAllowedOutputs in interface Operator
Returns:
the number of outputs that this Operator can accept

getRequiredInputs

public int getRequiredInputs()
Specified by:
getRequiredInputs in interface Operator
Returns:
int - The number of input connections that are required by this operator

acceptsInputFrom

public boolean acceptsInputFrom(Operator o)
Check the operators that are allowed to output data to this operator

Specified by:
acceptsInputFrom in interface Operator
Parameters:
o - -The Operator to check
Returns:
true if o is allowed to output data to this operator, false otherwise

getOutputData

public DataTypeConstant getOutputData()
Get the type of the data that is output from this operator. This should be one of the constants defined in DataTypeConstant

Specified by:
getOutputData in interface Operator
Returns:
DataTypeConstant - that corresponds to a data type

execute

public java.awt.image.RenderedImage execute(java.awt.image.renderable.ParameterBlock inData)
                                     throws java.lang.Exception
Execute this operator with the input data passed as a parameter

Specified by:
execute in interface Operator
Parameters:
inData - - The input data to this operator
Throws:
java.lang.Exception

getIcon

public java.net.URL getIcon()
Get the URL to the icon for this operator

Specified by:
getIcon in interface Operator
Returns:

getInputParameters

public java.awt.image.renderable.ParameterBlock getInputParameters()
Specified by:
getInputParameters in interface Operator
Returns:

setInputParameters

public void setInputParameters(java.awt.image.renderable.ParameterBlock inputParameters)
Description copied from interface: Operator
TODO: Should there be a different method when params have been read??

Specified by:
setInputParameters in interface Operator

getInputParametersForWriting

public java.awt.image.renderable.ParameterBlock getInputParametersForWriting()
Any operator that has special requirements for writing there parameters should override this method. An operator may not want to write its parameter in the form accepted by the JAI operator. An example of this is the MatchCDFOperator, the JAI operator underlying it takes a float[][] howver it is inefficient to store all these values and it is better to store mathematical equations that generate these arrays. By default this just returns the inputParameters ParameterBlock of the operator.

Specified by:
getInputParametersForWriting in interface Operator
Returns:
ParameterBlock - The input parameters to this operator

initSingleImageParameterBlock

protected java.awt.image.RenderedImage initSingleImageParameterBlock(java.awt.image.renderable.ParameterBlock inData)
                                                              throws java.lang.Exception
Throws:
java.lang.Exception

getSingleSource

protected java.awt.image.RenderedImage getSingleSource(java.awt.image.renderable.ParameterBlock parameters)
                                                throws java.lang.Exception
Checks the parameter block to see if it contains a single source RenderedImage. If so this is returned otherwise it throws an exception

Parameters:
parameters -
Throws:
java.lang.Exception