Package gov.nih.mipav.view.dialogs
Class JDialogCaptureScreen
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Dialog
-
- javax.swing.JDialog
-
- gov.nih.mipav.view.dialogs.JDialogBase
-
- gov.nih.mipav.view.dialogs.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 gov.nih.mipav.view.dialogs.JDialogBase
JDialogBase.CancelAction, JDialogBase.HelpAction, JDialogBase.OKAction
-
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
-
-
Field Summary
Fields Modifier and Type Field Description ViewJFrameImage
activeFrame
Active frameprivate boolean
copy
Flag that indicates whether to copy capture to clipboardprivate 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 userprivate 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 attachedjava.lang.String
fileName
String to house the user inputed file nameprivate boolean
imageAttacher
Boolean indicating if JDialogCaptureScreen has been initialized through ReportBugBuilderprivate java.awt.Image
imagePix
The image selected by the userboolean
insert
Boolean indicating if the Insert button has been pressedprivate javax.swing.JButton
insertButton
Button for inserting the image into the body of a bug reportprivate 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 windowprivate 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 formprivate 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 gov.nih.mipav.view.dialogs.JDialogBase
applyButton, bar, cancelButton, cancelFlag, closeButton, HELP, helpButton, mainDialogPanel, NEW, OKButton, parentFrame, progressBar, REPLACE, runInSeparateThread, runningScriptFlag, runQuiet, serif12, serif12B, voiManager
-
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
Constructor Summary
Constructors Constructor Description JDialogCaptureScreen(ViewJFrameImage parent)
Creates new dialog for screen capture.JDialogCaptureScreen(ViewJFrameImage parent, boolean bugReport)
-
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 imagevoid
componentResized(java.awt.event.ComponentEvent event)
Resizes the currentRectangle to the dimensions of the changed windowvoid
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 closingprivate boolean
writeImage()
Writes the image captured from the screen, using currentRectangle as the bounding box of the capture.-
Methods inherited from class gov.nih.mipav.view.dialogs.JDialogBase
buildApplyButton, buildButtons, buildCancelButton, buildCancelButton, buildCloseButton, buildHelpButton, buildImageComboBox, buildOKButton, buildOKButton, buildOKCancelButtons, buildTitledBorder, buildTitledBorder, createLabel, createProgressBar, createProgressBar, createTextField, focusGained, focusLost, getDialogName, isCancelled, isQuietRunning, isRunInSeparateThread, isScriptRunning, loadDefaults, loadDefaults, makeImageName, makeString, openNewFrame, saveDefaults, saveDefaults, setLeftHandSystem, setQuietRunning, setScriptRunning, setSeparateThread, setVisible, setVisible, setVisibleMenuBar, setVisibleStandard, setVOIManager, setWCSystem, testParameter, testParameterMin, updateFFTFileInfo, updateFileInfo, updateFileInfoOtherModality, updateFileInfoStatic, updateFileInfoStatic, updateFileTypeInfo, updateFileTypeInfo, windowClosed, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
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
-
-
-
-
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.
-
mode
private JDialogCaptureScreen.WindowProperties 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 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.
-
activeFrame
public ViewJFrameImage activeFrame
Active frame
-
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 interfacejava.awt.event.ActionListener
- Overrides:
actionPerformed
in classJDialogBase
- 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 interfacejava.awt.event.ItemListener
- Overrides:
itemStateChanged
in classJDialogBase
- Parameters:
event
- Event that triggered this function.
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
Unchanged.- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
- Parameters:
e
- DOCUMENT ME!
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
Unchanged.- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
- Parameters:
e
- DOCUMENT ME!
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
Unchanged.- Specified by:
mouseExited
in interfacejava.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 interfacejava.awt.event.MouseListener
- Parameters:
e
- Event that triggered this function.
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
Unchanged.- Specified by:
mouseReleased
in interfacejava.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 interfacejava.awt.event.WindowListener
- Overrides:
windowActivated
in classJDialogBase
- 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 interfacejava.awt.event.WindowListener
- Overrides:
windowClosing
in classJDialogBase
- Parameters:
event
- WindowEvent
-
componentHidden
public void componentHidden(java.awt.event.ComponentEvent e)
- Specified by:
componentHidden
in interfacejava.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 interfacejava.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 interfacejava.awt.event.ComponentListener
-
componentShown
public void componentShown(java.awt.event.ComponentEvent e)
- Specified by:
componentShown
in interfacejava.awt.event.ComponentListener
-
-