Class GpxDrawHelper

    • Constructor Detail

      • GpxDrawHelper

        public GpxDrawHelper​(GpxLayer gpxLayer)
        Constructs a new GpxDrawHelper.
        Parameters:
        gpxLayer - The layer to draw
        Since:
        12157
    • Method Detail

      • opt

        private java.lang.String opt​(java.lang.String key)
      • optBool

        private boolean optBool​(java.lang.String key)
      • optInt

        private int optInt​(java.lang.String key)
      • readPreferences

        public void readPreferences()
        Read all drawing-related settings from preferences
      • paint

        public void paint​(MapViewGraphics graphics)
        Description copied from interface: MapViewPaintable.LayerPainter
        Paints 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.LayerPainter for different map views.

        Specified by:
        paint in interface MapViewPaintable.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.
      • getLinesIterable

        protected java.lang.Iterable<LinegetLinesIterable​(boolean[] trackVisibility)
      • ensureTrackVisibilityLength

        private void 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

        public void drawAll​(java.awt.Graphics2D g,
                            MapView mv,
                            java.util.List<WayPoint> visibleSegments,
                            Bounds clipBounds)
        Draw all enabled GPX elements of layer.
        Parameters:
        g - the common draw object to use
        mv - the meta data to current displayed area
        visibleSegments - segments visible in the current scope of mv
        clipBounds - the clipping rectangle for the current view
        Since:
        14748 : new parameter clipBounds
      • calculateColors

        public void calculateColors()
        Calculate colors of way segments based on latest configuration settings
      • drawLines

        private void drawLines​(java.awt.Graphics2D g,
                               MapView mv,
                               java.util.List<WayPoint> visibleSegments)
        Draw all GPX ways segments
        Parameters:
        g - the common draw object to use
        mv - the meta data to current displayed area
        visibleSegments - segments visible in the current scope of mv
      • drawArrows

        private void drawArrows​(java.awt.Graphics2D g,
                                MapView mv,
                                java.util.List<WayPoint> visibleSegments)
        Draw all GPX arrays
        Parameters:
        g - the common draw object to use
        mv - the meta data to current displayed area
        visibleSegments - segments visible in the current scope of mv
      • drawArrows3b

        private void drawArrows3b​(java.awt.Graphics2D g,
                                  MapView mv,
                                  java.util.List<WayPoint> visibleSegments)
        STEP 3b - DRAW NICE ARROWS **************************
      • drawArrows3c

        private void drawArrows3c​(java.awt.Graphics2D g,
                                  MapView mv,
                                  java.util.List<WayPoint> visibleSegments)
        STEP 3c - DRAW FAST ARROWS **************************
      • drawPoints

        private void drawPoints​(java.awt.Graphics2D g,
                                MapView mv,
                                java.util.List<WayPoint> visibleSegments)
        Draw all GPX points
        Parameters:
        g - the common draw object to use
        mv - the meta data to current displayed area
        visibleSegments - segments visible in the current scope of mv
      • drawPointsStep3d

        private void drawPointsStep3d​(java.awt.Graphics2D g,
                                      MapView mv,
                                      java.util.List<WayPoint> visibleSegments)
        STEP 3d - DRAW LARGE POINTS AND CIRCLES ***********
      • drawCircle

        private void drawCircle​(java.awt.Graphics2D g,
                                MapView mv,
                                WayPoint trkPnt,
                                java.awt.Point screen,
                                float circleSize)
      • drawPointsStep3e

        private void drawPointsStep3e​(java.awt.Graphics2D g,
                                      MapView mv,
                                      java.util.List<WayPoint> visibleSegments)
        STEP 3e - DRAW SMALL POINTS FOR LINES ***************
      • drawPointsStep3f

        private void drawPointsStep3f​(java.awt.Graphics2D g,
                                      MapView mv,
                                      java.util.List<WayPoint> visibleSegments)
        STEP 3f - DRAW SMALL POINTS INSTEAD OF LINES ********
      • drawLinesAlpha

        private void drawLinesAlpha​(java.awt.Graphics2D g,
                                    MapView mv,
                                    java.util.List<WayPoint> visibleSegments,
                                    float layerAlpha)
        Draw GPX lines by using alpha blending
        Parameters:
        g - the common draw object to use
        mv - the meta data to current displayed area
        visibleSegments - segments visible in the current scope of mv
        layerAlpha - the color alpha value set for that operation
      • createImageGradientMap

        protected static java.awt.image.BufferedImage createImageGradientMap​(int width,
                                                                             int height,
                                                                             java.awt.Color... colors)
        Generates a linear gradient map image
        Parameters:
        width - image width
        height - image height
        colors - 1..n color descriptions
        Returns:
        image object
      • createColorLut

        protected static java.awt.Color[] createColorLut​(int lowerLimit,
                                                         java.awt.Color... colors)
        Creates a distributed colormap by linear blending between colors
        Parameters:
        lowerLimit - lower limit for first visible color
        colors - 1..n colors
        Returns:
        array of Color objects
      • darkerColor

        protected static java.awt.Color darkerColor​(java.awt.Color in,
                                                    float adjust)
        Creates a darker color
        Parameters:
        in - Color object
        adjust - darker adjustment amount
        Returns:
        new Color
      • createColorFromResource

        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)
        Parameters:
        str - the filename (without extension) to look for into data/gpx
        Returns:
        the parsed colormap
      • selectColorMap

        protected static java.awt.Color[] selectColorMap​(java.awt.Color userColor,
                                                         int tableIdx)
        Returns the next user color map
        Parameters:
        userColor - - default or fallback user color
        tableIdx - - selected user color index
        Returns:
        color array
      • getColorMapImageIcon

        public static javax.swing.ImageIcon getColorMapImageIcon​(java.awt.Color userColor,
                                                                 int tableIdx,
                                                                 int size)
        Generates a Icon
        Parameters:
        userColor - selected user color
        tableIdx - tabled index
        size - size of the image
        Returns:
        a image icon that shows the
      • drawHeatGrayLineMap

        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
        Parameters:
        gB - the common draw object to use
        mv - the meta data to current displayed area
        listSegm - segments visible in the current scope of mv
        foreComp - composite use to draw foreground objects
        foreStroke - stroke use to draw foreground objects
        backComp - composite use to draw background objects
        backStroke - stroke use to draw background objects
      • drawHeatMapGrayMap

        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
        Parameters:
        g - the common draw object to use
        imgGray - gray scale input image
        sampleRaster - the line with for drawing
        outlineWidth - line width for outlines
      • drawHeatMap

        private void drawHeatMap​(java.awt.Graphics2D g,
                                 MapView mv,
                                 java.util.List<WayPoint> visibleSegments)
        Collect and draw GPS segments and displays a heat-map
        Parameters:
        g - the common draw object to use
        mv - the meta data to current displayed area
        visibleSegments - segments visible in the current scope of mv
      • drawHeatGrayDotMap

        private static void drawHeatGrayDotMap​(java.awt.Graphics2D gB,
                                               MapView mv,
                                               java.util.List<WayPoint> listSegm,
                                               int drawSize)
        Draw a dotted heat map
        Parameters:
        gB - the common draw object to use
        mv - the meta data to current displayed area
        listSegm - segments visible in the current scope of mv
        drawSize - draw size of draw element
      • drawHeatSurfaceLine

        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
        Parameters:
        g - the common draw object to use
        fromPnt - start point
        toPnt - end point
        drawSize - size of draw elements
        rmsSizeX - RMS size of circle for X (width)
        rmsSizeY - RMS size of circle for Y (height)
        dropRate - Pixel render drop rate
      • fixColors

        private void fixColors​(java.util.List<WayPoint> visibleSegments)
        Apply default color configuration to way segments
        Parameters:
        visibleSegments - segments visible in the current scope of mv
      • checkCache

        private void checkCache()
        Check cache validity set necessary flags
      • drawColorBar

        public void drawColorBar​(java.awt.Graphics2D g,
                                 MapView mv)
        Draw all GPX arrays
        Parameters:
        g - the common draw object to use
        mv - the meta data to current displayed area