Class TrackPainter

  • All Implemented Interfaces:
    GlimpsePainter
    Direct Known Subclasses:
    LatLonTrackPainter

    public class TrackPainter
    extends GlimpsePainterBase
    Paints groups of line segments of points with associated timestamps. Often these points represent the locations of objects moving over time (here referred to as a track). TrackPainter allows very fast selection of specified time segments within the set of tracks, hiding all segments outside this time window.
    Author:
    ulman
    See Also:
    com.metsci.glimpse.examples.animated.AnimatedGeoPlotExample
    • Constructor Detail

      • TrackPainter

        public TrackPainter()
      • TrackPainter

        public TrackPainter​(boolean enableSpatialIndex)
    • Method Detail

      • isSpatialIndexed

        public boolean isSpatialIndexed()
      • getTrackHead

        public Point getTrackHead​(Object trackId)
      • deleteAll

        public void deleteAll()
      • deleteTrack

        public void deleteTrack​(Object trackId)
      • clearTrack

        public void clearTrack​(Object trackId)
      • addPoint

        public void addPoint​(Object trackId,
                             Object pointId,
                             double x,
                             double y,
                             long time)
      • addPoints

        public void addPoints​(Object trackId,
                              List<Point> points)
      • setLineColor

        public void setLineColor​(Object trackId,
                                 float[] color)
      • setLineColor

        public void setLineColor​(Object trackId,
                                 float r,
                                 float g,
                                 float b,
                                 float a)
      • setLineWidth

        public void setLineWidth​(Object trackId,
                                 float width)
      • setLineStyle

        public void setLineStyle​(Object trackId,
                                 LineStyle style)
      • setPointColor

        public void setPointColor​(Object trackId,
                                  float[] color)
      • setPointColor

        public void setPointColor​(Object trackId,
                                  float r,
                                  float g,
                                  float b,
                                  float a)
      • setPointSize

        public void setPointSize​(Object trackId,
                                 float size)
      • setShowPoints

        public void setShowPoints​(Object trackId,
                                  boolean show)
      • setHeadPointColor

        public void setHeadPointColor​(Object trackId,
                                      float[] color)
      • setHeadPointColor

        public void setHeadPointColor​(Object trackId,
                                      float r,
                                      float g,
                                      float b,
                                      float a)
      • setHeadPointSize

        public void setHeadPointSize​(Object trackId,
                                     float size)
      • setShowHeadPoint

        public void setShowHeadPoint​(Object trackId,
                                     boolean show)
      • setShowLines

        public void setShowLines​(Object trackId,
                                 boolean show)
      • setDotted

        public void setDotted​(Object trackId,
                              boolean dotted)
      • setDotted

        public void setDotted​(Object trackId,
                              int stippleFactor,
                              short stipplePattern)
      • setLabelColor

        public void setLabelColor​(Object trackId,
                                  float[] color)
      • setLabelColor

        public void setLabelColor​(Object trackId,
                                  float r,
                                  float g,
                                  float b,
                                  float a)
      • setLabelLineColor

        public void setLabelLineColor​(Object trackId,
                                      float[] color)
      • setLabelLineColor

        public void setLabelLineColor​(Object trackId,
                                      float r,
                                      float g,
                                      float b,
                                      float a)
      • setShowLabelLine

        public void setShowLabelLine​(Object trackId,
                                     boolean show)
      • setLabel

        public void setLabel​(Object trackId,
                             String label)
      • setShowLabel

        public void setShowLabel​(Object trackId,
                                 boolean show)
      • displayTimeRange

        public void displayTimeRange​(Object trackId,
                                     double startTime,
                                     double endTime)
      • displayTimeRange

        public void displayTimeRange​(double startTime,
                                     double endTime)
      • displayTimeRange

        public void displayTimeRange​(Object trackId,
                                     long startTime,
                                     long endTime)
      • displayTimeRange

        public void displayTimeRange​(Object trackId,
                                     long startTime,
                                     long endTime,
                                     long selectedTime)
      • displayTimeRange

        public void displayTimeRange​(long startTime,
                                     long endTime)
      • displayTimeRange

        public void displayTimeRange​(long startTime,
                                     long endTime,
                                     long selectedTime)
      • getGeoRange

        public Collection<Point> getGeoRange​(double minX,
                                             double maxX,
                                             double minY,
                                             double maxY)
        Returns all Points within the given bounding box in axis coordinates (regardless of time stamp).
        Parameters:
        minX - left edge of the bounding box
        maxX - right edge of the bounding box
        minY - bottom edge of the bounding box
        maxY - top edge of the bounding box
        Returns:
        all Points within the bounding box
      • getPixelRange

        public Collection<Point> getPixelRange​(Axis2D axis,
                                               double centerX,
                                               double centerY,
                                               int pixelWidth,
                                               int pixelHeight)

        Returns all the Points within the bounding box specified with a center in axis coordinates and width/height specified in pixels.

        This is useful for querying for points near the cursor. When used in this way, the pixelWidth and pixelHeight arguments control how close the user must get to a point before it is selected. The Axis2D argument is usually obtained from a GlimpseMouseListener.

        Parameters:
        axis - the axis to use to convert pixel values into axis coordinates.
        centerX - the x center of the query box in axis coordinates
        centerY - the y center of the query box in axis coordinates
        pixelWidth - the width of the query box in pixels
        pixelHeight - the height of the query box in pixels
        Returns:
        all the Points within the specified bounding box
      • getNearestPoint

        public Point getNearestPoint​(Axis2D axis,
                                     double centerX,
                                     double centerY,
                                     int maxPixelDistance)
        Returns the closest point to the cursor position. Distance is measured in pixels, not in axis units. However, the cursor position is specified in axis coordinates. If the closest point is further away than maxPixelDistance then null is returned.
        Parameters:
        axis - the axis to use to convert pixel values into axis coordinates
        centerX - the x center of the query box in axis coordinates
        centerY - the y center of the query box in axis coordinates
        maxPixelDistance - only search for nearby points within this pixel radius
        Returns:
        the closest point to the given axis coordinates, or null if none exists
      • getNearestPoint

        public Point getNearestPoint​(GlimpseMouseEvent mouseEvent,
                                     int maxPixelDistance)
        Returns the closest Point to the mouse position specified in the given GlimpseMouseEvent. If the closest point is farther away than maxPixelDistance pixels, then null is returned.
        Parameters:
        mouseEvent - event containing a mouse position
        maxPixelDistance - the farthest point allowed
        Returns:
        the closest point to the provided mouse position
      • getNearestPoint

        public Point getNearestPoint​(Axis2D axis,
                                     int centerPixelX,
                                     int centerPixelY,
                                     int maxPixelDistance)
        Returns the closest point to the cursor position. Distance is measured in pixels, not in axis units. The cursor position is specified in pixel/screen coordinates. If the closest point is further away than maxPixelDistance then null is returned.
        Parameters:
        axis - the axis to use to convert pixel values into axis coordinates
        centerPixelX - the x center of the query box in pixel coordinates
        centerPixelY - the y center of the query box in pixel coordinates
        maxPixelDistance - only search for nearby points within this pixel radius
        Returns:
        the closest point to the given axis coordinates, or null if none exists
      • getTimeGeoRange

        public Collection<Point> getTimeGeoRange​(double minTime,
                                                 double maxTime,
                                                 double minX,
                                                 double maxX,
                                                 double minY,
                                                 double maxY)
      • getTimeGeoRange

        public Collection<Point> getTimeGeoRange​(long minTime,
                                                 long maxTime,
                                                 double minX,
                                                 double maxX,
                                                 double minY,
                                                 double maxY)
        Returns:
        all the points within a specified bounding box which fall between the specified times.
      • getTimeGeoRange

        public Collection<Point> getTimeGeoRange​(double minX,
                                                 double maxX,
                                                 double minY,
                                                 double maxY)
        Returns:
        all the points within a specified bounding box which fall between the time span specified for their track using displayTimeRange.
      • gcDataBuffer

        public void gcDataBuffer()
        Reclaims direct host memory used to move track vertices between the host and device. By default, this memory is never reclaimed because it is slow to allocate. However, if the vertex data will not change in the near future, it may be beneficial to call this method to free up memory in the meantime.