Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.model.GenericViewable

java.lang.Object
  |
  +--ncsa.horizon.model.Viewable
        |
        +--ncsa.horizon.model.GenericViewable

public class GenericViewable
extends Viewable
implements java.io.Serializable
a Viewable wrapper for visualizing data from an internal ND array.

This is a simple Viewable implementation that wraps around an existing data array. As a result, applications can use this class most effectively when (1) the array is small enough to fit into memory in its entirety, and (2) when the application knows what type of data is being visualized at compile-time.

At a minimum, you need only provide the array to be visualized, assuming the array contains scalar, numeric data. If you wish to incorporate additional information, such as world coordinate systems, you should also provide metadata as well. The HorizonMetadata class can be used to help load the information into a Metadata container. (See also the CoordMetadata for help setting metadata specifically describing a coordinate system.)

If your array is not numeric, then you also need to provide a TransferFunction object. Such an object is used essentially for converting data values to intensity levels. These levels are then mapped to colors using a ColorModel when an image is to be produced.

See Also:
Serialized Form

Field Summary
ArrayND ary
          the data being viewed
CoordinateSystem csys
          the coordinate system
DataND dnd
          the DataND wrapper
Metadata md
          the metadata associated with the array data
 
Fields inherited from class ncsa.horizon.model.Viewable
curspecs, defspecs, finalState, listeners, name, source
 
Constructor Summary
GenericViewable(ArrayND array, TransferFunction deftrans, java.awt.image.ColorModel defcmodel, Metadata mdata, java.lang.String name)
          create the Viewable wrapper for an array
GenericViewable(java.lang.Object array, TransferFunction deftrans, java.awt.image.ColorModel defcmodel, Metadata mdata, java.lang.String name)
          create the Viewable wrapper for an array.
GenericViewable(java.lang.Object array, TransferFunction deftrans, java.awt.image.ColorModel defcmodel, java.lang.String name)
          create the Viewable wrapper for an array.
GenericViewable(java.lang.Object array, Metadata mdata, java.lang.String name)
          create the Viewable wrapper for a numeric array.
GenericViewable(ArrayND array, Metadata mdata, java.lang.String name)
          create the Viewable wrapper for a numeric array.
GenericViewable(java.lang.Object array, java.lang.String name)
          create the Viewable wrapper for a numeric array.
GenericViewable(ArrayND array, java.lang.String name)
          create the Viewable wrapper for a numeric array.
 
Method Summary
void close()
          close this Viewable, releasing resources as necessary.
CoordinateSystem getCoordSys()
          return a coordinate system for this data
DataND getData()
          return the data associated with this Viewable as a DataND. Since all of the data associated with this Viewable is in memory, this implementation returns an InMemoryDataND object
java.lang.Class getDataType()
          return the data type associated with the data in this array.
Volume getDataVolume()
          return the object representing the full extend of the dataset being visualized.
Metadata getMetadata()
          return the metadata associated with this viewable.
short getReversalHints()
          determine the hints for flipping based on the metadata.
int[] getSize()
          return the size of the dataset to be visualized
static short getStrategies(Slice sl, short hints)
          Determine the best strategy for creating an Image given the data, requested slice, and hints.
java.lang.Object getUndefinedDataValue()
          return the undefined value associated with the image data.
View2D getView(Slice slice, TransferFunction trans, java.awt.image.ColorModel cmodel, java.awt.Dimension size, short hints, boolean makeCurrent)
          return a visualization of a given slice of the dataset
ViewSpecs prepareSpecs(Slice slice, TransferFunction trans, java.awt.image.ColorModel cmodel, java.awt.Dimension size, short hints, boolean makeCurrent)
           
void setDefaultTransferFunction(ViewSpecs specs)
           
 
Methods inherited from class ncsa.horizon.model.Viewable
addViewableListener, checkTransferFunction, clone, close, dispatch, getArrayName, getCoordSys, getCurrentSpecs, getDataType, getData, getDataVolume, getDefaultSpecs, getMetadata, getSize, getSlice, getSource, getView, getView, getView, prepareSpecs, removeViewableListener, resetSpecs, setColorModel, setCurrentSpecs, setDefaultSpecs, setDefaultTransferFunction, setImageSize, setImageSize, setSlice, setTransferFunction, TransferFunctionUpdate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

ary

protected ArrayND ary
the data being viewed

md

protected Metadata md
the metadata associated with the array data

csys

protected CoordinateSystem csys
the coordinate system

dnd

protected transient DataND dnd
the DataND wrapper
Constructor Detail

GenericViewable

public GenericViewable(ArrayND array,
                       TransferFunction deftrans,
                       java.awt.image.ColorModel defcmodel,
                       Metadata mdata,
                       java.lang.String name)
                throws BadTransferFunctionException
create the Viewable wrapper for an array
Parameters:
array - the data wrapped as an ArrayND object
deftrans - the default transfer function to use
defcmodel - the default color model to use
mdata - the metadata describing the array data; null means use generic metadata
name - a name to give the array. This name may be internally modified if necessary to make it unique. If null, the Metadata will be consulted for a name.
Throws:
BadTransferFunctionException - if deftrans does not support the array's datatype

GenericViewable

public GenericViewable(java.lang.Object array,
                       TransferFunction deftrans,
                       java.awt.image.ColorModel defcmodel,
                       Metadata mdata,
                       java.lang.String name)
                throws BadTransferFunctionException
create the Viewable wrapper for an array.
Parameters:
array - a normal Java ND array
deftrans - the default transfer function to use
defcmodel - the default color model to use
mdata - the metadata describing the array data; null means use generic metadata.
name - a name to give the array. This name may be internally modified if necessary to make it unique. If null, the Metadata will be consulted for a name.
Throws:
BadTransferFunctionException - if deftrans does not support the array's datatype

