gov.nih.mipav.view.renderer
Class JPanelHistoLUT

java.lang.Object
  extended by gov.nih.mipav.view.renderer.JPanelHistoLUT
All Implemented Interfaces:
HistoLUTParent, ViewImageUpdateInterface, ActionListener, FocusListener, ItemListener, KeyListener, EventListener, ChangeListener

public class JPanelHistoLUT
extends Object
implements ItemListener, ActionListener, ChangeListener, ViewImageUpdateInterface, FocusListener, KeyListener, HistoLUTParent

This class produces a frame where the user can specify a specific LUT, the number of colors of the LUT or dynamically edit the LUT. The frame with histogram of the image data is displayed using the color map. All frames using the color map are dynamically updated with the new color map. This control panel is the control LUT of the gray scale images.

Version:
1.0

Field Summary
protected  int displayMode
          Indicates which image is to be acted upon when two images are displayed.
static int IMAGE_A
          Display mode image A.
static int IMAGE_B
          Display mode image B.
 
Constructor Summary
JPanelHistoLUT(ModelImage _imageA, ModelImage _imageB, ModelLUT _LUTa, ModelLUT _LUTb, boolean _entireFlag)
          Makes a frame of the histogram and LUT.
JPanelHistoLUT(ModelImage _imageA, ModelImage _imageB, ModelLUT _LUTa, ModelLUT _LUTb, boolean _entireFlag, boolean bUpdateImage)
          Makes a frame of the histogram and LUT.
 
Method Summary
 void actionPerformed(ActionEvent event)
          Calls various methods depending on the action.
 void disposeLocal()
          Still needs more work Matt.
 void dragPoint(MouseEvent mouseEvent)
          Placeholder.
protected  void finalize()
          Calls dispose.
 void focusGained(FocusEvent e)
          Focus Events:
 void focusLost(FocusEvent e)
          If focus is lost from either threshold field (lower/upper), update the new value on the LUT.
 int getDisplayMode()
          Get the LUT panel current display mode.
 ViewJComponentHLUTBase getHistoLUTComponentA()
          Get the histogram component for imageA.
 ViewJComponentHLUTBase getHistoLUTComponentB()
          Get the histogram component for imageB.
 ModelImage getImageA()
          Accessor that returns the imageA.
 ModelImage getImageB()
          Accessor that returns the imageB.
 ModelLUT getLUT()
          This method returns the current LUT.
 ModelLUT getLUTa()
          Get the imageA histo component lut.
 ModelLUT getLUTb()
          Get the imageB histo component lut.
 ViewJComponentLUT getLUTComponentA()
          Get the imageA LUT.
 ViewJComponentLUT getLUTComponentB()
          Get the imageB LUT.
 JPanel getMainPanel()
          Return the main control panel.
 int getSelectedLUT()
          Returns which LUT is currently visible.
 TransferFunction getTransferLine()
          This method is used to obtain the VOIBase Single Transfer Line.
 boolean isImageUpdate()
          Indicates if real-time update of the image should take place.
 void itemStateChanged(ItemEvent event)
          Sets the flags for the checkboxes.
 void keyPressed(KeyEvent e)
          Unchanged.
 void keyReleased(KeyEvent e)
          Unchanged.
 void keyTyped(KeyEvent e)
          If the ENTER key is hit while in threshold boxes, update the LUT's threshold (for dual threshold).
 void loadLUTFrom(boolean loadAll, String filename, String dirName, boolean quietMode)
          This method loads the LUT for the active image.
 void loadOnlyLUTFrom(boolean loadAll, String filename, String dirName, boolean quietMode)
          This method loads the LUT for the active image.
