Class NumberImageViewer

All Implemented Interfaces:
fr.esrf.tangoatk.core.IAttributeStateListener, fr.esrf.tangoatk.core.IErrorListener, fr.esrf.tangoatk.core.IImageListener, JDrawable, ActionListener, KeyListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class NumberImageViewer extends JPanel implements fr.esrf.tangoatk.core.IImageListener, MouseMotionListener, MouseListener, ActionListener, KeyListener, JDrawable
A high level class to display a TANGO image and handle several image manipulation function.
Author:
E.S.R.F
See Also:
  • Field Details

    • PROFILE_NONE

      public static final int PROFILE_NONE
      See Also:
    • PROFILE_FREELINE

      public static final int PROFILE_FREELINE
      See Also:
    • PROFILE_HISTO

      public static final int PROFILE_HISTO
      See Also:
    • PROFILE_DUAL

      public static final int PROFILE_DUAL
      See Also:
    • PROFILE_HLINE

      public static final int PROFILE_HLINE
      See Also:
    • PROFILE_VLINE

      public static final int PROFILE_VLINE
      See Also:
    • doubleValues

      protected double[][] doubleValues
    • hMarker

      protected int hMarker
    • vMarker

      protected int vMarker
    • profileMode

      protected int profileMode
    • startHisto

      protected int startHisto
    • noMargin

      protected Insets noMargin
    • imagePanel

      protected JImage imagePanel
    • imageView

      protected JScrollPane imageView
    • buttonPanel

      protected JPanel buttonPanel
    • selectButton

      protected JButton selectButton
    • selectMaxButton

      protected JButton selectMaxButton
    • selectColorButton

      protected JButton selectColorButton
    • fileButton

      protected JButton fileButton
    • zoomButton

      protected JButton zoomButton
    • tableButton

      protected JButton tableButton
    • profileButton

      protected JButton profileButton
    • profileHButton

      protected JButton profileHButton
    • profileVButton

      protected JButton profileVButton
    • histoButton

      protected JButton histoButton
    • settingsButton

      protected JButton settingsButton
    • axisButton

      protected JButton axisButton
    • loadButton

      protected JButton loadButton
    • saveButton

      protected JButton saveButton
    • printButton

      protected JButton printButton
    • buttonView

      protected JScrollPane buttonView
    • selText

      protected JTextField selText
    • imgMenu

      protected JPopupMenu imgMenu
    • infoMenuItem

      protected JMenuItem infoMenuItem
    • bestFitMenuItem

      protected JCheckBoxMenuItem bestFitMenuItem
    • snapToGridMenuItem

      protected JCheckBoxMenuItem snapToGridMenuItem
    • negativeMenuItem

      protected JCheckBoxMenuItem negativeMenuItem
    • toolbarMenuItem

      protected JCheckBoxMenuItem toolbarMenuItem
    • statusLineMenuItem

      protected JCheckBoxMenuItem statusLineMenuItem
    • showGradMenuItem

      protected JCheckBoxMenuItem showGradMenuItem
    • selectionMenuItem

      protected JMenuItem selectionMenuItem
    • selectionMaxMenuItem

      protected JMenuItem selectionMaxMenuItem
    • selectionColorMenuItem

      protected JMenuItem selectionColorMenuItem
    • fileMenuItem

      protected JMenuItem fileMenuItem
    • zoomMenuItem

      protected JMenuItem zoomMenuItem
    • tableMenuItem

      protected JMenuItem tableMenuItem
    • lineProfileMenuItem

      protected JMenuItem lineProfileMenuItem
    • lineHProfileMenuItem

      protected JMenuItem lineHProfileMenuItem
    • lineVProfileMenuItem

      protected JMenuItem lineVProfileMenuItem
    • lineProfile2MenuItem

      protected JMenuItem lineProfile2MenuItem
    • histogramMenuItem

      protected JMenuItem histogramMenuItem
    • settingsMenuItem

      protected JMenuItem settingsMenuItem
    • loadMenuItem

      protected JMenuItem loadMenuItem
    • saveMenuItem

      protected JMenuItem saveMenuItem
    • saveDataFileMenuItem

      protected JMenuItem saveDataFileMenuItem
    • printMenuItem

      protected JMenuItem printMenuItem
    • displayLogMenuItem

      protected JCheckBoxMenuItem displayLogMenuItem
    • lineProfiler

      protected LineProfilerViewer lineProfiler
    • lastSnapshotLocation

      protected String lastSnapshotLocation
    • lastFileFilter

      protected FileFilter lastFileFilter
    • logValues

      protected boolean logValues
  • Constructor Details

    • NumberImageViewer

      public NumberImageViewer()
      Create a new NumberImageViewer
  • Method Details

    • initImagePanel

      protected void initImagePanel()
    • initButtonPanel

      protected void initButtonPanel()
    • initGradient

      protected void initGradient()
    • initStatusLine

      protected void initStatusLine()
    • initPopupMenu

      protected void initPopupMenu()
    • initForEditing

      public void initForEditing()
      Description copied from interface: JDrawable
      Call after a component of a JDSwingObject is created, this give a default look and feel for editing.
      Specified by:
      initForEditing in interface JDrawable
    • getComponent

      public JComponent getComponent()
      Specified by:
      getComponent in interface JDrawable
      Returns:
      the JComponent that implements this interface.
    • getDescription

      public String getDescription(String name)
      Description copied from interface: JDrawable
      Get a description of this extensions.
      Specified by:
      getDescription in interface JDrawable
      Parameters:
      name - Extension name
      Returns:
      Empty string for no description.
    • getExtensionList

      public String[] getExtensionList()
      Specified by:
      getExtensionList in interface JDrawable
      Returns:
      list of extension name for this objects (Empty array for none).
    • setExtendedParam

      public boolean setExtendedParam(String name, String value, boolean popupErr)
      Description copied from interface: JDrawable
      Sets the specified param.
      Specified by:
      setExtendedParam in interface JDrawable
      Parameters:
      name - Parameter name (Case unsensitive).
      value - Parameter value.
      popupErr - true when the JDrawable should display a popup if the parameter value is incorrect, false otherwise. Note that the JDrawable must not display an error message if the parameter does not exists even if popupAllowed is true.
      Returns:
      true if parameters has been succesfully applied, false otherwise.
    • getExtendedParam

      public String getExtendedParam(String name)
      Description copied from interface: JDrawable
      Returns the specified parameter value.
      Specified by:
      getExtendedParam in interface JDrawable
      Parameters:
      name - Param name (Case unsensitive).
      Returns:
      Empty string if not exists, the value otherwise.
    • addRoiListener

      public void addRoiListener(IRoiListener l)
    • removeRoiListener

      public void removeRoiListener(IRoiListener l)
    • fireRoiChange

      public void fireRoiChange()
    • setBestFit

      public void setBestFit(boolean b)
      Displays the image using the whole color range.
      Parameters:
      b - Best fit toggle
    • isBestFit

      public boolean isBestFit()
      Returns true when best fit is on
      Returns:
      Best fit state
    • setAutoBestFit

      public void setAutoBestFit(boolean b)
      Sets the auto Best fit mode. Computes maximum and minimum value of the image when enabled else uses the min and max best fit user values.
      Parameters:
      b - True to enable auto best fit
    • isAutoBestFit

      public boolean isAutoBestFit()
      Returns true when automatic best fit is enabled
      Returns:
      Auto best fit state
    • setBestFitMinMax

      public void setBestFitMinMax(double min, double max)
      Sets the value of best fit min and max when automatic best fit is off.
      Parameters:
      min - Minimum value
      max - Maximum value
    • getBestFitMin

      public double getBestFitMin()
      Returns current best fit min value (user value)
      Returns:
      Minimum value
    • getBestFitMax

      public double getBestFitMax()
      Returns current best fit max value (user value)
      Returns:
      Maximum value
    • setGradient

      public void setGradient(Gradient g)
      Sets the colormap
      Parameters:
      g - New gradient colormap
    • getGradient

      public Gradient getGradient()
      Returns current colormap
      Returns:
      Gradient object
    • setNegative

      public void setNegative(boolean b)
      Displays negative image when enabled
      Parameters:
      b - True for negtive image
    • isNegative

      public boolean isNegative()
      Returns true only if negative image is displayed
      Returns:
      True when negative
    • setAlignToGrid

      public void setAlignToGrid(boolean b)
      Sets the align to grid mode for floating selection
      Parameters:
      b - True to enable
    • isAlignToGrid

      public boolean isAlignToGrid()
      Returns true is floating selection are aligned to grid
      Returns:
      Align to grid
    • setToolbarVisible

      public void setToolbarVisible(boolean b)
      Displays or hides the toolbar.
      Parameters:
      b - True if toolbar is displayed
    • isToolbarVisible

      public boolean isToolbarVisible()
      Returns true when the toolbar is visible.
      Returns:
      Toolbar visible state
    • setStatusLineVisible

      public void setStatusLineVisible(boolean b)
      Displays or hides the status line (bottom panel).
      Parameters:
      b - True if status line is displayed
    • isStatusLineVisible

      public boolean isStatusLineVisible()
      Returns true when the status line is visible.
      Returns:
      Status line visible state
    • setGradientVisible

      public void setGradientVisible(boolean b)
      Displays or hides the gradient (right panel).
      Parameters:
      b - True if status line is displayed
    • isGradientVisible

      public boolean isGradientVisible()
      Returns:
      true when the gradient is visible.
    • setShowingMenu

      public void setShowingMenu(boolean b)
      True to enable menu displayed when clicking on right mouse button.
      Parameters:
      b - True to enable the menu
    • setZoom

      public void setZoom(int zoomIndex)
      Sets the image zoom factor (does not affect the zoom dialog). If you want to start you viewer with a fixed zoom factor, you have to call setZoom() before setModel().
       Possible zoomIndex values are:
         0 : 800%
         1 : 400%
         2 : 200%
         3 : 100%
         4 : 50%
         5 : 25%
         6 : 12.5%
       
      Parameters:
      zoomIndex - ZoomFactor index (see description).
    • getZoom

      public int getZoom()
      Returns:
      the current zoom factor index.
      See Also:
    • setAutoZoom

      public void setAutoZoom(boolean auto)
      Enables or disables the auto zoom. When enabled, the image size (zoom) is automatically adjusted according to the component size. The calcul of the size is triggered by a call to setData() or imageChange().
      Parameters:
      auto - AutoZoom flag
    • getAutoZoom

      public boolean getAutoZoom()
      Determines wheter this image viewer has auto zoom enabled.
      Returns:
      AutoZoom flag
      See Also:
    • isShowingMenu

      public boolean isShowingMenu()
      Returns true is the image viewer menu is displayed when clicking on the right mouse button.
      Returns:
      True is menu is enabled
    • getImageMargin

      public Insets getImageMargin()
      Returns image margin.
      Returns:
      Mergin
    • setImageMargin

      public void setImageMargin(Insets i)
      Sets the image margin.
      Parameters:
      i - Image margin
    • getCurrentImageSize

      public Dimension getCurrentImageSize()
      Returns the current image size
      Returns:
      Current image size
    • setSelectionEnabled

      public void setSelectionEnabled(boolean b)
      True is floating selection is enabled
      Parameters:
      b - True to allow floating selection
    • isSelectionEnabled

      public boolean isSelectionEnabled()
      Returns true is floating selection is enabled
      Returns:
      True when floating selection is allowed
    • setCrossCursor

      public void setCrossCursor(boolean enable)
      Enable or disable the cross cursor.
      Parameters:
      enable - True to enable cross cursor, false otherwise.
    • setCrossCursorColor

      public void setCrossCursorColor(Color c)
      Set the cross cursor color.
      Parameters:
      c - Cursor color
      See Also:
    • setSelection

      public void setSelection(Rectangle r)
      Sets the floating selection.
      Parameters:
      r - Rectangle to select
    • setSelectionFull

      public void setSelectionFull()
      Select all
    • getSelection

      public Rectangle getSelection()
      Return current floating rectangle selection
      Returns:
      Selection rectangle, Null is returned when nothing is selected.
    • getSelectionFull

      public Rectangle getSelectionFull()
      Return current floating rectangle selection
      Returns:
      Selection rectangle, full size is returned when nothing is selected.
    • getSelectionMode

      public int getSelectionMode()
      Returns the floating selection mode
      Returns:
      0 when Line selection, 1 when rectangle selection
    • setSelectionMode

      public void setSelectionMode(int m)
      Sets the floating selection mode
      Parameters:
      m - 0 for Line selection, 1 fro rectangle selection
    • setData

      public void setData(double[][] v)
      Sets data to display.
      Parameters:
      v - Handle to data
    • loadImage

      public void loadImage(String fileName) throws IOException
      Load an image (gif,jpg or png) into the viewer. For color image the green field is taken.
      Parameters:
      fileName - File to be loaded
      Throws:
      IOException - Exception thrown in case of failure
    • addCrossMarker

      public int addCrossMarker(int x, int y, Color c)
      Adds a cross marker at the specified pos
      Parameters:
      x - X coordinates
      y - Y coordinates
      c - Marker Color
      Returns:
      Marker id
    • addRectangleMarker

      public int addRectangleMarker(int x, int y, int width, int height, Color c)
      Adds a rectangle marker
      Parameters:
      x - X topleft corner coordinate
      y - Y topleft corner coordinate
      width - Rectangle width
      height - Rectangle hieght
      c - Marker Color
      Returns:
      Marker id
    • addVerticalLineMarker

      public int addVerticalLineMarker(int x, Color c)
      Adds a vertical line marker
      Parameters:
      x - Horizontal position
      c - Marker color
      Returns:
      Marker id
    • addHorizontalLineMarker

      public int addHorizontalLineMarker(int y, Color c)
      Adds a horizontal line marker
      Parameters:
      y - Vertical position
      c - Marker color
      Returns:
      Marker id
    • setMarkerPos

      public void setMarkerPos(int id, int x, int y, int nWidth, int nHeight)
      Sets the position of a marker
      Parameters:
      id - Marker index
      x - X coordinate (ignored when HORIZONTAL_LINE Marker)
      y - Y coordinate (ignored when VERTICAL_LINE Marker)
      nWidth - Rectangle width (ignored when CROSS Marker or LINE Marker)
      nHeight - Rectangle height (ignored when CROSS Marker or LINE Marker)
    • clearMarkers

      public void clearMarkers()
      Clears all markers
    • hasMarker

      public boolean hasMarker()
    • getXAxis

      public JLAxis getXAxis()
      Returns:
      a handle to the x axis.
    • getYAxis

      public JLAxis getYAxis()
      Returns:
      a handle to the Y axis.
    • getGradientAxis

      public JLAxis getGradientAxis()
      Returns:
      a handle to the Gradient axis.
    • getImageXCoord

      public int getImageXCoord(int x)
      Converts the component horizontal coordinate to the image coordinate.
      Parameters:
      x - Component horizontal coordinate
      Returns:
      Converted coordinates
    • getImageYCoord

      public int getImageYCoord(int y)
      Converts the component vertical coordinate to the image coordinate.
      Parameters:
      y - Component vertical coordinate
      Returns:
      Converted coordinates
    • setVerticalExtent

      public void setVerticalExtent(int ratio)
      Extend verticaly the image.
      Parameters:
      ratio - Vertical extent ration
    • mulRect

      protected void mulRect(Rectangle r)
    • mulPoint

      protected void mulPoint(Point p)
    • freePopup

      protected void freePopup()
    • buildProfileData

      protected double[] buildProfileData(Point p1, Point p2)
    • buildProfileData

      protected double[] buildProfileData(Point p1, Point p2, boolean convertPoint)
    • buildHistogramData

      protected double[] buildHistogramData()
    • setSourceFromProfile

      public void setSourceFromProfile(String src, int profileId)
    • refreshLineProfile

      protected void refreshLineProfile()
    • refreshStatusLine

      protected void refreshStatusLine()
    • saveSetting

      public void saveSetting(String filename)
      Save settings.
      Parameters:
      filename - file to be saved.
    • getSettings

      public String getSettings()
      Returns:
      the configuration as string.
      See Also:
    • loadSetting

      public String loadSetting(String filename)
      Load NumberImageViewer settings.
      Parameters:
      filename - file to be read
      Returns:
      An error string or An empty string when succes
    • constructLineProfiler

      protected void constructLineProfiler()
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Specified by:
      actionPerformed in interface ActionListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • keyPressed

      public void keyPressed(KeyEvent e)
      Specified by:
      keyPressed in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent e)
      Specified by:
      keyTyped in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent e)
      Specified by:
      keyReleased in interface KeyListener
    • errorChange

      public void errorChange(fr.esrf.tangoatk.core.ErrorEvent errorEvent)
      Specified by:
      errorChange in interface fr.esrf.tangoatk.core.IErrorListener
    • stateChange

      public void stateChange(fr.esrf.tangoatk.core.AttributeStateEvent evt)
      Specified by:
      stateChange in interface fr.esrf.tangoatk.core.IAttributeStateListener
    • imageChange

      public void imageChange(fr.esrf.tangoatk.core.NumberImageEvent evt)
      Specified by:
      imageChange in interface fr.esrf.tangoatk.core.IImageListener
    • setModel

      public void setModel(fr.esrf.tangoatk.core.INumberImage v)
      setModel Set the model.
      Parameters:
      v - Value to assign to model. This image must have a height equals to 2.
    • clearModel

      public void clearModel()
      Removes all listener belonging to the viewer.
    • setNaNcolor

      public void setNaNcolor(Color color)
      Set a specified color for NaN values.
      Parameters:
      color - the specified color for NaN values (if null NaN color is not managed)
    • printImage

      public void printImage()
      Prints out this image.
    • isLogValues

      public boolean isLogValues()
      Returns:
      the logValues
    • setLogValues

      public void setLogValues(boolean logValues)
      Parameters:
      logValues - the logValues to set
    • computeLog

      protected double[][] computeLog(double[][] values)
    • changeSelectionColor

      protected void changeSelectionColor()
    • main

      public static void main(String[] args)