fable.imageviewer.component
Class ImageComponent

java.lang.Object
  extended by fable.imageviewer.component.ImageComponent
All Implemented Interfaces:
IImagesVarKeys, java.util.EventListener, org.eclipse.jface.util.IPropertyChangeListener, org.eclipse.ui.ISelectionListener

public class ImageComponent
extends java.lang.Object
implements org.eclipse.jface.util.IPropertyChangeListener, IImagesVarKeys, org.eclipse.ui.ISelectionListener

ImageComponent implements a view to display an image using the SWT Image widget. The image is automatically fitted to the window size. The main features are the display is fast, a variety of controls allow the user to zoom a box, line, integrated profile or 3d relief, change lookup tables, autoscale or manually scale the range. The image is treated as a floating point image so that images scaled between 0 and 1 are displayed correctly. Images can be loaded using loadFile(FabioFile) or via changeImageData().

ImageView allows multiple Views. These are distinguished by the secondary ID. The secondary ID is typically set by IWorkbenchPage.showView(String viewId, String secondaryId, int mode). The viewId to use is ImageView.ID. Any plug-in can call this method and is free to specify the secondary ID as it wishes. ImageView manages 5 secondary IDs, for the main, zoom, slice1D, slice2D, and copy views. These IDs are determined by the public fields SECONDARY_ID_xxx. If you wish to call these views, then you should use these fields by name. Except for the copy views, there is expected to be zero or one of the others. On workspace shutdown ImageView hides (i.e. removes) all of the views that it manages, except the main one with SECONDARY_ID_MAIN. This is to prevent workspace clutter on restarting the workspace. It does not remove others. Other plug-ins are responsible for removing ones they created if desired. When ImageView is first created and does not have an image, then the part name (name on the tab) is set to the secondary ID + "Image View". This should help to distinguish empty Image Views created by ImageView and other plug-ins. Eclipse can create ImageViews with a null secondary ID, e.g. via Window | Show View. ImageView hides these and creates a new one with SECONDARY_ID_MAIN to insure all views have a non-null secondary ID.

New images are typically loaded to the Main view. For example, only the Main view listens for property change events from the SampleController associated with the Image Navigator. Loading into the Main view will cause existing Zoom, Slice1, and Slice2 views to update, depending on if there is a selection and the current selection mode. That is, if there is a selection and the current mode is Area then the Zoom view will update, but not Slice1 or Slice2. Drag and Drop supports dropping on any view.

ImageView is a large View and is implemented in several classes. The principal ones are (1) ImageView which manages the usual view things and holds the values of most of the settings, (2) ImageViewControls which manages the SWT controls except for the imageCanvas, and (3) ImageViewImage which manages the imageCanvas and things, such as selections, related to it.

Dependencies :
FabioFile - for loading FabioFiles
ZoomLineView - for plotting lines and integrated profiles

The image can be viewed in 8 orientations. These orientations are associated with the TotalCrys o parameters (o11, o12, o21, o22). The parameters that result in an image oriented as it would be looking at the detector in the direction of the beam are the o parameters to specify in other Fable software, such as ImageD11.

The coordinate origin can be selected as TL=(0,0) (typical image coordinates), TR=(0,0), BR=(0,0) (TotalCrys coordinates), and BL=(0,0) (usual xy coordinate system). They can also be specified as custom. The only place the coordinates appear is in the display of the mouse position. Note that the coordinate system and the image orientation may be specified independently.

