Package sc.fiji.snt

Class BookmarkManager

java.lang.Object
sc.fiji.snt.BookmarkManager

public class BookmarkManager extends Object
Implements the Bookmark Manager pane.
Author:
Tiago Ferreira
  • Constructor Summary

    Constructors
    Constructor
    Description
    SNT constructor: implements the Bookmark Manager pane embedded in SNT's UI.
    Viewer constructor: implements a standalone marker manager for a BigDataViewer-family viewer (Bvv, Bdv, etc.).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double x, double y, double z)
    BVV mode: adds a marker at the specified world coordinates.
    void
    add(double x, double y, double z, int c, int t)
    Adds a bookmark at the specified world/calibrated coordinates and time/channel positions.
    void
    add(double x, double y, double z, Color color, float size)
    BVV mode: adds a marker at the specified world coordinates with a color and size, and default label.
    void
    add(int x, int y, int z, int c, int t)
    Adds a bookmark at the specified pixel/voxel coordinates and time/channel positions.
    protected void
    add(int x, int y, int z, ij.ImagePlus imp)
     
    void
    add(String label, double x, double y, double z, Color color, float size)
    BVV mode: adds a marker at the specified world coordinates with a color and size.
    void
    add(String label, List<double[]> xyzctLocations)
    Adds multiple bookmarks with the specified label and locations.
    void
    add(String label, List<double[]> xyzctLocations, Color color)
    Adds multiple bookmarks with the specified label, locations, and color tag.
    void
    add(String label, List<SNTPoint> locations, int channel, int frame)
    Adds multiple bookmarks with the specified label and locations.
    void
    add(String label, List<SNTPoint> locations, int channel, int frame, String color)
    Adds multiple bookmarks with the specified label and locations.
    void
    add(Map<Path,Set<Integer>> map, String commonLabel)
    Adds multiple bookmarks from selected path nodes
    void
    add(Path path, int nodeIndex)
    Adds a bookmark at the (world/calibrated) position of the specified path node.
    void
    Adds a component to the viewer toolbar section of this panel.
    void
    Clears the selection of bookmarks in the table.
    int
    Returns the number of bookmarks.
    Returns the position of the most recently added bookmark/marker, in spatially calibrated ("world") coordinates (canonical storage format).
    protected JPanel
     
    getPixelPositions(boolean onlySelectedRows)
    Returns bookmark/marker positions in pixel/voxel coordinates, converted from this manager's canonical world/calibrated storage via worldToPixel(Bookmark).
    getPositions(boolean onlySelectedRows)
    Returns bookmark/marker positions in spatially calibrated ("world") coordinates, i.e., this manager's canonical storage format, returned as-is (fresh copies) in both modes.
    static List<ij.gui.PointRoi>
    getRois(String commonLabel, List<double[]> xyzctLocations)
     
    static List<ij.gui.PointRoi>
    getRois(String commonLabel, List<double[]> xyzctLocations, Color color)
    Creates a list of PointRois from XYZCT locations with a color tag.
    List<ij.gui.Roi>
    getROIs(boolean onlySelectedRows)
    Returns a list of ROIs representing the bookmarks.
    Returns the floating dialog for viewer mode, creating it on first call.
    boolean
    Returns whether any bookmarks exist.
    protected boolean
     
    void
    load(ij.gui.Roi[] rois)
     
    boolean
    load(File file)
    Loads bookmarks from the specified file.
    boolean
    load(String filePathOrURL)
     
    void
    load(List<ij.gui.Roi> rois)
    Loads bookmarks from the specified list of ROIs.
    void
    remove(Path path, int nodeIndex)
     
    void
    Clears all bookmarks.
    boolean
    save(File file)
    Saves bookmarks to the specified file.
    boolean
    save(String filePath)
     
    void
    Shows the marker panel, bringing it to front if already visible.
    void
    Shows or hides this marker manager's UI: redirects to SNTUI's "Bookmarks" tab whenever when SNTUI is present (e.g., in stream mode, see insideSNTUI()), otherwise toggles the floating viewer dialog.
    void
    toOverlay(ij.gui.Overlay overlay)
    Adds the bookmark ROIs to the specified overlay.
    void
    Adds the bookmarks to the ROI Manager.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BookmarkManager

      public BookmarkManager(SNTUI sntui)
      SNT constructor: implements the Bookmark Manager pane embedded in SNT's UI.
    • BookmarkManager

      public BookmarkManager(AbstractBigViewer viewer)
      Viewer constructor: implements a standalone marker manager for a BigDataViewer-family viewer (Bvv, Bdv, etc.). Markers are rendered as spheres/circles in the viewer overlay and can be placed with the M key. The manager is displayed as a floating panel.
      Parameters:
      viewer - the viewer instance to attach to
  • Method Details

    • getViewerDialogPanel

      public JDialog getViewerDialogPanel()
      Returns the floating dialog for viewer mode, creating it on first call.
    • addViewerToolbarButton

      public void addViewerToolbarButton(JComponent component)
      Adds a component to the viewer toolbar section of this panel. The component is appended after a separator the first time this method is called. Viewer subclasses use this to inject context-specific controls (e.g. a slab-clip toggle).
      Parameters:
      component - the component to add; must not be null
    • toggleViewerPanel

      public void toggleViewerPanel()
      Shows or hides this marker manager's UI: redirects to SNTUI's "Bookmarks" tab whenever when SNTUI is present (e.g., in stream mode, see insideSNTUI()), otherwise toggles the floating viewer dialog.
    • showPanel

      public void showPanel()
      Shows the marker panel, bringing it to front if already visible.
    • getPanel

      protected JPanel getPanel()
    • add

      public void add(double x, double y, double z)
      BVV mode: adds a marker at the specified world coordinates. The marker is auto-labeled and immediately rendered in the BVV overlay.
      Parameters:
      x - world x-coordinate
      y - world y-coordinate
      z - world z-coordinate
    • add

      public void add(String label, double x, double y, double z, Color color, float size)
      BVV mode: adds a marker at the specified world coordinates with a color and size.
      Parameters:
      label - the marker's label (will be made unique if a repeated entry exists)
      x - world x-coordinate
      y - world y-coordinate
      z - world z-coordinate
      color - the marker color, or null for the viewer default
      size - the sphere radius in world units; 0 uses the viewer default
    • add

      public void add(double x, double y, double z, Color color, float size)
      BVV mode: adds a marker at the specified world coordinates with a color and size, and default label.
      Parameters:
      x - world x-coordinate
      y - world y-coordinate
      z - world z-coordinate
      color - the marker color, or null for the viewer default
      size - the sphere radius in world units; 0 uses the viewer default
    • add

      protected void add(int x, int y, int z, ij.ImagePlus imp)
      Parameters:
      x - , y, z pixel/voxel coordinates (as sourced from a mouse click on imp)
    • add

      public void add(Path path, int nodeIndex)
      Adds a bookmark at the (world/calibrated) position of the specified path node.
      Parameters:
      path - the path
      nodeIndex - the node index
    • remove

      public void remove(Path path, int nodeIndex)
    • add

      public void add(int x, int y, int z, int c, int t)
      Adds a bookmark at the specified pixel/voxel coordinates and time/channel positions. Coordinates are converted to (and stored as) world/calibrated units using the active image's calibration.
      Parameters:
      x - the x-coordinate of the bookmark, in pixels
      y - the y-coordinate of the bookmark, in pixels
      z - the z-coordinate of the bookmark, in pixels (slice index, 0-based)
      c - the channel position of the bookmark
      t - the time position of the bookmark
    • add

      public void add(double x, double y, double z, int c, int t)
      Adds a bookmark at the specified world/calibrated coordinates and time/channel positions.
      Parameters:
      x - the x-coordinate of the bookmark, in calibrated units
      y - the y-coordinate of the bookmark, in calibrated units
      z - the z-coordinate of the bookmark, in calibrated units
      c - the channel position of the bookmark
      t - the time position of the bookmark
    • add

      public void add(String label, List<SNTPoint> locations, int channel, int frame, String color)
      Adds multiple bookmarks with the specified label and locations.
      Parameters:
      label - the label for the bookmarks
      locations - the list of SNTPoint (world/calibrated) locations for the bookmarks
      channel - the channel position for the bookmarks
      frame - the time position for the bookmarks
      color - the color (category) for the bookmarks
    • add

      public void add(String label, List<SNTPoint> locations, int channel, int frame)
      Adds multiple bookmarks with the specified label and locations.
      Parameters:
      label - the label for the bookmarks
      locations - the list of SNTPoint locations for the bookmarks
      channel - the channel position for the bookmarks
      frame - the time position for the bookmarks
    • add

      public void add(String label, List<double[]> xyzctLocations)
      Adds multiple bookmarks with the specified label and locations.
      Parameters:
      label - the label for the bookmarks
      xyzctLocations - the list of XYZCT locations, in pixel/voxel coordinates (see Detection.xyzct())
    • add

      public void add(String label, List<double[]> xyzctLocations, Color color)
      Adds multiple bookmarks with the specified label, locations, and color tag. Coordinates are converted to (and stored as) world/calibrated units using the active image's calibration.
      Parameters:
      label - the label prefix for the bookmarks
      xyzctLocations - the list of XYZCT locations, in pixel/voxel coordinates (see Detection.xyzct())
      color - the color tag for the bookmarks, or null for no tag
    • add

      public void add(Map<Path,Set<Integer>> map, String commonLabel)
      Adds multiple bookmarks from selected path nodes
      Parameters:
      map - the map of [k=Path, v=list of node indices] from which node positions are extracted
      commonLabel - an (optional) bookmark label suffix
    • clearSelection

      public void clearSelection()
      Clears the selection of bookmarks in the table. Does nothing if no selection exists.
    • reset

      public void reset()
      Clears all bookmarks.
    • hasBookmarks

      public boolean hasBookmarks()
      Returns whether any bookmarks exist.
      Returns:
      true if there is at least one bookmark
    • isShowing

      protected boolean isShowing()
    • load

      public boolean load(File file)
      Loads bookmarks from the specified file.
      Parameters:
      file - the file to load bookmarks from. File is expected to be a CSV file with 6 columns in the following order: Label, X, Y, Z, C, T.
      Returns:
      true if bookmarks were loaded successfully, false otherwise
    • load

      public boolean load(String filePathOrURL)
      Parameters:
      filePathOrURL - local path or remote URL (e.g. https://.../markers.csv) to a CSV file with the same layout expected by load(File).
      Returns:
      true if bookmarks were loaded successfully, false otherwise.
    • load

      public void load(List<ij.gui.Roi> rois)
      Loads bookmarks from the specified list of ROIs. ROIs can be of any type. If area ROIs are provided, their centroids are used as bookmark locations.
      Parameters:
      rois - the list of ROIs to load bookmarks from
    • load

      public void load(ij.gui.Roi[] rois)
      See Also:
    • save

      public boolean save(File file)
      Saves bookmarks to the specified file.
      Parameters:
      file - the file to save bookmarks to
      Returns:
      true if bookmarks were saved successfully, false otherwise
    • save

      public boolean save(String filePath)
      See Also:
    • getCount

      public int getCount()
      Returns the number of bookmarks.
      Returns:
      the number of bookmarks currently stored in the manager.
    • getROIs

      public List<ij.gui.Roi> getROIs(boolean onlySelectedRows)
      Returns a list of ROIs representing the bookmarks.
      Parameters:
      onlySelectedRows - if true, only selected rows are included; otherwise, all ROIs in the manager are included
      Returns:
      the list of ROIs (PointRoi) representing the bookmarks
    • getPixelPositions

      public List<SNTPoint> getPixelPositions(boolean onlySelectedRows)
      Returns bookmark/marker positions in pixel/voxel coordinates, converted from this manager's canonical world/calibrated storage via worldToPixel(Bookmark).
      Parameters:
      onlySelectedRows - if true, only selected rows are included; otherwise, all bookmarks in the manager are included
      Returns:
      the list of Points (fresh PointInImage copies) of the bookmarks, in pixel/voxel coordinates
    • getPositions

      public List<SNTPoint> getPositions(boolean onlySelectedRows)
      Returns bookmark/marker positions in spatially calibrated ("world") coordinates, i.e., this manager's canonical storage format, returned as-is (fresh copies) in both modes.
      Parameters:
      onlySelectedRows - if true, only selected rows are included; otherwise, all bookmarks in the manager are included
      Returns:
      the list of Points representing the bookmarks, in calibrated ("world") coordinates
    • getLastPosition

      public SNTPoint getLastPosition()
      Returns the position of the most recently added bookmark/marker, in spatially calibrated ("world") coordinates (canonical storage format).

      In viewer mode (BVV/BDV), this is the last marker placed with the M key (or added programmatically). In SNT-UI mode, this is the last entry added to the Bookmark Manager pane. Since new entries are always appended, this reflects placement order in the common case; it can become stale relative to placement order after an explicit list-reordering operation (e.g. the table's "Sort by Distance..." menu, or a Merge/Colocalize operation, both of which re-write the backing list).

      Returns:
      the position of the last bookmark, or null if none have been added
    • toOverlay

      public void toOverlay(ij.gui.Overlay overlay)
      Adds the bookmark ROIs to the specified overlay. If no bookmarks are selected, all bookmarks are added, otherwise only the selected bookmarks are added.
      Parameters:
      overlay - the overlay to add the bookmarks to. Null not allowed
    • toRoiManager

      public void toRoiManager()
      Adds the bookmarks to the ROI Manager. If no bookmarks are selected, all bookmarks are added, otherwise only the selected bookmarks are added.
    • getRois

      public static List<ij.gui.PointRoi> getRois(String commonLabel, List<double[]> xyzctLocations)
    • getRois

      public static List<ij.gui.PointRoi> getRois(String commonLabel, List<double[]> xyzctLocations, Color color)
      Creates a list of PointRois from XYZCT locations with a color tag.
      Parameters:
      commonLabel - the label prefix for each ROI
      xyzctLocations - the list of XYZCT locations (pixel coordinates)
      color - the stroke color for the ROIs, or null for default
      Returns:
      list of PointRoi objects