Class SyncWindows

All Implemented Interfaces:
ImageListener, PlugIn, ActionListener, FocusListener, ItemListener, MouseListener, MouseMotionListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

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 <phkelly@ucsd.edu>; Improved GUI, support of image coordinates and z-slices by Joachim Walter <correspondence@walter-witzenhausen.de>
See Also:
  • Field Details

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

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

    • 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:
      mouseMoved in interface MouseMotionListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Propagate mouse dragged events to all synchronized windows.
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Propagate mouse clicked events to all synchronized windows.
      Specified by:
      mouseClicked in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Propagate mouse entered events to all synchronized windows.
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Propagate mouse exited events to all synchronized windows.
      Specified by:
      mouseExited in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Propagate mouse pressed events to all synchronized windows.
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Propagate mouse released events to all synchronized windows.
      Specified by:
      mouseReleased in interface MouseListener
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Implementation of ActionListener interface.
      Specified by:
      actionPerformed in interface ActionListener
    • itemStateChanged

      public void itemStateChanged(ItemEvent e)
      Item Listener method
      Specified by:
      itemStateChanged in interface ItemListener
    • windowClosing

      public void windowClosing(WindowEvent e)
      Override parent windowClosing method to clean up synchronized resources on exit.
      Specified by:
      windowClosing in interface WindowListener
      Overrides:
      windowClosing in class PlugInFrame
    • imageOpened

      public void imageOpened(ImagePlus imp)
      Implementation of ImageListener interface: update window list, if image is opened or closed
      Specified by:
      imageOpened in interface ImageListener
    • imageClosed

      public void imageClosed(ImagePlus imp)
      Implementation of ImageListener interface: update window list, if image is opened or closed
      Specified by:
      imageClosed in interface ImageListener
    • imageUpdated

      public void imageUpdated(ImagePlus imp)
      Specified by:
      imageUpdated in interface ImageListener
    • 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()
    • setCursor

      public void setCursor(ImagePlus imp, Roi cursor)
    • 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.
    • getInsets

      public Insets getInsets()
      Overrides:
      getInsets in class Container
    • close

      public void close()
      Description copied from class: PlugInFrame
      Closes this window.
      Overrides:
      close in class PlugInFrame
    • getInstance

      public static SyncWindows getInstance()