The TotalCryst project (cf. http://fable.wiki.sourceforge.net/space/showimage/Geometry_version_1.0.2.pdf) defines the coordinate system as follows:
(o) Horizontal axis as Y with zero on the right and positive to the left
(o) Vertical axis as Z with zero at the bottom and positive up.

Author:
Andy Gotz (ESRF), Ken Evans (APS)

Field Summary
static int copySecondaryID
          Number to use for the secondary ID for the next copy ImageView.
 ImageComponentImage image
          A reference to the class that manages the SWT image for this view.
static int SECONDARY_ID_COPY_START
          Number to use for the secondary ID for the first copy ImageView.
static java.lang.String SECONDARY_ID_MAIN
          Secondary ID for the main ImageView.
static java.lang.String SECONDARY_ID_SLICE1D
          Secondary ID for the slice 1D ImageView.
static java.lang.String SECONDARY_ID_SLICE2D
          Secondary ID for the slice 2D ImageView.
static java.lang.String SECONDARY_ID_ZOOM
          Secondary ID for the Zoom ImageView.
 
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
ImageComponent(org.eclipse.ui.IWorkbenchPart3 parentPart)
           
ImageComponent(org.eclipse.ui.IWorkbenchPart3 parentPart, ActionsProvider provider)
           
 
Method Summary
 void calcImageDiff()
          Calculate / image
 void createPartControl(org.eclipse.swt.widgets.Composite parent)
           
 void dispose()
           
 org.eclipse.ui.IActionBars getActionBars()
           
 SampleController getController()
           
 ImageComponentUI getControls()
           
 Coordinates getCoordinates()
           
 java.lang.String getCoordinatesName()
          Gets the short name of the current coordinate origin.
 int getCoordOrigin()
           
 org.eclipse.swt.widgets.Display getDisplay()
           
 java.lang.String getFileName()
           
 ImageComponentImage getImage()
           
 ImageModel getImageDiffModel()
           
 ImageModel getImageModel()
           
 ImageModel getImageSavedModel()
           
 float getMaximum()
           
 float getMean()
           
 float getMinimum()
           
 int getOrientation()
           
 org.eclipse.swt.graphics.PaletteData getPalette()
           
 int getPaletteIndex()
           
 org.eclipse.ui.IWorkbenchPart3 getParentPart()
           
 java.lang.Object getPartName()
           
 int getPeakMarkerSize()
           
 java.util.Vector<java.lang.Float> getPeaks()
           
 double getPixelHeightSave()
           
 double getPixelWidthSave()
           
 java.lang.String getSecondaryId()
           
 float[] getStatistics()
          Gets the statistics.
 float getUserMaximum()
           
 float getUserMinimum()
           
 double getX0Save()
           
 java.lang.String getXNameSave()
           
 double getY0Save()
           
 java.lang.String getYNameSave()
           
 ZoomSelection getZoomSelection()
           
 void initWithShowPeaks()
           
 boolean isImageDiffOn()
           
 boolean isPeaksOn()
           
 void loadFile(java.lang.String fileName)
           
 void loadModel(ImageModel imageModel)
          Loads a new image from the specified image model.
 void propertyChange(org.eclipse.jface.util.PropertyChangeEvent evt)
           
 void resetCoordinates()
          Reset the coordinates to reflect the current image and orientation.
 void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection)
          This method receives selectionEvents from the workbench.
 void setControls(ImageComponentUI controls)
           
 void setCoordOrigin(int coordOrigin)
           
 void setFocus()
           
 void setImage(ImageComponentImage image)
           
 void setImageDiffModel(ImageModel imageDiffModel)
           
 void setImageDiffOn(boolean imageDiffOn)
           
 void setImageModel(ImageModel imageModel)
           
 void setImageSavedModel(ImageModel imageSavedModel)
           
 void setOrientation(int orientation)
           
 void setPalette(int index)
          Creates a palette in the palettes array if it has not been created yet, sets that palette, and redisplays the image.
 void setPalette(org.eclipse.swt.graphics.PaletteData palette)
           
 void setPaletteIndex(int paletteIndex)
           
 void setPeakMarkerSize(int peakMarkerSize)
           
 void setPeaks(java.util.Vector<java.lang.Float> vals)
          set the list of peaks to display
 void setPeaksOn(boolean peaksOn)
           
 void setPixelHeightSave(double pixelHeightSave)
           
 void setPixelWidthSave(double pixelWidthSave)
           
 void setPlotTitle(java.lang.String title)
           
 void setStatistics(float[] statistics)
          Sets the statistics.
 void setStatistics(float[] statistics, boolean autoScale)
          Sets the statistics and autoScale.
 void setStatusLabel(org.eclipse.swt.widgets.Text statusLabel)
           
 void setUserMaximum(float userMaximum)
           
 void setUserMinimum(float userMinimum)
           
 void setX0Save(double save)
           
 void setXNameSave(java.lang.String nameSave)
           
 void setY0Save(double save)
           
 void setYNameSave(java.lang.String nameSave)
           
 void setZoomSelection(ZoomSelection zoomSelection)
          Sets the zoomSelection.
 java.lang.String toString()
           
 void transferSelectedSettings(ImageComponent src)
          Transfer some of settings from another instance to this one.
 void updateStatusLabel(java.lang.String _status)
          update status label asynchronously
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SECONDARY_ID_MAIN

public static final java.lang.String SECONDARY_ID_MAIN
Secondary ID for the main ImageView. There should be zero or one of these.

See Also:
Constant Field Values

SECONDARY_ID_ZOOM

public static final java.lang.String SECONDARY_ID_ZOOM
Secondary ID for the Zoom ImageView. There should be zero or one of these. Do not change the string is referenced in projects outside Fable (for reasons of avoiding direct connections).

See Also:
Constant Field Values

