Module ij
Package ij.gui

Class PlotWindow

  • All Implemented Interfaces:
    RoiListener, ImageListener, java.awt.datatransfer.ClipboardOwner, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.MouseWheelListener, java.awt.event.WindowListener, java.awt.event.WindowStateListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible

    public class PlotWindow
    extends ImageWindow
    implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.datatransfer.ClipboardOwner, ImageListener, RoiListener, java.lang.Runnable
    This class implements the Analyze/Plot Profile command.
    Author:
    Michael Schmid, Wayne Rasband
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.awt.Frame

        java.awt.Frame.AccessibleAWTFrame
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean autoClose
      Automatically close window after saving values.
      static int BOX
      Deprecated. 
      static int CIRCLE
      Deprecated. 
      static int CROSS
      Deprecated. 
      static int fontSize
      The plot text size, can be overridden by Plot.setFont, Plot.setFontSize, Plot.setXLabelFont etc.
      static boolean interpolate
      Interpolate line profiles.
      static int LINE
      Deprecated. 
      static boolean listValues
      Display the XY coordinates in a separate window.
      static boolean noGridLines
      Have axes with no grid lines.
      static boolean noTicks
      Have axes with no ticks.
      static int plotHeight
      The height of the plot in pixels.
      static int plotWidth
      The width of the plot (without frame) in pixels.
      static boolean saveXValues
      Write first X column when listing or saving.
      static int TRIANGLE
      Deprecated. 
      static int X
      Deprecated. 
      • Fields inherited from class java.awt.Frame

        CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, PROPERTIES, SOMEBITS
    • Constructor Summary

      Constructors 
      Constructor Description
      PlotWindow​(ImagePlus imp, Plot plot)
      Creates a PlotWindow from a given ImagePlus with a Plot object.
      PlotWindow​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, double[] xValues, double[] yValues)
      Deprecated.
      replaced by the Plot class.
      PlotWindow​(java.lang.String title, java.lang.String xLabel, java.lang.String yLabel, float[] xValues, float[] yValues)
      Deprecated.
      replaced by the Plot class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)
      Called if user has activated a button or popup menu item
      void addErrorBars​(float[] errorBars)
      Deprecated.
      use the corresponding method of the Plot class
      void addLabel​(double x, double y, java.lang.String label)
      Deprecated.
      use the corresponding method of the Plot class
      void addPoints​(double[] x, double[] y, int shape)
      Deprecated.
      use the corresponding method of the Plot class
      void addPoints​(float[] x, float[] y, int shape)
      Deprecated.
      use the corresponding method of the Plot class
      void changeFont​(java.awt.Font font)
      Deprecated.
      use the corresponding method of the Plot class
      void dispose()
      Releases the resources used by this PlotWindow
      void draw()
      Displays the plot.
      void drawPlot​(Plot plot)
      Draws a new plot in this window.
      static void freeze()
      Freezes the active plot window, so the image does not get redrawn for zooming, setting the range, etc.
      static int getDefaultFontSize()  
      Plot getPlot()
      Returns the Plot associated with this PlotWindow.
      ResultsTable getResultsTable()
      Returns the plot values with simple headings (X, Y, Y1 etc, not the labels) as a ResultsTable.
      float[] getXValues()  
      float[] getYValues()  
      void imageClosed​(ImagePlus imp)
      For live plots, if either the source image or this image are closed, exit live mode
      void imageOpened​(ImagePlus imp)  
      void imageUpdated​(ImagePlus imp)
      For live plots, this method is called if the source image content is changed.
      void itemStateChanged​(java.awt.event.ItemEvent e)
      Called if the user activates/deactivates a CheckboxMenuItem
      void lostOwnership​(java.awt.datatransfer.Clipboard clipboard, java.awt.datatransfer.Transferable contents)  
      void mouseMoved​(int x, int y)
      Updates the X and Y values when the mouse is moved and, if appropriate, shows/hides the overlay with the triangular buttons for changing the axis range limits.
      void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
      Mouse wheel: zooms when shift or ctrl is pressed, scrolls in x if space bar down, in y otherwise.
      void roiModified​(ImagePlus img, int id)
      For live plots, update the plot if the ROI of the source image changes
      void run()  
      static void savePreferences​(java.util.Properties prefs)
      Called once when ImageJ quits.
      void setColor​(java.awt.Color c)
      Deprecated.
      use the corresponding method of the Plot class
      static void setDefaultFontSize​(int size)  
      void setLimits​(double xMin, double xMax, double yMin, double yMax)
      Deprecated.
      use the corresponding method of the Plot class
      void setLineWidth​(int lineWidth)
      Deprecated.
      use the corresponding method of the Plot class
      void setPlot​(Plot plot)
      Sets the Plot object shown in this PlotWindow.
      void showStatus​(java.lang.String text)
      Shows the text in the coordinate&status readout field at the bottom.
      void windowActivated​(java.awt.event.WindowEvent e)
      Called when the window is activated (WindowListener) Window layout is finished at latest a few millisec after windowActivated, then the 'wasActivated' boolean is set to tell the ImageCanvas that resize events should lead to resizing the canvas (before, creating the layout can lead to resize events)
      • Methods inherited from class java.awt.Frame

        addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setBackground, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.awt.MenuContainer

        getFont, postEvent
    • Field Detail

      • saveXValues

        public static boolean saveXValues
        Write first X column when listing or saving.
      • autoClose

        public static boolean autoClose
        Automatically close window after saving values. To set, use Edit/Options/Plots.
      • listValues

        public static boolean listValues
        Display the XY coordinates in a separate window. To set, use Edit/Options/Plots.
      • interpolate

        public static boolean interpolate
        Interpolate line profiles. To set, use Edit/Options/Plots or setOption("InterpolateLines",boolean).
      • plotWidth

        public static int plotWidth
        The width of the plot (without frame) in pixels.
      • plotHeight

        public static int plotHeight
        The height of the plot in pixels.
      • fontSize

        public static int fontSize
        The plot text size, can be overridden by Plot.setFont, Plot.setFontSize, Plot.setXLabelFont etc.
      • noGridLines

        public static boolean noGridLines
        Have axes with no grid lines. If both noGridLines and noTicks are true, only min&max value of the axes are given
      • noTicks

        public static boolean noTicks
        Have axes with no ticks. If both noGridLines and noTicks are true, only min&max value of the axes are given
    • Constructor Detail

      • PlotWindow

        public PlotWindow​(java.lang.String title,
                          java.lang.String xLabel,
                          java.lang.String yLabel,
                          float[] xValues,
                          float[] yValues)
        Deprecated.
        replaced by the Plot class.
      • PlotWindow

        public PlotWindow​(java.lang.String title,
                          java.lang.String xLabel,
                          java.lang.String yLabel,
                          double[] xValues,
                          double[] yValues)
        Deprecated.
        replaced by the Plot class.
      • PlotWindow

        public PlotWindow​(ImagePlus imp,
                          Plot plot)
        Creates a PlotWindow from a given ImagePlus with a Plot object. (called when reading an ImagePlus with an associated plot from a file)
    • Method Detail

      • setLimits

        public void setLimits​(double xMin,
                              double xMax,
                              double yMin,
                              double yMax)
        Deprecated.
        use the corresponding method of the Plot class
        Sets the x-axis and y-axis range.
      • addPoints

        public void addPoints​(float[] x,
                              float[] y,
                              int shape)
        Deprecated.
        use the corresponding method of the Plot class
        Adds a set of points to the plot or adds a curve if shape is set to LINE. Note that there are more options available by using the methods of the Plot class instead.
        Parameters:
        x - the x-coodinates
        y - the y-coodinates
        shape - Plot.CIRCLE, X, BOX, TRIANGLE, CROSS, LINE etc.
      • addPoints

        public void addPoints​(double[] x,
                              double[] y,
                              int shape)
        Deprecated.
        use the corresponding method of the Plot class
        Adds a set of points to the plot using double arrays. Must be called before the plot is displayed. Note that there are more options available by using the methods of the Plot class instead.
      • addErrorBars

        public void addErrorBars​(float[] errorBars)
        Deprecated.
        use the corresponding method of the Plot class
        Adds vertical error bars to the plot. Must be called before the plot is displayed. Note that there are more options available by using the methods of the Plot class instead.
      • addLabel

        public void addLabel​(double x,
                             double y,
                             java.lang.String label)
        Deprecated.
        use the corresponding method of the Plot class
        Draws a label. Note that there are more options available by using the methods of the Plot class instead.
      • setColor

        public void setColor​(java.awt.Color c)
        Deprecated.
        use the corresponding method of the Plot class
        Changes the drawing color. The frame and labels are always drawn in black. Must be called before the plot is displayed. Note that there are more options available by using the methods of the Plot class instead.
      • setLineWidth

        public void setLineWidth​(int lineWidth)
        Deprecated.
        use the corresponding method of the Plot class
        Changes the line width. Must be called before the plot is displayed. Note that there are more options available by using the methods of the Plot class instead.
      • changeFont

        public void changeFont​(java.awt.Font font)
        Deprecated.
        use the corresponding method of the Plot class
        Changes the font. Must be called before the plot is displayed. Note that there are more options available by using the methods of the Plot class instead.
      • draw

        public void draw()
        Displays the plot.
      • setPlot

        public void setPlot​(Plot plot)
        Sets the Plot object shown in this PlotWindow. Does not update the window.
      • dispose

        public void dispose()
        Releases the resources used by this PlotWindow
        Overrides:
        dispose in class java.awt.Window
      • windowActivated

        public void windowActivated​(java.awt.event.WindowEvent e)
        Called when the window is activated (WindowListener) Window layout is finished at latest a few millisec after windowActivated, then the 'wasActivated' boolean is set to tell the ImageCanvas that resize events should lead to resizing the canvas (before, creating the layout can lead to resize events)
        Specified by:
        windowActivated in interface java.awt.event.WindowListener
        Overrides:
        windowActivated in class ImageWindow
      • showStatus

        public void showStatus​(java.lang.String text)
        Shows the text in the coordinate&status readout field at the bottom. This text may get temporarily replaced for 'tooltips' (mouse over range arrows etc.). Call with a null argument to enable coordinate readout again.
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Called if user has activated a button or popup menu item
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • itemStateChanged

        public void itemStateChanged​(java.awt.event.ItemEvent e)
        Called if the user activates/deactivates a CheckboxMenuItem
        Specified by:
        itemStateChanged in interface java.awt.event.ItemListener
      • mouseMoved

        public void mouseMoved​(int x,
                               int y)
        Updates the X and Y values when the mouse is moved and, if appropriate, shows/hides the overlay with the triangular buttons for changing the axis range limits. Overrides mouseMoved() in ImageWindow.
        Overrides:
        mouseMoved in class ImageWindow
        See Also:
        ImageWindow.mouseMoved(int, int)
      • mouseWheelMoved

        public void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
        Mouse wheel: zooms when shift or ctrl is pressed, scrolls in x if space bar down, in y otherwise.
        Specified by:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
        Overrides:
        mouseWheelMoved in class ImageWindow
      • getResultsTable

        public ResultsTable getResultsTable()
        Returns the plot values with simple headings (X, Y, Y1 etc, not the labels) as a ResultsTable. Use plot.getResultsTableWithLabels for a table with data set labels as column headings
      • lostOwnership

        public void lostOwnership​(java.awt.datatransfer.Clipboard clipboard,
                                  java.awt.datatransfer.Transferable contents)
        Specified by:
        lostOwnership in interface java.awt.datatransfer.ClipboardOwner
      • getXValues

        public float[] getXValues()
      • getYValues

        public float[] getYValues()
      • drawPlot

        public void drawPlot​(Plot plot)
        Draws a new plot in this window.
      • savePreferences

        public static void savePreferences​(java.util.Properties prefs)
        Called once when ImageJ quits.
      • roiModified

        public void roiModified​(ImagePlus img,
                                int id)
        For live plots, update the plot if the ROI of the source image changes
        Specified by:
        roiModified in interface RoiListener
      • imageUpdated

        public void imageUpdated​(ImagePlus imp)
        For live plots, this method is called if the source image content is changed.
        Specified by:
        imageUpdated in interface ImageListener
      • imageClosed

        public void imageClosed​(ImagePlus imp)
        For live plots, if either the source image or this image are closed, exit live mode
        Specified by:
        imageClosed in interface ImageListener
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • getPlot

        public Plot getPlot()
        Returns the Plot associated with this PlotWindow.
      • freeze

        public static void freeze()
        Freezes the active plot window, so the image does not get redrawn for zooming, setting the range, etc.
      • setDefaultFontSize

        public static void setDefaultFontSize​(int size)
      • getDefaultFontSize

        public static int getDefaultFontSize()