protected  String makeString(float number, int decPts)
          Makes a string of a float with a specific number of decimal points.
 void notifyOfUpdate(ModelLUT LUT, int imageAorB)
          Enable button to indicate image has changed and the histogram should be recalculated.
 void removeHistoLUTb()
          Removes the tabbed pane for the histogram of image B.
 void resizePanel(int panelWidth, int frameHeight)
          Resizig the control panel with ViewJFrameVolumeView's frame width and height.
 void saveLUTAs(boolean saveAll, String filename, String dirName)
          This method saves the LUT for the active image.
 void saveOnlyLUTAs(boolean saveAll, String filename, String dirName)
          This method saves the LUT for the active image.
 void selectLUTa()
          Forces the panel to display the LUTB panel.
 void selectLUTb()
          Forces the panel to display the LUTB panel.
 void setAllOff()
          Placeholder.
 void setCTMode(int st, int end)
          This method is used to set Computed Tomography (CT) presets for CT images.
 void setHistoLUTa(ModelLUT lut)
          Change the histogram component LUT.
 void setHistoLUTb(ModelLUT lut)
          Change the histogram component LUT.
 void setImageA(ModelImage image)
          Accessor that sets the imageA.
 void setImageB(ModelImage image)
          Accessor that sets the imageB.
 void setLinearLUT()
          This method sets the histogram to Linear Transfer Function Mode.
 void setLUT(ModelLUT LUT)
          Replaces the LUT and builds a new LUT component.
 void setLUTa(ModelLUT _LUTa)
          Set imageA lookup table.
 void setLUTA(ModelLUT LUT)
          Replaces the LUT A component.
 void setLUTb(ModelLUT _LUTb)
          Set imageB lookup table.
 void setLUTB(ModelLUT LUT)
          Replaces the LUT B component.
 void setRangeText(float x, float y, int _index)
          Set the range value of the text field.
 void setSlice(int slice)
          Does nothing in this.
 void setTimeSlice(int tSlice)
          Does nothing in this class.
 void stateChanged(ChangeEvent e)
          Sets values based on knob along slider.
protected  boolean testParameter(String str, double minValue, double maxValue)
          Tests that the entered parameter is in range.
 void updateComponentLUT()
          Placeholder.
 void updateFrames(boolean flag)
          Update all of the image frames that display the image this histo lut is for.
 void updateHistoLUT(ModelImage _imageA, ModelLUT _LUTa, ModelImage _imageB, ModelLUT _LUTb, boolean progressFlag)
          This method is called to update the histogram(s) displayed in each tabbed pane of the frame.
 boolean updateImageExtents()
          This methods calls the componentImage's REPAINT method to redraw the screen.
 boolean updateImages()
          This methods calls the componentImage's REPAINT method to redraw the screen.
 boolean updateImages(boolean flag)
          This methods calls the componentImage's update method to redraw the screen.
 boolean updateImages(ModelLUT LUTa, ModelLUT LUTb, boolean flag, int interpMode)
          This methods calls the componentImage's update method to redraw the screen.
 void updateLUTPositionString(String str)
          Sets the position string in the LUT text field.
 void updateThresholdFields(float lower, float upper)
          Method to update the threshold text fields when the lower or upper threshold changes.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAGE_A

public static final int IMAGE_A
Display mode image A.

See Also:
Constant Field Values

IMAGE_B

public static final int IMAGE_B
Display mode image B.

See Also:
Constant Field Values

displayMode

protected int displayMode
Indicates which image is to be acted upon when two images are displayed.

Constructor Detail

JPanelHistoLUT

public JPanelHistoLUT(ModelImage _imageA,
                      ModelImage _imageB,
                      ModelLUT _LUTa,
                      ModelLUT _LUTb,
                      boolean _entireFlag)
Makes a frame of the histogram and LUT.

Parameters:
_imageA - Model of imageA
_imageB - Model of imageB
_LUTa - Model of LUT for image A
_LUTb - Model of LUT for image B
_entireFlag - Flag indicating if histogram should be done on all of image.

JPanelHistoLUT

public JPanelHistoLUT(ModelImage _imageA,
                      ModelImage _imageB,
                      ModelLUT _LUTa,
                      ModelLUT _LUTb,
                      boolean _entireFlag,
                      boolean bUpdateImage)
Makes a frame of the histogram and LUT.

Parameters:
_imageA - Model of imageA
_imageB - Model of imageB
_LUTa - Model of LUT for image A
_LUTb - Model of LUT for image B
_entireFlag - Flag indicating if histogram should be done on all of image.
Method Detail

actionPerformed

