Class TrackPainter
- java.lang.Object
-
- com.metsci.glimpse.core.painter.base.GlimpsePainterBase
-
- com.metsci.glimpse.core.painter.track.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TrackPainter.SpatialSelectionAxisListener
-
Field Summary
Fields Modifier and Type Field Description static Comparator<Point>
comparator
static int
FLOATS_PER_VERTEX
static int
QUAD_TREE_BIN_MAX
static long
SPATIAL_SELECTION_UPDATE_RATE
static Font
textFont
static int
TRACK_LABEL_OFFSET_X
static int
TRACK_LABEL_OFFSET_Y
static int
TRACK_SIZE_ESTIMATE
-
Constructor Summary
Constructors Constructor Description TrackPainter()
TrackPainter(boolean enableSpatialIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPoint(Object trackId, Object pointId, double x, double y, long time)
void
addPoints(Object trackId, List<Point> points)
void
addSpatialSelectionListener(Axis2D axis, SpatialSelectionListener<Point> listener)
void
addTemporalSelectionListener(TemporalSelectionListener<Point> listener)
void
clearTrack(Object trackId)
void
deleteAll()
void
deleteTrack(Object trackId)
void
displayTimeRange(double startTime, double endTime)
void
displayTimeRange(long startTime, long endTime)
void
displayTimeRange(long startTime, long endTime, long selectedTime)
void
displayTimeRange(Object trackId, double startTime, double endTime)
void
displayTimeRange(Object trackId, long startTime, long endTime)
void
displayTimeRange(Object trackId, long startTime, long endTime, long selectedTime)
void
doDispose(GlimpseContext context)
void
doPaintTo(GlimpseContext context)
void
gcDataBuffer()
Reclaims direct host memory used to move track vertices between the host and device.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).Point
getNearestPoint(Axis2D axis, double centerX, double centerY, int maxPixelDistance)
Returns the closest point to the cursor position.Point
getNearestPoint(Axis2D axis, int centerPixelX, int centerPixelY, int maxPixelDistance)
Returns the closest point to the cursor position.Point
getNearestPoint(GlimpseMouseEvent mouseEvent, int maxPixelDistance)
Returns the closest Point to the mouse position specified in the given GlimpseMouseEvent.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.Collection<Point>
getTimeGeoRange(double minX, double maxX, double minY, double maxY)
Collection<Point>
getTimeGeoRange(double minTime, double maxTime, double minX, double maxX, double minY, double maxY)
Collection<Point>
getTimeGeoRange(long minTime, long maxTime, double minX, double maxX, double minY, double maxY)
Collection<Point>
getTimePixelRange(Axis2D axis, double minTime, double maxTime, double centerX, double centerY, int pixelWidth, int pixelHeight)
Point
getTrackHead(Object trackId)
Collection<Point>
getTrackHeads()
boolean
isSpatialIndexed()
void
removeTemporalSelectionListener(TemporalSelectionListener<Point> listener)
void
setDotted(Object trackId, boolean dotted)
void
setDotted(Object trackId, int stippleFactor, short stipplePattern)
void
setHeadPointColor(Object trackId, float[] color)
void
setHeadPointColor(Object trackId, float r, float g, float b, float a)
void
setHeadPointSize(Object trackId, float size)
void
setLabel(Object trackId, String label)
void
setLabelColor(Object trackId, float[] color)
void
setLabelColor(Object trackId, float r, float g, float b, float a)
void
setLabelLineColor(Object trackId, float[] color)
void
setLabelLineColor(Object trackId, float r, float g, float b, float a)
void
setLineColor(Object trackId, float[] color)
void
setLineColor(Object trackId, float r, float g, float b, float a)
void
setLineStyle(Object trackId, LineStyle style)
void
setLineWidth(Object trackId, float width)
void
setPointColor(Object trackId, float[] color)
void
setPointColor(Object trackId, float r, float g, float b, float a)
void
setPointSize(Object trackId, float size)
void
setShowHeadPoint(Object trackId, boolean show)
void
setShowLabel(Object trackId, boolean show)
void
setShowLabelLine(Object trackId, boolean show)
void
setShowLines(Object trackId, boolean show)
void
setShowPoints(Object trackId, boolean show)
-
Methods inherited from class com.metsci.glimpse.core.painter.base.GlimpsePainterBase
dispose, getAxis1D, getAxis2D, getBounds, getGL3, isDisposed, isVisible, paintTo, requireAxis1D, requireAxis2D, setLookAndFeel, setVisible
-
-
-
-
Field Detail
-
FLOATS_PER_VERTEX
public static final int FLOATS_PER_VERTEX
- See Also:
- Constant Field Values
-
QUAD_TREE_BIN_MAX
public static final int QUAD_TREE_BIN_MAX
- See Also:
- Constant Field Values
-
SPATIAL_SELECTION_UPDATE_RATE
public static final long SPATIAL_SELECTION_UPDATE_RATE
- See Also:
- Constant Field Values
-
TRACK_SIZE_ESTIMATE
public static final int TRACK_SIZE_ESTIMATE
- See Also:
- Constant Field Values
-
TRACK_LABEL_OFFSET_X
public static final int TRACK_LABEL_OFFSET_X
- See Also:
- Constant Field Values
-
TRACK_LABEL_OFFSET_Y
public static final int TRACK_LABEL_OFFSET_Y
- See Also:
- Constant Field Values
-
comparator
public static final Comparator<Point> comparator
-
textFont
public static final Font textFont
-
-
Method Detail
-
isSpatialIndexed
public boolean isSpatialIndexed()
-
addTemporalSelectionListener
public void addTemporalSelectionListener(TemporalSelectionListener<Point> listener)
-
removeTemporalSelectionListener
public void removeTemporalSelectionListener(TemporalSelectionListener<Point> listener)
-
addSpatialSelectionListener
public void addSpatialSelectionListener(Axis2D axis, SpatialSelectionListener<Point> listener)
-
getTrackHeads
public Collection<Point> getTrackHeads()
-
deleteAll
public void deleteAll()
-
deleteTrack
public void deleteTrack(Object trackId)
-
clearTrack
public void clearTrack(Object trackId)
-
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)
-
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)
-
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 boxmaxX
- right edge of the bounding boxminY
- bottom edge of the bounding boxmaxY
- top edge of the bounding box- Returns:
- all Points within the bounding box
-
getTimePixelRange
public Collection<Point> getTimePixelRange(Axis2D axis, double minTime, double maxTime, double centerX, double centerY, int pixelWidth, int pixelHeight)
-
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 coordinatescenterY
- the y center of the query box in axis coordinatespixelWidth
- the width of the query box in pixelspixelHeight
- 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 coordinatescenterX
- the x center of the query box in axis coordinatescenterY
- the y center of the query box in axis coordinatesmaxPixelDistance
- 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 positionmaxPixelDistance
- 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 coordinatescenterPixelX
- the x center of the query box in pixel coordinatescenterPixelY
- the y center of the query box in pixel coordinatesmaxPixelDistance
- 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.
-
doPaintTo
public void doPaintTo(GlimpseContext context)
-
doDispose
public void doDispose(GlimpseContext context)
-
-