fable.imageviewer.model
Class ImageModel

java.lang.Object
  extended by fable.imageviewer.model.ImageModel

public class ImageModel
extends java.lang.Object

This class implements a simple image model that stores the the width, height, and the pixel data. The data are stored as a float[index] with index = col + row * width. It calculates the statistics (min, max, and mean) when requested and then stores the values.

Author:
evans

Field Summary
static java.lang.String DATA_CHANGED
          Denotes that the data and statistics changed but not the other parameters.
static java.lang.String RESET
          Denotes the data and parameters changed.
 
Method Summary
 void addImageModelListener(ImageModelListener l)
          Adds the listener.
 float[] getData()
           
 float getData(int row, int col)
          Return the value of the data corresponding to the given row and column of the stored data.
 float getData(int row, int col, org.eclipse.swt.graphics.Rectangle rect)
          return the value of the data corresponding to given row and column of the given Rectangle.
 float[] getData(org.eclipse.swt.graphics.Rectangle rect)
          Returns a sub array of the data corresponding to the given Rectangle.
 java.lang.String getFileName()
           
 int getHeight()
           
 org.eclipse.swt.graphics.Rectangle getRect()
           
 float[] getStatistics()
          Get the statistics (min, max, mean) for the whole image.
 float[] getStatistics(org.eclipse.swt.graphics.Rectangle rect)
          Get the statistics (min, max, mean) for a sub Rectangle.
 long getTimeToReadImage()
           
 int getWidth()
           
 void removeAllImageModelListeners(ImageModelListener l)
          Removes all the listeners.
 void removeImageModelListener(ImageModelListener l)
          Removes the listener.
 void reset(java.lang.String fileName, int width, int height, float[] data)
          Resets the model based on the given parameters.
 void set(FabioFile fabioFile)
          Resets the model based on the given FabioFile;
 void setData(float[] data)
          Sets a new value for the data and cause a DATA_CHANGED ImageModelEvent to be fired.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_CHANGED

public static final java.lang.String DATA_CHANGED
Denotes that the data and statistics changed but not the other parameters.


RESET

public static final java.lang.String RESET
Denotes the data and parameters changed.

Method Detail

addImageModelListener

public void addImageModelListener(ImageModelListener l)
Adds the listener.

Parameters:
l -

removeImageModelListener

public void removeImageModelListener(ImageModelListener l)
Removes the listener.

Parameters:
l -

removeAllImageModelListeners

public void removeAllImageModelListeners(ImageModelListener l)
Removes all the listeners.

Parameters:
l -

set

public void set(FabioFile fabioFile)
         throws java.lang.Throwable
Resets the model based on the given FabioFile;

Parameters:
fabioFile -
Throws:
jep.JepException
java.lang.Throwable

reset

public void reset(java.lang.String fileName,
                  int width,
                  int height,
                  float[] data)
Resets the model based on the given parameters. Will cause a RESET ImageModelEvent but not a DATA_CHANGED event to be fired.

Parameters:
fileName -
width -
height -
mean -
data -

getFileName

public java.lang.String getFileName()
Returns:
the fileName

getWidth

public int getWidth()
Returns:
the width

getHeight

public int getHeight()
Returns:
the height

getRect

public org.eclipse.swt.graphics.Rectangle getRect()

getStatistics

public float[] getStatistics()
Get the statistics (min, max, mean) for the whole image. The values are cached after the first time they are calculated.

Returns:
The statistics as float[3] = {min, max, mean}.

getStatistics

public float[] getStatistics(org.eclipse.swt.graphics.Rectangle rect)
Get the statistics (min, max, mean) for a sub Rectangle. These are calculated each time this method is called.

Parameters:
rect -
Returns:
The statistics as float[3] = {min, max, mean}.

getData

public float[] getData()
Returns:
the data

getData

public float getData(int row,
                     int col)
Return the value of the data corresponding to the given row and column of the stored data.

Parameters:
row -
col -
Returns:

getData

public float getData(int row,
                     int col,
                     org.eclipse.swt.graphics.Rectangle rect)
return the value of the data corresponding to given row and column of the given Rectangle.

Parameters:
row -
col -
rect -
Returns:

getData

public float[] getData(org.eclipse.swt.graphics.Rectangle rect)
Returns a sub array of the data corresponding to the given Rectangle.

Parameters:
rect -
Returns:

setData

public void setData(float[] data)
Sets a new value for the data and cause a DATA_CHANGED ImageModelEvent to be fired.

Parameters:
data - the data to set

getTimeToReadImage

public long getTimeToReadImage()