Changeset 1283 in josm


Ignore:
Timestamp:
2009-01-17T22:35:18+01:00 (12 years ago)
Author:
stoecker
Message:

fix #1978. Patch by xeen

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r1245 r1283  
    8787    private Color computeCacheColorUsed;
    8888    private boolean computeCacheColored;
     89    private int computeCacheColorTracksTune;
    8990
    9091    public GpxLayer(GpxData d) {
     
    389390        int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0);
    390391        // don't draw arrows nearer to each other than this
    391 
     392        int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45); // allows to tweak line coloring for different speed levels.
    392393        /****************************************************************
    393394         ********** STEP 2a - CHECK CACHE VALIDITY **********************
     
    395396        if (computeCacheInSync && ((computeCacheMaxLineLengthUsed != maxLineLength) ||
    396397                                   (!neutralColor.equals(computeCacheColorUsed)) ||
    397                                    (computeCacheColored != colored))) {
     398                                   (computeCacheColored != colored) ||
     399                                   (computeCacheColorTracksTune != colorTracksTune))) {
    398400//          System.out.println("(re-)computing gpx line styles, reason: CCIS=" + computeCacheInSync + " CCMLLU=" + (computeCacheMaxLineLengthUsed != maxLineLength) + " CCCU=" +  (!neutralColor.equals(computeCacheColorUsed)) + " CCC=" + (computeCacheColored != colored));
    399401            computeCacheMaxLineLengthUsed = maxLineLength;
     
    401403            computeCacheColorUsed = neutralColor;
    402404            computeCacheColored = colored;
     405            computeCacheColorTracksTune = colorTracksTune;
    403406        }
    404407
     
    421424                            double dtime = trkPnt.time - oldWp.time;
    422425                            double vel = dist/dtime;
     426                            double velColor = vel/colorTracksTune*255;
    423427
    424428                            if (!colored) {
    425429                                trkPnt.speedLineColor = neutralColor;
    426                             } else if (dtime <= 0 || vel < 0 || vel > 36) { // attn: bad case first
     430                            } else if (dtime <= 0 || vel < 0 || velColor > 255) { // attn: bad case first
    427431                                trkPnt.speedLineColor = colors[255];
    428432                            } else {
    429                                 trkPnt.speedLineColor = colors[(int) (7*vel)];
     433                                trkPnt.speedLineColor = colors[(int) (velColor)];
    430434                            }
    431435                            if (maxLineLength == -1 || dist <= maxLineLength) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java

    r1222 r1283  
    1111import javax.swing.BorderFactory;
    1212import javax.swing.JCheckBox;
     13import javax.swing.JComboBox;
    1314import javax.swing.JLabel;
    1415import javax.swing.JTextField;
     
    2728    private JCheckBox largeGpsPoints = new JCheckBox(tr("Draw large GPS points."));
    2829    private JCheckBox colorTracks = new JCheckBox(tr("Color tracks by velocity."));
     30    private JComboBox colorTracksTune = new JComboBox(new String[] {tr("Car"), tr("Bicycle"), tr("Foot")});
    2931    private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
    3032    private JCheckBox drawGpsArrows = new JCheckBox(tr("Draw Direction Arrows"));
     
    5254                            drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
    5355                            colorTracks.setEnabled(drawRawGpsLines.isSelected());
     56                            colorTracksTune.setEnabled(colorTracks.isSelected() && drawRawGpsLines.isSelected());
    5457            }
    5558        });
     
    97100
    98101        // colorTracks
     102        colorTracks.addActionListener(new ActionListener(){
     103            public void actionPerformed(ActionEvent e) {
     104                            colorTracksTune.setEnabled(colorTracks.isSelected() && drawRawGpsLines.isSelected());
     105            }
     106        });
    99107        colorTracks.setSelected(Main.pref.getBoolean("draw.rawgps.colors"));
    100108        colorTracks.setToolTipText(tr("Choose the hue for the track color by the velocity at that point."));
    101109        colorTracks.setEnabled(drawRawGpsLines.isSelected());
    102         panel.add(colorTracks, GBC.eop().insets(40,0,0,0));
    103 
     110        panel.add(colorTracks, GBC.std().insets(40,0,0,0));
     111       
     112        // color Tracks by Velocity Tune
     113        int ccts = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45);
     114        colorTracksTune.setSelectedIndex(ccts==10 ? 2 : (ccts==20 ? 1 : 0));
     115        colorTracksTune.setToolTipText(tr("Allows to tune the track coloring for different average speeds."));
     116        colorTracksTune.setEnabled(colorTracks.isSelected() && colorTracks.isEnabled());
     117        panel.add(colorTracksTune, GBC.eop().insets(5,0,0,5));
     118       
    104119        // largeGpsPoints
    105120        largeGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.large"));
     
    174189        Main.pref.put("draw.rawgps.min-arrow-distance", drawGpsArrowsMinDist.getText());
    175190        Main.pref.put("draw.rawgps.colors", colorTracks.isSelected());
     191        int ccti=colorTracksTune.getSelectedIndex();
     192        Main.pref.putInteger("draw.rawgps.colorTracksTune", ccti==2 ? 10 : (ccti==1 ? 20 : 45));
    176193        Main.pref.put("draw.rawgps.large", largeGpsPoints.isSelected());
    177194        Main.pref.put("draw.segment.direction", directionHint.isSelected());
Note: See TracChangeset for help on using the changeset viewer.