SECONDARY_ID_SLICE1D

public static final java.lang.String SECONDARY_ID_SLICE1D
Secondary ID for the slice 1D ImageView. There should be zero or one of these.

See Also:
Constant Field Values

SECONDARY_ID_SLICE2D

public static final java.lang.String SECONDARY_ID_SLICE2D
Secondary ID for the slice 2D ImageView. There should be zero or one of these.

See Also:
Constant Field Values

SECONDARY_ID_COPY_START

public static int SECONDARY_ID_COPY_START
Number to use for the secondary ID for the first copy ImageView. Do not use this explicitly as a secondary ID. Use zoomSecondaryID and increment it afterward.


copySecondaryID

public static int copySecondaryID
Number to use for the secondary ID for the next copy ImageView. It should be incremented when used so each copy appears in a different view.


image

public ImageComponentImage image
A reference to the class that manages the SWT image for this view.

Constructor Detail

ImageComponent

public ImageComponent(org.eclipse.ui.IWorkbenchPart3 parentPart)

ImageComponent

public ImageComponent(org.eclipse.ui.IWorkbenchPart3 parentPart,
                      ActionsProvider provider)
Method Detail

createPartControl

public void createPartControl(org.eclipse.swt.widgets.Composite parent)

setFocus

public void setFocus()

selectionChanged

public void selectionChanged(org.eclipse.ui.IWorkbenchPart part,
                             org.eclipse.jface.viewers.ISelection selection)
This method receives selectionEvents from the workbench. This is currently used for PeakSearch and its spt output file. When a user selects a peak in a TableViewer and if the selection is a instance of PeakSearchSpt or an instance of Peak, spots are displayed in the image.

Specified by:
selectionChanged in interface org.eclipse.ui.ISelectionListener
See Also:
ISelectionListener.selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)

loadFile

public void loadFile(java.lang.String fileName)
              throws java.lang.Throwable
Parameters:
fileName -
Throws:
java.lang.Throwable

loadModel

public void loadModel(ImageModel imageModel)
Loads a new image from the specified image model.

Parameters:
imageModel - The image model to use.

calcImageDiff

public void calcImageDiff()
Calculate / image


updateStatusLabel

public void updateStatusLabel(java.lang.String _status)
update status label asynchronously

Parameters:
_status - - status to display

setPeaks

public void setPeaks(java.util.Vector<java.lang.Float> vals)
set the list of peaks to display

Parameters:
vals - - list of peaks as pairs of [y,z] coordinates

propertyChange

public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent evt)
Specified by:
propertyChange in interface org.eclipse.jface.util.IPropertyChangeListener

dispose

public void dispose()

transferSelectedSettings

public void transferSelectedSettings(ImageComponent src)
Transfer some of settings from another instance to this one. Typically used when zooming, copying, doing slices, etc. The values transferred are:

Parameters:
source - The source instance.

initWithShowPeaks

public void initWithShowPeaks()

resetCoordinates

public void resetCoordinates()
Reset the coordinates to reflect the current image and orientation. Does not reset custom coordinates.


getCoordOrigin

public int getCoordOrigin()
Returns:
the coordOrigin

setCoordOrigin

public void setCoordOrigin(int coordOrigin)
Parameters:
coordOrigin - the coordOrigin to set

getOrientation

public int getOrientation()
Returns:
the orientation

setOrientation

public void setOrientation(int orientation)
Parameters:
orientation - the orientation to set

getPalette

public org.eclipse.swt.graphics.PaletteData getPalette()
Returns:
the palette

setPalette

public void setPalette(int index)
Creates a palette in the palettes array if it has not been created yet, sets that palette, and redisplays the image. New palettes must be added here, in IImagesVarKeys, and in PaletteUtils.

Parameters:
index - The index of the palette in the palettes array.
See Also:
for possible indices.

getStatistics

public float[] getStatistics()
Gets the statistics.

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

setStatistics

public void setStatistics(float[] statistics,
                          boolean autoScale)
Sets the statistics and autoScale.

Parameters:
statistics - The new values as float[] {min, max, mean}.

setStatistics

public void setStatistics(float[] statistics)
Sets the statistics.

Parameters:
statistics - The new values as float[] {min, max, mean}.

getFileName

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

getImageModel

public ImageModel getImageModel()
Returns:
the imageModel

setImageModel

public void setImageModel(ImageModel imageModel)
Parameters:
imageModel - The imageModel to set.

getImageDiffModel

public ImageModel getImageDiffModel()
Returns:
the imageDiffModel

setImageDiffModel

public void setImageDiffModel(ImageModel imageDiffModel)
Parameters:
imageDiffModel -

