Class ScrollingPlotSegmenter

java.lang.Object
dataPlotsFX.clickPlotFX.ScrollingPlotSegmenter

public abstract class ScrollingPlotSegmenter extends Object
A method to quickly plot data units on the display

A list of writable images is stored in memory. These record the UID of the data unit that has been painted and repainting of the data unit does not occur unless a specific clear() function is called.

An example use case is plotting raw waveform data. At high sample rates, each raw bin can only be plotted as the minimum and maximum bin withing a time segment representing a single pixel. iterating through all raw data bins and calculating this each time a plot needs repainting is processor intensive. So the bin data can be processed and added to PlotSegments, then the PlotSegments can be reused until either the plot scale time scale changes sufficiently that new segments are required (e.g. zooming in) or the plot moves to a completely new time section of data.

Author:
Jamie Macaulay
  • Field Details

    • millisPerPixel

      public double millisPerPixel
      The number of seconds each pixel represents.
  • Constructor Details

    • ScrollingPlotSegmenter

      public ScrollingPlotSegmenter()
      Create a new scrolling 2D segmented.
  • Method Details

    • resetImageBuffer

      public void resetImageBuffer()
      Reset the buffer so that all images are cleared all data units must redraw.
    • getMillisePerPixel

      public double getMillisePerPixel()
      Return the number of milliseconds each width pixel corresponds to
      Returns:
      the number of milliseconds per pixel.
    • getImageSegmentEnd

      public long getImageSegmentEnd()
      Get the location of the last image.
      Returns:
      the location of the last image.
    • getImageMillisTime

      public long getImageMillisTime(double pixel)
      Get the image millis time for a given pixel. This
      Parameters:
      pixel - - pixels form start of the first image segment in the buffer
    • getImagePixelTime

      public double getImagePixelTime(double timeMillis)
      Get the image pixel time for a given millis. This is the total pixels form the first image segment in the buffer.
      Parameters:
      timeMillis - - the time in millis.
    • getImageXPixels

      public double getImageXPixels(long timeMillis, ScrollingPlotSegmenter.PlotSegment writiableImage)
      Get the number of X pixels into an image that the time in millis represents
      Parameters:
      timeMillis - - the time in milliseconds
      Returns:
      - the number of x pixels into the image segment;
    • bufferCheck

      public boolean bufferCheck(double starttime, double secondsWidth)
      Check the writable images and remove fringe images if necessary.
      Returns:
      true if some images have been deleted from memory.
    • addPlotData

      public abstract void addPlotData(PamDataUnit pamDataUnit, ScrollingPlotSegmenter.PlotSegment plotSegmentData, TDProjectorFX tdProjector, double scrollStart)
      Add plot data to the plot segment.
      Parameters:
      pamDataUnit - - the data unit.
      plotSegmentData - - the writable image .
      tdProjector - - the TD projector for the display.
      scrollStart - - the start of the display in milliseconds.
      g - - the graphics context the image will be drawn onto.
    • getPath2D

      public abstract Path2D getPath2D(PamDataUnit pamDataUnit, ScrollingPlotSegmenter.PlotSegment plotSegmentData, TDProjectorFX tdProjector, double scrollStart)
      Get the polygon for the detection. This allows it to be selected by markers.
      Parameters:
      pamDataUnit - - the data unit.
      tdProjector - - the TD projector for the display.
      scrollStart - - the start of the display in milliseconds.
      g - - the graphics context the image will be drawn onto.
      writableImage - - the writable image.
    • paintPlotData

      public abstract void paintPlotData(javafx.scene.canvas.GraphicsContext g, ScrollingPlotSegmenter.PlotSegment plotSegmentData, TDProjectorFX tdProjector, double scrollStart)
      Paint a plot segment on the graphics context.
      Parameters:
      g - - the graphics context the image will be drawn onto.
      plotSegmentData - - the plot data.
      tdProjector - - the TD projector for the display.
      scrollStart - - the start of the display in milliseconds.
    • paintImages

      public void paintImages(javafx.scene.canvas.GraphicsContext g, TDProjectorFX tdProjector, double scrollStart, long tm)
      Paint the images.
      Parameters:
      g - - the graphics context.
      tdProjector - - the projector of the graph.
      scrollStart - - the start of the display in millis.
      tm - - the repaint time in millis.
    • addPlotData

      public Path2D addPlotData(PamDataUnit pamDataUnit, TDProjectorFX tdProjector, double scrollStart)
      Draw the data on the plot segment
      Parameters:
      pamDataUnit - - the pamDataUnit.
      g - - the graphics context.
      tC - - the time to plot in seconds form the start of the display.
      Returns:
      the Path2D of the click.
    • getImageSegments

      public ArrayList<ScrollingPlotSegmenter.PlotSegment> getImageSegments()
      Get the image segments.
      Returns:
      the image segments