public void actionPerformed(ActionEvent event)
Calls various methods depending on the action.

Specified by:
actionPerformed in interface ActionListener
Parameters:
event - event that triggered function

disposeLocal

public void disposeLocal()
Still needs more work Matt.


dragPoint

public void dragPoint(MouseEvent mouseEvent)
Placeholder.

Specified by:
dragPoint in interface HistoLUTParent
Parameters:
mouseEvent - drag event

focusGained

public void focusGained(FocusEvent e)
Focus Events:

Specified by:
focusGained in interface FocusListener
Parameters:
e - event handler.

focusLost

public void focusLost(FocusEvent e)
If focus is lost from either threshold field (lower/upper), update the new value on the LUT.

Specified by:
focusLost in interface FocusListener
Parameters:
e - FocusEvent

getDisplayMode

public int getDisplayMode()
Get the LUT panel current display mode.

Returns:
int displayMode value, which is either IMAGE_A or IMAGE_B

getHistoLUTComponentA

public ViewJComponentHLUTBase getHistoLUTComponentA()
Get the histogram component for imageA.

Returns:
the imageA histogram component

getHistoLUTComponentB

public ViewJComponentHLUTBase getHistoLUTComponentB()
Get the histogram component for imageB.

Returns:
the imageB histogram component

getImageA

public ModelImage getImageA()
Accessor that returns the imageA.

Returns:
image

getImageB

public ModelImage getImageB()
Accessor that returns the imageB.

Returns:
imageB

getLUT

public ModelLUT getLUT()
This method returns the current LUT.

Returns:
LUT for Image A if selected, otherwise for Image B

getLUTa

public final ModelLUT getLUTa()
Get the imageA histo component lut.

Returns:
ModelLUT

getLUTb

public final ModelLUT getLUTb()
Get the imageB histo component lut.

Returns:
ModelLUT

getLUTComponentA

public ViewJComponentLUT getLUTComponentA()
Get the imageA LUT.

Returns:
the imageA LUT component

getLUTComponentB

public ViewJComponentLUT getLUTComponentB()
Get the imageB LUT.

Returns:
the imageB LUT component

getMainPanel

public JPanel getMainPanel()
Return the main control panel.

Returns:
mainPanel the main control panel

getSelectedLUT

public int getSelectedLUT()
Returns which LUT is currently visible.

Returns:
return the currently selcted LUT table index.

getTransferLine

public TransferFunction getTransferLine()
This method is used to obtain the VOIBase Single Transfer Line.

Returns:
LUTb.getTransferFunction() - VOIBase of Single Transfer Line for Image B

isImageUpdate

public boolean isImageUpdate()
Indicates if real-time update of the image should take place.

Specified by:
isImageUpdate in interface HistoLUTParent
Returns:
true if real time update should take place

itemStateChanged

public void itemStateChanged(ItemEvent event)
Sets the flags for the checkboxes.

Specified by:
itemStateChanged in interface ItemListener
Parameters:
event - event that triggered this function

keyPressed

public void keyPressed(KeyEvent e)
Unchanged.

Specified by:
keyPressed in interface KeyListener
Parameters:
e - key press event handler.

keyReleased

public void keyReleased(KeyEvent e)
Unchanged.

Specified by:
keyReleased in interface KeyListener
Parameters:
e - kay release event handler.

keyTyped

public void keyTyped(KeyEvent e)
If the ENTER key is hit while in threshold boxes, update the LUT's threshold (for dual threshold).

Specified by:
keyTyped in interface KeyListener
Parameters:
e - KeyEvent

loadLUTFrom

public void loadLUTFrom(boolean loadAll,
                        String filename,
                        String dirName,
                        boolean quietMode)
This method loads the LUT for the active image. If the image is not a color image then both the functions and the LUT data are loaded. If this is a color image, then only the functions are loaded.

Parameters:
loadAll - loadAll boolean indicating that both lut and transfer functions should be loaded. If false, then only transfer functions are loaded.
filename - filename filename to save LUT as
dirName - dirName directory to save LUT to
quietMode - quietMode if true indicates that warnings should not be displayed.

loadOnlyLUTFrom

