edu.washington.biostr.sig.brainj3d.data
Class DefaultDataView<T extends Data>

java.lang.Object
  extended by edu.washington.biostr.sig.brainj3d.data.DefaultDataView<T>
Type Parameters:
T - The type of Data that this takes
All Implemented Interfaces:
DataView
Direct Known Subclasses:
AbstractVolumeView, BrainInfoAtlasDataView, BranchGroupSurface3DView, ImageView, IndexedSurface3DView, LabelDataView, MapSurface3DView, PlainTextView, QuickPlugin, SharingDataView, VolumeDataView, VolumeIsosurfaceView

public abstract class DefaultDataView<T extends Data>
extends Object
implements DataView

The DefaultDataView handles much of the DataView's jobs, including tracking parameters, the key and data. It also does type checking of the data and makes sure that the data is only set once.
To monitor parameters being set, override setParameter(String parameter, Object value, Object oldValue, boolean beLazy)

Author:
Eider Moore

Constructor Summary
DefaultDataView()
          Create a basic data view that accepts all types of data.
DefaultDataView(Class<? extends Data> targetData)
          Create a data view that only accepts data of the given type.
 
Method Summary
 void addedToModel(DataModel<?> m)
          Notify this data that it was added to the model.
 boolean equals(Object obj)
           
protected  T getCastData()
          Deprecated. Due to an undocumented feature of Java 1.5, I can change getData() to do this.
 T getData()
          Return the data object associated with this view.
 DataKey getDataKey()
          Get the datakey for this view.
 int getInterval()
           
 FileGroup getKey()
          Return the key for this data.
 int getMaxTime()
           
 int getMinTime()
           
 Object getParameter(String parameter)
           
 Map<String,Object> getParameters()
          Get all of the parameters
 DoTarget getTarget()
           
 int hashCode()
           
 boolean hasTime()
           
 void removedFromModel()
          Notify this data that it was removed from model.
 void setData(FileGroup dataKey, Data data)
          Initialize this view with the given data and the specified meta data (in the form of a map of tags).
throw an ImmutableException if it is called more than once.
 void setDefaultParameters(Set<Tag> metadata)
          Restore the defaults parameters.
 Object setParameter(String parameter, Object value)
          Set a parameter, defer to setParameter(parameter, value, false) This method is currently final because overriding it will likely cause undesired behavior and make your life difficult.
 Object setParameter(String parameter, Object value, boolean beLazy)
          Set a parameter
protected  boolean setParameter(String parameter, Object value, Object oldValue, boolean beLazy)
          Set a parameter.
 void setParameters(Map<String,Object> parameters)
          Set the parameters to have the data in parameters, plus any disjoint parameters.
 void setTarget(DoTarget target)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.washington.biostr.sig.brainj3d.data.DataView
getController, getViewName
 

Constructor Detail

DefaultDataView

public DefaultDataView()
Create a basic data view that accepts all types of data.


DefaultDataView

public DefaultDataView(Class<? extends Data> targetData)
Create a data view that only accepts data of the given type.

Parameters:
targetData -
Method Detail

setData

public void setData(FileGroup dataKey,
                    Data data)
             throws ClassCastException
Description copied from interface: DataView
Initialize this view with the given data and the specified meta data (in the form of a map of tags).
throw an ImmutableException if it is called more than once. If the data is an inappropriate type, this should throw a ClassCastException. Acceptable types should be clearly documented.

Specified by:
setData in interface DataView
Throws:
ClassCastException - if data's class is the wrong type.

setParameters

public void setParameters(Map<String,Object> parameters)
Set the parameters to have the data in parameters, plus any disjoint parameters.

Specified by:
setParameters in interface DataView
Parameters:
parameters -

getParameters

public Map<String,Object> getParameters()
Get all of the parameters

Specified by:
getParameters in interface DataView
Returns:

getData

public T getData()
Description copied from interface: DataView
Return the data object associated with this view.

Specified by:
getData in interface DataView
Returns:

getCastData

protected T getCastData()
Deprecated. Due to an undocumented feature of Java 1.5, I can change getData() to do this.

The same result as getData() only cast to the generic.

Returns:

getKey

public FileGroup getKey()
Description copied from interface: DataView
Return the key for this data.

Specified by:
getKey in interface DataView
Returns:

setParameter

public final Object setParameter(String parameter,
                                 Object value)
Set a parameter, defer to setParameter(parameter, value, false) This method is currently final because overriding it will likely cause undesired behavior and make your life difficult. All internal parameter setting methods in DefaultDataView defer to setParameter(parameter, value, beLazy) so overriding that method is the way to do it.

Specified by:
setParameter in interface DataView
Parameters:
parameter -
value -
Returns:
the old value

setParameter

public Object setParameter(String parameter,
                           Object value,
                           boolean beLazy)
Set a parameter

Parameters:
parameter -
value -
beLazy - true if we should defer any lengthy processing. The last modified parameter must have use false.
Returns:
the old value

getParameter

public Object getParameter(String parameter)

setParameter

protected boolean setParameter(String parameter,
                               Object value,
                               Object oldValue,
                               boolean beLazy)
Set a parameter. When a bulk set is performed, this is called multiple times.
Default implementation just returns false.

Parameters:
parameter -
value -
oldValue -
Returns:
true if anything changed.

setDefaultParameters

public void setDefaultParameters(Set<Tag> metadata)
Restore the defaults parameters.

Specified by:
setDefaultParameters in interface DataView
Parameters:
metadata - Use metadata to customize the view.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

removedFromModel

public void removedFromModel()
Notify this data that it was removed from model.

Specified by:
removedFromModel in interface DataView

addedToModel

public void addedToModel(DataModel<?> m)
Notify this data that it was added to the model.

Specified by:
addedToModel in interface DataView

hasTime

public boolean hasTime()
Specified by:
hasTime in interface DataView
Returns:
data.hasTime()

getInterval

public int getInterval()
Specified by:
getInterval in interface DataView
Returns:
the interval between time points.

getMaxTime

public int getMaxTime()
Specified by:
getMaxTime in interface DataView
Returns:
the maximum time value.

getMinTime

public int getMinTime()
Specified by:
getMinTime in interface DataView
Returns:
the minimum time value

getDataKey

public DataKey getDataKey()
Description copied from interface: DataView
Get the datakey for this view.

Specified by:
getDataKey in interface DataView
Returns:

getTarget

public DoTarget getTarget()
Specified by:
getTarget in interface DataView

setTarget

public void setTarget(DoTarget target)
Specified by:
setTarget in interface DataView


Copyright © 2006 University of Washington. All Rights Reserved.