fable.imageviewer.component
Class ImageComponentImage

java.lang.Object
  extended by fable.imageviewer.component.ImageComponentImage
All Implemented Interfaces:
IImagesVarKeys

public class ImageComponentImage
extends java.lang.Object
implements IImagesVarKeys

This class manages the imageCanvas for the ImageView and things related to it. These include the selections and the Rectangles describing the image, the original image, the oriented image, and the oriented original image.


Field Summary
 
Fields inherited from interface fable.imageviewer.internal.IImagesVarKeys
BTN_IMG_ADD, BTN_IMG_ADD_PLOT, BTN_IMG_DELETE, BTN_IMG_SETTINGS, BTN_IMG_SUBTRACT, BTN_IMG_SUBTRACT_PLOT, COORD_BL, COORD_BR, COORD_CUSTOM, COORD_TL, COORD_TR, coordNameValues, O_MOOM, O_MOOP, O_OMMO, O_OMPO, O_OPMO, O_OPPO, O_POOM, O_POOP, orientNameValues, PALETTE_AUTUMN, PALETTE_BLUES, PALETTE_COLOR, PALETTE_GREENS, PALETTE_GREY, PALETTE_PASTEL1, PALETTE_RAINBOW1, PALETTE_RAINBOW2, PALETTE_REDS, PALETTE_SPRING, PALETTE_SUMMER, PALETTE_WINTER, paletteNameValues
 
Constructor Summary
ImageComponentImage(ImageComponent iv, ImageComponentUI controls)
          Constructor.
 
Method Summary
 void calculateMainRectangles()
          Calculates the origRect, orientedOrigRect, and orientedRect from the imageRect and the imageModel.
 void changeImageRect(org.eclipse.swt.graphics.Rectangle rect, float[] areaAsFloat, java.lang.String fileName, ImageModel _imageModel)
          Sets a new image rectangle to display along with the new data and name of the file.
 void clearCanvas()
          Clear the imageCanvas.
 org.eclipse.swt.graphics.ImageData createImageData(float _minimum, float _maximum, org.eclipse.swt.graphics.PaletteData palette)
          Creates an ImageData with pixels scaled between minimum and maximum, oriented according to the current orientation, and using the specified palette.
 org.eclipse.swt.graphics.Image createScreenImage(org.eclipse.swt.graphics.ImageData data)
          Converts an ImageData into an Image with the appropriate scaling and sets the global scaling parameters.
 void displayImage()
          Update the image display.
 void dispose()
          Called when the View is to be disposed
 org.eclipse.swt.graphics.Image getImage()
           
 org.eclipse.swt.graphics.Rectangle getImageRect()
           
 org.eclipse.swt.graphics.Rectangle getOrientedOrigRect()
           
 org.eclipse.swt.graphics.Rectangle getOrientedRect()
           
 org.eclipse.swt.graphics.Rectangle getOrigRect()
           
 org.eclipse.swt.graphics.Rectangle getSelectedArea()
           
 java.lang.Boolean getSelectOn()
           
 float[] imageToOriented(float[] point)
          Returns the unscaled, oriented image coordinates for the specified original image coordinates given as a float[].
 org.eclipse.swt.graphics.Point imageToOriented(org.eclipse.swt.graphics.Point point)
          Returns the unscaled, oriented image coordinates for the specified original image coordinates given as a Point.
 void initializeCanvas()
          Does initial setup for the canvas.
 boolean isImageChanged()
           
 org.eclipse.swt.graphics.Point orientedToImage(org.eclipse.swt.graphics.Point point)
          Returns the original image coordinates for the specified unscaled, oriented image coordinates.
 void resetZoom()
          Resets the zoom to full size.
 org.eclipse.swt.graphics.Rectangle screenRectangleToImageRectangle(org.eclipse.swt.graphics.Rectangle screenRect, boolean ordered)
          Converts a Rectangle in screen coordinates to a Rectangle in the original image coordinates and insures it is in bounds and has non-negative width and height.
 org.eclipse.swt.graphics.Rectangle screenRectangleToOrientedImageRectangle(org.eclipse.swt.graphics.Rectangle screenRect, boolean ordered)
          Converts a Rectangle in screen coordinates to a Rectangle in the oriented image coordinates and insures it is in bounds and has non-negative width and height.
 void selectZoom(ZoomSelection zoomselect)
           
 void setImageChanged(boolean imageChanged)
           
 void setImageRect(org.eclipse.swt.graphics.Rectangle imageRect)
           
 void setSelectOn(java.lang.Boolean selectOn)
           
 void showPeaks()
          Draws red squares around all peaks using the currentLinePeakWidth.
 void showSelectedPeaks(float[] peaksToColor)
          First calls showPeaks to draw red squares, then draws green squares around all peaks in the array using the currentLinePeakWidth.
 void showSelection(boolean force)
          Draws the current selection on the screen and calls showSelectedArea, showSelectedLine, or showProfile, as appropriate.
 void showZoom(org.eclipse.swt.events.MouseEvent ev, boolean in)
          Zooms in or out centered on the mouse coordinates.
 org.eclipse.swt.graphics.Point tcToScreen(float tcY, float tcZ)
          Returns the current oriented and scaled screen coordinates for a point (y, z) in the TotalCrys coordinate system.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageComponentImage

public ImageComponentImage(ImageComponent iv,
                           ImageComponentUI controls)
Constructor.

Parameters:
iv -
controls -
imageCanvas -
Method Detail

initializeCanvas

public void initializeCanvas()
Does initial setup for the canvas. The imageCanvas in ImageViewControls must be created first.


dispose

public void dispose()
Called when the View is to be disposed


calculateMainRectangles

public void calculateMainRectangles()
Calculates the origRect, orientedOrigRect, and orientedRect from the imageRect and the imageModel.


showSelection

public void showSelection(boolean force)
Draws the current selection on the screen and calls showSelectedArea, showSelectedLine, or showProfile, as appropriate. Thus when it is called, other views will be updated.


showZoom

public void showZoom(org.eclipse.swt.events.MouseEvent ev,
                     boolean in)
Zooms in or out centered on the mouse coordinates.

Parameters:
ev -
in - True to zoom in, false to zoom out.

resetZoom

public void resetZoom()
Resets the zoom to full size. This affects the zoom area whether done in the main view or the zoom view.


showPeaks

public void showPeaks()
Draws red squares around all peaks using the currentLinePeakWidth.


showSelectedPeaks

public void showSelectedPeaks(float[] peaksToColor)
First calls showPeaks to draw red squares, then draws green squares around all peaks in the array using the currentLinePeakWidth.

Parameters:
peaksToColor - An array of TotalCryst coordinates [y0,z0,y1,z1,...] to have a green square. Used in PeakSearchSptView to show the selected peaks in green.

changeImageRect

public void changeImageRect(org.eclipse.swt.graphics.Rectangle rect,
                            float[] areaAsFloat,
                            java.lang.String fileName,
                            ImageModel _imageModel)
Sets a new image rectangle to display along with the new data and name of the file.

Parameters:
rect - The new Rectangle.
areaAsFloat - The new data.
fileName - The new name of the file.
_imageModel - The new ImageModel. If null, then make a new ImageModel.

displayImage

public void displayImage()
Update the image display.


createImageData

public org.eclipse.swt.graphics.ImageData createImageData(float _minimum,
                                                          float _maximum,
                                                          org.eclipse.swt.graphics.PaletteData palette)
Creates an ImageData with pixels scaled between minimum and maximum, oriented according to the current orientation, and using the specified palette. Also calculates Rectangles for the oriented image and the original oriented image.

Parameters:
minimum - Maximum data value.
maximum - Minimum data value.
palette - PaletteData to use for ImageData.
Returns:
Scaled and oriented ImageData.

createScreenImage