GenericViewable

public GenericViewable(java.lang.Object array,
                       TransferFunction deftrans,
                       java.awt.image.ColorModel defcmodel,
                       java.lang.String name)
                throws BadTransferFunctionException
create the Viewable wrapper for an array.
Parameters:
array - a normal Java ND array
deftrans - the default transfer function to use
defcmodel - the default color model to use
name - a name to give the array. This name may be internally modified if necessary to make it unique.
Throws:
BadTransferFunctionException - if deftrans does not support the array's datatype

GenericViewable

public GenericViewable(java.lang.Object array,
                       Metadata mdata,
                       java.lang.String name)
                throws BadTransferFunctionException
create the Viewable wrapper for a numeric array.
Parameters:
array - a normal Java ND array
mdata - the metadata describing the array data; null means use generic metadata.
name - a name to give the array. This name may be internally modified if necessary to make it unique. If null, the Metadata will be consulted for a name.
Throws:
BadTransferFunctionException - if array does not contain numeric data

GenericViewable

public GenericViewable(ArrayND array,
                       Metadata mdata,
                       java.lang.String name)
                throws BadTransferFunctionException
create the Viewable wrapper for a numeric array.
Parameters:
array - an array wrapped as an ArrayND object
mdata - the metadata describing the array data; null means use generic metadata.
name - a name to give the array. This name may be internally modified if necessary to make it unique. If null, the Metadata will be consulted for a name.
Throws:
BadTransferFunctionException - if array does not contain numeric data

GenericViewable

public GenericViewable(java.lang.Object array,
                       java.lang.String name)
                throws BadTransferFunctionException
create the Viewable wrapper for a numeric array.
Parameters:
array - a normal Java ND array
name - a name to give the array. This name may be internally modified if necessary to make it unique.
Throws:
BadTransferFunctionException - if array does not contain numeric data

GenericViewable

public GenericViewable(ArrayND array,
                       java.lang.String name)
                throws BadTransferFunctionException
create the Viewable wrapper for a numeric array.
Parameters:
array - an array wrapped as an ArrayND object
mdata - the metadata describing the array data; null means use generic metadata.
name - a name to give the array. This name may be internally modified if necessary to make it unique.
Throws:
BadTransferFunctionException - if array does not contain numeric data
Method Detail

getSize

public int[] getSize()
return the size of the dataset to be visualized
Returns:
int[] the number of data voxels along each axis
Overrides:
getSize in class Viewable

getDataVolume

public Volume getDataVolume()
return the object representing the full extend of the dataset being visualized. This is equivalent to getMetadata().getMetadatum("dataVolume");
Overrides:
getDataVolume in class Viewable

getCoordSys

public CoordinateSystem getCoordSys()
return a coordinate system for this data
Overrides:
getCoordSys in class Viewable

getMetadata

public Metadata getMetadata()
return the metadata associated with this viewable. The returned Metadata is "protected"; that is, clients may make updates without affecting other clients of this Viewable.
Overrides:
getMetadata in class Viewable

getData

public DataND getData()
return the data associated with this Viewable as a DataND. Since all of the data associated with this Viewable is in memory, this implementation returns an InMemoryDataND object
Overrides:
getData in class Viewable

close

public void close()
close this Viewable, releasing resources as necessary. This usually causes data arrays to be thrown away so that its memory can be released.
Overrides:
close in class Viewable

getDataType

public java.lang.Class getDataType()
return the data type associated with the data in this array. This implementation will first check for a value in the metadata; if not found there, it will query the internal DataND object. (The former is prefered as the latter may cause the entire data array to be read in.)
Overrides:
getDataType in class Viewable

getUndefinedDataValue

protected java.lang.Object getUndefinedDataValue()
return the undefined value associated with the image data.

getView

public View2D getView(Slice slice,
                      TransferFunction trans,
                      java.awt.image.ColorModel cmodel,
                      java.awt.Dimension size,
                      short hints,
                      boolean makeCurrent)
                                 throws BadTransferFunctionException
return a visualization of a given slice of the dataset
Parameters:
slice - the requested slice of data. If null, use the current slice.
trans - the TransferFunction to use when creating the visualization. If null, use the current TransferFunction.
cmodel - the ColorModel to use when creating the visualization. If null, use the current visualization.
size - the recommended size of the the resulting output image. If null, use the current size.
makeCurrent - if true, set the current specifications to the values given by these (non-null) arguments.
Returns:
View2D the requested visualization. The specifications associated with the returned vis will differ from input specs to reflect the actual characteristics of the image it holds.
Throws:
BadTransferFunctionException - if the requested TransferFunction does not support the type of data being visualized by this Viewable
Overrides:
getView in class Viewable

prepareSpecs

protected ViewSpecs prepareSpecs(Slice slice,
                                 TransferFunction trans,
                                 java.awt.image.ColorModel cmodel,
                                 java.awt.Dimension size,
                                 short hints,
                                 boolean makeCurrent)
                                            throws BadTransferFunctionException
Overrides:
prepareSpecs in class Viewable

setDefaultTransferFunction

protected void setDefaultTransferFunction(ViewSpecs specs)
                                  throws BadTransferFunctionException
Overrides:
setDefaultTransferFunction in class Viewable

getStrategies

public static short getStrategies(Slice sl,
                                  short hints)
Determine the best strategy for creating an Image given the data, requested slice, and hints.
Returns:
short the strategy as ORed hints defined in ViewSpecs.Hints

getReversalHints

protected short getReversalHints()
determine the hints for flipping based on the metadata. The metadata list is consulted to determine the values of "xaxisReversed" and "yaxisReversed", converting them into ViewSpec hints.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD