Changeset 4270 in josm


Ignore:
Timestamp:
2011-07-27T20:41:25+02:00 (8 years ago)
Author:
stoecker
Message:

fix #6629 - patch by akks fixed by me - improve settings handling for individual GPX tracks

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
1 added
3 edited

Legend:

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

    r4230 r4270  
    6363    @Override
    6464    public void actionPerformed(ActionEvent e) {
    65         JColorChooser c = new JColorChooser(layers.get(0).getColor(false));
     65        Color cl=layers.get(0).getColor(false); if (cl==null) cl=Color.gray;
     66        JColorChooser c = new JColorChooser(cl);
    6667        Object[] options = new Object[]{tr("OK"), tr("Cancel"), tr("Default")};
    6768        int answer = JOptionPane.showOptionDialog(
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r4250 r4270  
    2626import java.util.Collections;
    2727import java.util.Comparator;
     28import java.util.Date;
     29import java.util.HashMap;
    2830import java.util.LinkedList;
    2931import java.util.List;
     32import java.util.Map;
    3033import java.util.concurrent.Future;
    3134
     
    3437import javax.swing.Box;
    3538import javax.swing.ButtonGroup;
     39import javax.swing.ButtonModel;
    3640import javax.swing.Icon;
    3741import javax.swing.JFileChooser;
     
    7074import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker;
    7175import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     76import org.openstreetmap.josm.gui.preferences.GPXSettingsPanel;
    7277import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    7378import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
     
    230235    public colorModes getColorMode() {
    231236        try {
    232             return colorModes.values()[Main.pref.getInteger("draw.rawgps.colors", "layer "+getName(), 0)];
     237            int i=Main.pref.getInteger("draw.rawgps.colors", "layer " + getName(), 0);
     238            return colorModes.values()[i];
    233239        } catch (Exception e) {
    234240        }
     
    249255                SeparatorLayerAction.INSTANCE,
    250256                new CustomizeColor(this),
    251                 new CustomizeLineDrawing(this),
     257                new CustomizeDrawing(this),
    252258                new ConvertToDataLayerAction(),
    253259                SeparatorLayerAction.INSTANCE,
     
    262268                new LayerSaveAsAction(this),
    263269                new CustomizeColor(this),
    264                 new CustomizeLineDrawing(this),
     270                new CustomizeDrawing(this),
    265271                new ImportImages(),
    266272                new ImportAudio(),
     
    376382    // the different color modes
    377383    enum colorModes {
    378         none, velocity, dilution, direction
     384        none, velocity, dilution, direction, time
    379385    }
    380386
     
    394400        // Long startTime = System.currentTimeMillis();
    395401        Color neutralColor = getColor(true);
     402        String spec="layer "+getName();
     403
    396404        // also draw lines between points belonging to different segments
    397         boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force", "layer "+getName(), false);
     405        boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force", spec, false);
    398406        // draw direction arrows on the lines
    399         boolean direction = Main.pref.getBoolean("draw.rawgps.direction", "layer "+getName(), false);
     407        boolean direction = Main.pref.getBoolean("draw.rawgps.direction", spec, false);
    400408        // don't draw lines if longer than x meters
    401         int lineWidth = Main.pref.getInteger("draw.rawgps.linewidth", "layer "+getName(), 0);
     409        int lineWidth = Main.pref.getInteger("draw.rawgps.linewidth", spec, 0);
    402410
    403411        int maxLineLength;
    404412        boolean lines;
    405413        if (this.isLocalFile) {
    406             maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length.local", "layer "+getName(), -1);
    407             lines = Main.pref.getBoolean("draw.rawgps.lines.local", "layer "+getName(), true);
     414            maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length.local", spec, -1);
     415            lines = Main.pref.getBoolean("draw.rawgps.lines.local", spec, true);
    408416        } else {
    409             maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", "layer "+getName(), 200);
    410             lines = Main.pref.getBoolean("draw.rawgps.lines", "layer "+getName(), true);
     417            maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", spec, 200);
     418            lines = Main.pref.getBoolean("draw.rawgps.lines", spec, true);
    411419        }
    412420        // paint large dots for points
    413         boolean large = Main.pref.getBoolean("draw.rawgps.large", "layer "+getName(), false);
    414         int largesize = Main.pref.getInteger("draw.rawgps.large.size", "layer "+getName(), 3);
    415         boolean hdopcircle = Main.pref.getBoolean("draw.rawgps.hdopcircle", "layer "+getName(), false);
     421        boolean large = Main.pref.getBoolean("draw.rawgps.large", spec, false);
     422        int largesize = Main.pref.getInteger("draw.rawgps.large.size", spec, 3);
     423        boolean hdopcircle = Main.pref.getBoolean("draw.rawgps.hdopcircle", spec, false);
    416424        // color the lines
    417425        colorModes colored = getColorMode();
    418426        // paint direction arrow with alternate math. may be faster
    419         boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection", "layer "+getName(), false);
     427        boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection", spec, false);
    420428        // don't draw arrows nearer to each other than this
    421         int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", "layer "+getName(), 40);
     429        int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", spec, 40);
    422430        // allows to tweak line coloring for different speed levels.
    423         int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", "layer "+getName(), 45);
    424         boolean colorModeDynamic = Main.pref.getBoolean("draw.rawgps.colors.dynamic", "layer "+getName(), false);
     431        int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", spec, 45);
     432        boolean colorModeDynamic = Main.pref.getBoolean("draw.rawgps.colors.dynamic", spec, false);
    425433        int hdopfactor = Main.pref.getInteger("hdop.factor", 25);
    426434
     
    448456         ****************************************************************/
    449457        if (!computeCacheInSync) { // don't compute if the cache is good
    450             Float minval = null;
    451             Float maxval = null;
     458            double minval = +1e10;
     459            double maxval = -1e10;
    452460            WayPoint oldWp = null;
    453461            if (colorModeDynamic) {
     
    462470                                }
    463471                                if (oldWp != null && trkPnt.time > oldWp.time) {
    464                                     Float vel = new Float(c.greatCircleDistance(oldWp.getCoor()) / (trkPnt.time - oldWp.time));
    465                                     if(maxval == null || vel > maxval) maxval = vel;
    466                                     if(minval == null || vel < minval) minval = vel;
     472                                    double vel = c.greatCircleDistance(oldWp.getCoor())
     473                                            / (trkPnt.time - oldWp.time);
     474                                    if(vel > maxval) maxval = vel;
     475                                    if(vel < minval) minval = vel;
    467476                                }
    468477                                oldWp = trkPnt;
     
    476485                                Object val = trkPnt.attr.get("hdop");
    477486                                if (val != null) {
    478                                     Float hdop = (Float) val;
    479                                     if(maxval == null || hdop > maxval) maxval = hdop;
    480                                     if(minval == null || hdop < minval) minval = hdop;
     487                                    double hdop = ((Float) val).doubleValue();
     488                                    if(hdop > maxval) maxval = hdop;
     489                                    if(hdop < minval) minval = hdop;
    481490                                }
    482491                            }
     
    486495                oldWp = null;
    487496            }
     497            if (colored == colorModes.time) {
     498                    for (GpxTrack trk : data.tracks) {
     499                        for (GpxTrackSegment segment : trk.getSegments()) {
     500                            for (WayPoint trkPnt : segment.getWayPoints()) {
     501                               double t=trkPnt.time;
     502                               if (t==0) continue; // skip non-dated trackpoints
     503                               if(t > maxval) maxval = t;
     504                               if(t < minval) minval = t;
     505                            }
     506                        }
     507                    }
     508                }
     509           
    488510            for (GpxTrack trk : data.tracks) {
    489511                for (GpxTrackSegment segment : trk.getSegments()) {
     
    499521                        if(colored == colorModes.dilution && trkPnt.attr.get("hdop") != null) {
    500522                            float hdop = ((Float) trkPnt.attr.get("hdop")).floatValue();
    501                             int hdoplvl = Math.round(colorModeDynamic ? ((hdop-minval)*255/(maxval-minval))
     523                            int hdoplvl =(int) Math.round(colorModeDynamic ? ((hdop-minval)*255/(maxval-minval))
    502524                            : (hdop <= 0 ? 0 : hdop * hdopfactor));
    503525                            // High hdop is bad, but high values in colors are green.
     
    508530                        if (oldWp != null) {
    509531                            double dist = c.greatCircleDistance(oldWp.getCoor());
    510 
     532                            boolean noDraw=false;
    511533                            switch (colored) {
    512534                            case velocity:
     
    514536                                if(dtime > 0) {
    515537                                    float vel = (float) (dist / dtime);
    516                                     int velColor = Math.round(colorModeDynamic ? ((vel-minval)*255/(maxval-minval))
     538                                    int velColor =(int) Math.round(colorModeDynamic ? ((vel-minval)*255/(maxval-minval))
    517539                                    : (vel <= 0 ? 0 : vel / colorTracksTune * 255));
    518540                                    trkPnt.customColoring = colors[velColor > 255 ? 255 : velColor];
     
    530552                                }
    531553                                break;
     554                            case time:
     555                                if (trkPnt.time>0){
     556                                    int tColor = (int) Math.round((trkPnt.time-minval)*255/(maxval-minval));
     557                                    trkPnt.customColoring = colors[tColor];
     558                                } else {
     559                                    trkPnt.customColoring = neutralColor;
     560                                }
     561                                break;
    532562                            }
    533 
    534                             if (maxLineLength == -1 || dist <= maxLineLength) {
     563                           
     564                            if (!noDraw && (maxLineLength == -1 || dist <= maxLineLength)) {
    535565                                trkPnt.drawLine = true;
    536566                                trkPnt.dir = (int) oldWp.getCoor().heading(trkPnt.getCoor());
     
    13381368    }
    13391369
    1340     private class CustomizeLineDrawing extends AbstractAction implements LayerAction, MultiLayerAction {
     1370    private class CustomizeDrawing extends AbstractAction implements LayerAction, MultiLayerAction {
    13411371        List<Layer> layers;
    13421372
    1343         public CustomizeLineDrawing(List<Layer> l) {
     1373        public CustomizeDrawing(List<Layer> l) {
    13441374            this();
    13451375            layers = l;
    13461376        }
    13471377
    1348         public CustomizeLineDrawing(Layer l) {
     1378        public CustomizeDrawing(Layer l) {
    13491379            this();
    13501380            layers = new LinkedList<Layer>();
     
    13521382        }
    13531383
    1354         private CustomizeLineDrawing() {
    1355             super(tr("Customize line drawing"), ImageProvider.get("mapmode/addsegment"));
     1384        private CustomizeDrawing() {
     1385            super(tr("Customize track drawing"), ImageProvider.get("mapmode/addsegment"));
    13561386        }
    13571387
     
    13721402        @Override
    13731403        public Action getMultiLayerAction(List<Layer> layers) {
    1374             return new CustomizeLineDrawing(layers);
     1404            return new CustomizeDrawing(layers);
    13751405        }
    13761406
    13771407        @Override
    13781408        public void actionPerformed(ActionEvent e) {
    1379             /* FIXME: Add all the other GPX settings here as well. Unify with DrawingPreferences
    1380                Each option should be able to "use global settings". Attention with the handling
    1381                of local layer for the two local layer options! */
    1382             JRadioButton[] r = new JRadioButton[3];
    1383             r[0] = new JRadioButton(tr("Use global settings."));
    1384             r[1] = new JRadioButton(tr("Draw lines between points for this layer."));
    1385             r[2] = new JRadioButton(tr("Do not draw lines between points for this layer."));
    1386             ButtonGroup group = new ButtonGroup();
    1387             Box panel = Box.createVerticalBox();
    1388             for (JRadioButton b : r) {
    1389                 group.add(b);
    1390                 panel.add(b);
    1391             }
    1392             String propbase = isLocalFile ? "draw.rawgps.lines.local" : "draw.rawgps.lines";
    1393             String propName = propbase + ".layer " + layers.get(0).getName();
    1394             if (Main.pref.hasKey(propName)) {
    1395                 group.setSelected(r[Main.pref.getBoolean(propName) ? 1 : 2].getModel(), true);
    1396             } else {
    1397                 group.setSelected(r[0].getModel(), true);
    1398             }
     1409            GPXSettingsPanel panel=new GPXSettingsPanel(getName());
    13991410            int answer = JOptionPane.showConfirmDialog(Main.parent, panel,
    1400                     tr("Select line drawing options"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    1401             switch (answer) {
    1402             case JOptionPane.CANCEL_OPTION:
    1403             case JOptionPane.CLOSED_OPTION:
    1404                 return;
    1405             default:
    1406                 // continue
    1407             }
     1411                    tr("Customize track drawing"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
     1412            if (answer == JOptionPane.CANCEL_OPTION || answer == JOptionPane.CLOSED_OPTION) return;
    14081413            for(Layer layer : layers) {
    1409                 propName = propbase + ".layer " + layer.getName();
    1410                 if (group.getSelection() == r[0].getModel()) {
    1411                     Main.pref.put(propName, null);
    1412                 } else {
    1413                     Main.pref.put(propName, group.getSelection() == r[1].getModel());
    1414                 }
     1414                // save preferences for all layers
     1415                panel.savePreferences(layer.getName());
    14151416            }
    14161417            Main.map.repaint();
     
    14181419    }
    14191420
    1420     private class MarkersFromNamedPoins extends AbstractAction {
     1421      private class MarkersFromNamedPoins extends AbstractAction {
    14211422
    14221423        public MarkersFromNamedPoins() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java

    r4269 r4270  
    3434    }
    3535
    36     private JRadioButton drawRawGpsLinesAll = new JRadioButton(tr("All"));
    37     private JRadioButton drawRawGpsLinesLocal = new JRadioButton(tr("Local files"));
    38     private JRadioButton drawRawGpsLinesNone = new JRadioButton(tr("None"));
    39     private ActionListener drawRawGpsLinesActionListener;
    40     private JTextField drawRawGpsMaxLineLength = new JTextField(8);
    41     private JTextField drawRawGpsMaxLineLengthLocal = new JTextField(8);
    42     private JCheckBox forceRawGpsLines = new JCheckBox(tr("Force lines if no segments imported."));
    43     private JCheckBox largeGpsPoints = new JCheckBox(tr("Draw large GPS points."));
    44     private JCheckBox hdopCircleGpsPoints = new JCheckBox(tr("Draw a circle form HDOP value."));
    45     private ButtonGroup colorGroup;
    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)"));
    48     private JRadioButton colorTypeDilution = new JRadioButton(tr("Dilution of Position (red = high, green = low, if available)"));
    49     private JRadioButton colorTypeNone = new JRadioButton(tr("Single Color (can be customized for named layers)"));
    50     private JComboBox colorTypeVelocityTune = new JComboBox(new String[] {tr("Car"), tr("Bicycle"), tr("Foot")});
     36    private GPXSettingsPanel gpxPanel;
    5137    private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
    52     private JCheckBox drawGpsArrows = new JCheckBox(tr("Draw Direction Arrows"));
    53     private JCheckBox drawGpsArrowsFast = new JCheckBox(tr("Fast drawing (looks uglier)"));
    54     private JTextField drawGpsArrowsMinDist = new JTextField(8);
    5538    private JCheckBox headArrow = new JCheckBox(tr("Only on the head of a way."));
    5639    private JCheckBox onewayArrow = new JCheckBox(tr("Draw oneway arrows."));
     
    6043    private JCheckBox inactive = new JCheckBox(tr("Draw inactive layers in other color"));
    6144    private JCheckBox useAntialiasing = new JCheckBox(tr("Smooth map graphics (antialiasing)"));
    62     private JCheckBox makeAutoMarkers = new JCheckBox(tr("Create markers when reading GPX."));
    6345    private JCheckBox outlineOnly = new JCheckBox(tr("Draw only outlines of areas"));
    64     private JCheckBox colorDynamic = new JCheckBox(tr("Dynamic color range based on data limits"));
    65     private JComboBox waypointLabel = new JComboBox(new String[] {tr("Auto"), /* gpx data field name */ trc("gpx_field", "Name"),
    66             /* gpx data field name */ trc("gpx_field", "Desc(ription)"), tr("Both"), tr("None")});
    6746
    6847    public void addGui(PreferenceTabbedPane gui) {
    6948        gui.display.setPreferredSize(new Dimension(400,600));
    70         JPanel panel = new JPanel(new GridBagLayout());
    71         panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    72 
    73         // makeAutoMarkers
    74         makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true));
    75         makeAutoMarkers.setToolTipText(tr("Automatically make a marker layer from any waypoints when opening a GPX layer."));
    76         panel.add(makeAutoMarkers, GBC.eol().insets(20,0,0,5));
    77 
    78         // drawRawGpsLines
    79         ButtonGroup gpsLinesGroup = new ButtonGroup();
    80         gpsLinesGroup.add(drawRawGpsLinesNone);
    81         gpsLinesGroup.add(drawRawGpsLinesLocal);
    82         gpsLinesGroup.add(drawRawGpsLinesAll);
    83 
    84 
    85         /* ensure that default is in data base */
    86         Boolean lf = Main.pref.getBoolean("draw.rawgps.lines.local", true);
    87         if(Main.pref.getBoolean("draw.rawgps.lines", true)) {
    88             drawRawGpsLinesAll.setSelected(true);
    89         } else if (lf) {
    90             drawRawGpsLinesLocal.setSelected(true);
    91         } else {
    92             drawRawGpsLinesNone.setSelected(true);
    93         }
    94 
    95         panel.add(new JLabel(tr("Draw lines between raw GPS points")), GBC.eol().insets(20,0,0,0));
    96         panel.add(drawRawGpsLinesNone, GBC.eol().insets(40,0,0,0));
    97         panel.add(drawRawGpsLinesLocal, GBC.eol().insets(40,0,0,0));
    98         panel.add(drawRawGpsLinesAll, GBC.eol().insets(40,0,0,0));
    99 
    100         drawRawGpsLinesActionListener = new ActionListener(){
    101             public void actionPerformed(ActionEvent e) {
    102                 forceRawGpsLines.setEnabled(!drawRawGpsLinesNone.isSelected());
    103                 drawRawGpsMaxLineLength.setEnabled(!(drawRawGpsLinesNone.isSelected() || drawRawGpsLinesLocal.isSelected()));
    104                 drawRawGpsMaxLineLengthLocal.setEnabled(!drawRawGpsLinesNone.isSelected());
    105                 drawGpsArrows.setEnabled(!drawRawGpsLinesNone.isSelected() );
    106                 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
    107                 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
    108             }
    109         };
    110 
    111         drawRawGpsLinesNone.addActionListener(drawRawGpsLinesActionListener);
    112         drawRawGpsLinesLocal.addActionListener(drawRawGpsLinesActionListener);
    113         drawRawGpsLinesAll.addActionListener(drawRawGpsLinesActionListener);
    114 
    115         // drawRawGpsMaxLineLengthLocal
    116         drawRawGpsMaxLineLengthLocal.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length.local", -1)));
    117         drawRawGpsMaxLineLengthLocal.setToolTipText(tr("Maximum length (in meters) to draw lines for local files. Set to ''-1'' to draw all lines."));
    118         drawRawGpsMaxLineLengthLocal.setEnabled(!drawRawGpsLinesNone.isSelected());
    119         panel.add(new JLabel(tr("Maximum length for local files (meters)")), GBC.std().insets(40,0,0,0));
    120         panel.add(drawRawGpsMaxLineLengthLocal, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    121 
    122         // drawRawGpsMaxLineLength
    123         drawRawGpsMaxLineLength.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length", 200)));
    124         drawRawGpsMaxLineLength.setToolTipText(tr("Maximum length (in meters) to draw lines. Set to ''-1'' to draw all lines."));
    125         drawRawGpsMaxLineLength.setEnabled(!drawRawGpsLinesNone.isSelected());
    126         panel.add(new JLabel(tr("Maximum length (meters)")), GBC.std().insets(40,0,0,0));
    127         panel.add(drawRawGpsMaxLineLength, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    128 
    129         // forceRawGpsLines
    130         forceRawGpsLines.setToolTipText(tr("Force drawing of lines if the imported data contain no line information."));
    131         forceRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines.force", false));
    132         forceRawGpsLines.setEnabled(!drawRawGpsLinesNone.isSelected());
    133         panel.add(forceRawGpsLines, GBC.eop().insets(40,0,0,0));
    134 
    135         // drawGpsArrows
    136         drawGpsArrows.addActionListener(new ActionListener(){
    137             public void actionPerformed(ActionEvent e) {
    138                 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
    139                 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
    140             }
    141         });
    142         drawGpsArrows.setToolTipText(tr("Draw direction arrows for lines, connecting GPS points."));
    143         drawGpsArrows.setSelected(Main.pref.getBoolean("draw.rawgps.direction", false));
    144         drawGpsArrows.setEnabled(!drawRawGpsLinesNone.isSelected());
    145         panel.add(drawGpsArrows, GBC.eop().insets(40,0,0,0));
    146 
    147         // drawGpsArrowsFast
    148         drawGpsArrowsFast.setToolTipText(tr("Draw the direction arrows using table lookups instead of complex math."));
    149         drawGpsArrowsFast.setSelected(Main.pref.getBoolean("draw.rawgps.alternatedirection", false));
    150         drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
    151         panel.add(drawGpsArrowsFast, GBC.eop().insets(60,0,0,0));
    152 
    153         // drawGpsArrowsMinDist
    154         drawGpsArrowsMinDist.setToolTipText(tr("Do not draw arrows if they are not at least this distance away from the last one."));
    155         drawGpsArrowsMinDist.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.min-arrow-distance", 40)));
    156         drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled());
    157         panel.add(new JLabel(tr("Minimum distance (pixels)")), GBC.std().insets(60,0,0,0));
    158         panel.add(drawGpsArrowsMinDist, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    159 
    160         // hdopCircleGpsPoints
    161         hdopCircleGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.hdopcircle", false));
    162         hdopCircleGpsPoints.setToolTipText(tr("Draw a circle form HDOP value."));
    163         panel.add(hdopCircleGpsPoints, GBC.eop().insets(20,0,0,0));
    164 
    165         // largeGpsPoints
    166         largeGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.large", false));
    167         largeGpsPoints.setToolTipText(tr("Draw larger dots for the GPS points."));
    168         panel.add(largeGpsPoints, GBC.eop().insets(20,0,0,0));
    169 
    170         // colorTracks
    171         colorGroup = new ButtonGroup();
    172         colorGroup.add(colorTypeNone);
    173         colorGroup.add(colorTypeVelocity);
    174         colorGroup.add(colorTypeDirection);
    175         colorGroup.add(colorTypeDilution);
    176 
    177         colorTypeVelocity.addChangeListener(new ChangeListener(){
    178             public void stateChanged(ChangeEvent e) {
    179                 colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected());
    180                 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected());
    181             }
    182         });
    183         colorTypeDilution.addChangeListener(new ChangeListener(){
    184             public void stateChanged(ChangeEvent e) {
    185                 colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected());
    186             }
    187         });
    188 
    189         switch(Main.pref.getInteger("draw.rawgps.colors", 0)) {
    190         case 0:
    191             colorTypeNone.setSelected(true);
    192             break;
    193         case 1:
    194             colorTypeVelocity.setSelected(true);
    195             break;
    196         case 2:
    197             colorTypeDilution.setSelected(true);
    198             break;
    199         case 3:
    200             colorTypeDirection.setSelected(true);
    201             break;
    202         }
    203 
    204         colorTypeNone.setToolTipText(tr("All points and track segments will have the same color. Can be customized in Layer Manager."));
    205         colorTypeVelocity.setToolTipText(tr("Colors points and track segments by velocity."));
    206         colorTypeDirection.setToolTipText(tr("Colors points and track segments by direction."));
    207         colorTypeDilution.setToolTipText(tr("Colors points and track segments by dilution of position (HDOP). Your capture device needs to log that information."));
    208 
    209         // color Tracks by Velocity Tune
    210         int ccts = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45);
    211         colorTypeVelocityTune.setSelectedIndex(ccts==10 ? 2 : (ccts==20 ? 1 : 0));
    212         colorTypeVelocityTune.setToolTipText(tr("Allows to tune the track coloring for different average speeds."));
    213         colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected() && colorTypeVelocity.isEnabled());
    214 
    215         panel.add(Box.createVerticalGlue(), GBC.eol().insets(0, 20, 0, 0));
    216 
    217         panel.add(new JLabel(tr("Track and Point Coloring")), GBC.eol().insets(20,0,0,0));
    218         panel.add(colorTypeNone, GBC.eol().insets(40,0,0,0));
    219         panel.add(colorTypeVelocity, GBC.std().insets(40,0,0,0));
    220         panel.add(colorTypeVelocityTune, GBC.eop().insets(5,0,0,5));
    221         panel.add(colorTypeDirection, GBC.eol().insets(40,0,0,0));
    222         panel.add(colorTypeDilution, GBC.eol().insets(40,0,0,0));
    223         colorDynamic.setToolTipText(tr("Colors points and track segments by data limits."));
    224         colorDynamic.setSelected(Main.pref.getBoolean("draw.rawgps.colors.dynamic", false));
    225         colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected());
    226         panel.add(colorDynamic, GBC.eop().insets(40,0,0,0));
    227 
    228         // waypointLabel
    229         panel.add(Box.createVerticalGlue(), GBC.eol().insets(0, 20, 0, 0));
    230 
    231         waypointLabel.setSelectedIndex(Main.pref.getInteger("draw.rawgps.layer.wpt", 0 ));
    232         panel.add(new JLabel(tr("Waypoint labelling")), GBC.std().insets(20,0,0,0));
    233         panel.add(waypointLabel, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    234 
    235         panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
     49        gpxPanel = new GPXSettingsPanel();
     50        JPanel panel = gpxPanel;
     51       
    23652        JScrollPane scrollpane = new JScrollPane(panel);
    23753        scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
     
    303119
    304120    public boolean ok() {
    305         Main.pref.put("marker.makeautomarkers", makeAutoMarkers.isSelected());
     121        gpxPanel.savePreferences();
    306122        Main.pref.put("draw.data.area_outline_only", outlineOnly.isSelected());
    307         Main.pref.put("draw.rawgps.lines", drawRawGpsLinesAll.isSelected());
    308         Main.pref.put("draw.rawgps.lines.local", drawRawGpsLinesAll.isSelected() || drawRawGpsLinesLocal.isSelected());
    309         Main.pref.put("draw.rawgps.max-line-length", drawRawGpsMaxLineLength.getText());
    310         Main.pref.put("draw.rawgps.max-line-length.local", drawRawGpsMaxLineLengthLocal.getText());
    311         Main.pref.put("draw.rawgps.lines.force", forceRawGpsLines.isSelected());
    312         Main.pref.put("draw.rawgps.direction", drawGpsArrows.isSelected());
    313         Main.pref.put("draw.rawgps.alternatedirection", drawGpsArrowsFast.isSelected());
    314         Main.pref.put("draw.rawgps.min-arrow-distance", drawGpsArrowsMinDist.getText());
    315         Main.pref.put("draw.rawgps.colors.dynamic", colorDynamic.isSelected());
    316         if(colorTypeVelocity.isSelected()) {
    317             Main.pref.putInteger("draw.rawgps.colors", 1);
    318         } else if(colorTypeDilution.isSelected()) {
    319             Main.pref.putInteger("draw.rawgps.colors", 2);
    320         } else if(colorTypeDirection.isSelected()) {
    321             Main.pref.putInteger("draw.rawgps.colors", 3);
    322         } else {
    323             Main.pref.putInteger("draw.rawgps.colors", 0);
    324         }
    325         int ccti=colorTypeVelocityTune.getSelectedIndex();
    326         Main.pref.putInteger("draw.rawgps.colorTracksTune", ccti==2 ? 10 : (ccti==1 ? 20 : 45));
    327         Main.pref.put("draw.rawgps.hdopcircle", hdopCircleGpsPoints.isSelected());
    328         Main.pref.put("draw.rawgps.large", largeGpsPoints.isSelected());
    329123        Main.pref.put("draw.segment.direction", directionHint.isSelected());
    330124        Main.pref.put("draw.segment.head_only", headArrow.isSelected());
     
    344138        }
    345139        Main.pref.putInteger("mappaint.node.virtual-size", vn);
    346         Main.pref.putInteger("draw.rawgps.layer.wpt", waypointLabel.getSelectedIndex());
    347140        return false;
    348141    }
Note: See TracChangeset for help on using the changeset viewer.