Class JDialogCaptureScreen

  • All Implemented Interfaces:
    DialogDefaultsInterface, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.MouseListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class JDialogCaptureScreen
    extends JDialogBase
    implements java.awt.event.MouseListener, java.awt.event.ComponentListener
    Dialog for creating and saving a screen capture to a TIFF file. The user can draw a rectangle around the region to save, or can choose a window and the object in the window will be saved. Anything drawn on the image will also be saved. This class uses the glass panes of the JFrames created by MIPAV to draw the bounding boxes. Therefore anything created by MIPAV is fair game to draw upon, but clicking elsewhere on the screen will make MIPAV inactive and the rectangle drawn invalid.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  JDialogCaptureScreen.GlassPaneListener
      Listener for the glass panes.
      private class  JDialogCaptureScreen.ImageConverter
      changes an image to a Transferable
      (package private) class  JDialogCaptureScreen.MyGlassPane
      Our special glass panes draw rectangles based on how the user traces them using the mouse.
      static class  JDialogCaptureScreen.WindowProperties  
      • Nested classes/interfaces inherited from class javax.swing.JDialog

        javax.swing.JDialog.AccessibleJDialog
      • Nested classes/interfaces inherited from class java.awt.Dialog

        java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
      • 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
      ViewJFrameImage activeFrame
      Active frame
      private boolean copy
      Flag that indicates whether to copy capture to clipboard
      private javax.swing.JRadioButton copyCheck
      Button for selecting copy to clipboard.
      private java.awt.Rectangle currentRectangle
      The rectangle that will be captured from the screen to save to a file.
      static java.awt.image.BufferedImage currImage
      The buffered image selected by the user
      private boolean display
      Flag that indicates whether to put capture in a new frame on screen.
      private javax.swing.JRadioButton displayCheck
      Button for selecting display in window.
      private javax.swing.JTextField fileField
      JTextField for the name of the file being attached
      java.lang.String fileName
      String to house the user inputed file name
      private boolean imageAttacher
      Boolean indicating if JDialogCaptureScreen has been initialized through ReportBugBuilder
      private java.awt.Image imagePix
      The image selected by the user
      boolean insert
      Boolean indicating if the Insert button has been pressed
      private javax.swing.JButton insertButton
      Button for inserting the image into the body of a bug report
      private javax.swing.JLabel instructions
      Instructions on how to use screen capture, line 1.
      private javax.swing.JLabel instructions2
      Instructions on how to use screen capture, line 2.
      private javax.swing.JLabel instructions3
      Instructions on how to use screen capture, line 3.
      private JDialogCaptureScreen.WindowProperties mode
      Mode - region or window
      private JDialogCaptureScreen.MyGlassPane[] myGlassPanes
      Special glass panes for all the valid frames in the GUI so that the user can draw rectangles on top of objects in the GUI.
      boolean ok
      Boolean indicating if the OK button has been pressed when JDialogCaptureScreen is launched through the report bug form
      private javax.swing.JFrame[] oldFrames
      All the valid JFrames in the GUI.
      private java.awt.Component[] oldPanes
      Old glass panes to reset to after drawing is done.
      private javax.swing.JRadioButton regionButton
      Button for selecting region mode.
      private boolean save
      Flag that indicates whether to save capture as file.
      private javax.swing.JRadioButton saveCheck
      Button for selecting save to computer.
      private static long serialVersionUID
      Use serialVersionUID for interoperability.
      private ViewUserInterface userInterface
      Pointer to the user interface.
      private javax.swing.JRadioButton windowButton
      Button for selecting window mode.
      • Fields inherited from class javax.swing.JDialog

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Dialog

        DEFAULT_MODALITY_TYPE
      • Fields inherited from class java.awt.Component

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

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)
      Performs the following actions based on the command:
      OK - uses the "current rectangle" set either by a listener of a glass pane (region mode) or by the window listener (window mode) Cancel - cleans up and disposes the dialog Region - sets all the glass panes visible to enable drawing on top of objects without selecting them Window - sets the glass panes invisible; then when a window is selected, the listener will save that rectangle.
      void componentHidden​(java.awt.event.ComponentEvent e)  
      void componentMoved​(java.awt.event.ComponentEvent event)
      Moves the currentRectangle to the location of the window on the screen to maintain the correct image
      void componentResized​(java.awt.event.ComponentEvent event)
      Resizes the currentRectangle to the dimensions of the changed window
      void componentShown​(java.awt.event.ComponentEvent e)  
      private void init()
      Initialize GUI.
      void init​(boolean imageAttacher)
      Initialize GUI for the bug report form.
      void itemStateChanged​(java.awt.event.ItemEvent event)
      Sets save, copy, and display flags based on whether or not they are selected.
      void mouseClicked​(java.awt.event.MouseEvent e)
      Unchanged.
      void mouseEntered​(java.awt.event.MouseEvent e)
      Unchanged.
      void mouseExited​(java.awt.event.MouseEvent e)
      Unchanged.
      void mousePressed​(java.awt.event.MouseEvent e)
      When the user presses the mouse in any valid frame of the GUI, causes all the glass panes to repaint.
      void mouseReleased​(java.awt.event.MouseEvent e)
      Unchanged.
      void windowActivated​(java.awt.event.WindowEvent event)
      If in Window mode, captures the content pane of the window activated and sets the current rectangle to the bounds of the content pane.
      void windowClosing​(java.awt.event.WindowEvent event)
      window closing
      private boolean writeImage()
      Writes the image captured from the screen, using currentRectangle as the bounding box of the capture.
      • Methods inherited from class javax.swing.JDialog

        addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Dialog

        addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
      • Methods inherited from class java.awt.Window

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

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, 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, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • currentRectangle

        private java.awt.Rectangle currentRectangle
        The rectangle that will be captured from the screen to save to a file.
      • instructions

        private javax.swing.JLabel instructions
        Instructions on how to use screen capture, line 1.
      • instructions2

        private javax.swing.JLabel instructions2
        Instructions on how to use screen capture, line 2.
      • instructions3

        private javax.swing.JLabel instructions3
        Instructions on how to use screen capture, line 3.
      • myGlassPanes

        private JDialogCaptureScreen.MyGlassPane[] myGlassPanes
        Special glass panes for all the valid frames in the GUI so that the user can draw rectangles on top of objects in the GUI.
      • oldFrames

        private javax.swing.JFrame[] oldFrames
        All the valid JFrames in the GUI.
      • oldPanes

        private java.awt.Component[] oldPanes
        Old glass panes to reset to after drawing is done.
      • regionButton

        private javax.swing.JRadioButton regionButton
        Button for selecting region mode.
      • save

        private boolean save
        Flag that indicates whether to save capture as file.
      • copy

        private boolean copy
        Flag that indicates whether to copy capture to clipboard
      • display

        private boolean display
        Flag that indicates whether to put capture in a new frame on screen.
      • displayCheck

        private javax.swing.JRadioButton displayCheck
        Button for selecting display in window.
      • copyCheck

        private javax.swing.JRadioButton copyCheck
        Button for selecting copy to clipboard.
      • saveCheck

        private javax.swing.JRadioButton saveCheck
        Button for selecting save to computer.
      • userInterface

        private ViewUserInterface userInterface
        Pointer to the user interface.
      • windowButton

        private javax.swing.JRadioButton windowButton
        Button for selecting window mode.
      • fileField

        private javax.swing.JTextField fileField
        JTextField for the name of the file being attached
      • ok

        public boolean ok
        Boolean indicating if the OK button has been pressed when JDialogCaptureScreen is launched through the report bug form
      • fileName

        public java.lang.String fileName
        String to house the user inputed file name
      • currImage

        public static java.awt.image.BufferedImage currImage
        The buffered image selected by the user
      • imagePix

        private java.awt.Image imagePix
        The image selected by the user
      • insertButton

        private javax.swing.JButton insertButton
        Button for inserting the image into the body of a bug report
      • insert

        public boolean insert
        Boolean indicating if the Insert button has been pressed
      • imageAttacher

        private boolean imageAttacher
        Boolean indicating if JDialogCaptureScreen has been initialized through ReportBugBuilder
    • Constructor Detail

      • JDialogCaptureScreen

        public JDialogCaptureScreen​(ViewJFrameImage parent)
        Creates new dialog for screen capture. Sets up glass panes of all the JFrames currently in the user interface so that we can draw on the frame to delineate a bounding box for a capture.
        Parameters:
        parent - Parent frame of this dialog.
      • JDialogCaptureScreen

        public JDialogCaptureScreen​(ViewJFrameImage parent,
                                    boolean bugReport)
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent event)
        Performs the following actions based on the command:
        • OK - uses the "current rectangle" set either by a listener of a glass pane (region mode) or by the window listener (window mode)
        • Cancel - cleans up and disposes the dialog
        • Region - sets all the glass panes visible to enable drawing on top of objects without selecting them
        • Window - sets the glass panes invisible; then when a window is selected, the listener will save that rectangle.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Overrides:
        actionPerformed in class JDialogBase
        Parameters:
        event - Event that triggered this function.
      • itemStateChanged

        public void itemStateChanged​(java.awt.event.ItemEvent event)
        Sets save, copy, and display flags based on whether or not they are selected.
        Specified by:
        itemStateChanged in interface java.awt.event.ItemListener
        Overrides:
        itemStateChanged in class JDialogBase
        Parameters:
        event - Event that triggered this function.
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        Unchanged.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        e - DOCUMENT ME!
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        Unchanged.
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        e - DOCUMENT ME!
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Unchanged.
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Parameters:
        e - DOCUMENT ME!
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        When the user presses the mouse in any valid frame of the GUI, causes all the glass panes to repaint. This is so that multiple rectangles in different windows won't show up on the screen.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Parameters:
        e - Event that triggered this function.
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Unchanged.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Parameters:
        e - DOCUMENT ME!
      • windowActivated

        public void windowActivated​(java.awt.event.WindowEvent event)
        If in Window mode, captures the content pane of the window activated and sets the current rectangle to the bounds of the content pane.
        Specified by:
        windowActivated in interface java.awt.event.WindowListener
        Overrides:
        windowActivated in class JDialogBase
        Parameters:
        event - Event that triggered this method.
      • init

        private void init()
        Initialize GUI. This is a very simple dialog, with two radio buttons to indicate the mode (drawing a region or selecting a window), a label for instructions, and an OK and Cancel button.
      • init

        public void init​(boolean imageAttacher)
        Initialize GUI for the bug report form. This form includes an instruction section, field for a file name, and Insert, Ok, and Cancel buttons.
      • writeImage

        private boolean writeImage()
        Writes the image captured from the screen, using currentRectangle as the bounding box of the capture. Converts pixels grabbed using a Robot to an RGB TIFF file.
        Returns:
        DOCUMENT ME!
      • windowClosing

        public void windowClosing​(java.awt.event.WindowEvent event)
        window closing
        Specified by:
        windowClosing in interface java.awt.event.WindowListener
        Overrides:
        windowClosing in class JDialogBase
        Parameters:
        event - WindowEvent
      • componentHidden

        public void componentHidden​(java.awt.event.ComponentEvent e)
        Specified by:
        componentHidden in interface java.awt.event.ComponentListener
      • componentMoved

        public void componentMoved​(java.awt.event.ComponentEvent event)
        Moves the currentRectangle to the location of the window on the screen to maintain the correct image
        Specified by:
        componentMoved in interface java.awt.event.ComponentListener
      • componentResized

        public void componentResized​(java.awt.event.ComponentEvent event)
        Resizes the currentRectangle to the dimensions of the changed window
        Specified by:
        componentResized in interface java.awt.event.ComponentListener
      • componentShown

        public void componentShown​(java.awt.event.ComponentEvent e)
        Specified by:
        componentShown in interface java.awt.event.ComponentListener