- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Frame
-
- ij.plugin.frame.PlugInFrame
-
- ij.plugin.frame.SyncWindows
-
- All Implemented Interfaces:
CommandListener,ImageListener,PlugIn,ActionListener,FocusListener,ItemListener,MouseListener,MouseMotionListener,WindowListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible
public class SyncWindows extends PlugInFrame implements ActionListener, MouseMotionListener, MouseListener, ItemListener, ImageListener, CommandListener
This class "synchronizes" mouse input in multiple windows. Once several windows are synchronized, mouse events in any one of the synchronized windows are propagated to the others. Note, the notion of synchronization use by the SyncWindows class here (i.e. multiple windows that all get the same mouse input) is somewhat different than the use of the synchronize keyword in the Java language. (In Java, synchronize has to do w/ critical section access by multiple threads.)Optionally passes on change of z-slice of a stack to other stacks; Optionally translates positions to different windows via offscreen coordinates, i.e. correctly translates coordinates to windows with a different zoom; Updates the list of windows by click of a button;
- Author:
- Patrick Kelly
; Improved GUI, support of image coordinates and z-slices by Joachim Walter - See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
-
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected ButtonbSyncAllButtons for user control.protected ButtonbUnsyncAllButtons for user control.protected CheckboxcChannelCheckboxes for user control.protected CheckboxcCoordsCheckboxes for user control.protected CheckboxcCursorCheckboxes for user control.protected CheckboxcFrameCheckboxes for user control.protected CheckboxcScalingCheckboxes for user control.protected CheckboxcSliceCheckboxes for user control.protected ImageJijInstancereference to current instance of ImageJ (to avoid repeated IJ.getInstance() s)protected intoldXprotected intoldYprotected PanelpanelPanel for GUIprotected VectorvListMapHashtable to map list ids to image window ids.protected VectorvwinsIndices of synchronized image windows are maintained in this Vector.protected ListwListList of currently displayed windows retrieved from ImageJ window manager.protected intxprotected inty-
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, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description SyncWindows()Create window sync frame.SyncWindows(String s)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(ActionEvent e)Implementation of ActionListener interface.protected RectangleboundingRect(int x, int y, int oldX, int oldY)Compute bounding rectangle given current and old cursor locations.protected PanelbuildControlPanel()Builds panel containing control buttons.protected ComponentbuildWindowList()Builds list of open ImageWindowsvoidclose()Closes this window.StringcommandExecuting(String command)protected PanelcontrolPanel()Build window list display and button controls.voiddisplayChanged(ij.plugin.frame.DisplayChangeEvent e)Method to pass on changes of the z-slice of a stack.ImagePlusgetImageFromVector(int n)Get ImagePlus from Windows-Vector vwins.StringgetImageTitleFromVector(int n)Get the title of image n from Windows-Vector vwins.intgetIndexOfImage(ImagePlus image)Get index of "image" in vector of synchronized windows, if image is in vector.InsetsgetInsets()static SyncWindowsgetInstance()protected PointgetMatchingCoords(ImageCanvas ic, ImageCanvas icc, int x, int y)Get Screen Coordinates for ImageCanvas ic matching the OffScreen Coordinates of the current ImageCanvas.voidimageClosed(ImagePlus imp)Implementation of ImageListener interface: update window list, if image is opened or closedvoidimageOpened(ImagePlus imp)Implementation of ImageListener interface: update window list, if image is opened or closedvoidimageUpdated(ImagePlus imp)voiditemStateChanged(ItemEvent e)Item Listener methodvoidmouseClicked(MouseEvent e)Propagate mouse clicked events to all synchronized windows.voidmouseDragged(MouseEvent e)Propagate mouse dragged events to all synchronized windows.voidmouseEntered(MouseEvent e)Propagate mouse entered events to all synchronized windows.voidmouseExited(MouseEvent e)Propagate mouse exited events to all synchronized windows.voidmouseMoved(MouseEvent e)Draws the "synchronize" cursor in each of the synchronized windows.voidmousePressed(MouseEvent e)Propagate mouse pressed events to all synchronized windows.voidmouseReleased(MouseEvent e)Propagate mouse released events to all synchronized windows.static voidsetC(ImageWindow source, int channel)voidsetCursor(ImagePlus imp, Roi cursor)static voidsetT(ImageWindow source, int frame)static voidsetZ(ImageWindow source, int slice)protected voidupdateWindowList()voidwindowClosing(WindowEvent e)Override parent windowClosing method to clean up synchronized resources on exit.-
Methods inherited from class ij.plugin.frame.PlugInFrame
focusGained, focusLost, run, windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
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, 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, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
-
Methods inherited from class java.awt.Container
add, 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, toString, 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
-
vwins
protected Vector vwins
Indices of synchronized image windows are maintained in this Vector.
-
oldX
protected int oldX
-
oldY
protected int oldY
-
x
protected int x
-
y
protected int y
-
wList
protected List wList
List of currently displayed windows retrieved from ImageJ window manager.
-
panel
protected Panel panel
Panel for GUI
-
cCursor
protected Checkbox cCursor
Checkboxes for user control.
-
cSlice
protected Checkbox cSlice
Checkboxes for user control.
-
cChannel
protected Checkbox cChannel
Checkboxes for user control.
-
cFrame
protected Checkbox cFrame
Checkboxes for user control.
-
cCoords
protected Checkbox cCoords
Checkboxes for user control.
-
cScaling
protected Checkbox cScaling
Checkboxes for user control.
-
bSyncAll
protected Button bSyncAll
Buttons for user control.
-
bUnsyncAll
protected Button bUnsyncAll
Buttons for user control.
-
vListMap
protected Vector vListMap
Hashtable to map list ids to image window ids.
-
ijInstance
protected final ImageJ ijInstance
reference to current instance of ImageJ (to avoid repeated IJ.getInstance() s)
-
-
Constructor Detail
-
SyncWindows
public SyncWindows()
Create window sync frame. Frame is shown via call to show() or by invoking run method.
-
SyncWindows
public SyncWindows(String s)
-
-
Method Detail
-
setC
public static void setC(ImageWindow source, int channel)
-
setZ
public static void setZ(ImageWindow source, int slice)
-
setT
public static void setT(ImageWindow source, int frame)
-
displayChanged
public void displayChanged(ij.plugin.frame.DisplayChangeEvent e)
Method to pass on changes of the z-slice of a stack.
-
mouseMoved
public void mouseMoved(MouseEvent e)
Draws the "synchronize" cursor in each of the synchronized windows.- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mouseDragged
public void mouseDragged(MouseEvent e)
Propagate mouse dragged events to all synchronized windows.- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseClicked
public void mouseClicked(MouseEvent e)
Propagate mouse clicked events to all synchronized windows.- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
public void mouseEntered(MouseEvent e)
Propagate mouse entered events to all synchronized windows.- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
public void mouseExited(MouseEvent e)
Propagate mouse exited events to all synchronized windows.- Specified by:
mouseExitedin interfaceMouseListener
-
mousePressed
public void mousePressed(MouseEvent e)
Propagate mouse pressed events to all synchronized windows.- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
public void mouseReleased(MouseEvent e)
Propagate mouse released events to all synchronized windows.- Specified by:
mouseReleasedin interfaceMouseListener
-
actionPerformed
public void actionPerformed(ActionEvent e)
Implementation of ActionListener interface.- Specified by:
actionPerformedin interfaceActionListener
-
itemStateChanged
public void itemStateChanged(ItemEvent e)
Item Listener method- Specified by:
itemStateChangedin interfaceItemListener
-
windowClosing
public void windowClosing(WindowEvent e)
Override parent windowClosing method to clean up synchronized resources on exit.- Specified by:
windowClosingin interfaceWindowListener- Overrides:
windowClosingin classPlugInFrame
-
imageOpened
public void imageOpened(ImagePlus imp)
Implementation of ImageListener interface: update window list, if image is opened or closed- Specified by:
imageOpenedin interfaceImageListener
-
imageClosed
public void imageClosed(ImagePlus imp)
Implementation of ImageListener interface: update window list, if image is opened or closed- Specified by:
imageClosedin interfaceImageListener
-
imageUpdated
public void imageUpdated(ImagePlus imp)
- Specified by:
imageUpdatedin interfaceImageListener
-
controlPanel
protected Panel controlPanel()
Build window list display and button controls. Create Hashtable that connects list entries to window IDs.
-
buildWindowList
protected Component buildWindowList()
Builds list of open ImageWindows
-
buildControlPanel
protected Panel buildControlPanel()
Builds panel containing control buttons.
-
boundingRect
protected Rectangle boundingRect(int x, int y, int oldX, int oldY)
Compute bounding rectangle given current and old cursor locations. This is used to determine what part of image to redraw.
-
updateWindowList
protected void updateWindowList()
-
getImageFromVector
public ImagePlus getImageFromVector(int n)
Get ImagePlus from Windows-Vector vwins.
-
getImageTitleFromVector
public String getImageTitleFromVector(int n)
Get the title of image n from Windows-Vector vwins. If the image ends with .tif, the extension is removed.
-
getIndexOfImage
public int getIndexOfImage(ImagePlus image)
Get index of "image" in vector of synchronized windows, if image is in vector. Else return -1.
-
getMatchingCoords
protected Point getMatchingCoords(ImageCanvas ic, ImageCanvas icc, int x, int y)
Get Screen Coordinates for ImageCanvas ic matching the OffScreen Coordinates of the current ImageCanvas. (srcRect and magnification stored after each received event.) Input: The target ImageCanvas, the current ImageCanvas, x-ScreenCoordinate for current Canvas, y-ScreenCoordinate for current Canvas If the "ImageScaling" checkbox is selected, Scaling and Offset of the images are taken into account.
-
close
public void close()
Description copied from class:PlugInFrameCloses this window.- Overrides:
closein classPlugInFrame
-
getInstance
public static SyncWindows getInstance()
-
commandExecuting
public String commandExecuting(String command)
- Specified by:
commandExecutingin interfaceCommandListener
-
-