Ticket #20600: 20600.patch
File 20600.patch, 11.8 KB (added by , 3 years ago) |
---|
-
src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
### Eclipse Workspace Patch 1.0 #P josm-2
132 132 /** Colors (without custom alpha channel, if given) for HDOP painting. **/ 133 133 private ColorScale hdopScale; 134 134 private ColorScale qualityScale; 135 private ColorScale fixScale; 135 136 private ColorScale dateScale; 136 137 private ColorScale directionScale; 137 138 … … 190 191 Color.CYAN // PPP 191 192 }; 192 193 194 private static final String[] rtkLibQualityNames = { 195 "1 - Fixed", 196 "2 - Float", 197 "3 - Reserved", 198 "4 - DGPS", 199 "5 - Single", 200 "6 - PPP" 201 }; 202 203 /** 204 * @see GpxConstants#FIX_VALUES 205 */ 206 private static final Color[] gpsFixQualityColors = { 207 Color.MAGENTA, //None 208 new Color(255, 125, 0), //2D (orange-red) 209 Color.ORANGE, //3D 210 Color.CYAN, //DGPS 211 new Color(150, 255, 150), //PPS (light-green) 212 Color.GREEN, //RTK 213 Color.YELLOW, //Float RTK 214 Color.RED, //Estimated 215 Color.BLUE, //Manual 216 Color.GRAY //Simulated 217 }; 218 219 private static final String[] gpsFixQualityNames = { 220 "None", 221 "2D", 222 "3D", 223 "DGPS", 224 "PPS", 225 "RTK", 226 "Float RTK", 227 "Estimated", 228 "Manual", 229 "Simulated" 230 }; 231 193 232 // user defined heatmap color 194 233 private Color[] heatMapLutColor = createColorLut(0, Color.BLACK, Color.WHITE); 195 234 … … 201 240 velocityScale = ColorScale.createHSBScale(256); 202 241 /** Colors (without custom alpha channel, if given) for HDOP painting. **/ 203 242 hdopScale = ColorScale.createHSBScale(256).makeReversed().addTitle(tr("HDOP")); 204 qualityScale = ColorScale.createFixedScale(rtkLibQualityColors).addTitle(tr("Quality")); 243 qualityScale = ColorScale.createFixedScale(rtkLibQualityColors).addTitle(tr("Quality")).addColorBarTitles(rtkLibQualityNames); 244 fixScale = ColorScale.createFixedScale(gpsFixQualityColors).addTitle(tr("GPS Fix")).addColorBarTitles(gpsFixQualityNames); 205 245 dateScale = ColorScale.createHSBScale(256).addTitle(tr("Time")); 206 246 directionScale = ColorScale.createCyclicScale(256).setIntervalCount(4).addTitle(tr("Direction")); 207 247 … … 246 286 /** 247 287 * Color by quality (RTKLib) 248 288 */ 249 QUALITY; 289 QUALITY, 290 /** 291 * Color by GPS fix 292 */ 293 FIX; 250 294 251 295 static ColorMode fromIndex(final int index) { 252 296 return values()[index]; … … 347 391 dateScale.setNoDataColor(neutralColor); 348 392 hdopScale.setNoDataColor(neutralColor); 349 393 qualityScale.setNoDataColor(neutralColor); 394 fixScale.setNoDataColor(neutralColor); 350 395 directionScale.setNoDataColor(neutralColor); 351 396 352 397 largesize += lineWidth; … … 562 607 velocityScale.setRange(0, velocityTune); 563 608 hdopScale.setRange(0, hdoprange); 564 609 qualityScale.setRange(1, rtkLibQualityColors.length); 610 fixScale.setRange(0, gpsFixQualityColors.length); 565 611 } 566 612 double now = System.currentTimeMillis()/1000.0; 567 613 if (colored == ColorMode.TIME) { … … 589 635 color = hdopScale.getColor((Float) trkPnt.get(GpxConstants.PT_HDOP)); 590 636 } else if (colored == ColorMode.QUALITY) { 591 637 color = qualityScale.getColor((Integer) trkPnt.get(GpxConstants.RTKLIB_Q)); 638 } else if (colored == ColorMode.FIX) { 639 Object fixval = trkPnt.get(GpxConstants.PT_FIX); 640 if (fixval != null) { 641 int fix = GpxConstants.FIX_VALUES.indexOf(fixval); 642 if (fix >= 0) { 643 color = fixScale.getColor(fix); 644 } 645 } 592 646 } 593 647 if (oldWp != null) { // other coloring modes need segment for calcuation 594 648 double dist = c.greatCircleDistance(oldWp.getCoor()); … … 1516 1570 hdopScale.drawColorBar(g, w-30, 50, 20, 100, 1.0); 1517 1571 } else if (colored == ColorMode.QUALITY) { 1518 1572 qualityScale.drawColorBar(g, w-30, 50, 20, 100, 1.0); 1573 } else if (colored == ColorMode.FIX) { 1574 fixScale.drawColorBar(g, w-30, 50, 20, 175, 1.0); 1519 1575 } else if (colored == ColorMode.VELOCITY) { 1520 1576 SystemOfMeasurement som = SystemOfMeasurement.getSystemOfMeasurement(); 1521 1577 velocityScale.drawColorBar(g, w-30, 50, 20, 100, som.speedValue); -
src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
70 70 private final JRadioButton colorTypeDirection = new JRadioButton(tr("Direction (red = west, yellow = north, green = east, blue = south)")); 71 71 private final JRadioButton colorTypeDilution = new JRadioButton(tr("Dilution of Position (red = high, green = low, if available)")); 72 72 private final JRadioButton colorTypeQuality = new JRadioButton(tr("Quality (RTKLib only, if available)")); 73 private final JRadioButton colorTypeFix = new JRadioButton(tr("GPS fix value")); 73 74 private final JRadioButton colorTypeTime = new JRadioButton(tr("Track date")); 74 75 private final JRadioButton colorTypeHeatMap = new JRadioButton(tr("Heat Map (dark = few, bright = many)")); 75 76 private final JRadioButton colorTypeNone = new JRadioButton(tr("Single Color (can be customized in the layer manager)")); … … 452 453 colorGroup.add(colorTypeDirection); 453 454 colorGroup.add(colorTypeDilution); 454 455 colorGroup.add(colorTypeQuality); 456 colorGroup.add(colorTypeFix); 455 457 colorGroup.add(colorTypeTime); 456 458 colorGroup.add(colorTypeHeatMap); 457 459 … … 462 464 tr("Colors points and track segments by dilution of position (HDOP). Your capture device needs to log that information.")); 463 465 colorTypeQuality.setToolTipText( 464 466 tr("Colors points and track segments by RTKLib quality flag (Q). Your capture device needs to log that information.")); 467 colorTypeFix.setToolTipText(tr("Colors points and track segments by GPS fix value.")); 465 468 colorTypeTime.setToolTipText(tr("Colors points and track segments by its timestamp.")); 466 469 colorTypeHeatMap.setToolTipText(tr("Collected points and track segments for a position and displayed as heat map.")); 467 470 … … 483 486 add(colorTypeDirection, GBC.eol().insets(40, 0, 0, 0)); 484 487 add(colorTypeDilution, GBC.eol().insets(40, 0, 0, 0)); 485 488 add(colorTypeQuality, GBC.eol().insets(40, 0, 0, 0)); 489 add(colorTypeFix, GBC.eol().insets(40, 0, 0, 0)); 486 490 add(colorTypeTime, GBC.eol().insets(40, 0, 0, 0)); 487 491 add(colorTypeHeatMap, GBC.std().insets(40, 0, 0, 0)); 488 492 add(colorTypeHeatIconLabel, GBC.std().insets(5, 0, 0, 5)); … … 636 640 case 4: colorTypeTime.setSelected(true); break; 637 641 case 5: colorTypeHeatMap.setSelected(true); break; 638 642 case 6: colorTypeQuality.setSelected(true); break; 643 case 7: colorTypeFix.setSelected(true); break; 639 644 default: Logging.warn("Unknown color type: " + colorType); 640 645 } 641 646 int ccts = prefInt("colormode.velocity.tune"); … … 712 717 putPref("colormode", 5); 713 718 } else if (colorTypeQuality.isSelected()) { 714 719 putPref("colormode", 6); 720 } else if (colorTypeFix.isSelected()) { 721 putPref("colormode", 7); 715 722 } else { 716 723 putPref("colormode", 0); 717 724 } -
src/org/openstreetmap/josm/io/GpxReader.java
464 464 case "urlname": 465 465 case "cmt": 466 466 case "desc": 467 case "fix": 467 468 currentWayPoint.put(localName, accumulator.toString()); 468 469 break; 469 470 case "hdop": -
src/org/openstreetmap/josm/tools/ColorScale.java
4 4 import java.awt.Color; 5 5 import java.awt.FontMetrics; 6 6 import java.awt.Graphics2D; 7 import java.util.Arrays; 7 8 8 9 /** 9 10 * Utility class that helps to work with color scale for coloring GPX tracks etc. … … 16 17 private Color aboveMaxColor; 17 18 18 19 private Color[] colors; 20 private String[] colorBarTitles; 19 21 private String title = ""; 20 22 private int intervalCount = 5; 21 23 … … 182 184 return this; 183 185 } 184 186 187 public ColorScale addColorBarTitles(String[] titles) { 188 this.intervalCount = titles.length - 1; 189 this.colorBarTitles = titles; 190 return this; 191 } 192 185 193 /** 186 194 * Sets the interval count for this scale 187 195 * @param intervalCount The interval count hint … … 234 242 int fw, fh; 235 243 FontMetrics fm = g.getFontMetrics(); 236 244 fh = fm.getHeight()/2; 237 fw = fm.stringWidth(String.valueOf(Math.max((int) Math.abs(max*valueScale), 238 (int) Math.abs(min*valueScale)))) + fm.stringWidth("0.123"); 245 if (colorBarTitles != null && colorBarTitles.length > 0) { 246 fw = Arrays.asList(colorBarTitles).stream().mapToInt(title -> fm.stringWidth(title)).max().orElse(50); 247 } else { 248 fw = fm.stringWidth( 249 String.valueOf(Math.max((int) Math.abs(max * valueScale), (int) Math.abs(min * valueScale)))) 250 + fm.stringWidth("0.123"); 251 } 239 252 g.setColor(noDataColor); 240 253 if (title != null) { 241 254 g.drawString(title, x-fw-3, y-fh*3/2); … … 242 255 } 243 256 for (int i = 0; i <= intervalCount; i++) { 244 257 g.setColor(colors[(int) (1.0*i*n/intervalCount-1e-10)]); 245 final double val = min+i*(max-min)/intervalCount; 246 final String txt = String.format("%.3f", val*valueScale); 258 String txt; 259 if (colorBarTitles != null && i < colorBarTitles.length) { 260 txt = colorBarTitles[i]; 261 } else { 262 final double val = min+i*(max-min)/intervalCount; 263 txt = String.format("%.3f", val*valueScale); 264 } 247 265 if (w < h) { 248 266 g.drawString(txt, x-fw-3, y+i*h/intervalCount+fh/2); 249 267 } else { -
src/org/openstreetmap/josm/data/gpx/GpxConstants.java
3 3 4 4 import java.awt.Color; 5 5 import java.util.Arrays; 6 import java.util.Collection;7 6 import java.util.Collections; 8 7 import java.util.List; 9 8 import java.util.Map; … … 252 251 /** 253 252 * Possible fix values. NMEA 0183 Version 4.00 254 253 */ 255 Collection<String> FIX_VALUES = Collections.unmodifiableList(254 List<String> FIX_VALUES = Collections.unmodifiableList( 256 255 Arrays.asList("none", "2d", "3d", "dgps", "pps", "rtk", "float rtk", "estimated", "manual", "simulated")); 257 256 258 257 /**