Changeset 18396 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2022-03-13T13:27:16+01:00 (3 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxConstants.java
r18287 r18396 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; … … 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 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r18253 r18396 133 133 private ColorScale hdopScale; 134 134 private ColorScale qualityScale; 135 private ColorScale fixScale; 135 136 private ColorScale dateScale; 136 137 private ColorScale directionScale; … … 191 192 }; 192 193 194 private static final String[] rtkLibQualityNames = { 195 tr("1 - Fixed"), 196 tr("2 - Float"), 197 tr("3 - Reserved"), 198 tr("4 - DGPS"), 199 tr("5 - Single"), 200 tr("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 tr("None"), 221 tr("2D"), 222 tr("3D"), 223 tr("DGPS"), 224 tr("PPS"), 225 tr("RTK"), 226 tr("Float RTK"), 227 tr("Estimated"), 228 tr("Manual"), 229 tr("Simulated") 230 }; 231 193 232 // user defined heatmap color 194 233 private Color[] heatMapLutColor = createColorLut(0, Color.BLACK, Color.WHITE); … … 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")); … … 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) { … … 348 392 hdopScale.setNoDataColor(neutralColor); 349 393 qualityScale.setNoDataColor(neutralColor); 394 fixScale.setNoDataColor(neutralColor); 350 395 directionScale.setNoDataColor(neutralColor); 351 396 … … 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; … … 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 … … 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(); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
r18287 r18396 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)")); … … 453 454 colorGroup.add(colorTypeDilution); 454 455 colorGroup.add(colorTypeQuality); 456 colorGroup.add(colorTypeFix); 455 457 colorGroup.add(colorTypeTime); 456 458 colorGroup.add(colorTypeHeatMap); … … 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.")); … … 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)); … … 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 } … … 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); -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r18211 r18396 465 465 case "cmt": 466 466 case "desc": 467 case "fix": 467 468 currentWayPoint.put(localName, accumulator.toString()); 468 469 break; -
trunk/src/org/openstreetmap/josm/tools/ColorScale.java
r15586 r18396 5 5 import java.awt.FontMetrics; 6 6 import java.awt.Graphics2D; 7 import java.util.Arrays; 7 8 8 9 /** … … 17 18 18 19 private Color[] colors; 20 private String[] colorBarTitles; 19 21 private String title = ""; 20 22 private int intervalCount = 5; … … 184 186 185 187 /** 188 * Adds titles to the color bar for a fixed scale 189 * @param titles Array of String, same length as the colors array 190 * @return This scale, for chaining 191 * @since 18396 192 */ 193 public ColorScale addColorBarTitles(String[] titles) { 194 this.intervalCount = titles.length - 1; 195 this.colorBarTitles = titles; 196 return this; 197 } 198 199 /** 186 200 * Sets the interval count for this scale 187 201 * @param intervalCount The interval count hint … … 235 249 FontMetrics fm = g.getFontMetrics(); 236 250 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"); 251 if (colorBarTitles != null && colorBarTitles.length > 0) { 252 fw = Arrays.asList(colorBarTitles).stream().mapToInt(title -> fm.stringWidth(title)).max().orElse(50); 253 } else { 254 fw = fm.stringWidth( 255 String.valueOf(Math.max((int) Math.abs(max * valueScale), (int) Math.abs(min * valueScale)))) 256 + fm.stringWidth("0.123"); 257 } 239 258 g.setColor(noDataColor); 240 259 if (title != null) { … … 243 262 for (int i = 0; i <= intervalCount; i++) { 244 263 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); 264 String txt; 265 if (colorBarTitles != null && i < colorBarTitles.length) { 266 txt = colorBarTitles[i]; 267 } else { 268 final double val = min+i*(max-min)/intervalCount; 269 txt = String.format("%.3f", val*valueScale); 270 } 247 271 if (w < h) { 248 272 g.drawString(txt, x-fw-3, y+i*h/intervalCount+fh/2);
Note:
See TracChangeset
for help on using the changeset viewer.