public class GpxDrawHelper extends java.lang.Object implements SystemOfMeasurement.SoMChangeListener, MapViewPaintable.LayerPainter, MapViewPaintable.PaintableInvalidationListener, GpxData.GpxDataChangeListener
Modifier and Type | Class and Description |
---|---|
static class |
GpxDrawHelper.ColorMode
Different color modes
|
Modifier and Type | Field and Description |
---|---|
private boolean |
alphaLines |
private boolean |
alternateDirection
paint direction arrow with alternate math.
|
private GpxDrawHelper.ColorMode |
colored
Mode of the line coloring
|
private boolean |
colorModeDynamic |
private int |
colorTracksTune
max speed for coloring - allows to tweak line coloring for different speed levels.
|
private boolean |
computeCacheColorDynamic |
private GpxDrawHelper.ColorMode |
computeCacheColored |
private int |
computeCacheColorTracksTune |
private java.awt.Color |
computeCacheColorUsed |
private int |
computeCacheHeatMapDrawColorTableIdx |
private int |
computeCacheHeatMapDrawGain |
private int |
computeCacheHeatMapDrawLowerLimit |
private boolean |
computeCacheHeatMapDrawPointMode |
private boolean |
computeCacheInSync |
private int |
computeCacheMaxLineLengthUsed |
private GpxData |
data |
private ColorScale |
dateScale |
static NamedColorProperty |
DEFAULT_COLOR
The color that is used for drawing GPX points.
|
private int |
delta
don't draw arrows nearer to each other than this
|
private static int[][] |
dir |
private boolean |
direction |
private ColorScale |
directionScale |
private boolean |
forceLines |
private boolean |
gpxLayerInvalidated |
private int |
hdopAlpha
Opacity for hdop points
|
private boolean |
hdopCircle |
private int |
hdoprange
maximum value of displayed HDOP, minimum is 0
|
private ColorScale |
hdopScale
Colors (without custom alpha channel, if given) for HDOP painting.
|
(package private) int |
heatMapCacheLineWith |
(package private) java.awt.Rectangle |
heatMapCacheScreenBounds |
private int |
heatMapDrawColorTableIdx |
private boolean |
heatMapDrawExtraLine |
private int |
heatMapDrawGain |
private int |
heatMapDrawLowerLimit |
private boolean |
heatMapDrawPointMode |
private boolean |
heatMapEnabled
heat map parameters
|
private java.awt.Graphics2D |
heatMapGraph2d |
private java.awt.image.BufferedImage |
heatMapImgGray |
private java.awt.Color[] |
heatMapLutColor |
private static java.awt.Color[] |
heatMapLutColorJosmBrown2Green |
private static java.awt.Color[] |
heatMapLutColorJosmInferno |
private static java.awt.Color[] |
heatMapLutColorJosmRed2Blue |
private static java.awt.Color[] |
heatMapLutColorJosmViridis |
(package private) MapViewState |
heatMapMapViewState |
private java.util.List<java.lang.Integer> |
heatMapPolyX |
private java.util.List<java.lang.Integer> |
heatMapPolyY |
private boolean |
large
paint large dots for points
|
private int |
largePointAlpha |
private int |
largesize |
private GpxLayer |
layer |
private boolean |
lines |
private int |
lineWidth
width of line for paint
|
private static int |
ll0 |
private int |
maxLineLength
don't draw lines if longer than x meters
|
private double |
minTrackDurationForTimeColoring |
private java.awt.Color |
neutralColor |
private static double |
PHI |
private ColorScale |
qualityScale |
private static java.awt.Color[] |
rtkLibQualityColors |
private static int |
sl4 |
private static int |
sl9 |
private ColorScale |
velocityScale |
Constructor and Description |
---|
GpxDrawHelper(GpxLayer gpxLayer)
Constructs a new
GpxDrawHelper . |
Modifier and Type | Method and Description |
---|---|
void |
calculateColors()
Calculate colors of way segments based on latest configuration settings
|
private void |
checkCache()
Check cache validity set necessary flags
|
protected static java.awt.Color[] |
createColorFromResource(java.lang.String str)
Creates a colormap by using a static color map with 1..n colors (RGB 0.0 ..1.0)
|
protected static java.awt.Color[] |
createColorLut(int lowerLimit,
java.awt.Color... colors)
Creates a distributed colormap by linear blending between colors
|
protected static java.awt.image.BufferedImage |
createImageGradientMap(int width,
int height,
java.awt.Color... colors)
Generates a linear gradient map image
|
protected static java.awt.Color |
darkerColor(java.awt.Color in,
float adjust)
Creates a darker color
|
void |
detachFromMapView(MapViewPaintable.MapViewEvent event)
Called when the layer is removed from the map view and this painter is not used any more.
|
void |
drawAll(java.awt.Graphics2D g,
MapView mv,
java.util.List<WayPoint> visibleSegments,
Bounds clipBounds)
Draw all enabled GPX elements of layer.
|
private void |
drawArrows(java.awt.Graphics2D g,
MapView mv,
java.util.List<WayPoint> visibleSegments)
Draw all GPX arrays
|
void |
drawColorBar(java.awt.Graphics2D g,
MapView mv)
Draw all GPX arrays
|
private static void |
drawHeatGrayDotMap(java.awt.Graphics2D gB,
MapView mv,
java.util.List<WayPoint> listSegm,
int drawSize)
Draw a dotted heat map
|
private void |
drawHeatGrayLineMap(java.awt.Graphics2D gB,
MapView mv,
java.util.List<WayPoint> listSegm,
java.awt.Composite foreComp,
java.awt.Stroke foreStroke,
java.awt.Composite backComp,
java.awt.Stroke backStroke)
Draw gray heat map with current Graphics2D setting
|
private void |
drawHeatMap(java.awt.Graphics2D g,
MapView mv,
java.util.List<WayPoint> visibleSegments)
Collect and draw GPS segments and displays a heat-map
|
private void |
drawHeatMapGrayMap(java.awt.Graphics2D g,
java.awt.image.BufferedImage imgGray,
int sampleRaster,
int outlineWidth)
Map the gray map to heat map and draw them with current Graphics2D setting
|
private static void |
drawHeatSurfaceLine(java.awt.Graphics2D g,
java.awt.Point fromPnt,
java.awt.Point toPnt,
int drawSize,
double rmsSizeX,
double rmsSizeY,
double dropRate)
Draw a dotted surface line
|
private void |
drawLines(java.awt.Graphics2D g,
MapView mv,
java.util.List<WayPoint> visibleSegments)
Draw all GPX ways segments
|
private void |
drawLinesAlpha(java.awt.Graphics2D g,
MapView mv,
java.util.List<WayPoint> visibleSegments,
float layerAlpha)
Draw GPX lines by using alpha blending
|
private void |
drawPoints(java.awt.Graphics2D g,
MapView mv,
java.util.List<WayPoint> visibleSegments)
Draw all GPX points
|
private void |
ensureTrackVisibilityLength()
ensures the trackVisibility array has the correct length without losing data.
|
private void |
fixColors(java.util.List<WayPoint> visibleSegments)
Apply default color configuration to way segments
|
java.awt.Color |
getColor(java.lang.String layerName,
boolean ignoreCustom)
Get the default color for gps tracks for specified layer
|
static javax.swing.ImageIcon |
getColorMapImageIcon(java.awt.Color userColor,
int tableIdx,
int size)
Generates a Icon
|
GpxDrawHelper.ColorMode |
getColorMode(java.lang.String layerName)
Read coloring mode for specified layer from preferences
|
static java.awt.Color |
getGenericColor()
Reads generic color from preferences (usually gray)
|
void |
gpxDataChanged(GpxData.GpxDataChangeEvent e)
callback when data is changed, invalidate cached configuration parameters
|
private java.util.List<WayPoint> |
listVisibleSegments(Bounds box) |
void |
paint(MapViewGraphics graphics)
Paints the given layer.
|
void |
paintableInvalidated(MapViewPaintable.PaintableInvalidationEvent event)
Called whenever a
MapViewPaintable.PaintableInvalidationEvent is fired. |
void |
readPreferences(java.lang.String layerName)
Read all drawing-related settings from preferences
|
protected static java.awt.Color[] |
selectColorMap(java.awt.Color userColor,
int tableIdx)
Returns the next user color map
|
private void |
setupColors() |
private static java.lang.String |
specName(java.lang.String layerName) |
void |
systemOfMeasurementChanged(java.lang.String oldSoM,
java.lang.String newSoM)
The current SoM has changed.
|
public static final NamedColorProperty DEFAULT_COLOR
private boolean forceLines
private boolean alphaLines
private boolean direction
private int lineWidth
private int maxLineLength
private boolean lines
private boolean large
private int largesize
private boolean hdopCircle
private boolean alternateDirection
private int delta
private double minTrackDurationForTimeColoring
private int hdoprange
private static final double PHI
private boolean computeCacheInSync
private int computeCacheMaxLineLengthUsed
private java.awt.Color computeCacheColorUsed
private boolean computeCacheColorDynamic
private GpxDrawHelper.ColorMode computeCacheColored
private int computeCacheColorTracksTune
private int computeCacheHeatMapDrawColorTableIdx
private boolean computeCacheHeatMapDrawPointMode
private int computeCacheHeatMapDrawGain
private int computeCacheHeatMapDrawLowerLimit
private GpxDrawHelper.ColorMode colored
private int colorTracksTune
private boolean colorModeDynamic
private java.awt.Color neutralColor
private int largePointAlpha
private ColorScale velocityScale
private ColorScale hdopScale
private ColorScale qualityScale
private ColorScale dateScale
private ColorScale directionScale
private int hdopAlpha
private static final int ll0
private static final int sl4
private static final int sl9
private static final int[][] dir
private boolean heatMapEnabled
private boolean heatMapDrawExtraLine
private int heatMapDrawColorTableIdx
private boolean heatMapDrawPointMode
private int heatMapDrawGain
private int heatMapDrawLowerLimit
private java.awt.image.BufferedImage heatMapImgGray
private java.awt.Graphics2D heatMapGraph2d
java.awt.Rectangle heatMapCacheScreenBounds
MapViewState heatMapMapViewState
int heatMapCacheLineWith
private final java.util.List<java.lang.Integer> heatMapPolyX
private final java.util.List<java.lang.Integer> heatMapPolyY
private static java.awt.Color[] heatMapLutColorJosmInferno
private static java.awt.Color[] heatMapLutColorJosmViridis
private static java.awt.Color[] heatMapLutColorJosmBrown2Green
private static java.awt.Color[] heatMapLutColorJosmRed2Blue
private static java.awt.Color[] rtkLibQualityColors
private java.awt.Color[] heatMapLutColor
private boolean gpxLayerInvalidated
public GpxDrawHelper(GpxLayer gpxLayer)
GpxDrawHelper
.gpxLayer
- The layer to drawprivate void setupColors()
public void systemOfMeasurementChanged(java.lang.String oldSoM, java.lang.String newSoM)
SystemOfMeasurement.SoMChangeListener
systemOfMeasurementChanged
in interface SystemOfMeasurement.SoMChangeListener
oldSoM
- The old system of measurementnewSoM
- The new (current) system of measurementprivate static java.lang.String specName(java.lang.String layerName)
public java.awt.Color getColor(java.lang.String layerName, boolean ignoreCustom)
layerName
- name of the GpxLayerignoreCustom
- do not use preferencespublic GpxDrawHelper.ColorMode getColorMode(java.lang.String layerName)
layerName
- name of the GpxLayerpublic static java.awt.Color getGenericColor()
public void readPreferences(java.lang.String layerName)
layerName
- layer name used to access its specific preferencespublic void paint(MapViewGraphics graphics)
MapViewPaintable.LayerPainter
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.LayerPainter
for different map views.
paint
in interface MapViewPaintable.LayerPainter
graphics
- The graphics object of the map view you should use.
It provides you with a content pane, the bounds and the view state.private java.util.List<WayPoint> listVisibleSegments(Bounds box)
private void ensureTrackVisibilityLength()
public void drawAll(java.awt.Graphics2D g, MapView mv, java.util.List<WayPoint> visibleSegments, Bounds clipBounds)
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 viewpublic void calculateColors()
private void drawLines(java.awt.Graphics2D g, MapView mv, java.util.List<WayPoint> visibleSegments)
g
- the common draw object to usemv
- the meta data to current displayed areavisibleSegments
- segments visible in the current scope of mvprivate void drawArrows(java.awt.Graphics2D g, MapView mv, java.util.List<WayPoint> visibleSegments)
g
- the common draw object to usemv
- the meta data to current displayed areavisibleSegments
- segments visible in the current scope of mvprivate void drawPoints(java.awt.Graphics2D g, MapView mv, java.util.List<WayPoint> visibleSegments)
g
- the common draw object to usemv
- the meta data to current displayed areavisibleSegments
- segments visible in the current scope of mvprivate void drawLinesAlpha(java.awt.Graphics2D g, MapView mv, java.util.List<WayPoint> visibleSegments, float layerAlpha)
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 operationprotected static java.awt.image.BufferedImage createImageGradientMap(int width, int height, java.awt.Color... colors)
width
- image widthheight
- image heightcolors
- 1..n color descriptionsprotected static java.awt.Color[] createColorLut(int lowerLimit, java.awt.Color... colors)
lowerLimit
- lower limit for first visible colorcolors
- 1..n colorsprotected static java.awt.Color darkerColor(java.awt.Color in, float adjust)
in
- Color objectadjust
- darker adjustment amountprotected static java.awt.Color[] createColorFromResource(java.lang.String str)
str
- the filename (without extension) to look for into data/gpxprotected static java.awt.Color[] selectColorMap(java.awt.Color userColor, int tableIdx)
userColor
- - default or fallback user colortableIdx
- - selected user color indexpublic static javax.swing.ImageIcon getColorMapImageIcon(java.awt.Color userColor, int tableIdx, int size)
userColor
- selected user colortableIdx
- tabled indexsize
- size of the imageprivate void drawHeatGrayLineMap(java.awt.Graphics2D gB, MapView mv, java.util.List<WayPoint> listSegm, java.awt.Composite foreComp, java.awt.Stroke foreStroke, java.awt.Composite backComp, java.awt.Stroke backStroke)
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 objectsprivate void drawHeatMapGrayMap(java.awt.Graphics2D g, java.awt.image.BufferedImage imgGray, int sampleRaster, int outlineWidth)
g
- the common draw object to useimgGray
- gray scale input imagesampleRaster
- the line with for drawingoutlineWidth
- line width for outlinesprivate void drawHeatMap(java.awt.Graphics2D g, MapView mv, java.util.List<WayPoint> visibleSegments)
g
- the common draw object to usemv
- the meta data to current displayed areavisibleSegments
- segments visible in the current scope of mvprivate static void drawHeatGrayDotMap(java.awt.Graphics2D gB, MapView mv, java.util.List<WayPoint> listSegm, int drawSize)
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 elementprivate static void drawHeatSurfaceLine(java.awt.Graphics2D g, java.awt.Point fromPnt, java.awt.Point toPnt, int drawSize, double rmsSizeX, double rmsSizeY, double dropRate)
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 rateprivate void fixColors(java.util.List<WayPoint> visibleSegments)
visibleSegments
- segments visible in the current scope of mvprivate void checkCache()
public void gpxDataChanged(GpxData.GpxDataChangeEvent e)
gpxDataChanged
in interface GpxData.GpxDataChangeListener
e
- The eventpublic void drawColorBar(java.awt.Graphics2D g, MapView mv)
g
- the common draw object to usemv
- the meta data to current displayed areapublic void paintableInvalidated(MapViewPaintable.PaintableInvalidationEvent event)
MapViewPaintable.PaintableInvalidationListener
MapViewPaintable.PaintableInvalidationEvent
is fired. This might be called from any thread.paintableInvalidated
in interface MapViewPaintable.PaintableInvalidationListener
event
- The eventpublic void detachFromMapView(MapViewPaintable.MapViewEvent event)
MapViewPaintable.LayerPainter
This method is called once on the painter returned by AbstractMapViewPaintable.attachToMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)
detachFromMapView
in interface MapViewPaintable.LayerPainter
event
- The event.