- Timestamp:
- 2011-07-07T10:51:48+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r4143 r4207 78 78 import org.openstreetmap.josm.tools.ImageProvider; 79 79 import org.openstreetmap.josm.tools.UrlLabel; 80 import org.openstreetmap.josm.tools.Utils; 80 81 81 82 public class GpxLayer extends Layer { … … 304 305 } 305 306 306 private static Color[] colors = new Color[256];307 private final static Color[] colors = new Color[256]; 307 308 static { 308 309 for (int i = 0; i < colors.length; i++) { … … 311 312 } 312 313 314 private final static Color[] colors_cyclic = new Color[256]; 315 static { 316 for (int i = 0; i < colors_cyclic.length; i++) { 317 // red yellow green blue red 318 int[] h = new int[] { 0, 59, 127, 244, 360}; 319 int[] s = new int[] { 100, 84, 99, 100 }; 320 int[] b = new int[] { 90, 93, 74, 83 }; 321 322 float angle = 4 - i / 256f * 4; 323 int quadrant = (int) angle; 324 angle -= quadrant; 325 quadrant = Utils.mod(quadrant+1, 4); 326 327 float vh = h[quadrant] * w(angle) + h[quadrant+1] * (1 - w(angle)); 328 float vs = s[quadrant] * w(angle) + s[Utils.mod(quadrant+1, 4)] * (1 - w(angle)); 329 float vb = b[quadrant] * w(angle) + b[Utils.mod(quadrant+1, 4)] * (1 - w(angle)); 330 331 colors_cyclic[i] = Color.getHSBColor(vh/360f, vs/100f, vb/100f); 332 } 333 } 334 335 /** 336 * transition function: 337 * w(0)=1, w(1)=0, 0<=w(x)<=1 338 * @param x number: 0<=x<=1 339 * @return the weighted value 340 */ 341 private static float w(float x) { 342 if (x < 0.5) { 343 return 1 - 2*x*x; 344 } else { 345 return 2*(1-x)*(1-x); 346 } 347 } 348 313 349 // lookup array to draw arrows without doing any math 314 private static int ll0 = 9;315 private static int sl4 = 5;316 private static int sl9 = 3;317 private static int[][] dir = { { +sl4, +ll0, +ll0, +sl4 }, { -sl9, +ll0, +sl9, +ll0 }, { -ll0, +sl4, -sl4, +ll0 },350 private final static int ll0 = 9; 351 private final static int sl4 = 5; 352 private final static int sl9 = 3; 353 private final static int[][] dir = { { +sl4, +ll0, +ll0, +sl4 }, { -sl9, +ll0, +sl9, +ll0 }, { -ll0, +sl4, -sl4, +ll0 }, 318 354 { -ll0, -sl9, -ll0, +sl9 }, { -sl4, -ll0, -ll0, -sl4 }, { +sl9, -ll0, -sl9, -ll0 }, 319 355 { +ll0, -sl4, +sl4, -ll0 }, { +ll0, +sl9, +ll0, -sl9 }, { +sl4, +ll0, +ll0, +sl4 }, … … 322 358 // the different color modes 323 359 enum colorModes { 324 none, velocity, dilution 360 none, velocity, dilution, direction 325 361 } 326 362 … … 430 466 break; 431 467 468 case direction: 469 // unfortunately "heading" misses a cos-factor in the 470 // longitudes to account for the convergence of meridians 471 double dirColor = oldWp.getCoor().heading(trkPnt.getCoor()) / (2.0 * Math.PI) * 256; 472 // Bad case first 473 if (dirColor != dirColor || dirColor < 0.0 || dirColor >= 256.0) { 474 trkPnt.customColoring = colors_cyclic[0]; 475 } else { 476 trkPnt.customColoring = colors_cyclic[(int) (dirColor)]; 477 } 478 break; 432 479 case dilution: 433 480 if (trkPnt.attr.get("hdop") != null) { … … 647 694 } 648 695 696 @Override 649 697 public void actionPerformed(ActionEvent e) { 650 698 JPanel msg = new JPanel(new GridBagLayout()); … … 702 750 } 703 751 752 @Override 704 753 public void actionPerformed(ActionEvent e) { 705 754 JPanel msg = new JPanel(new GridBagLayout()); … … 876 925 Main.worker.submit( 877 926 new Runnable() { 927 @Override 878 928 public void run() { 879 929 try { … … 1087 1137 1088 1138 Collections.sort((ArrayList<WayPoint>) waypoints, new Comparator<WayPoint>() { 1139 @Override 1089 1140 public int compare(WayPoint a, WayPoint b) { 1090 1141 return a.time <= b.time ? -1 : 1; … … 1405 1456 if (sel.length > 1) { 1406 1457 Arrays.sort(sel, new Comparator<File>() { 1458 @Override 1407 1459 public int compare(File a, File b) { 1408 1460 return a.lastModified() <= b.lastModified() ? -1 : 1; -
trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java
r3996 r4207 45 45 private ButtonGroup colorGroup; 46 46 private JRadioButton colorTypeVelocity = new JRadioButton(tr("Velocity (red = slow, green = fast)")); 47 private JRadioButton colorTypeDirection = new JRadioButton(tr("Direction (red = west, yellow = north, green = east, blue = south)")); 47 48 private JRadioButton colorTypeDilution = new JRadioButton(tr("Dilution of Position (red = high, green = low, if available)")); 48 49 private JRadioButton colorTypeNone = new JRadioButton(tr("Single Color (can be customized for named layers)")); … … 170 171 colorGroup.add(colorTypeNone); 171 172 colorGroup.add(colorTypeVelocity); 173 colorGroup.add(colorTypeDirection); 172 174 colorGroup.add(colorTypeDilution); 173 175 … … 188 190 colorTypeDilution.setSelected(true); 189 191 break; 192 case 3: 193 colorTypeDirection.setSelected(true); 194 break; 190 195 } 191 196 192 197 colorTypeNone.setToolTipText(tr("All points and track segments will have the same color. Can be customized in Layer Manager.")); 193 198 colorTypeVelocity.setToolTipText(tr("Colors points and track segments by velocity.")); 199 colorTypeDirection.setToolTipText(tr("Colors points and track segments by direction.")); 194 200 colorTypeDilution.setToolTipText(tr("Colors points and track segments by dilution of position (HDOP). Your capture device needs to log that information.")); 195 201 … … 206 212 panel.add(colorTypeVelocity, GBC.std().insets(40,0,0,0)); 207 213 panel.add(colorTypeVelocityTune, GBC.eop().insets(5,0,0,5)); 214 panel.add(colorTypeDirection, GBC.eol().insets(40,0,0,0)); 208 215 panel.add(colorTypeDilution, GBC.eol().insets(40,0,0,0)); 209 216 … … 300 307 } else if(colorTypeDilution.isSelected()) { 301 308 Main.pref.putInteger("draw.rawgps.colors", 2); 309 } else if(colorTypeDirection.isSelected()) { 310 Main.pref.putInteger("draw.rawgps.colors", 3); 302 311 } else { 303 312 Main.pref.putInteger("draw.rawgps.colors", 0);
Note:
See TracChangeset
for help on using the changeset viewer.