Class JDialogCaptureScreen

All Implemented Interfaces:
DialogDefaultsInterface, ActionListener, ComponentListener, FocusListener, ItemListener, MouseListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JDialogCaptureScreen extends JDialogBase implements MouseListener, 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:
  • Field Details

    • serialVersionUID

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

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

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

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

      private JLabel instructions3
      Instructions on how to use screen capture, line 3.
    • mode

      Mode - region or window
    • 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 JFrame[] oldFrames
      All the valid JFrames in the GUI.
    • oldPanes

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

      private 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 JRadioButton displayCheck
      Button for selecting display in window.
    • copyCheck

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

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

      private ViewUserInterface userInterface
      Pointer to the user interface.
    • windowButton

      private JRadioButton windowButton
      Button for selecting window mode.
    • activeFrame

      public ViewJFrameImage activeFrame
      Active frame
    • fileField

      private 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 String fileName
      String to house the user inputed file name
    • currImage

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

      private Image imagePix
      The image selected by the user
    • insertButton

      private 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 Details

    • 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 Details

    • actionPerformed

      public void actionPerformed(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 ActionListener
      Overrides:
      actionPerformed in class JDialogBase
      Parameters:
      event - Event that triggered this function.
    • itemStateChanged

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

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

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

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

      public void mousePressed(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 MouseListener
      Parameters:
      e - Event that triggered this function.
    • mouseReleased

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

      public void windowActivated(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 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(WindowEvent event)
      window closing
      Specified by:
      windowClosing in interface WindowListener
      Overrides:
      windowClosing in class JDialogBase
      Parameters:
      event - WindowEvent
    • componentHidden

      public void componentHidden(ComponentEvent e)
      Specified by:
      componentHidden in interface ComponentListener
    • componentMoved

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

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

      public void componentShown(ComponentEvent e)
      Specified by:
      componentShown in interface ComponentListener