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,ActionListener,ComponentListener,FocusListener,ItemListener,MouseListener,WindowListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classListener for the glass panes.private classchanges an image to a Transferable(package private) classOur special glass panes draw rectangles based on how the user traces them using the mouse.static enumNested classes/interfaces inherited from class gov.nih.mipav.view.dialogs.JDialogBase
JDialogBase.CancelAction, JDialogBase.HelpAction, JDialogBase.OKActionNested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialogNested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionActive frameprivate booleanFlag that indicates whether to copy capture to clipboardprivate JRadioButtonButton for selecting copy to clipboard.private RectangleThe rectangle that will be captured from the screen to save to a file.static BufferedImageThe buffered image selected by the userprivate booleanFlag that indicates whether to put capture in a new frame on screen.private JRadioButtonButton for selecting display in window.private JTextFieldJTextField for the name of the file being attachedString to house the user inputed file nameprivate booleanBoolean indicating if JDialogCaptureScreen has been initialized through ReportBugBuilderprivate ImageThe image selected by the userbooleanBoolean indicating if the Insert button has been pressedprivate JButtonButton for inserting the image into the body of a bug reportprivate JLabelInstructions on how to use screen capture, line 1.private JLabelInstructions on how to use screen capture, line 2.private JLabelInstructions on how to use screen capture, line 3.Mode - region or windowprivate JDialogCaptureScreen.MyGlassPane[]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.booleanBoolean indicating if the OK button has been pressed when JDialogCaptureScreen is launched through the report bug formprivate JFrame[]All the valid JFrames in the GUI.private Component[]Old glass panes to reset to after drawing is done.private JRadioButtonButton for selecting region mode.private booleanFlag that indicates whether to save capture as file.private JRadioButtonButton for selecting save to computer.private static final longUse serialVersionUID for interoperability.private ViewUserInterfacePointer to the user interface.private JRadioButtonButton 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, voiManagerFields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPEFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsConstructorDescriptionJDialogCaptureScreen(ViewJFrameImage parent) Creates new dialog for screen capture.JDialogCaptureScreen(ViewJFrameImage parent, boolean bugReport) -
Method Summary
Modifier and TypeMethodDescriptionvoidactionPerformed(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.voidvoidcomponentMoved(ComponentEvent event) Moves the currentRectangle to the location of the window on the screen to maintain the correct imagevoidcomponentResized(ComponentEvent event) Resizes the currentRectangle to the dimensions of the changed windowvoidprivate voidinit()Initialize GUI.voidinit(boolean imageAttacher) Initialize GUI for the bug report form.voiditemStateChanged(ItemEvent event) Sets save, copy, and display flags based on whether or not they are selected.voidUnchanged.voidUnchanged.voidUnchanged.voidWhen the user presses the mouse in any valid frame of the GUI, causes all the glass panes to repaint.voidUnchanged.voidwindowActivated(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.voidwindowClosing(WindowEvent event) window closingprivate booleanWrites 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, windowOpenedMethods 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, updateMethods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBackMethods 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, toFrontMethods 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, validateTreeMethods 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 Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
currentRectangle
The rectangle that will be captured from the screen to save to a file. -
instructions
Instructions on how to use screen capture, line 1. -
instructions2
Instructions on how to use screen capture, line 2. -
instructions3
Instructions on how to use screen capture, line 3. -
mode
Mode - region or window -
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
All the valid JFrames in the GUI. -
oldPanes
Old glass panes to reset to after drawing is done. -
regionButton
Button for selecting region mode. -
save
private boolean saveFlag that indicates whether to save capture as file. -
copy
private boolean copyFlag that indicates whether to copy capture to clipboard -
display
private boolean displayFlag that indicates whether to put capture in a new frame on screen. -
displayCheck
Button for selecting display in window. -
copyCheck
Button for selecting copy to clipboard. -
saveCheck
Button for selecting save to computer. -
userInterface
Pointer to the user interface. -
windowButton
Button for selecting window mode. -
activeFrame
Active frame -
fileField
JTextField for the name of the file being attached -
ok
public boolean okBoolean indicating if the OK button has been pressed when JDialogCaptureScreen is launched through the report bug form -
fileName
String to house the user inputed file name -
currImage
The buffered image selected by the user -
imagePix
The image selected by the user -
insertButton
Button for inserting the image into the body of a bug report -
insert
public boolean insertBoolean indicating if the Insert button has been pressed -
imageAttacher
private boolean imageAttacherBoolean indicating if JDialogCaptureScreen has been initialized through ReportBugBuilder
-
-
Constructor Details
-
JDialogCaptureScreen
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
-
-
Method Details
-
actionPerformed
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:
actionPerformedin interfaceActionListener- Overrides:
actionPerformedin classJDialogBase- Parameters:
event- Event that triggered this function.
-
itemStateChanged
Sets save, copy, and display flags based on whether or not they are selected.- Specified by:
itemStateChangedin interfaceItemListener- Overrides:
itemStateChangedin classJDialogBase- Parameters:
event- Event that triggered this function.
-
mouseClicked
Unchanged.- Specified by:
mouseClickedin interfaceMouseListener- Parameters:
e- DOCUMENT ME!
-
mouseEntered
Unchanged.- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
e- DOCUMENT ME!
-
mouseExited
Unchanged.- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
e- DOCUMENT ME!
-
mousePressed
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:
mousePressedin interfaceMouseListener- Parameters:
e- Event that triggered this function.
-
mouseReleased
Unchanged.- Specified by:
mouseReleasedin interfaceMouseListener- Parameters:
e- DOCUMENT ME!
-
windowActivated
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:
windowActivatedin interfaceWindowListener- Overrides:
windowActivatedin 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
window closing- Specified by:
windowClosingin interfaceWindowListener- Overrides:
windowClosingin classJDialogBase- Parameters:
event- WindowEvent
-
componentHidden
- Specified by:
componentHiddenin interfaceComponentListener
-
componentMoved
Moves the currentRectangle to the location of the window on the screen to maintain the correct image- Specified by:
componentMovedin interfaceComponentListener
-
componentResized
Resizes the currentRectangle to the dimensions of the changed window- Specified by:
componentResizedin interfaceComponentListener
-
componentShown
- Specified by:
componentShownin interfaceComponentListener
-