public org.eclipse.swt.graphics.Image createScreenImage(org.eclipse.swt.graphics.ImageData data)
Converts an ImageData into an Image with the appropriate scaling and sets the global scaling parameters.

Parameters:
data - The ImageData.
Returns:
The Image.

orientedToImage

public org.eclipse.swt.graphics.Point orientedToImage(org.eclipse.swt.graphics.Point point)
Returns the original image coordinates for the specified unscaled, oriented image coordinates.

Parameters:
point - The coordinates of the oriented image.
Returns:
The coordinates of the original image.

imageToOriented

public org.eclipse.swt.graphics.Point imageToOriented(org.eclipse.swt.graphics.Point point)
Returns the unscaled, oriented image coordinates for the specified original image coordinates given as a Point.

Parameters:
point - The coordinates of the original image (x, y}.
Returns:
The coordinates of the oriented image {x, y}.

imageToOriented

public float[] imageToOriented(float[] point)
Returns the unscaled, oriented image coordinates for the specified original image coordinates given as a float[]. The input and output are float arrays to allow fractional values.

Parameters:
point - The coordinates of the original image {x, y}.
Returns:
The coordinates of the oriented image {x, y}.

screenRectangleToImageRectangle

public org.eclipse.swt.graphics.Rectangle screenRectangleToImageRectangle(org.eclipse.swt.graphics.Rectangle screenRect,
                                                                          boolean ordered)
Converts a Rectangle in screen coordinates to a Rectangle in the original image coordinates and insures it is in bounds and has non-negative width and height.

Parameters:
screenRect -
ordered - Whether the returned Rectangle is ordered so x + width > x and y + height > y.
Returns:

screenRectangleToOrientedImageRectangle

public org.eclipse.swt.graphics.Rectangle screenRectangleToOrientedImageRectangle(org.eclipse.swt.graphics.Rectangle screenRect,
                                                                                  boolean ordered)
Converts a Rectangle in screen coordinates to a Rectangle in the oriented image coordinates and insures it is in bounds and has non-negative width and height.

Parameters:
screenRect -
ordered - Whether the returned Rectangle is ordered so x + width > x and y + height > y.
Returns:

tcToScreen

public org.eclipse.swt.graphics.Point tcToScreen(float tcY,
                                                 float tcZ)
Returns the current oriented and scaled screen coordinates for a point (y, z) in the TotalCrys coordinate system. It is assumed the orientation represents the correct view of the detector, so that the origin of the TotalCrys coordinates is at the lower right of the image.

Parameters:
tcY - The value of y in the TotalCrys system.
tcZ - The value of z in the TotalCrys system.
Returns:
Point representing the location in the current screen image.

clearCanvas

public void clearCanvas()
Clear the imageCanvas.


getSelectedArea

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

selectZoom

public void selectZoom(ZoomSelection zoomselect)

isImageChanged

public boolean isImageChanged()
Returns:
the imageChanged

setImageChanged

public void setImageChanged(boolean imageChanged)
Parameters:
imageChanged - the imageChanged to set

getImageRect

public org.eclipse.swt.graphics.Rectangle getImageRect()
Returns:
the imageRect

setImageRect

public void setImageRect(org.eclipse.swt.graphics.Rectangle imageRect)
Parameters:
imageRect - the imageRect to set

getOrigRect

public org.eclipse.swt.graphics.Rectangle getOrigRect()
Returns:
the origRect

getOrientedOrigRect

public org.eclipse.swt.graphics.Rectangle getOrientedOrigRect()
Returns:
the orientedOrigRect

getOrientedRect

public org.eclipse.swt.graphics.Rectangle getOrientedRect()
Returns:
the orientedRect

getSelectOn

public java.lang.Boolean getSelectOn()
Returns:
the selectOn

setSelectOn

public void setSelectOn(java.lang.Boolean selectOn)
Parameters:
selectOn - the selectOn to set

getImage

public org.eclipse.swt.graphics.Image getImage()
Returns:
the image