adams.data.image
Class AbstractImageFlattener<T extends AbstractImage>

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.data.image.AbstractImageFlattener<T>
Type Parameters:
T - the type of image to process
All Implemented Interfaces:
CleanUpHandler, Debuggable, Destroyable, OptionHandler, SizeOfHandler, Serializable, Comparable
Direct Known Subclasses:
AbstractImageJFlattener, AbstractJAIFlattener

public abstract class AbstractImageFlattener<T extends AbstractImage>
extends AbstractOptionHandler
implements Comparable, CleanUpHandler

Abstract base class for AbstractImage flattening operations.

Version:
$Revision: 5189 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  Field[] m_Fields
          fields to add to the output data.
protected  Instances m_Header
          the current header.
protected  BaseString[] m_Notes
          the notes to add as attributes.
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
AbstractImageFlattener()
           
 
Method Summary
protected  void checkImage(T img)
          Optional checks of the image.
 void cleanUp()
          Cleans up data structures, frees up memory.
 int compareTo(Object o)
          Compares this object with the specified object for order.
abstract  Instances createHeader(T img)
          Creates the header from a template image.
 void defineOptions()
          Adds options to the internal list of options.
 void destroy()
          Frees up memory in a "destructive" non-reversible way.
abstract  Instance[] doFlatten(T img)
          Performs the actual flattening of the image.
 boolean equals(Object o)
          Returns whether the two objects are the same.
 String fieldsTipText()
          Returns the tip text for this property.
 Instance[] flatten(T img)
          Process the given image.
 Field[] getFields()
          Returns the targets to add.
 BaseString[] getNotes()
          Returns the current notes to add as attributes.
protected  double[] newArray(int numAttributes)
          Returns a double array filled with missing values.
 String notesTipText()
          Returns the tip text for this property.
 Instances postProcessHeader(Instances header)
          Post-processes the header, adding fields and notes.
 Instance postProcessInstance(T img, Instance inst)
          Post-processes the generated instance, adding notes and fields.
protected  void reset()
          Resets the scheme, i.e., the header information.
 void setFields(Field[] value)
          Sets the targets to add.
 void setNotes(BaseString[] value)
          Sets the notes to add as attributes.
 T shallowCopy()
          Returns a shallow copy of itself, i.e., based on the commandline options.
 T shallowCopy(boolean expand)
          Returns a shallow copy of itself, i.e., based on the commandline options.
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, globalInfo, initialize, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Header

protected Instances m_Header
the current header.


m_Fields

protected Field[] m_Fields
fields to add to the output data.


m_Notes

protected BaseString[] m_Notes
the notes to add as attributes.

Constructor Detail

AbstractImageFlattener

public AbstractImageFlattener()
Method Detail

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractOptionHandler

reset

protected void reset()
Resets the scheme, i.e., the header information.

Overrides:
reset in class AbstractOptionHandler

setFields

public void setFields(Field[] value)
Sets the targets to add.

Parameters:
value - the targets

getFields

public Field[] getFields()
Returns the targets to add.

Returns:
the targets

fieldsTipText

public String fieldsTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setNotes

public void setNotes(BaseString[] value)
Sets the notes to add as attributes.

Parameters:
value - the notes prefixes, e.g., "PROCESS INFORMATION"

getNotes

public BaseString[] getNotes()
Returns the current notes to add as attributes.

Returns:
the notes prefixes, e.g., "PROCESS INFORMATION"

notesTipText

public String notesTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the gui

checkImage

protected void checkImage(T img)
Optional checks of the image.

Default implementation only checks whether image is null.

Parameters:
img - the image to check

createHeader

public abstract Instances createHeader(T img)
Creates the header from a template image.

Parameters:
img - the image to act as a template
Returns:
the generated header

postProcessHeader

public Instances postProcessHeader(Instances header)
Post-processes the header, adding fields and notes.

Parameters:
header - the header to process
Returns:
the post-processed header

newArray

protected double[] newArray(int numAttributes)
Returns a double array filled with missing values.

Parameters:
numAttributes - the length of the array
Returns:
the array

doFlatten

public abstract Instance[] doFlatten(T img)
Performs the actual flattening of the image. Will use the previously generated header.

Parameters:
img - the image to process
Returns:
the generated array
See Also:
m_Header

postProcessInstance

public Instance postProcessInstance(T img,
                                    Instance inst)
Post-processes the generated instance, adding notes and fields.

Parameters:
img - the image container
inst - the inst to process
Returns:
the updated instance

flatten

public Instance[] flatten(T img)
Process the given image. This method will also create the header if necessary.

Parameters:
img - the image to process
Returns:
the generated array
See Also:
m_Header, #createHeader(T)

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Only compares the commandlines of the two objects.

Specified by:
compareTo in interface Comparable
Parameters:
o - the object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this object.

equals

public boolean equals(Object o)
Returns whether the two objects are the same.

Only compares the commandlines of the two objects.

Overrides:
equals in class Object
Parameters:
o - the object to be compared
Returns:
true if the object is the same as this one

shallowCopy

public T shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.

Returns:
the shallow copy

shallowCopy

public T shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.

Parameters:
expand - whether to expand variables to their current values
Returns:
the shallow copy

cleanUp

public void cleanUp()
Cleans up data structures, frees up memory.

Specified by:
cleanUp in interface CleanUpHandler

destroy

public void destroy()
Frees up memory in a "destructive" non-reversible way.

Calls cleanUp() and cleans up the options.

Specified by:
destroy in interface Destroyable
Overrides:
destroy in class AbstractOptionHandler


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.