Changeset 29586 in osm for applications/editors


Ignore:
Timestamp:
2013-05-12T17:45:58+02:00 (12 years ago)
Author:
donvip
Message:

[josm_routing] Fix a bunch of problems and NPEs (fix #josm5132 and #josm8257)

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/routing/.settings/org.eclipse.jdt.core.prefs

    r28966 r29586  
    11eclipse.preferences.version=1
     2org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
     3org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
     4org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
     5org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
     6org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
    27org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
    38org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
     
    712org.eclipse.jdt.core.compiler.debug.localVariable=generate
    813org.eclipse.jdt.core.compiler.debug.sourceFile=generate
     14org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
    915org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
     16org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
     17org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
     18org.eclipse.jdt.core.compiler.problem.deadCode=warning
     19org.eclipse.jdt.core.compiler.problem.deprecation=warning
     20org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
     21org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
     22org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
     23org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
    1024org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
     25org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
     26org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
     27org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
     28org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
     29org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
     30org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
     31org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
     32org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
     33org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
     34org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
     35org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
     36org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
     37org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
     38org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
     39org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
     40org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
     41org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
     42org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
     43org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
     44org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
     45org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
     46org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
     47org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
     48org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
     49org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
     50org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
     51org.eclipse.jdt.core.compiler.problem.nullReference=warning
     52org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
     53org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
     54org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
     55org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
     56org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
     57org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
     58org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
     59org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
     60org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
     61org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
     62org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
     63org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
     64org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
     65org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
     66org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
     67org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
     68org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
     69org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
     70org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
     71org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
     72org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
     73org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
     74org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
     75org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
     76org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
     77org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
     78org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
     79org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
     80org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
     81org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
     82org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
     83org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
     84org.eclipse.jdt.core.compiler.problem.unusedImport=warning
     85org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
     86org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
     87org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
     88org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
     89org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
     90org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
     91org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
     92org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
     93org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
     94org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
    1195org.eclipse.jdt.core.compiler.source=1.6
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java

    r27760 r29586  
    275275                if(routingModel != null) {
    276276                        if(routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {
    277                         Color color2 = ColorHelper.html2color("#00ff00");               /* just green for now  */
    278277                        Set<OsmEdge> graphEdges =  routingModel.routingGraph.getGraph().edgeSet();
    279                         OsmEdge firstedge = (OsmEdge) graphEdges.toArray()[0];
    280                         Point from = mv.getPoint(firstedge.fromEastNorth());
    281                         g.drawRect(from.x-4, from.y+4, from.x+4, from.y-4);
    282                         for(OsmEdge edge : graphEdges) {
    283                                 drawGraph(g, mv, edge, color2, width);
     278                        if (!graphEdges.isEmpty()) {
     279                        Color color2 = ColorHelper.html2color("#00ff00");               /* just green for now  */
     280                                OsmEdge firstedge = (OsmEdge) graphEdges.toArray()[0];
     281                                Point from = mv.getPoint(firstedge.fromEastNorth());
     282                                g.drawRect(from.x-4, from.y+4, from.x+4, from.y-4);
     283                                for(OsmEdge edge : graphEdges) {
     284                                        drawGraph(g, mv, edge, color2, width);
     285                                }
    284286                        }
    285287                     }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java

    r29525 r29586  
    175175        public void addLayer() {
    176176                OsmDataLayer osmLayer = Main.map.mapView.getEditLayer();
    177                 RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.getName() + "]", osmLayer);
    178                 layers.add(layer);
    179                 Main.main.addLayer(layer);
     177                if (osmLayer != null) {
     178                        RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.getName() + "]", osmLayer);
     179                        layers.add(layer);
     180                        Main.main.addLayer(layer);
     181                }
    180182        }
    181183
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java

    r27288 r29586  
    3737import org.openstreetmap.josm.data.osm.Node;
    3838import org.openstreetmap.josm.gui.MapFrame;
     39import org.openstreetmap.josm.gui.layer.Layer;
    3940import org.openstreetmap.josm.tools.ImageProvider;
    40 
    41 import org.openstreetmap.josm.gui.layer.Layer;
    4241
    4342import com.innovant.josm.plugin.routing.RoutingLayer;
    4443import com.innovant.josm.plugin.routing.RoutingPlugin;
    45 import com.innovant.josm.plugin.routing.gui.RoutingDialog;
    4644
    4745/**
     
    5351 */
    5452public class AddRouteNodeAction extends MapMode {
    55     /**
    56      * Serial.
    57      */
    58     private static final long serialVersionUID = 1L;
     53
    5954    /**
    6055     * Logger.
    6156     */
    6257    static Logger logger = Logger.getLogger(AddRouteNodeAction.class);
    63     /**
    64      * Routing Dialog.
    65      */
    66     private RoutingDialog routingDialog;
    6758
    6859    /**
     
    7566                tr("Click to add destination."),
    7667                mapFrame, ImageProvider.getCursor("crosshair", null));
    77         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
    7868    }
    7969
     
    10292                logger.debug("selected node " + node);
    10393                layer.getRoutingModel().addNode(node);
    104                 routingDialog.addNode(node);
     94                RoutingPlugin.getInstance().getRoutingDialog().addNode(node);
    10595            }
    10696        }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java

    r27288 r29586  
    5656 */
    5757public class MoveRouteNodeAction extends MapMode {
    58     /**
    59      * Serial.
    60      */
    61     private static final long serialVersionUID = 1L;
    6258
    6359    /**
     
    7066     */
    7167    static Logger logger = Logger.getLogger(RoutingLayer.class);
    72 
    73     /**
    74      * Routing Dialog.
    75      */
    76     private RoutingDialog routingDialog;
    7768
    7869    /**
     
    9081                tr("Click and drag to move destination"),
    9182                mapFrame, ImageProvider.getCursor("normal", "move"));
    92         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
    9383    }
    9484
     
    141131            RoutingLayer layer = (RoutingLayer)Main.map.mapView.getActiveLayer();
    142132            RoutingModel routingModel = layer.getRoutingModel();
     133            RoutingDialog routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
    143134            // Search for nearest highway node
    144135            Node node = null;
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java

    r27288 r29586  
    3838import org.openstreetmap.josm.data.osm.Node;
    3939import org.openstreetmap.josm.gui.MapFrame;
     40import org.openstreetmap.josm.gui.layer.Layer;
    4041import org.openstreetmap.josm.tools.ImageProvider;
    41 import org.openstreetmap.josm.gui.layer.Layer;
    4242
    4343import com.innovant.josm.plugin.routing.RoutingLayer;
    4444import com.innovant.josm.plugin.routing.RoutingModel;
    4545import com.innovant.josm.plugin.routing.RoutingPlugin;
    46 import com.innovant.josm.plugin.routing.gui.RoutingDialog;
    4746
    4847/**
     
    5453 */
    5554public class RemoveRouteNodeAction extends MapMode {
    56     /**
    57      * Serial.
    58      */
    59     private static final long serialVersionUID = 1L;
    6055
    6156    /**
     
    6863     */
    6964    static Logger logger = Logger.getLogger(RoutingLayer.class);
    70     /**
    71      * Routing Dialog.
    72      */
    73     private RoutingDialog routingDialog;
    7465
    7566    public RemoveRouteNodeAction(MapFrame mapFrame) {
     
    7869                tr("Click to remove destination"),
    7970                mapFrame, ImageProvider.getCursor("normal", "delete"));
    80         this.routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
    8171    }
    8272
     
    114104                    logger.debug("Removing node " + nl.get(index));
    115105                    routingModel.removeNode(index);
    116                     routingDialog.removeNode(index);
     106                    RoutingPlugin.getInstance().getRoutingDialog().removeNode(index);
    117107                    Main.map.repaint();
    118108                } else {
Note: See TracChangeset for help on using the changeset viewer.