Class Viewer2D


public class Viewer2D extends TreeColorMapper
Class for rendering Trees as 2D plots that can be exported as SVG, PNG or PDF.
Author:
Tiago Ferreira
  • Field Details

    • plot

      protected org.scijava.plot.XYPlot plot
  • Constructor Details

    • Viewer2D

      public Viewer2D()
      Instantiates an empty 2D viewer using SNT's default context.
    • Viewer2D

      public Viewer2D(org.scijava.Context context)
      Instantiates an empty 2D viewer.
      Parameters:
      context - the SciJava application context providing the services required by the viewer.
    • Viewer2D

      public Viewer2D(org.scijava.Context context, Viewer2D template)
      Instantiates an empty 2D viewer.
      Parameters:
      context - the SciJava application context providing the services required by the viewer.
      template - a viewer instance from which properties (axes visibility, title, etc.) will be applied
  • Method Details

    • addNodes

      public void addNodes(Collection<SNTPoint> points, String color, String label)
    • addNodes

      public void addNodes(Map<org.scijava.util.ColorRGB,List<SNTPoint>> coloredNodes)
    • addPolygon

      public void addPolygon(net.imglib2.roi.geom.real.Polygon2D poly, String label)
    • addColorBarLegend

      protected void addColorBarLegend(String colorTable, double min, double max)
    • addColorBarLegend

      public void addColorBarLegend(net.imglib2.display.ColorTable colorTable, double min, double max)
      Adds a color bar legend (LUT ramp).
      Parameters:
      colorTable - the color table
      min - the minimum value in the color table
      max - the maximum value in the color table
    • addColorBarLegend

      public <T extends ColorMapper> void addColorBarLegend(T colorMapper)
      Adds a color bar legend (LUT ramp) from a ColorMapper.
      Parameters:
      colorMapper - the class extending ColorMapper (TreeColorMapper, etc.)
    • addColorBarLegend

      public void addColorBarLegend()
      Adds a color bar legend (LUT ramp) to the viewer. Does nothing if no measurement mapping occurred successfully. Note that when performing mapping to different measurements, the legend reflects only the last mapped measurement.
    • addTree

      @Deprecated public void addTree(Tree tree)
      Deprecated.
      Use add(Object) instead
      Appends a tree to the viewer using default options.
      Parameters:
      tree - the Collection of paths to be plotted
    • addTrees

      @Deprecated public void addTrees(Collection<Tree> trees)
      Deprecated.
      use add(Object) instead
      Adds a collection of trees. Each tree will be rendered using a unique color.
      Parameters:
      trees - the list of trees to be plotted
    • add

      public void add(Object object)
      Appends a single tree, a single Polygon2D, a collection of Trees, or a collection of Polygon2D to the viewer using default options.
      Parameters:
      object - the tree(s) or Polygon2D(s) to be added
    • add

      public void add(List<Tree> trees, String lut)
      Adds a list of trees while assigning each tree to a LUT index.
      Parameters:
      trees - the list of trees to be plotted
      lut - the lookup table specifying the color mapping
    • add

      public void add(Tree tree, org.scijava.util.ColorRGB color)
      Appends a tree to the viewer.
      Parameters:
      tree - the Collection of paths to be plotted
      color - the color to render the Tree
    • add

      public void add(Tree tree, String color)
      Appends a tree to the viewer.
      Parameters:
      tree - the Collection of paths to be plotted
      color - a string representation of the color to render the Tree
    • add

      public void add(Tree tree, String measurement, net.imglib2.display.ColorTable colorTable, double min, double max)
      Appends a tree to the viewer rendered after the specified measurement.
      Parameters:
      tree - the tree to be plotted
      measurement - the measurement (TreeColorMapper.PATH_ORDER }TreeColorMapper.PATH_LENGTH, etc.)
      colorTable - the color table specifying the color mapping
      min - the mapping lower bound (i.e., the highest measurement value for the LUT scale)
      max - the mapping upper bound (i.e., the highest measurement value for the LUT scale)
    • add

      public void add(Tree tree, String measurement, String lut)
      Appends a tree to the viewer rendered after the specified measurement. Mapping bounds are automatically determined.
      Parameters:
      tree - the tree to be plotted
      measurement - the measurement (TreeColorMapper.PATH_ORDER }TreeColorMapper.PATH_LENGTH, etc.)
      lut - the lookup table specifying the color mapping
    • add

      public void add(Tree tree, String measurement, String lut, double min, double max)
      Appends a tree to the viewer rendered after the specified measurement.
      Parameters:
      tree - the tree to be plotted
      measurement - the measurement (TreeColorMapper.PATH_ORDER }TreeColorMapper.PATH_LENGTH, etc.)
      lut - the lookup table specifying the color mapping
      min - the mapping lower bound (i.e., the highest measurement value for the LUT scale)
      max - the mapping upper bound (i.e., the highest measurement value for the LUT scale)
    • getJFreeChart

      public org.jfree.chart.JFreeChart getJFreeChart()
      Gets the current viewer as a JFreeChart object
      Returns:
      the converted viewer
    • getChart

      public SNTChart getChart()
      Gets the current viewer as a SNTChart object
      Returns:
      the converted viewer
    • getPlot

      public org.scijava.plot.XYPlot getPlot()
      Gets the current plot as a XYPlot object
      Returns:
      the current plot
    • setDefaultColor

      public void setDefaultColor(org.scijava.util.ColorRGB color)
      Sets the default (fallback) color for plotting paths.
      Parameters:
      color - null not allowed
    • setPreferredSize

      public void setPreferredSize(int width, int height)
      Sets the preferred size of the plot to a constant value.
      Parameters:
      width - the preferred width
      height - the preferred height
    • setTitle

      public void setTitle(String title)
      Sets the plot display title.
      Parameters:
      title - the new title
    • getTitle

      public String getTitle()
      Gets the plot display title.
      Returns:
      the current display title
    • setXrange

      public void setXrange(double xMin, double xMax)
      Sets a manual range for the viewers' X-axis. Calling setXrange(-1, -1) enables auto-range (the default). Must be called before Viewer is fully assembled.
      Parameters:
      xMin - the lower-limit for the X-axis
      xMax - the upper-limit for the X-axis
    • setYrange

      public void setYrange(double yMin, double yMax)
      Sets a manual range for the viewers' Y-axis. Calling setYrange(-1, -1) enables auto-range (the default). Must be called before Viewer is fully assembled.
      Parameters:
      yMin - the lower-limit for the Y-axis
      yMax - the upper-limit for the Y-axis
    • showPlot

      @Deprecated public void showPlot()
      Deprecated.
      Use show() instead.
    • show

      public void show()
      Displays the current plot on a dedicated frame
    • show

      public void show(int width, int height)
      Displays the current plot on a dedicated frame *
      Parameters:
      width - the preferred frame width
      height - the preferred frame height
    • setGridlinesVisible

      public void setGridlinesVisible(boolean visible)
    • setAxesVisible

      public void setAxesVisible(boolean visible)
    • setOutlineVisible

      public void setOutlineVisible(boolean visible)
    • setEqualizeAxes

      public void setEqualizeAxes(boolean equalizeAxes)
      /** Sets whether the axes should be equalized (same scale).

      When enabled, both X and Y axes will use the same scale to maintain equal aspect ratio. When disabled, each axis maximizes its range.

      Parameters:
      equalizeAxes - true to equalize axes, false otherwise
    • main

      public static void main(String... args)