Class GpxDrawHelper
java.lang.Object
org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper
- All Implemented Interfaces:
GpxData.GpxDataChangeListener,SystemOfMeasurement.SoMChangeListener,MapViewPaintable.LayerPainter,MapViewPaintable.PaintableInvalidationListener
public class GpxDrawHelper
extends Object
implements SystemOfMeasurement.SoMChangeListener, MapViewPaintable.LayerPainter, MapViewPaintable.PaintableInvalidationListener, GpxData.GpxDataChangeListener
Class that helps to draw large set of GPS tracks with different colors and options
- Since:
- 7319
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate intdon't draw arrows nearer to each other than thisprivate booleanpaint direction arrow with alternate math.private intOpacity for circle pointsprivate intprivate Colorprivate Colorprivate GpxDrawHelper.ColorModeMode of the line coloringprivate booleanprivate booleanprivate GpxDrawHelper.ColorModeprivate Colorprivate intprivate intprivate intprivate booleanprivate booleanprivate intprivate intprivate final GpxDataprivate ColorScalestatic final NamedColorPropertyThe default color property that is used for drawing GPX points.private static final int[][]private ColorScaleprivate booleanprivate ColorScaleprivate booleanprivate static final Color[]private static final String[]private booleanprivate intmaximum value of displayed HDOP, minimum is 0private ColorScaleColors (without custom alpha channel, if given) for HDOP painting.(package private) int(package private) Rectangleprivate intprivate booleanheat map parametersprivate intprivate intprivate booleanprivate Graphics2Dprivate BufferedImageprivate Color[]private static final Color[]private static final Color[]private static final Color[]private static final Color[](package private) MapViewStateprivate booleanpaint large dots for pointsprivate intprivate intprivate final GpxLayerprivate booleanprivate intwidth of line for paintprivate static final intprivate intdon't draw lines if longer than x metersprivate doublemaxTime saves the end time of the track as epoch secondsprivate doubleminTime saves the start time of the track as epoch secondsprivate doubleprivate Colorprivate static final doubleprivate ColorScaleprivate ColorScaleprivate static final Color[]private static final String[]private static final intprivate static final intprivate ColorScaleprivate intmax speed for coloring - allows to tweak line coloring for different speed levels. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalculate colors of way segments based on latest configuration settingsprivate voidCheck cache validity set necessary flagsprotected static Color[]Creates a colormap by using a static color map with 1..n colors (RGB 0.0 ..1.0)protected static Color[]createColorLut(int lowerLimit, Color... colors) Creates a distributed colormap by linear blending between colorsprotected static BufferedImagecreateImageGradientMap(int width, int height, Color... colors) Generates a linear gradient map imageprotected static ColordarkerColor(Color in, float adjust) Creates a darker colorvoidCalled when the layer is removed from the map view and this painter is not used any more.voidDraw all enabled GPX elements of layer.private voiddrawArrows(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) Draw all GPX arraysprivate voiddrawArrows3b(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) STEP 3b - DRAW NICE ARROWS **************************private voiddrawArrows3c(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) STEP 3c - DRAW FAST ARROWS **************************private voiddrawCircle(Graphics2D g, MapView mv, WayPoint trkPnt, Point screen, float circleSize) voiddrawColorBar(Graphics2D g, MapView mv) Draw all GPX arraysprivate static voiddrawHeatGrayDotMap(Graphics2D gB, MapView mv, List<WayPoint> listSegm, int drawSize) Draw a dotted heat mapprivate voiddrawHeatGrayLineMap(Graphics2D gB, MapView mv, List<WayPoint> listSegm, Composite foreComp, Stroke foreStroke, Composite backComp, Stroke backStroke) Draw gray heat map with current Graphics2D settingprivate voiddrawHeatMap(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) Collect and draw GPS segments and displays a heat-mapprivate voiddrawHeatMapGrayMap(Graphics2D g, BufferedImage imgGray, int sampleRaster, int outlineWidth) Map the gray map to heat map and draw them with current Graphics2D settingprivate static voiddrawHeatSurfaceLine(Graphics2D g, Point fromPnt, Point toPnt, int drawSize, double rmsSizeX, double rmsSizeY, double dropRate) Draw a dotted surface lineprivate voiddrawLines(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) Draw all GPX ways segmentsprivate voiddrawLinesAlpha(Graphics2D g, MapView mv, List<WayPoint> visibleSegments, float layerAlpha) Draw GPX lines by using alpha blendingprivate voiddrawPoints(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) Draw all GPX pointsprivate voiddrawPointsStep3d(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) STEP 3d - DRAW LARGE POINTS AND CIRCLES ***********private voiddrawPointsStep3e(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) STEP 3e - DRAW SMALL POINTS FOR LINES ***************private voiddrawPointsStep3f(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) STEP 3f - DRAW SMALL POINTS INSTEAD OF LINES ********private voidensures the trackVisibility array has the correct length without losing data.private voidApply default color configuration to way segmentsstatic ImageIcongetColorMapImageIcon(Color userColor, int tableIdx, int size) Generates a IconRead coloring mode for specified layer from preferencesgetLinesIterable(boolean[] trackVisibility) voidcallback when data is changed, invalidate cached configuration parametersprivate Stringprivate booleanprivate intvoidpaint(MapViewGraphics graphics) Paints the given layer.voidCalled whenever aMapViewPaintable.PaintableInvalidationEventis fired.voidRead all drawing-related settings from preferencesprotected static Color[]selectColorMap(Color userColor, int tableIdx) Returns the next user color mapprivate voidvoidsystemOfMeasurementChanged(String oldSoM, String newSoM) The current SoM has changed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener
modifiedStateChanged
-
Field Details
-
DEFAULT_COLOR_PROPERTY
The default color property that is used for drawing GPX points.- Since:
- 15496
-
data
-
layer
-
forceLines
-
alphaLines
-
arrows
-
lineWidth
width of line for paint -
maxLineLength
don't draw lines if longer than x meters -
lines
-
large
paint large dots for points -
largesize
-
drawCircle
-
circleDataSource
-
arrowsFast
paint direction arrow with alternate math. may be faster -
arrowsDelta
don't draw arrows nearer to each other than this -
minTrackDurationForTimeColoring
-
hdoprange
maximum value of displayed HDOP, minimum is 0 -
PHI
-
computeCacheInSync
-
computeCacheMaxLineLengthUsed
-
computeCacheColorUsed
-
computeCacheColorDynamic
-
computeCacheColored
-
computeCacheVelocityTune
-
computeCacheHeatMapDrawColorTableIdx
-
computeCacheHeatMapDrawPointMode
-
computeCacheHeatMapDrawGain
-
computeCacheHeatMapDrawLowerLimit
-
colorCache
-
colorCacheTransparent
-
colored
Mode of the line coloring -
velocityTune
max speed for coloring - allows to tweak line coloring for different speed levels. -
colorModeDynamic
-
neutralColor
-
largePointAlpha
-
velocityScale
-
hdopScale
Colors (without custom alpha channel, if given) for HDOP painting. -
qualityScale
-
fixScale
-
refScale
-
dateScale
-
directionScale
-
circleAlpha
Opacity for circle points -
ll0
- See Also:
-
sl4
- See Also:
-
sl9
- See Also:
-
dir
-
heatMapDrawExtraLine
heat map parameters -
heatMapDrawColorTableIdx
-
heatMapDrawPointMode
-
heatMapDrawGain
-
heatMapDrawLowerLimit
-
heatMapImgGray
-
heatMapGraph2d
-
heatMapCacheScreenBounds
-
heatMapMapViewState
-
heatMapCacheLineWith
-
heatMapPolyX
-
heatMapPolyY
-
heatMapLutColorJosmInferno
-
heatMapLutColorJosmViridis
-
heatMapLutColorJosmBrown2Green
-
heatMapLutColorJosmRed2Blue
-
rtkLibQualityColors
-
rtkLibQualityNames
-
gpsFixQualityColors
- See Also:
-
gpsFixQualityNames
-
heatMapLutColor
-
gpxLayerInvalidated
-
minTime
minTime saves the start time of the track as epoch seconds -
maxTime
maxTime saves the end time of the track as epoch seconds
-
-
Constructor Details
-
GpxDrawHelper
Constructs a newGpxDrawHelper.- Parameters:
gpxLayer- The layer to draw- Since:
- 12157
-
-
Method Details
-
setupColors
-
systemOfMeasurementChanged
Description copied from interface:SystemOfMeasurement.SoMChangeListenerThe current SoM has changed.- Specified by:
systemOfMeasurementChangedin interfaceSystemOfMeasurement.SoMChangeListener- Parameters:
oldSoM- The old system of measurementnewSoM- The new (current) system of measurement
-
getColorMode
Read coloring mode for specified layer from preferences- Returns:
- coloring mode
-
opt
-
optBool
-
optInt
-
readPreferences
Read all drawing-related settings from preferences -
paint
Description copied from interface:MapViewPaintable.LayerPainterPaints the given layer.This can be called in any thread at any time. You will not receive parallel calls for the same map view but you can receive parallel calls if you use the same
MapViewPaintable.LayerPainterfor different map views.- Specified by:
paintin interfaceMapViewPaintable.LayerPainter- Parameters:
graphics- The graphics object of the map view you should use. It provides you with a content pane, the bounds and the view state.
-
listVisibleSegments
-
getLinesIterable
-
ensureTrackVisibilityLength
ensures the trackVisibility array has the correct length without losing data. TODO: Make this nicer by syncing the trackVisibility automatically. additional entries are initialized to true; -
drawAll
Draw all enabled GPX elements of layer.- Parameters:
g- the common draw object to usemv- the meta data to current displayed areavisibleSegments- segments visible in the current scope of mvclipBounds- the clipping rectangle for the current view- Since:
- 14748 : new parameter clipBounds
-
calculateColors
Calculate colors of way segments based on latest configuration settings -
drawLines
Draw all GPX ways segments- Parameters:
g- the common draw object to usemv- the meta data to current displayed areavisibleSegments- segments visible in the current scope of mv
-
drawArrows
Draw all GPX arrays- Parameters:
g- the common draw object to usemv- the meta data to current displayed areavisibleSegments- segments visible in the current scope of mv
-
drawArrows3b
STEP 3b - DRAW NICE ARROWS ************************** -
drawArrows3c
STEP 3c - DRAW FAST ARROWS ************************** -
drawPoints
Draw all GPX points- Parameters:
g- the common draw object to usemv- the meta data to current displayed areavisibleSegments- segments visible in the current scope of mv
-
drawPointsStep3d
STEP 3d - DRAW LARGE POINTS AND CIRCLES *********** -
drawCircle
-
drawPointsStep3e
STEP 3e - DRAW SMALL POINTS FOR LINES *************** -
drawPointsStep3f
STEP 3f - DRAW SMALL POINTS INSTEAD OF LINES ******** -
drawLinesAlpha
private void drawLinesAlpha(Graphics2D g, MapView mv, List<WayPoint> visibleSegments, float layerAlpha) Draw GPX lines by using alpha blending- Parameters:
g- the common draw object to usemv- the meta data to current displayed areavisibleSegments- segments visible in the current scope of mvlayerAlpha- the color alpha value set for that operation
-
createImageGradientMap
Generates a linear gradient map image- Parameters:
width- image widthheight- image heightcolors- 1..n color descriptions- Returns:
- image object
-
createColorLut
Creates a distributed colormap by linear blending between colors- Parameters:
lowerLimit- lower limit for first visible colorcolors- 1..n colors- Returns:
- array of Color objects
-
darkerColor
Creates a darker color- Parameters:
in- Color objectadjust- darker adjustment amount- Returns:
- new Color
-
createColorFromResource
Creates a colormap by using a static color map with 1..n colors (RGB 0.0 ..1.0)- Parameters:
str- the filename (without extension) to look for into data/gpx- Returns:
- the parsed colormap
-
selectColorMap
Returns the next user color map- Parameters:
userColor- - default or fallback user colortableIdx- - selected user color index- Returns:
- color array
-
getColorMapImageIcon
Generates a Icon- Parameters:
userColor- selected user colortableIdx- tabled indexsize- size of the image- Returns:
- a image icon that shows the
-
drawHeatGrayLineMap
private void drawHeatGrayLineMap(Graphics2D gB, MapView mv, List<WayPoint> listSegm, Composite foreComp, Stroke foreStroke, Composite backComp, Stroke backStroke) Draw gray heat map with current Graphics2D setting- Parameters:
gB- the common draw object to usemv- the meta data to current displayed arealistSegm- segments visible in the current scope of mvforeComp- composite use to draw foreground objectsforeStroke- stroke use to draw foreground objectsbackComp- composite use to draw background objectsbackStroke- stroke use to draw background objects
-
drawHeatMapGrayMap
private void drawHeatMapGrayMap(Graphics2D g, BufferedImage imgGray, int sampleRaster, int outlineWidth) Map the gray map to heat map and draw them with current Graphics2D setting- Parameters:
g- the common draw object to useimgGray- gray scale input imagesampleRaster- the line with for drawingoutlineWidth- line width for outlines
-
drawHeatMap
Collect and draw GPS segments and displays a heat-map- Parameters:
g- the common draw object to usemv- the meta data to current displayed areavisibleSegments- segments visible in the current scope of mv
-
drawHeatGrayDotMap
private static void drawHeatGrayDotMap(Graphics2D gB, MapView mv, List<WayPoint> listSegm, int drawSize) Draw a dotted heat map- Parameters:
gB- the common draw object to usemv- the meta data to current displayed arealistSegm- segments visible in the current scope of mvdrawSize- draw size of draw element
-
drawHeatSurfaceLine
private static void drawHeatSurfaceLine(Graphics2D g, Point fromPnt, Point toPnt, int drawSize, double rmsSizeX, double rmsSizeY, double dropRate) Draw a dotted surface line- Parameters:
g- the common draw object to usefromPnt- start pointtoPnt- end pointdrawSize- size of draw elementsrmsSizeX- RMS size of circle for X (width)rmsSizeY- RMS size of circle for Y (height)dropRate- Pixel render drop rate
-
fixColors
Apply default color configuration to way segments- Parameters:
visibleSegments- segments visible in the current scope of mv
-
checkCache
Check cache validity set necessary flags -
gpxDataChanged
callback when data is changed, invalidate cached configuration parameters- Specified by:
gpxDataChangedin interfaceGpxData.GpxDataChangeListener- Parameters:
e- The event
-
drawColorBar
Draw all GPX arrays- Parameters:
g- the common draw object to usemv- the meta data to current displayed area
-
paintableInvalidated
Description copied from interface:MapViewPaintable.PaintableInvalidationListenerCalled whenever aMapViewPaintable.PaintableInvalidationEventis fired. This might be called from any thread.- Specified by:
paintableInvalidatedin interfaceMapViewPaintable.PaintableInvalidationListener- Parameters:
event- The event
-
detachFromMapView
Description copied from interface:MapViewPaintable.LayerPainterCalled when the layer is removed from the map view and this painter is not used any more.This method is called once on the painter returned by
AbstractMapViewPaintable.attachToMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)- Specified by:
detachFromMapViewin interfaceMapViewPaintable.LayerPainter- Parameters:
event- The event.
-