public void loadOnlyLUTFrom(boolean loadAll,
                            String filename,
                            String dirName,
                            boolean quietMode)
This method loads the LUT for the active image. If the image is not a color image then both the functions and the LUT data are loaded. If this is a color image, then only the functions are loaded.

Parameters:
loadAll - loadAll boolean indicating that both lut and transfer functions should be loaded. If false, then only transfer functions are loaded.
filename - filename filename to save LUT as
dirName - dirName directory to save LUT to
quietMode - quietMode if true indicates that warnings should not be displayed.

notifyOfUpdate

public void notifyOfUpdate(ModelLUT LUT,
                           int imageAorB)
Enable button to indicate image has changed and the histogram should be recalculated.

Parameters:
LUT - new Lookup table
imageAorB - indicates which histogram needs to be recalculated

removeHistoLUTb

public void removeHistoLUTb()
Removes the tabbed pane for the histogram of image B.


resizePanel

public void resizePanel(int panelWidth,
                        int frameHeight)
Resizig the control panel with ViewJFrameVolumeView's frame width and height.

Parameters:
panelWidth - panel width.
frameHeight - parent frame height.

saveLUTAs

public void saveLUTAs(boolean saveAll,
                      String filename,
                      String dirName)
This method saves the LUT for the active image. If the image is not a color image then both the functions and the LUT data are saved. If this is a color image, then only the functions are saved.

Parameters:
saveAll - boolean indicating that both lut and transfer functions should be saved. If false, then only transfer functions are saved.

If either filename or directory is null, then the user will be prompted for a filename.

filename - filename to save LUT as
dirName - directory to save LUT to

saveOnlyLUTAs

public void saveOnlyLUTAs(boolean saveAll,
                          String filename,
                          String dirName)
This method saves the LUT for the active image. If the image is not a color image then both the functions and the LUT data are saved. If this is a color image, then only the functions are saved.

Parameters:
saveAll - boolean indicating that both lut and transfer functions should be saved. If false, then only transfer functions are saved.

If either filename or directory is null, then the user will be prompted for a filename.

filename - filename to save LUT as
dirName - directory to save LUT to

selectLUTa

public void selectLUTa()
Forces the panel to display the LUTB panel.


selectLUTb

public void selectLUTb()
Forces the panel to display the LUTB panel.


setAllOff

public void setAllOff()
Placeholder.

Specified by:
setAllOff in interface HistoLUTParent

setCTMode

public void setCTMode(int st,
                      int end)
This method is used to set Computed Tomography (CT) presets for CT images.

Parameters:
st - starting preset of the window
end - ending preset of the window
See Also:
JDialogCT

setHistoLUTa

public final void setHistoLUTa(ModelLUT lut)
Change the histogram component LUT.

Parameters:
lut - the new lut

setHistoLUTb

public final void setHistoLUTb(ModelLUT lut)
Change the histogram component LUT.

Parameters:
lut - the new lut

setImageA

public void setImageA(ModelImage image)
Accessor that sets the imageA.

Parameters:
image - image to set frame to

setImageB

public void setImageB(ModelImage image)
Accessor that sets the imageB.

Parameters:
image - image to set frame to

setLinearLUT

public void setLinearLUT()
This method sets the histogram to Linear Transfer Function Mode.


setLUT

public void setLUT(ModelLUT LUT)
Replaces the LUT and builds a new LUT component.

Specified by:
setLUT in interface HistoLUTParent
Parameters:
LUT - New LUT

setLUTA

public void setLUTA(ModelLUT LUT)
Replaces the LUT A component.

Parameters:
LUT - new LUT

setLUTa

public void setLUTa(ModelLUT _LUTa)
Set imageA lookup table.

Parameters:
_LUTa - ModelLUTa

setLUTB

public void setLUTB(ModelLUT LUT)
Replaces the LUT B component.

Parameters:
LUT - new LUT

setLUTb

public void setLUTb(ModelLUT _LUTb)
Set imageB lookup table.

Parameters:
_LUTb - ModelLUTb

setRangeText

public void setRangeText(float x,
                         float y,
                         int _index)
Set the range value of the text field.

