Ignore:
Timestamp:
2016-08-04T02:50:46+02:00 (8 years ago)
Author:
donvip
Message:

checkstyle

Location:
applications/editors/josm/plugins/routing
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/routing/.project

    r32286 r32768  
    1616                        </arguments>
    1717                </buildCommand>
     18                <buildCommand>
     19                        <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
     20                        <arguments>
     21                        </arguments>
     22                </buildCommand>
    1823        </buildSpec>
    1924        <natures>
    2025                <nature>org.eclipse.jdt.core.javanature</nature>
     26                <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    2127        </natures>
    2228</projectDescription>
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/EdgeIterator.java

    r23189 r32768  
     1// License: GPL. For details, see LICENSE file.
    12package com.innovant.josm.jrt.core;
    23
    34public interface EdgeIterator {
    45
    5     public boolean hasNext();
     6    boolean hasNext();
    67
    7     public RoutingEdge next();
     8    RoutingEdge next();
    89
    910}
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingEdge.java

    r23189 r32768  
     1// License: GPL. For details, see LICENSE file.
    12package com.innovant.josm.jrt.core;
    23
     
    56public interface RoutingEdge {
    67
    7       public LatLon fromLatLon();
     8    LatLon fromLatLon();
    89
    9       public LatLon toLatLon();
     10    LatLon toLatLon();
    1011
    11       public Object fromV();
     12    Object fromV();
    1213
    13       public Object toV();
     14    Object toV();
    1415
    15       public double getLength();
     16    double getLength();
    1617
    17       public void setLength(double length);
     18    void setLength(double length);
    1819
    19       public double getSpeed();
     20    double getSpeed();
    2021
    21       public void setSpeed(double speed);
     22    void setSpeed(double speed);
    2223
    23       public boolean isOneway();
     24    boolean isOneway();
    2425
    25       public void setOneway(boolean isOneway);
     26    void setOneway(boolean isOneway);
    2627
    2728}
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java

    r32348 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.jrt.core;
    293
     
    6842    public enum Algorithm {
    6943        ROUTING_ALG_DIJKSTRA, ROUTING_ALG_BELLMANFORD
    70     };
     44    }
    7145
    7246    /**
    7347     * Search criteria for the route.
    7448     */
    75     public enum RouteType {FASTEST,SHORTEST};
     49    public enum RouteType {
     50        FASTEST,
     51        SHORTEST
     52    }
    7653
    7754    /**
     
    9168
    9269    private static Collection<String> excludedHighwayValues = Arrays.asList(new String[]{
    93         "bus_stop", "traffic_signals", "street_lamp", "stop", "construction",
    94         "platform", "give_way", "proposed", "milestone", "speed_camera", "abandoned"
     70            "bus_stop", "traffic_signals", "street_lamp", "stop", "construction",
     71            "platform", "give_way", "proposed", "milestone", "speed_camera", "abandoned"
    9572    });
    96    
     73
    9774    /**
    9875     * Graph state
     
    10885    //  private WeightedMultigraph<Node, OsmEdge> graph;
    10986    private Graph<Node, OsmEdge> graph;
    110     private RoutingGraphDelegator rgDelegator=null;
     87    private RoutingGraphDelegator rgDelegator = null;
    11188
    11289
     
    11491     * Graph getter
    11592     */
    116     public Graph<Node, OsmEdge> getGraph(){
     93    public Graph<Node, OsmEdge> getGraph() {
    11794        return graph;
    118 
    119     }
    120 
    121 
    122     private void addEdgeBidirectional( Way way, Node from, Node to){
    123         addEdge(way,from,to);
    124         addEdge(way,to,from);
    125     }
    126 
    127     private void addEdgeReverseOneway( Way way, Node from, Node to){
    128         addEdge(way,to,from);
    129     }
    130 
    131     private void addEdgeNormalOneway( Way way, Node from, Node to){
    132         addEdge(way,from,to);
     95    }
     96
     97    private void addEdgeBidirectional(Way way, Node from, Node to) {
     98        addEdge(way, from, to);
     99        addEdge(way, to, from);
     100    }
     101
     102    private void addEdgeReverseOneway(Way way, Node from, Node to) {
     103        addEdge(way, to, from);
     104    }
     105
     106    private void addEdgeNormalOneway(Way way, Node from, Node to) {
     107        addEdge(way, from, to);
    133108    }
    134109
     
    136111     * Speeds
    137112     */
    138     private Map<String,Double> waySpeeds;
     113    private Map<String, Double> waySpeeds;
    139114
    140115    /**
     
    145120        this.graph = null;
    146121        this.data = data;
    147         routeType=RouteType.SHORTEST;
    148         routingProfile=new RoutingProfile("default");
     122        routeType = RouteType.SHORTEST;
     123        routingProfile = new RoutingProfile("default");
    149124        routingProfile.setOnewayUse(true); // Don't ignore oneways by default
    150125        this.setWaySpeeds(routingProfile.getWaySpeeds());
     
    154129    /**
    155130     * Create OSM graph for routing
    156      *
    157      * @return
    158131     */
    159132    public void createGraph() {
     
    161134        logger.debug("Creating Graph...");
    162135        graph = new DirectedWeightedMultigraph<>(OsmEdge.class);
    163         rgDelegator=new RoutingGraphDelegator(graph);
     136        rgDelegator = new RoutingGraphDelegator(graph);
    164137        rgDelegator.setRouteType(this.routeType);
    165138        // iterate all ways and segments for all nodes:
     
    178151            /*
    179152             * Assume node is A B C D E. The procedure should be
    180              * 
     153             *
    181154             *  case 1 - bidirectional ways:
    182155             *  1) Add vertex A B C D E
    183156             *  2) Link A<->B, B<->C, C<->D, D<->E as Edges
    184              * 
     157             *
    185158             *  case 2 - oneway reverse:
    186159             *  1) Add vertex A B C D E
    187160             *  2) Link B->A,C->B,D->C,E->D as Edges. result: A<-B<-C<-D<-E
    188              * 
     161             *
    189162             *  case 3 - oneway normal:
    190163             *  1) Add vertex A B C D E
    191164             *  2) Link A->B, B->C, C->D, D->E as Edges. result: A->B->C->D->E
    192              * 
    193              * 
     165             *
     166             *
    194167             */
    195168
     
    244217    /**
    245218     * Compute weight and add edge to the graph
    246      * @param way
    247      * @param from
    248      * @param to
    249      */
    250     private void addEdge(Way way,Node from, Node to) {
     219     */
     220    private void addEdge(Way way, Node from, Node to) {
    251221        LatLon fromLL = from.getCoor();
    252222        LatLon toLL = from.getCoor();
     
    263233        setWeight(edge, length);
    264234        logger.debug("edge for way " + way.getId()
    265                 + "(from node " + from.getId() + " to node "
    266                 + to.getId() + ") has weight: " + weight);
    267         ((DirectedWeightedMultigraph<Node,OsmEdge>)graph).setEdgeWeight(edge, weight);
     235        + "(from node " + from.getId() + " to node "
     236        + to.getId() + ") has weight: " + weight);
     237        ((DirectedWeightedMultigraph<Node, OsmEdge>) graph).setEdgeWeight(edge, weight);
    268238    }
    269239
     
    275245     * @param way
    276246     *            the way.
    277      * @return
    278247     */
    279248    private void setWeight(OsmEdge osmedge, double length) {
     
    292261     * @param way
    293262     *            the way.
    294      * @return
    295263     */
    296264    private double getWeight(Way way, double length) {
     
    302270            // Same speed for all types of ways
    303271            if (this.waySpeeds.containsKey("residential"))
    304                 speed=this.waySpeeds.get("residential");
     272                speed = this.waySpeeds.get("residential");
    305273            break;
    306274        case FASTEST:
    307275            // Each type of way may have a different speed
    308276            if (this.waySpeeds.containsKey(way.get("highway")))
    309                 speed=this.waySpeeds.get(way.get("highway"));
     277                speed = this.waySpeeds.get(way.get("highway"));
    310278            logger.debug("Speed="+speed);
    311279            break;
     
    327295        //if (!way.isTagged())            <---not needed me thinks
    328296        //    return false;
    329        
     297
    330298        String highway = way.get("highway");
    331299
     
    348316    public List<OsmEdge> applyAlgorithm(List<Node> nodes, Algorithm algorithm) {
    349317        List<OsmEdge> path = new ArrayList<>();
    350         Graph<Node,OsmEdge> g;
     318        Graph<Node, OsmEdge> g;
    351319        double totalWeight = 0;
    352         RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     320        RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    353321        RoutingModel routingModel = layer.getRoutingModel();
    354322
     
    405373     * @return the number of vertices.
    406374     */
    407     public int getVertexCount(){
    408         int value=0;
    409         if (graph!=null) value=graph.vertexSet().size();
     375    public int getVertexCount() {
     376        int value = 0;
     377        if (graph != null) value = graph.vertexSet().size();
    410378        return value;
    411379    }
     
    415383     * @return the number of edges.
    416384     */
    417     public int getEdgeCount(){
    418         int value=0;
    419         if (graph!=null) value=graph.edgeSet().size();
     385    public int getEdgeCount() {
     386        int value = 0;
     387        if (graph != null) value = graph.edgeSet().size();
    420388        return value;
    421389    }
     
    445413
    446414    public void resetGraph() {
    447         graph=null;
     415        graph = null;
    448416    }
    449417
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraphDelegator.java

    r23189 r32768  
    1 /**
    2  *
    3  */
     1// License: GPL. For details, see LICENSE file.
    42package com.innovant.josm.jrt.core;
    53
     
    97import org.openstreetmap.josm.data.osm.Node;
    108
    11 import com.innovant.josm.jrt.core.RoutingGraphDelegator;
    129import com.innovant.josm.jrt.core.RoutingGraph.RouteType;
    1310import com.innovant.josm.jrt.osm.OsmEdge;
     
    3330    }
    3431
    35 
    3632    public RouteType getRouteType() {
    3733        return routeType;
     
    4238    }
    4339
    44 
    4540    /**
    4641     *
     
    5045    @Override
    5146    public double getEdgeWeight(OsmEdge edge) {
    52         double weight=Double.MAX_VALUE;
     47        double weight = Double.MAX_VALUE;
    5348
    54         if (routeType==RouteType.SHORTEST) weight=edge.getLength();
    55         if (routeType==RouteType.FASTEST) weight=edge.getLength() / edge.getSpeed();
     49        if (routeType == RouteType.SHORTEST) weight = edge.getLength();
     50        if (routeType == RouteType.FASTEST) weight = edge.getLength() / edge.getSpeed();
    5651        // Return the time spent to traverse the way
    5752        return weight;
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingProfile.java

    r30737 r32768  
     1// License: GPL. For details, see LICENSE file.
    12package com.innovant.josm.jrt.core;
    23
     
    5758     * A speed of zero means that this type of way cannot be traversed.
    5859     */
    59     private Map<String,Double> waySpeeds;
     60    private Map<String, Double> waySpeeds;
    6061
    6162
     
    6465     * Holds permission of use for each type of transport mode, using the mode as key.
    6566     */
    66     private Map<String,Boolean> allowedModes;
     67    private Map<String, Boolean> allowedModes;
    6768
    6869    /**
     
    7576        logger.debug("Init RoutingProfile with name: "+name);
    7677        this.name = name;
    77         waySpeeds=new HashMap<>();
    78         Map<String,String> prefs=Main.pref.getAllPrefix("routing.profile."+name+".speed");
    79         for(String key:prefs.keySet()){
     78        waySpeeds = new HashMap<>();
     79        Map<String, String> prefs = Main.pref.getAllPrefix("routing.profile."+name+".speed");
     80        for (String key:prefs.keySet()) {
    8081            waySpeeds.put((key.split("\\.")[4]), Double.valueOf(prefs.get(key)));
    8182        }
    82         for (String key:waySpeeds.keySet())
     83        for (String key:waySpeeds.keySet()) {
    8384            logger.debug(key+ "-- speed: "+waySpeeds.get(key));
     85        }
    8486        logger.debug("End init RoutingProfile with name: "+name);
    8587    }
     
    147149    }
    148150
    149     public double getSpeed(String key){
    150         if(!waySpeeds.containsKey(key)) return 0.0;
     151    public double getSpeed(String key) {
     152        if (!waySpeeds.containsKey(key)) return 0.0;
    151153        return waySpeeds.get(key);
    152154    }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/gtfs/GTFSTransportModes.java

    r15707 r32768  
     1// License: GPL. For details, see LICENSE file.
    12package com.innovant.josm.jrt.gtfs;
    23
     
    78 * Routing Profile keys should be Strings
    89 */
    9 public class GTFSTransportModes {
     10public final class GTFSTransportModes {
     11
     12    private GTFSTransportModes() {
     13
     14    }
    1015
    1116    /**
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmEdge.java

    r23189 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
     1// License: GPL. For details, see LICENSE file.
    272package com.innovant.josm.jrt.osm;
    283
     
    3712 */
    3813public class OsmEdge extends DefaultWeightedEdge {
    39  /**
    40   * Serial
    41   */
    42   private static final long serialVersionUID = 1L;
    43   /**
    44    * Way associated
    45    */
    46   private Way way;
    47   /**
    48    * Nodes in the edge
    49    */
    50   private Node from, to;
    51   /**
    52    * Length edge
    53    */
    54   private double length;
    55   /**
    56    * Speed edge.
    57    */
    58   private double speed;
     14    /**
     15     * Serial
     16     */
     17    private static final long serialVersionUID = 1L;
     18    /**
     19     * Way associated
     20     */
     21    private Way way;
     22    /**
     23     * Nodes in the edge
     24     */
     25    private Node from, to;
     26    /**
     27     * Length edge
     28     */
     29    private double length;
     30    /**
     31     * Speed edge.
     32     */
     33    private double speed;
    5934
    60 
    61 /**
    62    * Constructor
    63    * @param way
    64    * @param length
    65    */
    66   public OsmEdge(Way way, Node from, Node to) {
     35    /**
     36     * Constructor
     37     */
     38    public OsmEdge(Way way, Node from, Node to) {
    6739        super();
    6840        this.way = way;
     
    7042        this.to = to;
    7143        this.length = from.getCoor().greatCircleDistance(to.getCoor());
    72       }
     44    }
    7345
    74   /**
    75    * @return the way
    76    */
    77   public Way getWay() {
    78       return this.way;
    79   }
     46    /**
     47     * @return the way
     48     */
     49    public Way getWay() {
     50        return this.way;
     51    }
    8052
    81   public EastNorth fromEastNorth() {
    82       return this.from.getEastNorth();
    83   }
     53    public EastNorth fromEastNorth() {
     54        return this.from.getEastNorth();
     55    }
    8456
    85   public EastNorth toEastNorth() {
    86       return this.to.getEastNorth();
    87   }
     57    public EastNorth toEastNorth() {
     58        return this.to.getEastNorth();
     59    }
    8860
    89   /**
    90    * Returns length of segment in meters
    91    * @return length of segment in meters.
    92    */
    93   public double getLength() {
    94     return length;
    95   }
     61    /**
     62     * Returns length of segment in meters
     63     * @return length of segment in meters.
     64     */
     65    public double getLength() {
     66        return length;
     67    }
    9668
    97   public void setLength(double length) {
    98     this.length = length;
     69    public void setLength(double length) {
     70        this.length = length;
     71    }
     72
     73    public double getSpeed() {
     74        return speed;
     75    }
     76
     77    public void setSpeed(double speed) {
     78        this.speed = speed;
     79    }
    9980}
    100 
    101 public double getSpeed() {
    102         return speed;
    103   }
    104 
    105   public void setSpeed(double speed) {
    106         this.speed = speed;
    107   }
    108 }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmWayTypes.java

    r15707 r32768  
    1 /*
    2  *
    3  * Copyright (C) 2008 Innovant
    4  *
    5  * This program is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU General Public License
    7  * as published by the Free Software Foundation; either version 2
    8  * of the License, or (at your option) any later version.
    9  *
    10  * This program is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  * GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program; if not, write to the Free Software
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    18  *
    19  * For more information, please contact:
    20  *
    21  *  Innovant
    22  *   juangui@gmail.com
    23  *   vidalfree@gmail.com
    24  *
    25  *  http://public.grupoinnovant.com/blog
    26  *
    27  */
    28 
     1// License: GPL. For details, see LICENSE file.
    292package com.innovant.josm.jrt.osm;
    303
     
    347 */
    358public enum OsmWayTypes {
    36     MOTORWAY ("motorway",120),
    37     MOTORWAY_LINK ("motorway_link",120),
    38     TRUNK ("trunk",120),
    39     TRUNK_LINK ("trunk_link",120),
    40     PRIMARY  ("primary",100),
    41     PRIMARY_LINK ("primary_link",100),
    42     SECONDARY ("secondary",90),
    43     TERTIARY ("tertiary",90),
    44     UNCLASSIFIED ("unclassified",50),
    45     ROAD ("road",100),
    46     RESIDENTIAL ("residential",50),
    47     LIVING_STREET ("living_street",30),
    48     SERVICE ("service",30),
    49     TRACK ("track",50),
    50     PEDESTRIAN ("pedestrian",30),
    51     BUS_GUIDEWAY ("bus_guideway",50),
    52     PATH ("path",40),
    53     CYCLEWAY ("cycleway",40),
    54     FOOTWAY ("footway",20),
    55     BRIDLEWAY ("bridleway",40),
    56     BYWAY ("byway",50),
    57     STEPS ("steps",10);
     9    MOTORWAY("motorway", 120),
     10    MOTORWAY_LINK("motorway_link", 120),
     11    TRUNK("trunk", 120),
     12    TRUNK_LINK("trunk_link", 120),
     13    PRIMARY("primary", 100),
     14    PRIMARY_LINK("primary_link", 100),
     15    SECONDARY("secondary", 90),
     16    TERTIARY("tertiary", 90),
     17    UNCLASSIFIED("unclassified", 50),
     18    ROAD("road", 100),
     19    RESIDENTIAL("residential", 50),
     20    LIVING_STREET("living_street", 30),
     21    SERVICE("service", 30),
     22    TRACK("track", 50),
     23    PEDESTRIAN("pedestrian", 30),
     24    BUS_GUIDEWAY("bus_guideway", 50),
     25    PATH("path", 40),
     26    CYCLEWAY("cycleway", 40),
     27    FOOTWAY("footway", 20),
     28    BRIDLEWAY("bridleway", 40),
     29    BYWAY("byway", 50),
     30    STEPS("steps", 10);
    5831
    5932    /**
    6033     * Default Constructor
    61      * @param tag
    6234     */
    63     OsmWayTypes(String tag,int speed) {
     35    OsmWayTypes(String tag, int speed) {
    6436        this.tag = tag;
    6537        this.speed = speed;
     
    7244    private final int speed;
    7345
    74     /**
    75      * @return
    76      */
    77     public String getTag() {return tag;};
    78     public int getSpeed() {return speed;};
     46    public String getTag() {
     47        return tag;
     48    }
     49
     50    public int getSpeed() {
     51        return speed;
     52    }
    7953}
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java

    r32349 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing;
    293
     
    7246
    7347    public enum PreferencesKeys {
    74         KEY_ACTIVE_ROUTE_COLOR (marktr("routing active route")),
    75         KEY_INACTIVE_ROUTE_COLOR (marktr("routing inactive route")),
    76         KEY_ROUTE_WIDTH ("routing.route.width"),
    77         KEY_ROUTE_SELECT ("routing.route.select");
     48        KEY_ACTIVE_ROUTE_COLOR(marktr("routing active route")),
     49        KEY_INACTIVE_ROUTE_COLOR(marktr("routing inactive route")),
     50        KEY_ROUTE_WIDTH("routing.route.width"),
     51        KEY_ROUTE_SELECT("routing.route.select");
    7852
    7953        public final String key;
    80         PreferencesKeys (String key) {
    81             this.key=key;
    82         }
    83 
    84         public String getKey() {return key;};
     54        PreferencesKeys(String key) {
     55            this.key = key;
     56        }
     57
     58        public String getKey() {
     59            return key;
     60        }
    8561    }
    8662
     
    10379     * Start, Middle and End icons
    10480     */
    105     private Icon startIcon,middleIcon,endIcon;
     81    private Icon startIcon, middleIcon, endIcon;
    10682
    10783    /**
     
    11793        super(name);
    11894        logger.debug("Creating Routing Layer...");
    119         if(startIcon == null) startIcon = ImageProvider.get("routing", "startflag");
    120         if(middleIcon == null) middleIcon = ImageProvider.get("routing", "middleflag");
    121         if(endIcon == null) endIcon = ImageProvider.get("routing", "endflag");
     95        if (startIcon == null) startIcon = ImageProvider.get("routing", "startflag");
     96        if (middleIcon == null) middleIcon = ImageProvider.get("routing", "middleflag");
     97        if (endIcon == null) endIcon = ImageProvider.get("routing", "endflag");
    12298        this.dataLayer = dataLayer;
    12399        this.routingModel = new RoutingModel(dataLayer.data);
    124100        logger.debug("Routing Layer created.");
    125        
     101
    126102
    127103        this.routingModel.routingGraph.createGraph();    /* construct the graph right after we we create the layer */
     
    155131        double minDist = 0;
    156132        for (Way w : dataLayer.data.getWays()) {
    157             if (w.isDeleted() || w.isIncomplete() || w.get("highway")==null) continue;
     133            if (w.isDeleted() || w.isIncomplete() || w.get("highway") == null) continue;
    158134            for (Node n : w.getNodes()) {
    159135                if (n.isDeleted() || n.isIncomplete()) continue;
     
    181157    public Object getInfoComponent() {
    182158        String info = "<html>"
    183                         + "<body>"
    184                             +"Graph Vertex: "+this.routingModel.routingGraph.getVertexCount()+"<br/>"
    185                             +"Graph Edges: "+this.routingModel.routingGraph.getEdgeCount()+"<br/>"
    186                         + "</body>"
    187                     + "</html>";
     159                + "<body>"
     160                +"Graph Vertex: "+this.routingModel.routingGraph.getVertexCount()+"<br/>"
     161                +"Graph Edges: "+this.routingModel.routingGraph.getEdgeCount()+"<br/>"
     162                + "</body>"
     163                + "</html>";
    188164        return info;
    189165    }
     
    193169        Collection<Action> components = new ArrayList<>();
    194170        components.add(LayerListDialog.getInstance().createShowHideLayerAction());
    195 //        components.add(new JMenuItem(new LayerListDialog.ShowHideMarkerText(this)));
     171        //        components.add(new JMenuItem(new LayerListDialog.ShowHideMarkerText(this)));
    196172        components.add(LayerListDialog.getInstance().createDeleteLayerAction());
    197173        components.add(SeparatorLayerAction.INSTANCE);
     
    241217        }
    242218        int width = Integer.parseInt(widthString);
    243        
    244        
     219
     220
    245221        // draw our graph
    246222        if (isActiveLayer) {
    247             if(routingModel != null) {
    248                 if(routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {
    249                     Set<OsmEdge> graphEdges =  routingModel.routingGraph.getGraph().edgeSet();
     223            if (routingModel != null) {
     224                if (routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {
     225                    Set<OsmEdge> graphEdges = routingModel.routingGraph.getGraph().edgeSet();
    250226                    if (!graphEdges.isEmpty()) {
    251227                        Color color2 = ColorHelper.html2color("#00ff00");        /* just green for now  */
     
    253229                        Point from = mv.getPoint(firstedge.fromEastNorth());
    254230                        g.drawRect(from.x-4, from.y+4, from.x+4, from.y-4);
    255                         for(OsmEdge edge : graphEdges) {
     231                        for (OsmEdge edge : graphEdges) {
    256232                            drawGraph(g, mv, edge, color2, width);
    257233                        }
    258234                    }
    259                  }
    260              }
    261         }
    262                    
    263        
    264         if(nodes == null || nodes.size() == 0) return;
    265        
     235                }
     236            }
     237        }
     238
     239
     240        if (nodes == null || nodes.size() == 0) return;
     241
    266242        // Paint routing path
    267243        List<OsmEdge> routeEdges = routingModel.getRouteEdges();
    268         if(routeEdges != null) {
    269             for(OsmEdge edge : routeEdges) {
     244        if (routeEdges != null) {
     245            for (OsmEdge edge : routeEdges) {
    270246                drawEdge(g, mv, edge, color, width, true);
    271247            }
     
    279255
    280256        // paint middle icons
    281         for(int index = 1; index < nodes.size() - 1; ++index) {
     257        for (int index = 1; index < nodes.size() - 1; ++index) {
    282258            node = nodes.get(index);
    283259            screen = mv.getPoint(node);
     
    286262        }
    287263        // paint end icon
    288         if(nodes.size() > 1) {
     264        if (nodes.size() > 1) {
    289265            node = nodes.get(nodes.size() - 1);
    290266            screen = mv.getPoint(node);
     
    304280    public void destroy() {
    305281        routingModel.reset();
    306 //      layerAdded = false;
     282        //      layerAdded = false;
    307283    }
    308284
     
    318294        to = mv.getPoint(edge.toEastNorth());
    319295
    320             Graphics2D g2d = (Graphics2D)g;
    321             g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias!
    322             Stroke oldStroke = g2d.getStroke();
    323             g2d.setStroke(new BasicStroke(width)); // thickness
    324             g2d.drawLine(from.x, from.y, to.x, to.y);
    325             if (showDirection) {
    326                 double t = Math.atan2(to.y-from.y, to.x-from.x) + Math.PI;
    327                 g.drawLine(to.x,to.y, (int)(to.x + 10*Math.cos(t-ARROW_PHI)), (int)(to.y + 10*Math.sin(t-ARROW_PHI)));
    328                 g.drawLine(to.x,to.y, (int)(to.x + 10*Math.cos(t+ARROW_PHI)), (int)(to.y + 10*Math.sin(t+ARROW_PHI)));
    329             }
    330             g2d.setStroke(oldStroke);
    331     }
     296        Graphics2D g2d = (Graphics2D) g;
     297        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias!
     298        Stroke oldStroke = g2d.getStroke();
     299        g2d.setStroke(new BasicStroke(width)); // thickness
     300        g2d.drawLine(from.x, from.y, to.x, to.y);
     301        if (showDirection) {
     302            double t = Math.atan2(to.y-from.y, to.x-from.x) + Math.PI;
     303            g.drawLine(to.x, to.y, (int) (to.x + 10*Math.cos(t-ARROW_PHI)), (int) (to.y + 10*Math.sin(t-ARROW_PHI)));
     304            g.drawLine(to.x, to.y, (int) (to.x + 10*Math.cos(t+ARROW_PHI)), (int) (to.y + 10*Math.sin(t+ARROW_PHI)));
     305        }
     306        g2d.setStroke(oldStroke);
     307    }
     308
    332309    private void drawGraph(Graphics g, MapView mv, OsmEdge edge, Color col, int width) {
    333310        g.setColor(col);
     
    336313        from = mv.getPoint(edge.fromEastNorth());
    337314        to = mv.getPoint(edge.toEastNorth());
    338        
    339             Graphics2D g2d = (Graphics2D)g;
    340             Stroke oldStroke = g2d.getStroke();
    341             g2d.setStroke(new BasicStroke(width)); // thickness
    342             g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias!
    343             g2d.drawLine(from.x, from.y, to.x, to.y);
    344             g2d.drawRect(to.x- 4, to.y+4, 4, 4);
    345 
    346             g2d.setStroke(oldStroke);
    347      }
    348        
     315
     316        Graphics2D g2d = (Graphics2D) g;
     317        Stroke oldStroke = g2d.getStroke();
     318        g2d.setStroke(new BasicStroke(width)); // thickness
     319        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias!
     320        g2d.drawLine(from.x, from.y, to.x, to.y);
     321        g2d.drawRect(to.x- 4, to.y+4, 4, 4);
     322
     323        g2d.setStroke(oldStroke);
     324    }
     325
    349326}
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java

    r30737 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing;
    293
     
    5630     * Graph to calculate route
    5731     */
    58     public RoutingGraph routingGraph=null;
     32    public RoutingGraph routingGraph = null;
    5933
    6034    /**
    6135     * List of nodes that the route has to traverse
    6236     */
    63     private List<Node> nodes=null;
     37    private List<Node> nodes = null;
    6438
    65     private List<OsmEdge> path=null;
     39    private List<OsmEdge> path = null;
    6640
    6741    /**
    6842     * Flag to advise about changes in the selected nodes.
    6943     */
    70     private boolean changeNodes=false;
     44    private boolean changeNodes = false;
    7145
    7246    /**
    7347     * Flag to advise about changes in ways.
    7448     */
    75     private boolean changeOneway=false;
     49    private boolean changeOneway = false;
    7650
    7751    /**
     
    9872    public void addNode(Node node) {
    9973        nodes.add(node);
    100         this.changeNodes=true;
     74        this.changeNodes = true;
    10175    }
    10276
     
    10680     */
    10781    public void removeNode(int index) {
    108         if (nodes.size()>index) {
     82        if (nodes.size() > index) {
    10983            nodes.remove(index);
    110             this.changeNodes=true;
     84            this.changeNodes = true;
    11185        }
    11286    }
     
    11892     */
    11993    public void insertNode(int index, Node node) {
    120         if (nodes.size()>=index) {
     94        if (nodes.size() >= index) {
    12195            nodes.add(index, node);
    122             this.changeNodes=true;
     96            this.changeNodes = true;
    12397        }
    12498    }
     
    130104        List<Node> aux = new ArrayList<>();
    131105        for (Node n : nodes) {
    132             aux.add(0,n);
     106            aux.add(0, n);
    133107        }
    134108        nodes = aux;
    135         this.changeNodes=true;
     109        this.changeNodes = true;
    136110    }
    137111
     
    141115     */
    142116    public List<OsmEdge> getRouteEdges() {
    143         if (this.changeNodes || path==null)
    144         {
    145             path=this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA);
    146             this.changeNodes=false;
    147             this.changeOneway=false;
     117        if (this.changeNodes || path == null) {
     118            path = this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA);
     119            this.changeNodes = false;
     120            this.changeOneway = false;
    148121        }
    149122        return path;
     
    176149    public void reset() {
    177150        nodes.clear();
    178         this.changeNodes=true;
     151        this.changeNodes = true;
    179152    }
    180153
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java

    r32465 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing;
    293
     
    148122        }
    149123        logger.debug("Loading routing plugin...");
    150         preferenceSettings=new RoutingPreferenceDialog();
     124        preferenceSettings = new RoutingPreferenceDialog();
    151125        // Initialize layers list
    152126        layers = new ArrayList<>();
     
    222196                routingDialog.refresh();
    223197            }
    224         }else{                                            /*   hide Routing toolbar and dialog window  */
     198        } else {                                           /*   hide Routing toolbar and dialog window  */
    225199            menu.disableRestOfItems();
    226200            if (routingDialog != null) {
     
    250224    public void layerRemoving(LayerRemoveEvent evt) {
    251225        Layer oldLayer = evt.getRemovedLayer();
    252         if ((oldLayer instanceof RoutingLayer) & (layers.size()==1)) {
     226        if ((oldLayer instanceof RoutingLayer) & (layers.size() == 1)) {
    253227            // Remove button(s) from the tool bar when the last routing layer is removed
    254228            addRouteNodeButton.setVisible(false);
     
    263237            // FIXME: can't remove associated routing layers without triggering exceptions in some cases
    264238            RoutingLayer[] layersArray = layers.toArray(new RoutingLayer[0]);
    265             for (int i=0;i<layersArray.length;i++) {
     239            for (int i = 0; i < layersArray.length; i++) {
    266240                if (layersArray[i].getDataLayer().equals(oldLayer)) {
    267241                    try {
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java

    r32329 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing.actions;
    293
     
    5933    /**
    6034     * Constructor
    61      * @param mapFrame
     35     * @param mapFrame map frame
    6236     */
    6337    public AddRouteNodeAction(MapFrame mapFrame) {
     
    8458            Node node = null;
    8559            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    86                 RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     60                RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    8761                node = layer.getNearestHighwayNode(e.getPoint());
    88                 if(node == null) {
     62                if (node == null) {
    8963                    logger.debug("no selected node");
    9064                    return;
     
    9771        Main.map.repaint();
    9872    }
     73
    9974    @Override public boolean layerIsSupported(Layer l) {
    10075        return l instanceof RoutingLayer;
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java

    r32329 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing.actions;
    293
     
    3913import org.openstreetmap.josm.data.osm.Node;
    4014import org.openstreetmap.josm.gui.MapFrame;
     15import org.openstreetmap.josm.gui.layer.Layer;
    4116import org.openstreetmap.josm.tools.ImageProvider;
    42 
    43 import org.openstreetmap.josm.gui.layer.Layer;
    4417
    4518import com.innovant.josm.plugin.routing.RoutingLayer;
     
    7447    /**
    7548     * Constructor
    76      * @param mapFrame
     49     * @param mapFrame map frame
    7750     */
    7851    public MoveRouteNodeAction(MapFrame mapFrame) {
     
    9871            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    9972                requestFocusInMapView();
    100                 RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     73                RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    10174                RoutingModel routingModel = layer.getRoutingModel();
    10275                // Search for the nearest node in the list
     
    10477                index = -1;
    10578                double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels
    106                 for (int i=0;i<nl.size();i++) {
     79                for (int i = 0; i < nl.size(); i++) {
    10780                    Node node = nl.get(i);
    10881                    double d = Main.map.mapView.getPoint(node).distanceSq(e.getPoint());
     
    11285                    }
    11386                }
    114                 if (index>=0)
     87                if (index >= 0)
    11588                    logger.debug("Moved from node " + nl.get(index));
    11689            }
     
    12093    @Override public void mouseReleased(MouseEvent e) {
    12194        // If left button is released and a route node is being dragged
    122         if ((e.getButton() == MouseEvent.BUTTON1) && (index>=0)) {
     95        if ((e.getButton() == MouseEvent.BUTTON1) && (index >= 0)) {
    12396            searchAndReplaceNode(e.getPoint());
    12497        }
     
    130103    private void searchAndReplaceNode(Point point) {
    131104        if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    132             RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     105            RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    133106            RoutingModel routingModel = layer.getRoutingModel();
    134107            RoutingDialog routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
     
    148121        }
    149122    }
     123
    150124    @Override public boolean layerIsSupported(Layer l) {
    151125        return l instanceof RoutingLayer;
    152126    }
    153 
    154127}
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java

    r32329 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing.actions;
    293
     
    8559        if (e.getButton() == MouseEvent.BUTTON1) {
    8660            if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    87                 RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     61                RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    8862                RoutingModel routingModel = layer.getRoutingModel();
    8963                // Search for the nearest node in the list
     
    9165                int index = -1;
    9266                double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels
    93                 for (int i=0;i<nl.size();i++) {
     67                for (int i = 0; i < nl.size(); i++) {
    9468                    Node node = nl.get(i);
    9569                    double d = Main.map.mapView.getPoint(node).distanceSq(e.getPoint());
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java

    r32329 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing.gui;
    293
     
    9973    /**
    10074     * Remove item from the list of nodes
    101      * @param index
    10275     */
    10376    public void removeNode(int index) {
     
    10780    /**
    10881     * Add item to the list of nodes
    109      * @param obj
    11082     */
    11183    public void addNode(Node n) {
     
    11587    /**
    11688     * Insert item to the list of nodes
    117      * @param index
    118      * @param obj
    11989     */
    12090    public void insertNode(int index, Node n) {
     
    132102        clearNodes();
    133103        if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    134             RoutingLayer routingLayer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     104            RoutingLayer routingLayer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    135105            RoutingModel routingModel = routingLayer.getRoutingModel();
    136106            for (Node n : routingModel.getSelectedNodes()) {
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java

    r32329 r32768  
    1 /*
    2  * Copyright (C) 2008 Innovant
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    17  *
    18  * For more information, please contact:
    19  *
    20  *  Innovant
    21  *   juangui@gmail.com
    22  *   vidalfree@gmail.com
    23  *
    24  *  http://public.grupoinnovant.com/blog
    25  *
    26  */
    27 
     1// License: GPL. For details, see LICENSE file.
    282package com.innovant.josm.plugin.routing.gui;
    293
     
    7852        startMI = new JMenuItem(tr("Add routing layer"));
    7953        startMI.addActionListener(new ActionListener() {
     54            @Override
    8055            public void actionPerformed(ActionEvent e) {
    8156                RoutingPlugin.getInstance().addLayer();
     
    9267        rshorter.setSelected(true);
    9368        rshorter.addItemListener(new ItemListener() {
     69            @Override
    9470            public void itemStateChanged(ItemEvent e) {
    9571                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    96                     RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     72                    RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    9773                    RoutingModel routingModel = layer.getRoutingModel();
    98                     if (e.getStateChange()==ItemEvent.SELECTED) {
     74                    if (e.getStateChange() == ItemEvent.SELECTED) {
    9975                        routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST);
    10076                    } else {
     
    12197        JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("Ignore oneways"));
    12298        cbmi.addItemListener(new ItemListener() {
     99            @Override
    123100            public void itemStateChanged(ItemEvent e) {
    124101                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    125                     RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     102                    RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    126103                    RoutingModel routingModel = layer.getRoutingModel();
    127                     if (e.getStateChange()==ItemEvent.SELECTED)
     104                    if (e.getStateChange() == ItemEvent.SELECTED)
    128105                        routingModel.routingGraph.getRoutingProfile().setOnewayUse(false);
    129106                    else
     
    141118        reverseMI = new JMenuItem(tr("Reverse route"));
    142119        reverseMI.addActionListener(new ActionListener() {
     120            @Override
    143121            public void actionPerformed(ActionEvent e) {
    144122                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    145                     RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     123                    RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    146124                    RoutingModel routingModel = layer.getRoutingModel();
    147125                    routingModel.reverseNodes();
     
    154132        clearMI = new JMenuItem(tr("Clear route"));
    155133        clearMI.addActionListener(new ActionListener() {
     134            @Override
    156135            public void actionPerformed(ActionEvent e) {
    157136                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    158                     RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     137                    RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    159138                    RoutingModel routingModel = layer.getRoutingModel();
    160139                    // Reset routing nodes and paths
     
    169148        regraphMI = new JMenuItem(tr("Reconstruct Graph"));
    170149        regraphMI.addActionListener(new ActionListener() {
     150            @Override
    171151            public void actionPerformed(ActionEvent e) {
    172152
    173153                if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    174                     RoutingLayer layer = (RoutingLayer)Main.getLayerManager().getActiveLayer();
     154                    RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
    175155                    RoutingModel routingModel = layer.getRoutingModel();
    176156                    routingModel.routingGraph.resetGraph();
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java

    r30532 r32768  
    1 /*
    2  *
    3  * Copyright (C) 2008 Innovant
    4  *
    5  * This program is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU General Public License
    7  * as published by the Free Software Foundation; either version 2
    8  * of the License, or (at your option) any later version.
    9  *
    10  * This program is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  * GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program; if not, write to the Free Software
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
    18  *
    19  * For more information, please contact:
    20  *
    21  *  Innovant
    22  *   juangui@gmail.com
    23  *   vidalfree@gmail.com
    24  *
    25  *  http://public.grupoinnovant.com/blog
    26  *
    27  */
    28 
     1// License: GPL. For details, see LICENSE file.
    292package com.innovant.josm.plugin.routing.gui;
    303
     
    7952    }
    8053
     54    @Override
    8155    public void addGui(final PreferenceTabbedPane gui) {
    8256
     
    8660        p.setLayout(new GridBagLayout());
    8761
    88         model = new DefaultTableModel(new String[] { tr("Highway type"),
     62        model = new DefaultTableModel(new String[] {tr("Highway type"),
    8963                tr("Speed (Km/h)") }, 0) {
    9064            private static final long serialVersionUID = 4253339034781567453L;
     
    10781        p.add(add, GBC.std().insets(0, 5, 0, 0));
    10882        add.addActionListener(new ActionListener() {
     83            @Override
    10984            public void actionPerformed(ActionEvent e) {
    11085                JPanel p = new JPanel(new GridBagLayout());
    11186                p.add(new JLabel(tr("Weight")), GBC.std().insets(0, 0, 5, 0));
    11287                JComboBox<String> key = new JComboBox<>();
    113                 for (OsmWayTypes pk : OsmWayTypes.values())
     88                for (OsmWayTypes pk : OsmWayTypes.values()) {
    11489                    key.addItem(pk.getTag());
     90                }
    11591                JTextField value = new JTextField(10);
    11692                p.add(key, GBC.eop().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL));
     
    132108        p.add(delete, GBC.std().insets(0, 5, 0, 0));
    133109        delete.addActionListener(new ActionListener() {
     110            @Override
    134111            public void actionPerformed(ActionEvent e) {
    135112                if (list.getSelectedRow() == -1)
     
    138115                else {
    139116                    Integer i;
    140                     while ((i = list.getSelectedRow()) != -1)
     117                    while ((i = list.getSelectedRow()) != -1) {
    141118                        model.removeRow(i);
     119                    }
    142120                }
    143121            }
     
    147125        p.add(edit, GBC.std().insets(5, 5, 5, 0));
    148126        edit.addActionListener(new ActionListener() {
     127            @Override
    149128            public void actionPerformed(ActionEvent e) {
    150129                edit(gui, list);
     
    158137        //      Opciones.addTab("Preferences", new JPanel());
    159138
    160         list.addMouseListener(new MouseAdapter(){
     139        list.addMouseListener(new MouseAdapter() {
    161140            @Override public void mouseClicked(MouseEvent e) {
    162141                if (e.getClickCount() == 2)
     
    169148    }
    170149
     150    @Override
    171151    public boolean ok() {
    172152        for (int i = 0; i < model.getRowCount(); ++i) {
     
    180160            }
    181161        }
    182         for (Entry<String, String> e : orig.entrySet())
     162        for (Entry<String, String> e : orig.entrySet()) {
    183163            Main.pref.put(e.getKey(), null);
     164        }
    184165        return false;
    185166    }
     
    203184        // Put these values in the model
    204185        for (String tag : orig.keySet()) {
    205             model.addRow(new String[] { tag, orig.get(tag) });
     186            model.addRow(new String[] {tag, orig.get(tag)});
    206187        }
    207188    }
     
    216197            }
    217198            orig = Main.pref.getAllPrefix("routing.profile.default.speed");
    218         }
    219         else logger.debug("Default preferences already exist.");
     199        } else logger.debug("Default preferences already exist.");
    220200    }
    221201    /*
Note: See TracChangeset for help on using the changeset viewer.