Changeset 6895 in josm


Ignore:
Timestamp:
2014-03-02T15:38:21+01:00 (10 years ago)
Author:
bastiK
Message:

applied #9228 - Set transparency of circle from HDOP value (by simon04; slightly extended)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r6246 r6895  
    2525    public double time;
    2626    public Color customColoring;
     27    public Color customColoringTransparent;
    2728    public boolean drawLine;
    2829    public int dir;
     
    3637        time = p.time;
    3738        customColoring = p.customColoring;
     39        customColoringTransparent = p.customColoringTransparent;
    3840        drawLine = p.drawLine;
    3941        dir = p.dir;
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r6889 r6895  
    367367        for (int i = 0; i < colors.length; i++) {
    368368            colors[i] = Color.getHSBColor(i / 300.0f, 1, 1);
     369        }
     370    }
     371    /** Colors (with custom alpha channel, if given) for HDOP painting. */
     372    private final Color[] hdopColors;
     373    private final int hdopAlpha = Main.pref.getInteger("hdop.color.alpha", -1);
     374    {
     375        if (hdopAlpha >= 0) {
     376            hdopColors = new Color[256];
     377            for (int i = 0; i < hdopColors.length; i++) {
     378                hdopColors[i] = new Color((colors[i].getRGB() & 0xFFFFFF) | ((hdopAlpha & 0xFF) << 24), true);
     379            }
     380        } else {
     381            hdopColors = colors;
    369382        }
    370383    }
     
    556569                    }
    557570                    trkPnt.customColoring = neutralColor;
    558                     if(colored == colorModes.dilution && trkPnt.attr.get("hdop") != null) {
    559                         float hdop = ((Float) trkPnt.attr.get("hdop")).floatValue();
    560                         int hdoplvl =(int) Math.round(colorModeDynamic ? ((hdop-minval)*255/(maxval-minval))
    561                                 : (hdop <= 0 ? 0 : hdop * hdopfactor));
    562                         // High hdop is bad, but high values in colors are green.
    563                         // Therefore inverse the logic
    564                         int hdopcolor = 255 - (hdoplvl > 255 ? 255 : hdoplvl);
    565                         trkPnt.customColoring = colors[hdopcolor];
     571                    if (trkPnt.attr.get("hdop") != null) {
     572                        if (colored == colorModes.dilution) {
     573                            float hdop = ((Float) trkPnt.attr.get("hdop")).floatValue();
     574                            int hdoplvl =(int) Math.round(colorModeDynamic ? ((hdop-minval)*255/(maxval-minval))
     575                                    : (hdop <= 0 ? 0 : hdop * hdopfactor));
     576                            // High hdop is bad, but high values in colors are green.
     577                            // Therefore inverse the logic
     578                            int hdopcolor = 255 - (hdoplvl > 255 ? 255 : hdoplvl);
     579                            trkPnt.customColoring = colors[hdopcolor];
     580                            trkPnt.customColoringTransparent = hdopColors[hdopcolor];
     581                        } else {
     582                            trkPnt.customColoringTransparent = new Color(
     583                                    neutralColor.getRed(), neutralColor.getGreen(), neutralColor.getBlue(), hdopAlpha & 0xFF);
     584                        }
    566585                    }
    567586                    if (oldWp != null) {
     
    740759                }
    741760                Point screen = mv.getPoint(trkPnt.getEastNorth());
    742                 g.setColor(trkPnt.customColoring);
     761                g.setColor(trkPnt.customColoringTransparent);
    743762                if (hdopcircle && trkPnt.attr.get("hdop") != null) {
    744763                    // hdop value
Note: See TracChangeset for help on using the changeset viewer.