Specified by:
setRangeText in interface HistoLUTParent
Parameters:
x - the x threshold range value
y - the y threshold range value
_index - the cursor index

setSlice

public void setSlice(int slice)
Does nothing in this.

Specified by:
setSlice in interface ViewImageUpdateInterface
Parameters:
slice - slice value.

setTimeSlice

public void setTimeSlice(int tSlice)
Does nothing in this class.

Specified by:
setTimeSlice in interface ViewImageUpdateInterface
Parameters:
tSlice - time slice value.

stateChanged

public void stateChanged(ChangeEvent e)
Sets values based on knob along slider.

Specified by:
stateChanged in interface ChangeListener
Parameters:
e - event that triggered this function

updateComponentLUT

public void updateComponentLUT()
Placeholder.

Specified by:
updateComponentLUT in interface HistoLUTParent

updateFrames

public void updateFrames(boolean flag)
Update all of the image frames that display the image this histo lut is for.

Specified by:
updateFrames in interface HistoLUTParent
Parameters:
flag - this boolean indicates if the frame that displays the image should re-export the image and apply new LUT
See Also:
ModelImage.notifyImageDisplayListeners()

updateHistoLUT

public void updateHistoLUT(ModelImage _imageA,
                           ModelLUT _LUTa,
                           ModelImage _imageB,
                           ModelLUT _LUTb,
                           boolean progressFlag)
This method is called to update the histogram(s) displayed in each tabbed pane of the frame.

Parameters:
_imageA - image A
_LUTa - lookup table for image A
_imageB - image B
_LUTb - lookup table for image B
progressFlag - passed to calculateHistogram algorithm. If false progress bar is not displayed

updateImageExtents

public boolean updateImageExtents()
This methods calls the componentImage's REPAINT method to redraw the screen. The extents on this image have changed, so the extents need to be read in again and menus, panes and slide bars adjusted accordingly.

Specified by:
updateImageExtents in interface ViewImageUpdateInterface
Returns:
return false.

updateImages

public boolean updateImages()
This methods calls the componentImage's REPAINT method to redraw the screen. Without LUT changes or image changes

Specified by:
updateImages in interface ViewImageUpdateInterface
Returns:
return false.

updateImages

public boolean updateImages(boolean flag)
This methods calls the componentImage's update method to redraw the screen. Without LUT changes. Does nothing in this class.

Specified by:
updateImages in interface ViewImageUpdateInterface
Parameters:
flag - forces show to re import image and calc. java image
Returns:
boolean confirming successful update

updateImages

public boolean updateImages(ModelLUT LUTa,
                            ModelLUT LUTb,
                            boolean flag,
                            int interpMode)
This methods calls the componentImage's update method to redraw the screen. Does nothing in this class.

Specified by:
updateImages in interface ViewImageUpdateInterface
Parameters:
LUTa - LUT used to update imageA
LUTb - LUT used to update imageB
flag - forces show to re import image and calc. java image
interpMode - image interpolation method (Nearest or Smooth)
Returns:
boolean confirming a successful update

updateLUTPositionString

public void updateLUTPositionString(String str)
Sets the position string in the LUT text field.

Specified by:
updateLUTPositionString in interface HistoLUTParent
Parameters:
str - the position string

updateThresholdFields

public void updateThresholdFields(float lower,
                                  float upper)
Method to update the threshold text fields when the lower or upper threshold changes.

Specified by:
updateThresholdFields in interface HistoLUTParent
Parameters:
lower - the lower threshold value
upper - the upper threshold value

finalize

protected void finalize()
                 throws Throwable
Calls dispose.

Overrides:
finalize in class Object
Throws:
Throwable - dispose memory.

makeString

protected String makeString(float number,
                            int decPts)
Makes a string of a float with a specific number of decimal points.

Parameters:
number - number to be converted to a string
decPts - the number of decimal points
Returns:
string representation of the number

testParameter

protected boolean testParameter(String str,
                                double minValue,
                                double maxValue)
Tests that the entered parameter is in range.

Parameters:
str - the value entered by the user
minValue - the minimum value this variable may be set to
maxValue - the maximum value this variable may be set to
Returns:
boolean result of test