Changeset 36085 in osm for applications/editors/josm


Ignore:
Timestamp:
2023-05-26T16:46:48+02:00 (18 months ago)
Author:
taylor.smock
Message:

Fix #22968: ClassCastException in RoutingGraph#applyAlgorithm

The problem pretty much comes down to the active layer not being the routing
layer.

This additionally fixes many SonarLint issues and drops a dependency on log4j.

Location:
applications/editors/josm/plugins/routing
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/routing/build.xml

    r35978 r36085  
    1212    <property name="plugin.icon" value="images/preferences/routing.png"/>
    1313    <property name="plugin.link" value="https://wiki.openstreetmap.org/index.php/JOSM/Plugins/Routing"/>
    14     <property name="plugin.requires" value="log4j"/>
    1514
    1615    <!--
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java

    r34187 r36085  
    55import java.util.Arrays;
    66import java.util.Collection;
     7import java.util.Collections;
    78import java.util.List;
    89import java.util.Map;
    910
    10 import org.apache.log4j.Logger;
    1111import org.jgrapht.Graph;
    1212import org.jgrapht.alg.BellmanFordShortestPath;
     
    2121import com.innovant.josm.plugin.routing.RoutingLayer;
    2222import com.innovant.josm.plugin.routing.RoutingModel;
     23import org.openstreetmap.josm.gui.layer.Layer;
     24import org.openstreetmap.josm.tools.Logging;
    2325
    2426/**
     
    6163    private final DataSet data;
    6264
    63     /**
    64      * Logger.
    65      */
    66     static Logger logger = Logger.getLogger(RoutingGraph.class);
    67 
    68     private static Collection<String> excludedHighwayValues = Arrays.asList(new String[]{
    69             "bus_stop", "traffic_signals", "street_lamp", "stop", "construction",
    70             "platform", "give_way", "proposed", "milestone", "speed_camera", "abandoned"
    71     });
     65    private static final Collection<String> excludedHighwayValues = Arrays.asList("bus_stop", "traffic_signals", "street_lamp", "stop",
     66            "construction", "platform", "give_way", "proposed", "milestone", "speed_camera", "abandoned");
    7267
    7368    /**
     
    8479    //  private WeightedMultigraph<Node, OsmEdge> graph;
    8580    private Graph<Node, OsmEdge> graph;
    86     private RoutingGraphDelegator rgDelegator = null;
    87 
     81    private RoutingGraphDelegator rgDelegator;
    8882
    8983    /**
     
    9488    }
    9589
     90    @SuppressWarnings("squid:S2234")
    9691    private void addEdgeBidirectional(Way way, Node from, Node to) {
    9792        addEdge(way, from, to);
     
    9994    }
    10095
     96    @SuppressWarnings("squid:S2234")
    10197    private void addEdgeReverseOneway(Way way, Node from, Node to) {
    10298        addEdge(way, to, from);
     
    114110    /**
    115111     * Default Constructor.
     112     * @param data The data to use for the graph
    116113     */
    117114    public RoutingGraph(DataSet data) {
     
    123120        routingProfile.setOnewayUse(true); // Don't ignore oneways by default
    124121        this.setWaySpeeds(routingProfile.getWaySpeeds());
    125         logger.debug("Created RoutingGraph");
     122        Logging.trace("Created RoutingGraph");
    126123    }
    127124
     
    130127     */
    131128    public void createGraph() {
    132 
    133         logger.debug("Creating Graph...");
     129        Logging.trace("Creating Graph...");
    134130        graph = new DirectedWeightedMultigraph<>(OsmEdge.class);
    135131        rgDelegator = new RoutingGraphDelegator(graph);
     
    140136            // skip way if not suitable for routing.
    141137            if (way == null || way.isDeleted() || !this.isvalidWay(way)
    142                     || way.getNodes().size() < 1) continue;
     138                    || way.getNodesCount() == 0) continue;
    143139
    144140            // INIT
     
    146142            Node to = null;
    147143            List<Node> nodes = way.getNodes();
    148             int nodes_count = nodes.size();
     144            int nodesCount = nodes.size();
    149145
    150146            /*
     
    166162             */
    167163
    168             String oneway_val = way.get("oneway");   /*   get (oneway=?) tag for this way.   */
    169             String junction_val = way.get("junction");   /*   get (junction=?) tag for this way.   */
     164            String onewayVal = way.get("oneway");   /*   get (oneway=?) tag for this way.   */
     165            String junctionVal = way.get("junction");   /*   get (junction=?) tag for this way.   */
    170166
    171167            from = nodes.get(0);                   /*   1st node A  */
    172168            graph.addVertex(from);                 /*   add vertex A */
    173169
    174             for (int i = 1; i < nodes_count; i++) { /*   loop from B until E */
     170            for (int i = 1; i < nodesCount; i++) { /*   loop from B until E */
    175171
    176172                to = nodes.get(i);                   /*   2nd node B   */
     
    185181                        addEdgeBidirectional(way, from, to);
    186182
    187                     } else if (oneway_val == null && junction_val == "roundabout") {
     183                    } else if (onewayVal == null && "roundabout".equals(junctionVal)) {
    188184                        //Case (roundabout): oneway=implicit yes
    189185                        addEdgeNormalOneway(way, from, to);
    190186
    191                     } else if (oneway_val == null || oneway_val == "false" || oneway_val == "no" || oneway_val == "0") {
     187                    } else if (onewayVal == null || Arrays.asList("false", "no", "0").contains(onewayVal)) {
    192188                        //Case (bi-way): oneway=false OR oneway=unset OR oneway=0 OR oneway=no
    193189                        addEdgeBidirectional(way, from, to);
    194190
    195                     } else if (oneway_val == "-1") {
     191                    } else if ("-1".equals(onewayVal)) {
    196192                        //Case (oneway reverse): oneway=-1
    197193                        addEdgeReverseOneway(way, from, to);
    198194
    199                     } else if (oneway_val == "1" || oneway_val == "yes" || oneway_val == "true") {
     195                    } else if (Arrays.asList("1", "yes", "true").contains(onewayVal)) {
    200196                        //Case (oneway normal): oneway=yes OR 1 OR true
    201197                        addEdgeNormalOneway(way, from, to);
     
    209205        } // end of looping thru ways
    210206
    211         logger.debug("End Create Graph");
    212         logger.debug("Vertex: "+graph.vertexSet().size());
    213         logger.debug("Edges: "+graph.edgeSet().size());
     207        Logging.trace("End Create Graph");
     208        Logging.trace("Vertex: {0}", graph.vertexSet().size());
     209        Logging.trace("Edges: {0}", graph.edgeSet().size());
    214210    }
    215211
     
    229225        double weight = getWeight(way, length);
    230226        setWeight(edge, length);
    231         logger.debug("edge for way " + way.getId()
    232         + "(from node " + from.getId() + " to node "
    233         + to.getId() + ") has weight: " + weight);
     227        Logging.trace("edge for way {0} (from node {1} to node {2}) has weight: {3}", way.getId(), from.getId(), to.getId(), weight);
    234228        ((DirectedWeightedMultigraph<Node, OsmEdge>) graph).setEdgeWeight(edge, weight);
    235229    }
     
    240234     * in routing.
    241235     *
    242      * @param way
     236     * @param osmedge
    243237     *            the way.
    244238     */
     
    273267            if (this.waySpeeds.containsKey(way.get("highway")))
    274268                speed = this.waySpeeds.get(way.get("highway"));
    275             logger.debug("Speed="+speed);
     269            Logging.trace("Speed={0}", speed);
    276270            break;
    277271        default:
     
    315309        Graph<Node, OsmEdge> g;
    316310        double totalWeight = 0;
    317         RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     311        final Layer editLayer = MainApplication.getLayerManager().getEditLayer();
     312        final RoutingLayer layer = MainApplication.getLayerManager().getLayersOfType(RoutingLayer.class)
     313                .stream().filter(rLayer -> rLayer.getDataLayer() == editLayer).findFirst().orElse(null);
     314        if (layer == null) {
     315            return Collections.emptyList();
     316        }
    318317        RoutingModel routingModel = layer.getRoutingModel();
    319318
    320319        if (graph == null || routingModel.getOnewayChanged())
    321320            this.createGraph();
    322         logger.debug("apply algorithm between nodes ");
     321        Logging.trace("apply algorithm between nodes ");
    323322
    324323        for (Node node : nodes) {
    325             logger.debug(node.getId());
     324            Logging.trace(Long.toString(node.getId()));
    326325        }
    327         logger.debug("-----------------------------------");
     326        Logging.trace("-----------------------------------");
    328327
    329328        // Assign the graph to g
     
    332331        switch (algorithm) {
    333332        case ROUTING_ALG_DIJKSTRA:
    334             logger.debug("Using Dijkstra algorithm");
     333            Logging.trace("Using Dijkstra algorithm");
    335334            DijkstraShortestPath<Node, OsmEdge> routingk = null;
    336335            for (int index = 1; index < nodes.size(); ++index) {
     
    338337                        .get(index - 1), nodes.get(index));
    339338                if (routingk.getPathEdgeList() == null) {
    340                     logger.debug("no path found!");
     339                    Logging.trace("no path found!");
    341340                    break;
    342341                }
     
    346345            break;
    347346        case ROUTING_ALG_BELLMANFORD:
    348             logger.debug("Using Bellman Ford algorithm");
     347            Logging.trace("Using Bellman Ford algorithm");
    349348            for (int index = 1; index < nodes.size(); ++index) {
    350349                path = BellmanFordShortestPath.findPathBetween(rgDelegator, nodes
    351350                        .get(index - 1), nodes.get(index));
    352                 if (path == null) {
    353                     logger.debug("no path found!");
    354                     return null;
     351                if (path == null || path.isEmpty()) {
     352                    Logging.trace("no path found!");
     353                    return Collections.emptyList();
    355354                }
    356355            }
    357356            break;
    358357        default:
    359             logger.debug("Wrong algorithm");
     358            Logging.trace("Wrong algorithm");
    360359            break;
    361360        }
    362361
    363         logger.debug("shortest path found: " + path + "\nweight: "
    364                 + totalWeight);
     362        Logging.trace("shortest path found: {0}\nweight: {1}", path, totalWeight);
    365363        return path;
    366364    }
     
    389387     * @param routeType the routeType to set
    390388     */
    391     public void setTypeRoute(RouteType routetype) {
    392         this.routeType = routetype;
    393         this.rgDelegator.setRouteType(routetype);
     389    public void setTypeRoute(RouteType routeType) {
     390        this.routeType = routeType;
     391        this.rgDelegator.setRouteType(routeType);
    394392    }
    395393
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraphDelegator.java

    r32768 r36085  
    22package com.innovant.josm.jrt.core;
    33
    4 import org.apache.log4j.Logger;
    54import org.jgrapht.Graph;
    65import org.jgrapht.graph.GraphDelegator;
     
    1514 */
    1615public class RoutingGraphDelegator extends GraphDelegator<Node, OsmEdge> {
    17 
    18     /**
    19      * Logger.
    20      */
    21     static Logger logger = Logger.getLogger(RoutingGraphDelegator.class);
    22 
    2316    /**
    2417     *
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingProfile.java

    r34554 r36085  
    55import java.util.Map;
    66
    7 import org.apache.log4j.Logger;
    87import org.openstreetmap.josm.data.Preferences;
    9 
     8import org.openstreetmap.josm.tools.Logging;
    109
    1110/**
     
    3029 */
    3130public class RoutingProfile {
    32     /**
    33      * logger
    34      */
    35     static Logger logger = Logger.getLogger(RoutingProfile.class);
    3631    /**
    3732     * True if oneway is used for routing (i.e. for cars).
     
    7469     */
    7570    public RoutingProfile(String name) {
    76         logger.debug("Init RoutingProfile with name: "+name);
     71        Logging.trace("Init RoutingProfile with name: {0}", name);
    7772        this.name = name;
    7873        waySpeeds = new HashMap<>();
    7974        Map<String, String> prefs = Preferences.main().getAllPrefix("routing.profile."+name+".speed");
    80         for (String key:prefs.keySet()) {
    81             waySpeeds.put((key.split("\\.")[4]), Double.valueOf(prefs.get(key)));
     75        for (Map.Entry<String, String> entry : prefs.entrySet()) {
     76            waySpeeds.put((entry.getKey().split("\\.")[4]), Double.valueOf(entry.getValue()));
    8277        }
    83         for (String key:waySpeeds.keySet()) {
    84             logger.debug(key+ "-- speed: "+waySpeeds.get(key));
     78        for (Map.Entry<String, Double> entry : waySpeeds.entrySet()) {
     79            Logging.trace("{0}-- speed: {1}", entry.getKey(), entry.getValue());
    8580        }
    86         logger.debug("End init RoutingProfile with name: "+name);
     81        Logging.trace("End init RoutingProfile with name: {0}", name);
    8782    }
    8883
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java

    r34554 r36085  
    2020import javax.swing.Icon;
    2121
    22 import org.apache.log4j.Logger;
    2322import org.openstreetmap.josm.actions.RenameLayerAction;
    2423import org.openstreetmap.josm.data.Bounds;
     
    3938
    4039import com.innovant.josm.jrt.osm.OsmEdge;
    41 
     40import org.openstreetmap.josm.tools.Logging;
    4241
    4342/**
     
    5453        KEY_ROUTE_SELECT("routing.route.select");
    5554
    56         public final String key;
     55        private final String key;
    5756        PreferencesKeys(String key) {
    5857            this.key = key;
     
    6564
    6665    /**
    67      * Logger
    68      */
    69     static Logger logger = Logger.getLogger(RoutingLayer.class);
    70 
    71     /**
    7266     * Constant
    7367     */
     
    7771     * Routing Model
    7872     */
    79     private RoutingModel routingModel;
     73    private final RoutingModel routingModel;
    8074
    8175    /**
    8276     * Start, Middle and End icons
    8377     */
    84     private Icon startIcon, middleIcon, endIcon;
     78    private final Icon startIcon;
     79    private final Icon middleIcon;
     80    private final Icon endIcon;
    8581
    8682    /**
    8783     * Associated OSM layer
    8884     */
    89     private OsmDataLayer dataLayer;
     85    private final OsmDataLayer dataLayer;
    9086
    9187    /**
    9288     * Default constructor
    9389     * @param name Layer name.
     90     * @param dataLayer The datalayer to use for routing
    9491     */
    9592    public RoutingLayer(String name, OsmDataLayer dataLayer) {
    9693        super(name);
    97         logger.debug("Creating Routing Layer...");
    98         if (startIcon == null) startIcon = ImageProvider.get("routing", "startflag");
    99         if (middleIcon == null) middleIcon = ImageProvider.get("routing", "middleflag");
    100         if (endIcon == null) endIcon = ImageProvider.get("routing", "endflag");
     94        Logging.trace("Creating Routing Layer...");
     95        this.startIcon = ImageProvider.get("routing", "startflag");
     96        this.middleIcon = ImageProvider.get("routing", "middleflag");
     97        this.endIcon = ImageProvider.get("routing", "endflag");
    10198        this.dataLayer = dataLayer;
    10299        this.routingModel = new RoutingModel(dataLayer.data);
    103         logger.debug("Routing Layer created.");
    104 
     100        Logging.trace("Routing Layer created.");
    105101
    106102        this.routingModel.routingGraph.createGraph();    /* construct the graph right after we we create the layer */
     
    138134                if (n.isDeleted() || n.isIncomplete()) continue;
    139135
    140                 Point P = MainApplication.getMap().mapView.getPoint(n);
    141                 double dist = p.distance(P);
    142                 if (dist < snapDistance) {
    143                     if ((nearest == null) || (dist < minDist)) {
    144                         nearest = n;
    145                         minDist = dist;
    146                     }
     136                Point point = MainApplication.getMap().mapView.getPoint(n);
     137                double dist = p.distance(point);
     138                if (dist < snapDistance && ((nearest == null) || (dist < minDist))) {
     139                    nearest = n;
     140                    minDist = dist;
    147141                }
    148142            }
     
    153147    @Override
    154148    public Icon getIcon() {
    155         Icon icon = ImageProvider.get("layer", "routing_small");
    156         return icon;
     149        return ImageProvider.get("layer", "routing_small");
    157150    }
    158151
    159152    @Override
    160153    public Object getInfoComponent() {
    161         String info = "<html>"
     154        return "<html>"
    162155                + "<body>"
    163156                +"Graph Vertex: "+this.routingModel.routingGraph.getVertexCount()+"<br/>"
     
    165158                + "</body>"
    166159                + "</html>";
    167         return info;
    168160    }
    169161
     
    183175    @Override
    184176    public String getToolTipText() {
    185         String tooltip = this.routingModel.routingGraph.getVertexCount() + " vertices, "
     177        return this.routingModel.routingGraph.getVertexCount() + " vertices, "
    186178                + this.routingModel.routingGraph.getEdgeCount() + " edges";
    187         return tooltip;
    188179    }
    189180
     
    208199        Color color;
    209200        if (isActiveLayer) {
    210             color = new NamedColorProperty(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.key, Color.RED).get();
     201            color = new NamedColorProperty(PreferencesKeys.KEY_ACTIVE_ROUTE_COLOR.getKey(), Color.RED).get();
    211202        } else {
    212             color = new NamedColorProperty(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.key, Color.decode("#dd2222")).get();
     203            color = new NamedColorProperty(PreferencesKeys.KEY_INACTIVE_ROUTE_COLOR.getKey(), Color.decode("#dd2222")).get();
    213204        }
    214205
    215206        // Get path stroke width from preferences
    216         String widthString = Config.getPref().get(PreferencesKeys.KEY_ROUTE_WIDTH.key);
     207        String widthString = Config.getPref().get(PreferencesKeys.KEY_ROUTE_WIDTH.getKey());
    217208        if (widthString.length() == 0) {
    218209            widthString = "2";                        /* I think 2 is better  */
     
    223214
    224215        // draw our graph
    225         if (isActiveLayer) {
    226             if (routingModel != null) {
    227                 if (routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {
    228                     Set<OsmEdge> graphEdges = routingModel.routingGraph.getGraph().edgeSet();
    229                     if (!graphEdges.isEmpty()) {
    230                         Color color2 = ColorHelper.html2color("#00ff00");        /* just green for now  */
    231                         OsmEdge firstedge = (OsmEdge) graphEdges.toArray()[0];
    232                         Point from = mv.getPoint(firstedge.fromEastNorth());
    233                         g.drawRect(from.x-4, from.y+4, from.x+4, from.y-4);
    234                         for (OsmEdge edge : graphEdges) {
    235                             drawGraph(g, mv, edge, color2, width);
    236                         }
    237                     }
     216        if (isActiveLayer && routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {
     217            Set<OsmEdge> graphEdges = routingModel.routingGraph.getGraph().edgeSet();
     218            if (!graphEdges.isEmpty()) {
     219                Color color2 = ColorHelper.html2color("#00ff00");        /* just green for now  */
     220                OsmEdge firstedge = (OsmEdge) graphEdges.toArray()[0];
     221                Point from = mv.getPoint(firstedge.fromEastNorth());
     222                g.drawRect(from.x - 4, from.y + 4, from.x + 4, from.y - 4);
     223                for (OsmEdge edge : graphEdges) {
     224                    drawGraph(g, mv, edge, color2, width);
    238225                }
    239226            }
     
    241228
    242229
    243         if (nodes == null || nodes.size() == 0) return;
     230        if (nodes == null || nodes.isEmpty()) return;
    244231
    245232        // Paint routing path
     
    289276     * Draw a line with the given color.
    290277     */
    291     private void drawEdge(Graphics g, MapView mv, OsmEdge edge, Color col, int width,
     278    private static void drawEdge(Graphics g, MapView mv, OsmEdge edge, Color col, int width,
    292279            boolean showDirection) {
    293280        g.setColor(col);
     
    310297    }
    311298
    312     private void drawGraph(Graphics g, MapView mv, OsmEdge edge, Color col, int width) {
     299    private static void drawGraph(Graphics g, MapView mv, OsmEdge edge, Color col, int width) {
    313300        g.setColor(col);
    314301        Point from;
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java

    r32768 r36085  
    55import java.util.List;
    66
    7 import org.apache.log4j.Logger;
    87import org.openstreetmap.josm.data.osm.DataSet;
    98import org.openstreetmap.josm.data.osm.Node;
     
    1211import com.innovant.josm.jrt.core.RoutingGraph.Algorithm;
    1312import com.innovant.josm.jrt.osm.OsmEdge;
    14 
     13import org.openstreetmap.josm.tools.Logging;
    1514
    1615/**
     
    2120 */
    2221public class RoutingModel {
    23 
    24     /**
    25      * Logger
    26      */
    27     static Logger logger = Logger.getLogger(RoutingModel.class);
    28 
    2922    /**
    3023     * Graph to calculate route
    3124     */
    32     public RoutingGraph routingGraph = null;
     25    public final RoutingGraph routingGraph;
    3326
    3427    /**
    3528     * List of nodes that the route has to traverse
    3629     */
    37     private List<Node> nodes = null;
     30    private List<Node> nodes;
    3831
    39     private List<OsmEdge> path = null;
     32    private List<OsmEdge> path;
    4033
    4134    /**
    4235     * Flag to advise about changes in the selected nodes.
    4336     */
    44     private boolean changeNodes = false;
     37    private boolean changeNodes;
    4538
    4639    /**
    4740     * Flag to advise about changes in ways.
    4841     */
    49     private boolean changeOneway = false;
     42    private boolean changeOneway;
    5043
    5144    /**
    5245     * Default Constructor.
     46     * @param data The data to use for the routing graph
    5347     */
    5448    public RoutingModel(DataSet data) {
    5549        nodes = new ArrayList<>();
    56         System.out.println("gr " + data);
     50        Logging.trace("gr " + data);
    5751        routingGraph = new RoutingGraph(data);
    5852    }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java

    r33794 r36085  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.io.File;
    76import java.util.ArrayList;
    87
    9 import org.apache.log4j.Logger;
    10 import org.apache.log4j.xml.DOMConfigurator;
     8import com.innovant.josm.plugin.routing.actions.AddRouteNodeAction;
     9import com.innovant.josm.plugin.routing.actions.MoveRouteNodeAction;
     10import com.innovant.josm.plugin.routing.actions.RemoveRouteNodeAction;
     11import com.innovant.josm.plugin.routing.gui.RoutingDialog;
     12import com.innovant.josm.plugin.routing.gui.RoutingMenu;
     13import com.innovant.josm.plugin.routing.gui.RoutingPreferenceDialog;
    1114import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
    1215import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
     
    2730import org.openstreetmap.josm.tools.Logging;
    2831
    29 import com.innovant.josm.plugin.routing.actions.AddRouteNodeAction;
    30 import com.innovant.josm.plugin.routing.actions.MoveRouteNodeAction;
    31 import com.innovant.josm.plugin.routing.actions.RemoveRouteNodeAction;
    32 import com.innovant.josm.plugin.routing.gui.RoutingDialog;
    33 import com.innovant.josm.plugin.routing.gui.RoutingMenu;
    34 import com.innovant.josm.plugin.routing.gui.RoutingPreferenceDialog;
    35 
    3632/**
    3733 * The main class of the routing plugin
     
    4339 */
    4440public class RoutingPlugin extends Plugin implements LayerChangeListener, DataSetListenerAdapter.Listener {
    45     /**
    46      * Logger
    47      */
    48     static Logger logger = Logger.getLogger(RoutingPlugin.class);
    4941
    5042    /**
     
    116108        datasetAdapter = new DataSetListenerAdapter(this);
    117109        plugin = this; // Assign reference to the plugin class
    118         File log4jConfigFile = new java.io.File("log4j.xml");
    119         if (log4jConfigFile.exists()) {
    120             DOMConfigurator.configure(log4jConfigFile.getPath());
    121         } else {
    122             System.err.println("Routing plugin warning: log4j configuration not found");
    123         }
    124         logger.debug("Loading routing plugin...");
     110        Logging.trace("Loading routing plugin...");
    125111        preferenceSettings = new RoutingPreferenceDialog();
    126112        // Initialize layers list
     
    131117        MainApplication.getLayerManager().addLayerChangeListener(this);
    132118        DatasetEventManager.getInstance().addDatasetListener(datasetAdapter, FireMode.IN_EDT_CONSOLIDATED);
    133         logger.debug("Finished loading plugin");
     119        Logging.trace("Finished loading plugin");
    134120    }
    135121
     
    178164            // Enable menu
    179165            menu.enableStartItem();
    180             newFrame.addToggleDialog(routingDialog = new RoutingDialog());
     166            routingDialog = new RoutingDialog();
     167            newFrame.addToggleDialog(routingDialog);
    181168        } else {
    182169            addRouteNodeAction = null;
     
    218205            // Set layer on top and select layer, also refresh toggleDialog to reflect selection
    219206            MainApplication.getMap().mapView.moveLayer(newLayer, 0);
    220             logger.debug("Added routing layer.");
     207            Logging.trace("Added routing layer.");
    221208        }
    222209    }
     
    232219            menu.disableRestOfItems();
    233220            layers.remove(oldLayer);
    234             logger.debug("Removed routing layer.");
     221            Logging.trace("Removed routing layer.");
    235222        } else if (oldLayer instanceof OsmDataLayer) {
    236223            // Remove all associated routing layers
     
    238225            // FIXME: can't remove associated routing layers without triggering exceptions in some cases
    239226            RoutingLayer[] layersArray = layers.toArray(new RoutingLayer[0]);
    240             for (int i = 0; i < layersArray.length; i++) {
    241                 if (layersArray[i].getDataLayer().equals(oldLayer)) {
     227            for (RoutingLayer routingLayer : layersArray) {
     228                if (routingLayer.getDataLayer().equals(oldLayer)) {
    242229                    try {
    243230                        // Remove layer
    244                         MainApplication.getLayerManager().removeLayer(layersArray[i]);
     231                        MainApplication.getLayerManager().removeLayer(routingLayer);
    245232                    } catch (IllegalArgumentException e) {
    246233                        Logging.error(e);
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java

    r33794 r36085  
    66import java.awt.event.MouseEvent;
    77
    8 import org.apache.log4j.Logger;
    98import org.openstreetmap.josm.actions.mapmode.MapMode;
    109import org.openstreetmap.josm.data.osm.Node;
     
    1514import com.innovant.josm.plugin.routing.RoutingLayer;
    1615import com.innovant.josm.plugin.routing.RoutingPlugin;
     16import org.openstreetmap.josm.tools.Logging;
    1717
    1818/**
     
    2424 */
    2525public class AddRouteNodeAction extends MapMode {
    26 
    27     /**
    28      * Logger.
    29      */
    30     static Logger logger = Logger.getLogger(AddRouteNodeAction.class);
    31 
    3226    /**
    3327     * Constructor
    34      * @param mapFrame map frame
    3528     */
    3629    public AddRouteNodeAction() {
     
    6053                node = layer.getNearestHighwayNode(e.getPoint());
    6154                if (node == null) {
    62                     logger.debug("no selected node");
     55                    Logging.trace("no selected node");
    6356                    return;
    6457                }
    65                 logger.debug("selected node " + node);
     58                Logging.trace("selected node {0}", node);
    6659                layer.getRoutingModel().addNode(node);
    6760                RoutingPlugin.getInstance().getRoutingDialog().addNode(node);
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java

    r33794 r36085  
    88import java.util.List;
    99
    10 import org.apache.log4j.Logger;
    1110import org.openstreetmap.josm.actions.mapmode.MapMode;
    1211import org.openstreetmap.josm.data.osm.Node;
     
    1918import com.innovant.josm.plugin.routing.RoutingPlugin;
    2019import com.innovant.josm.plugin.routing.gui.RoutingDialog;
     20import org.openstreetmap.josm.tools.Logging;
    2121
    2222/**
     
    3535
    3636    /**
    37      * Logger.
    38      */
    39     static Logger logger = Logger.getLogger(RoutingLayer.class);
    40 
    41     /**
    4237     * Index of dragged node
    4338     */
     
    4641    /**
    4742     * Constructor
    48      * @param mapFrame map frame
    4943     */
    5044    public MoveRouteNodeAction() {
     
    6761    @Override public void mousePressed(MouseEvent e) {
    6862        // If left button is pressed
    69         if (e.getButton() == MouseEvent.BUTTON1) {
    70             if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    71                 requestFocusInMapView();
    72                 RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    73                 RoutingModel routingModel = layer.getRoutingModel();
    74                 // Search for the nearest node in the list
    75                 List<Node> nl = routingModel.getSelectedNodes();
    76                 index = -1;
    77                 double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels
    78                 for (int i = 0; i < nl.size(); i++) {
    79                     Node node = nl.get(i);
    80                     double d = MainApplication.getMap().mapView.getPoint(node).distanceSq(e.getPoint());
    81                     if (d < dmax) {
    82                         dmax = d;
    83                         index = i;
    84                     }
     63        if (e.getButton() == MouseEvent.BUTTON1 && MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     64            requestFocusInMapView();
     65            RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     66            RoutingModel routingModel = layer.getRoutingModel();
     67            // Search for the nearest node in the list
     68            List<Node> nl = routingModel.getSelectedNodes();
     69            index = -1;
     70            double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels
     71            for (int i = 0; i < nl.size(); i++) {
     72                Node node = nl.get(i);
     73                double d = MainApplication.getMap().mapView.getPoint(node).distanceSq(e.getPoint());
     74                if (d < dmax) {
     75                    dmax = d;
     76                    index = i;
    8577                }
    86                 if (index >= 0)
    87                     logger.debug("Moved from node " + nl.get(index));
    8878            }
     79            if (index >= 0)
     80                Logging.trace("Moved from node {0}", nl.get(index));
    8981        }
    9082    }
     
    109101            node = layer.getNearestHighwayNode(point);
    110102            if (node == null) {
    111                 logger.debug("Didn't found a close node to move to.");
     103                Logging.trace("Didn't found a close node to move to.");
    112104                return;
    113105            }
    114             logger.debug("Moved to node " + node);
     106            Logging.trace("Moved to node {0}", node);
    115107            routingModel.removeNode(index);
    116108            routingDialog.removeNode(index);
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java

    r33794 r36085  
    77import java.util.List;
    88
    9 import org.apache.log4j.Logger;
    109import org.openstreetmap.josm.actions.mapmode.MapMode;
    1110import org.openstreetmap.josm.data.osm.Node;
     
    1716import com.innovant.josm.plugin.routing.RoutingModel;
    1817import com.innovant.josm.plugin.routing.RoutingPlugin;
     18import org.openstreetmap.josm.tools.Logging;
    1919
    2020/**
     
    3131     */
    3232    private static final int REMOVE_SQR_RADIUS = 100;
    33 
    34     /**
    35      * Logger.
    36      */
    37     static Logger logger = Logger.getLogger(RoutingLayer.class);
    3833
    3934    public RemoveRouteNodeAction() {
     
    5651    @Override public void mouseClicked(MouseEvent e) {
    5752        // If left button is clicked
    58         if (e.getButton() == MouseEvent.BUTTON1) {
    59             if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    60                 RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    61                 RoutingModel routingModel = layer.getRoutingModel();
    62                 // Search for the nearest node in the list
    63                 List<Node> nl = routingModel.getSelectedNodes();
    64                 int index = -1;
    65                 double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels
    66                 for (int i = 0; i < nl.size(); i++) {
    67                     Node node = nl.get(i);
    68                     double d = MainApplication.getMap().mapView.getPoint(node).distanceSq(e.getPoint());
    69                     if (d < dmax) {
    70                         dmax = d;
    71                         index = i;
    72                     }
     53        if (e.getButton() == MouseEvent.BUTTON1 && MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     54            RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     55            RoutingModel routingModel = layer.getRoutingModel();
     56            // Search for the nearest node in the list
     57            List<Node> nl = routingModel.getSelectedNodes();
     58            int index = -1;
     59            double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels
     60            for (int i = 0; i < nl.size(); i++) {
     61                Node node = nl.get(i);
     62                double d = MainApplication.getMap().mapView.getPoint(node).distanceSq(e.getPoint());
     63                if (d < dmax) {
     64                    dmax = d;
     65                    index = i;
    7366                }
    74                 // If found a close node, remove it and recalculate route
    75                 if (index >= 0) {
    76                     // Remove node
    77                     logger.debug("Removing node " + nl.get(index));
    78                     routingModel.removeNode(index);
    79                     RoutingPlugin.getInstance().getRoutingDialog().removeNode(index);
    80                     MainApplication.getMap().repaint();
    81                 } else {
    82                     logger.debug("Can't find a node to remove.");
    83                 }
     67            }
     68            // If found a close node, remove it and recalculate route
     69            if (index >= 0) {
     70                // Remove node
     71                Logging.trace("Removing node {0}", nl.get(index));
     72                routingModel.removeNode(index);
     73                RoutingPlugin.getInstance().getRoutingDialog().removeNode(index);
     74                MainApplication.getMap().repaint();
     75            } else {
     76                Logging.trace("Can't find a node to remove.");
    8477            }
    8578        }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java

    r33794 r36085  
    1818import com.innovant.josm.plugin.routing.RoutingLayer;
    1919import com.innovant.josm.plugin.routing.RoutingModel;
    20 
    2120
    2221/**
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java

    r33794 r36085  
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66
    7 import java.awt.event.ActionEvent;
    8 import java.awt.event.ActionListener;
    97import java.awt.event.ItemEvent;
    10 import java.awt.event.ItemListener;
    118import java.awt.event.KeyEvent;
    129
     
    1714import javax.swing.JRadioButtonMenuItem;
    1815
    19 import org.openstreetmap.josm.gui.MainApplication;
    20 import org.openstreetmap.josm.gui.MainMenu;
    21 
    2216import com.innovant.josm.jrt.core.RoutingGraph.RouteType;
    2317import com.innovant.josm.plugin.routing.RoutingLayer;
    2418import com.innovant.josm.plugin.routing.RoutingModel;
    2519import com.innovant.josm.plugin.routing.RoutingPlugin;
     20import org.openstreetmap.josm.gui.MainApplication;
     21import org.openstreetmap.josm.gui.MainMenu;
    2622
    2723/**
     
    5147
    5248        startMI = new JMenuItem(tr("Add routing layer"));
    53         startMI.addActionListener(new ActionListener() {
    54             @Override
    55             public void actionPerformed(ActionEvent e) {
    56                 RoutingPlugin.getInstance().addLayer();
    57             }
    58         });
     49        startMI.addActionListener(e -> RoutingPlugin.getInstance().addLayer());
    5950        menu.add(startMI);
    6051
     
    6657        JRadioButtonMenuItem rshorter = new JRadioButtonMenuItem(tr("Shortest"));
    6758        rshorter.setSelected(true);
    68         rshorter.addItemListener(new ItemListener() {
    69             @Override
    70             public void itemStateChanged(ItemEvent e) {
    71                 if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    72                     RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    73                     RoutingModel routingModel = layer.getRoutingModel();
    74                     if (e.getStateChange() == ItemEvent.SELECTED) {
    75                         routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
    76                     } else {
    77                         routingModel.routingGraph.setTypeRoute(RouteType.FASTEST);
    78                     }
    79                     //  routingModel.routingGraph.resetGraph();
    80                     //  routingModel.routingGraph.createGraph();
    81                     //TODO: Change this way
    82                     //FIXME: do not change node but recalculate routing.
    83                     routingModel.setNodesChanged();
    84                     MainApplication.getMap().repaint();
     59        rshorter.addItemListener(e -> {
     60            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     61                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     62                RoutingModel routingModel = layer.getRoutingModel();
     63                if (e.getStateChange() == ItemEvent.SELECTED) {
     64                    routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
     65                } else {
     66                    routingModel.routingGraph.setTypeRoute(RouteType.FASTEST);
    8567                }
     68                //  routingModel.routingGraph.resetGraph();
     69                //  routingModel.routingGraph.createGraph();
     70                //TODO: Change this way
     71                //FIXME: do not change node but recalculate routing.
     72                routingModel.setNodesChanged();
     73                MainApplication.getMap().repaint();
    8674            }
    87 
    8875        });
    8976
     
    9683        criteriaM.addSeparator();
    9784        JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("Ignore oneways"));
    98         cbmi.addItemListener(new ItemListener() {
    99             @Override
    100             public void itemStateChanged(ItemEvent e) {
    101                 if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    102                     RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    103                     RoutingModel routingModel = layer.getRoutingModel();
    104                     if (e.getStateChange() == ItemEvent.SELECTED)
    105                         routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
    106                     else
    107                         routingModel.routingGraph.getRoutingProfile().setOnewayUse(true);
    108                     routingModel.setNodesChanged();
    109                     routingModel.setOnewayChanged();
    110                     MainApplication.getMap().repaint();
    111                 }
     85        cbmi.addItemListener(e -> {
     86            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     87                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     88                RoutingModel routingModel = layer.getRoutingModel();
     89                routingModel.routingGraph.getRoutingProfile().setOnewayUse(e.getStateChange() != ItemEvent.SELECTED);
     90                routingModel.setNodesChanged();
     91                routingModel.setOnewayChanged();
     92                MainApplication.getMap().repaint();
    11293            }
    11394        });
     
    11798        menu.addSeparator();
    11899        reverseMI = new JMenuItem(tr("Reverse route"));
    119         reverseMI.addActionListener(new ActionListener() {
    120             @Override
    121             public void actionPerformed(ActionEvent e) {
    122                 if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    123                     RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    124                     RoutingModel routingModel = layer.getRoutingModel();
    125                     routingModel.reverseNodes();
    126                     MainApplication.getMap().repaint();
    127                 }
     100        reverseMI.addActionListener(e -> {
     101            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     102                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     103                RoutingModel routingModel = layer.getRoutingModel();
     104                routingModel.reverseNodes();
     105                MainApplication.getMap().repaint();
    128106            }
    129107        });
     
    131109
    132110        clearMI = new JMenuItem(tr("Clear route"));
    133         clearMI.addActionListener(new ActionListener() {
    134             @Override
    135             public void actionPerformed(ActionEvent e) {
    136                 if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    137                     RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    138                     RoutingModel routingModel = layer.getRoutingModel();
    139                     // Reset routing nodes and paths
    140                     routingModel.reset();
    141                     RoutingPlugin.getInstance().getRoutingDialog().clearNodes();
    142                     MainApplication.getMap().repaint();
    143                 }
     111        clearMI.addActionListener(e -> {
     112            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     113                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     114                RoutingModel routingModel = layer.getRoutingModel();
     115                // Reset routing nodes and paths
     116                routingModel.reset();
     117                RoutingPlugin.getInstance().getRoutingDialog().clearNodes();
     118                MainApplication.getMap().repaint();
    144119            }
    145120        });
     
    147122
    148123        regraphMI = new JMenuItem(tr("Reconstruct Graph"));
    149         regraphMI.addActionListener(new ActionListener() {
    150             @Override
    151             public void actionPerformed(ActionEvent e) {
    152                 if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    153                     RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    154                     RoutingModel routingModel = layer.getRoutingModel();
    155                     routingModel.routingGraph.resetGraph();
    156                     routingModel.routingGraph.createGraph();
    157                 }
     124        regraphMI.addActionListener(e -> {
     125            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     126                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
     127                RoutingModel routingModel = layer.getRoutingModel();
     128                routingModel.routingGraph.resetGraph();
     129                routingModel.routingGraph.createGraph();
    158130            }
    159131        });
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java

    r34554 r36085  
    77import java.awt.Dimension;
    88import java.awt.GridBagLayout;
    9 import java.awt.event.ActionEvent;
    10 import java.awt.event.ActionListener;
    119import java.awt.event.MouseAdapter;
    1210import java.awt.event.MouseEvent;
     
    2624import javax.swing.table.DefaultTableModel;
    2725
    28 import org.apache.log4j.Logger;
     26import com.innovant.josm.jrt.osm.OsmWayTypes;
    2927import org.openstreetmap.josm.data.Preferences;
    3028import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     
    3230import org.openstreetmap.josm.spi.preferences.Config;
    3331import org.openstreetmap.josm.tools.GBC;
    34 
    35 import com.innovant.josm.jrt.osm.OsmWayTypes;
     32import org.openstreetmap.josm.tools.Logging;
    3633
    3734public class RoutingPreferenceDialog extends DefaultTabPreferenceSetting {
    3835
    39     /**
    40      * Logger
    41      */
    42     static Logger logger = Logger.getLogger(RoutingPreferenceDialog.class);
    4336
    4437    private Map<String, String> orig;
     
    8174        p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
    8275        p.add(add, GBC.std().insets(0, 5, 0, 0));
    83         add.addActionListener(new ActionListener() {
    84             @Override
    85             public void actionPerformed(ActionEvent e) {
    86                 JPanel p = new JPanel(new GridBagLayout());
    87                 p.add(new JLabel(tr("Weight")), GBC.std().insets(0, 0, 5, 0));
    88                 JComboBox<String> key = new JComboBox<>();
    89                 for (OsmWayTypes pk : OsmWayTypes.values()) {
    90                     key.addItem(pk.getTag());
    91                 }
    92                 JTextField value = new JTextField(10);
    93                 p.add(key, GBC.eop().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL));
    94                 p.add(new JLabel(tr("Value")), GBC.std().insets(0, 0, 5, 0));
    95                 p.add(value, GBC.eol().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL));
    96                 int answer = JOptionPane.showConfirmDialog(gui, p,
    97                         tr("Enter weight values"),
    98                         JOptionPane.OK_CANCEL_OPTION);
    99                 if (answer == JOptionPane.OK_OPTION) {
    100                     model
    101                     .addRow(new String[] {
    102                             key.getSelectedItem().toString(),
    103                             value.getText() });
    104                 }
     76        add.addActionListener(e -> {
     77            JPanel p1 = new JPanel(new GridBagLayout());
     78            p1.add(new JLabel(tr("Weight")), GBC.std().insets(0, 0, 5, 0));
     79            JComboBox<String> key = new JComboBox<>();
     80            for (OsmWayTypes pk : OsmWayTypes.values()) {
     81                key.addItem(pk.getTag());
     82            }
     83            JTextField value = new JTextField(10);
     84            p1.add(key, GBC.eop().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL));
     85            p1.add(new JLabel(tr("Value")), GBC.std().insets(0, 0, 5, 0));
     86            p1.add(value, GBC.eol().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL));
     87            int answer = JOptionPane.showConfirmDialog(gui, p1,
     88                    tr("Enter weight values"),
     89                    JOptionPane.OK_CANCEL_OPTION);
     90            if (answer == JOptionPane.OK_OPTION) {
     91                model
     92                .addRow(new String[] {
     93                        key.getSelectedItem().toString(),
     94                        value.getText() });
    10595            }
    10696        });
     
    10898        JButton delete = new JButton(tr("Delete"));
    10999        p.add(delete, GBC.std().insets(0, 5, 0, 0));
    110         delete.addActionListener(new ActionListener() {
    111             @Override
    112             public void actionPerformed(ActionEvent e) {
    113                 if (list.getSelectedRow() == -1)
    114                     JOptionPane.showMessageDialog(gui,
    115                             tr("Please select the row to delete."));
    116                 else {
    117                     Integer i;
    118                     while ((i = list.getSelectedRow()) != -1) {
    119                         model.removeRow(i);
    120                     }
     100        delete.addActionListener(e -> {
     101            if (list.getSelectedRow() == -1)
     102                JOptionPane.showMessageDialog(gui,
     103                        tr("Please select the row to delete."));
     104            else {
     105                int i;
     106                while ((i = list.getSelectedRow()) != -1) {
     107                    model.removeRow(i);
    121108                }
    122109            }
     
    125112        JButton edit = new JButton(tr("Edit"));
    126113        p.add(edit, GBC.std().insets(5, 5, 5, 0));
    127         edit.addActionListener(new ActionListener() {
    128             @Override
    129             public void actionPerformed(ActionEvent e) {
    130                 edit(gui, list);
    131             }
    132         });
     114        edit.addActionListener(e -> edit(gui, list));
    133115
    134         JTabbedPane Opciones = new JTabbedPane();
    135         Opciones.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
     116        JTabbedPane options = new JTabbedPane();
     117        options.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    136118
    137         Opciones.addTab("Profile", null, p, null);
    138         //      Opciones.addTab("Preferences", new JPanel());
     119        options.addTab("Profile", null, p, null);
     120        //      options.addTab("Preferences", new JPanel());
    139121
    140122        list.addMouseListener(new MouseAdapter() {
     
    145127        });
    146128
    147         principal.add(Opciones, GBC.eol().fill(GBC.BOTH));
     129        principal.add(options, GBC.eol().fill(GBC.BOTH));
    148130
    149131    }
     
    184166        readPreferences();
    185167        // Put these values in the model
    186         for (String tag : orig.keySet()) {
    187             model.addRow(new String[] {tag, orig.get(tag)});
     168        for (Map.Entry<String, String> entry : orig.entrySet()) {
     169            model.addRow(new String[] {entry.getKey(), entry.getValue()});
    188170        }
    189171    }
     
    192174        orig = Preferences.main().getAllPrefix("routing.profile.default.speed");
    193175        if (orig.size() == 0) { // defaults
    194             logger.debug("Loading Default Preferences.");
     176            Logging.trace("Loading Default Preferences.");
    195177            for (OsmWayTypes owt : OsmWayTypes.values()) {
    196178                Config.getPref().putInt("routing.profile.default.speed."
     
    198180            }
    199181            orig = Preferences.main().getAllPrefix("routing.profile.default.speed");
    200         } else logger.debug("Default preferences already exist.");
     182        } else Logging.trace("Default preferences already exist.");
    201183    }
    202184    /*
Note: See TracChangeset for help on using the changeset viewer.