Ignore:
Timestamp:
2016-07-05T00:28:27+02:00 (9 years ago)
Author:
darya
Message:

removed old classes, updated unit tests, added AddStopPositionAction

Location:
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java

    r32522 r32567  
    22package org.openstreetmap.josm.plugins.pt_assistant;
    33
     4import javax.swing.JMenuItem;
     5
     6import org.openstreetmap.josm.Main;
    47import org.openstreetmap.josm.data.validation.OsmValidator;
     8import org.openstreetmap.josm.gui.MainMenu;
     9import org.openstreetmap.josm.gui.MapFrame;
    510import org.openstreetmap.josm.plugins.Plugin;
    611import org.openstreetmap.josm.plugins.PluginInformation;
    7 import org.openstreetmap.josm.plugins.pt_assistant.validation.PTAssitantValidatorTest;
     12import org.openstreetmap.josm.plugins.pt_assistant.actions.AddStopPositionAction;
     13import org.openstreetmap.josm.plugins.pt_assistant.validation.PTAssistantValidatorTest;
     14import org.openstreetmap.josm.tools.ImageProvider;
    815
    916/**
     
    1421 */
    1522public class PTAssistantPlugin extends Plugin {
    16        
     23
     24        private JMenuItem addStopPositionMenu;
     25
    1726        /**
    1827         * Main constructor.
     
    2534                super(info);
    2635
    27 //              OsmValidator.addTest(PlatformsFirstTest.class);
    28 //              OsmValidator.addTest(RoadTypeTest.class);
    29 //              OsmValidator.addTest(DirectionTest.class);
    30 //              OsmValidator.addTest(GapTest.class);
     36                OsmValidator.addTest(PTAssistantValidatorTest.class);
    3137               
    32                 OsmValidator.addTest(PTAssitantValidatorTest.class);
    33                
     38                AddStopPositionAction addStopPositionAction = new AddStopPositionAction();
     39                addStopPositionMenu = MainMenu.add(Main.main.menu.toolsMenu, addStopPositionAction, false);
    3440
    3541        }
     42
     43        /**
     44         * Called when the JOSM map frame is created or destroyed.
     45         */
     46        @Override
     47        public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     48                if (oldFrame == null && newFrame != null) {
     49                        addStopPositionMenu.setEnabled(true);
     50                } else if (oldFrame != null && newFrame == null) {
     51                        addStopPositionMenu.setEnabled(false);
     52                }
     53        }
    3654       
    37 
    38 
    39 
     55        /**
     56         * Returns a ImageProvider for the given string or null if in headless mode.
     57         *
     58         * @param s
     59         *            The name of the file where the picture is.
     60         * @return A ImageProvider object for the given string or null if in
     61         *         headless mode.
     62         */
     63        public static ImageProvider getProvider(String s) {
     64                if (Main.main == null) {
     65                        return null;
     66                }
     67                return new ImageProvider(s);
     68        }
    4069
    4170}
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java

    r32540 r32567  
    176176                                        }
    177177
    178                                         Main.map.repaint();
     178                                        Main.map.mapView.repaint();
    179179                                }
    180180
     
    200200
    201201                        this.primitives.clear();
    202                         Main.map.repaint();
     202                        Main.map.mapView.repaint();
    203203                }
    204204
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java

    r32415 r32567  
    44import org.openstreetmap.josm.data.osm.Relation;
    55import org.openstreetmap.josm.data.osm.RelationMember;
    6 import org.openstreetmap.josm.data.osm.Way;
    76
    87/**
     
    114113        }
    115114
    116         /**
    117          * Checks if the type of the way is suitable for buses to go on it. The
    118          * direction of the way (i.e. one-way roads) is irrelevant for this test.
    119          *
    120          * TODO: this test is duplicated in WayChecker, remove it here when the old
    121          * implementation is not needed anymore.
    122          *
    123          * @deprecated
    124          *
    125          * @param way
    126          *            to be checked
    127          * @return true if the way is suitable for buses, false otherwise.
    128          */
    129         public static boolean isWaySuitableForBuses(Way way) {
    130                 if (way.hasTag("highway", "motorway") || way.hasTag("highway", "trunk") || way.hasTag("highway", "primary")
    131                                 || way.hasTag("highway", "secondary") || way.hasTag("highway", "tertiary")
    132                                 || way.hasTag("highway", "unclassified") || way.hasTag("highway", "road")
    133                                 || way.hasTag("highway", "residential") || way.hasTag("highway", "service")
    134                                 || way.hasTag("highway", "motorway_link") || way.hasTag("highway", "trunk_link")
    135                                 || way.hasTag("highway", "primary_link") || way.hasTag("highway", "secondary_link")
    136                                 || way.hasTag("highway", "tertiary_link") || way.hasTag("highway", "living_street")
    137                                 || way.hasTag("highway", "bus_guideway") || way.hasTag("highway", "road")
    138                                 || way.hasTag("cycleway", "share_busway") || way.hasTag("cycleway", "shared_lane")) {
    139                         return true;
    140                 }
    141 
    142                 if (way.hasTag("highway", "pedestrian") && (way.hasTag("bus", "yes") || way.hasTag("psv", "yes")
    143                                 || way.hasTag("bus", "designated") || way.hasTag("psv", "designated"))) {
    144                         return true;
    145                 }
    146 
    147                 return false;
    148         }
    149 
    150         public static boolean hasIncompleteMembers(Relation r) {
    151                 if (r == null) {
    152                         return true;
    153                 }
    154                 for (RelationMember rm : r.getMembers()) {
    155                         if ((rm.isNode() && rm.getNode().isIncomplete()) || (rm.isWay() && rm.getWay().isIncomplete())
    156                                         || (rm.isRelation() && rm.getRelation().isIncomplete())) {
    157                                 return true;
    158                         }
    159                 }
    160 
    161                 return false;
    162         }
    163 
    164115}
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java

    r32497 r32567  
    6565                                TestError e = new TestError(this.test, Severity.WARNING,
    6666                                                tr("PT: Route contains a gap that can be fixed by sorting"),
    67                                                 PTAssitantValidatorTest.ERROR_CODE_SORTING, relation);
     67                                                PTAssistantValidatorTest.ERROR_CODE_SORTING, relation);
    6868                                this.errors.add(e);
    6969
     
    112112       
    113113        protected static Command fixSortingError(TestError testError) {
    114                 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_SORTING) {
     114                if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_SORTING) {
    115115                        return null;
    116116                }
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java

    r32522 r32567  
    5252                        highlighted.add(rm.getMember());
    5353                        TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Relation member roles do not match tags"),
    54                                         PTAssitantValidatorTest.ERROR_CODE_RELAITON_MEMBER_ROLES, primitives, highlighted);
     54                                        PTAssistantValidatorTest.ERROR_CODE_RELAITON_MEMBER_ROLES, primitives, highlighted);
    5555                        this.errors.add(e);
    5656                }
     
    112112                                TestError e = new TestError(this.test, Severity.WARNING,
    113113                                                tr("PT: Route should start and end with a stop_position"),
    114                                                 PTAssitantValidatorTest.ERROR_CODE_END_STOP, primitives, highlighted);
     114                                                PTAssistantValidatorTest.ERROR_CODE_END_STOP, primitives, highlighted);
    115115                                this.errors.add(e);
    116116                                return;
     
    130130
    131131                                TestError e = new TestError(this.test, Severity.WARNING, tr("PT: First or last way needs to be split"),
    132                                                 PTAssitantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
     132                                                PTAssistantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
    133133                                this.errors.add(e);
    134134                        }
     
    146146                                highlighted.add(endStop.getStopPosition());
    147147                                TestError e = new TestError(this.test, Severity.WARNING, tr("PT: First or last way needs to be split"),
    148                                                 PTAssitantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
     148                                                PTAssistantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
    149149                                this.errors.add(e);
    150150                        }
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java

    r32557 r32567  
    121121                                        TestError e = new TestError(this.test, Severity.WARNING,
    122122                                                        tr("PT: Route type does not match the type of the road it passes on"),
    123                                                         PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE, primitives, highlighted);
     123                                                        PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE, primitives, highlighted);
    124124                                        errors.add(e);
    125125
     
    132132                                        highlighted.add(way);
    133133                                        TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Road is under construction"),
    134                                                         PTAssitantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted);
     134                                                        PTAssistantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted);
    135135                                        errors.add(e);
    136136                                }
     
    180180                                        TestError e = new TestError(this.test, Severity.WARNING,
    181181                                                        tr("PT: Route passes a oneway road in the wrong direction"),
    182                                                         PTAssitantValidatorTest.ERROR_CODE_DIRECTION, primitives, highlighted);
     182                                                        PTAssistantValidatorTest.ERROR_CODE_DIRECTION, primitives, highlighted);
    183183                                        this.errors.add(e);
    184184                                        return;
     
    221221        protected static Command fixErrorByRemovingWay(TestError testError) {
    222222
    223                 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE
    224                                 && testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
     223                if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE
     224                                && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
    225225                        return null;
    226226                }
     
    279279        protected static Command fixErrorByZooming(TestError testError) {
    280280
    281                 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
     281                if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
    282282                        return null;
    283283                }
     
    337337                GenericRelationEditor editor = new GenericRelationEditor(layer, r, r.getMembersFor(primitives));
    338338                RelationDialogManager.getRelationDialogManager().register(layer, r, editor);
    339                
    340                
    341339                editor.setVisible(true);
    342 //              editor.requestFocus();
    343 //              editor.requestFocusInWindow();
    344                
    345 //              editor.firePropertyChange("focusedWindow", editor, editor);
    346 //              editor.setRelation(r);
     340
    347341
    348342        }
Note: See TracChangeset for help on using the changeset viewer.