getImageSavedModel

public ImageModel getImageSavedModel()
Returns:
the imageSavedModel

setImageSavedModel

public void setImageSavedModel(ImageModel imageSavedModel)
Parameters:
imageSavedModel - the imageSavedModel to set

getCoordinates

public Coordinates getCoordinates()
Returns:
the coordinates

getCoordinatesName

public java.lang.String getCoordinatesName()
Gets the short name of the current coordinate origin.

Returns:
the short name.

getController

public SampleController getController()
Returns:
the controller

isPeaksOn

public boolean isPeaksOn()
Returns:
the peaksOn

setPeaksOn

public void setPeaksOn(boolean peaksOn)
Parameters:
peaksOn - the peaksOn to set

getPeakMarkerSize

public int getPeakMarkerSize()
Returns:
the peakMarkerSize

setPeakMarkerSize

public void setPeakMarkerSize(int peakMarkerSize)
Parameters:
peakMarkerSize - the peakMarkerSize to set

getControls

public ImageComponentUI getControls()
Returns:
the controls

setControls

public void setControls(ImageComponentUI controls)
Parameters:
controls - the controls to set

getImage

public ImageComponentImage getImage()
Returns:
the image

setImage

public void setImage(ImageComponentImage image)
Parameters:
image - the image to set

setZoomSelection

public void setZoomSelection(ZoomSelection zoomSelection)
Sets the zoomSelection.

Parameters:
zoomSelection -

getZoomSelection

public ZoomSelection getZoomSelection()
Returns:
the zoomSelection.

getPeaks

public java.util.Vector<java.lang.Float> getPeaks()
Returns:
the peaks

isImageDiffOn

public boolean isImageDiffOn()
Returns:
the imageDiffOn

setImageDiffOn

public void setImageDiffOn(boolean imageDiffOn)
Parameters:
imageDiffOn - the imageDiffOn to set

getMinimum

public float getMinimum()
Returns:
the minimum

getMaximum

public float getMaximum()
Returns:
the maximum

getMean

public float getMean()
Returns:
the mean

getUserMinimum

public float getUserMinimum()
Returns:
the userMinimum

setUserMinimum

public void setUserMinimum(float userMinimum)
Parameters:
userMinimum - the userMinimum to set

getUserMaximum

public float getUserMaximum()
Returns:
the userMaximum

setUserMaximum

public void setUserMaximum(float userMaximum)
Parameters:
userMaximum - the userMaximum to set

getX0Save

public double getX0Save()
Returns:
the x0Save

setX0Save

public void setX0Save(double save)
Parameters:
save - the x0Save to set

getY0Save

public double getY0Save()
Returns:
the y0Save

setY0Save

public void setY0Save(double save)
Parameters:
save - the y0Save to set

getPixelWidthSave

public double getPixelWidthSave()
Returns:
the pixelWidthSave

setPixelWidthSave

public void setPixelWidthSave(double pixelWidthSave)
Parameters:
pixelWidthSave - the pixelWidthSave to set

getPixelHeightSave

public double getPixelHeightSave()
Returns:
the pixelHeightSave

setPixelHeightSave

public void setPixelHeightSave(double pixelHeightSave)
Parameters:
pixelHeightSave - the pixelHeightSave to set

getXNameSave

public java.lang.String getXNameSave()
Returns:
the xNameSave

setXNameSave

public void setXNameSave(java.lang.String nameSave)
Parameters:
nameSave - the xNameSave to set

getYNameSave

public java.lang.String getYNameSave()
Returns:
the yNameSave

setYNameSave

public void setYNameSave(java.lang.String nameSave)
Parameters:
nameSave - the yNameSave to set

getPaletteIndex

public int getPaletteIndex()
Returns:
the paletteIndex

setPaletteIndex

public void setPaletteIndex(int paletteIndex)
Parameters:
paletteIndex - the paletteIndex to set

setPalette

public void setPalette(org.eclipse.swt.graphics.PaletteData palette)
Parameters:
palette - the palette to set

getDisplay

public org.eclipse.swt.widgets.Display getDisplay()
Returns:
the display

getSecondaryId

public java.lang.String getSecondaryId()
Returns:
the secondary ID of this instance.

getPartName

public java.lang.Object getPartName()

getActionBars

public org.eclipse.ui.IActionBars getActionBars()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getParentPart

public org.eclipse.ui.IWorkbenchPart3 getParentPart()

setStatusLabel

public void setStatusLabel(org.eclipse.swt.widgets.Text statusLabel)

setPlotTitle

public void setPlotTitle(java.lang.String title)