Ignore:
Timestamp:
2016-08-23T05:53:57+02:00 (9 years ago)
Author:
darya
Message:

documentation

Location:
applications/editors/josm/plugins/pt_assistant
Files:
17 edited

Legend:

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

    r32871 r32874  
    3232        private static PTRouteSegment lastFix;
    3333
     34        /* item of the Tools menu for adding stop_positions */
    3435        private JMenuItem addStopPositionMenu;
     36       
     37        /* item of the Tools menu for repeating the last fix */
    3538        private static JMenuItem repeatLastFixMenu;
    3639
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java

    r32855 r32874  
    3939        }
    4040
     41        /**
     42         * Actions that add the new node, set tags and update the map frame.
     43         */
    4144        @Override
    4245        public void actionPerformed(ActionEvent e) {
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java

    r32871 r32874  
    1414import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils;
    1515
     16/**
     17 * Thread that downloads incomplete relation members while pausing the rest of testing
     18 * @author darya
     19 *
     20 */
    1621public class IncompleteMembersDownloadThread extends Thread {
    1722
     23        /**
     24         * Default constructor
     25         */
    1826        public IncompleteMembersDownloadThread() {
    1927                super();
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/RepeatLastFixAction.java

    r32871 r32874  
    1313import org.openstreetmap.josm.tools.Shortcut;
    1414
     15/**
     16 * Carries out the changes after the Repeat last fix button has been pressed
     17 *
     18 * @author darya
     19 *
     20 */
    1521public class RepeatLastFixAction extends JosmAction {
    1622
    1723        private static final long serialVersionUID = 2681464946469047054L;
    1824
     25        /**
     26         * Default constructor
     27         */
    1928        public RepeatLastFixAction() {
    2029                super(tr("Repeat last fix"), new ImageProvider("presets/transport", "bus.svg"), tr("Repeat last fix"),
     
    2433        }
    2534
     35        /**
     36         * Applies the fixes, resets the last fix attribute
     37         */
    2638        @Override
    2739        public void actionPerformed(ActionEvent e) {
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTRouteSegment.java

    r32855 r32874  
    1919public class PTRouteSegment {
    2020
     21        /* first stop of the route segment */
    2122        private PTStop firstStop;
     23       
     24        /* last stop of the route segment */
    2225        private PTStop lastStop;
     26       
     27        /* ptways that belong to this route segment */
    2328        private List<PTWay> ptways;
     29       
     30        /* fix variants available for this route segment */
    2431        private List<List<PTWay>> fixVariants;
     32       
     33        /* route relation for which this route segment was created */
    2534        private Relation relation;
    2635
     36        /**
     37         * Constructor
     38         * @param firstStop first stop of the route segment
     39         * @param lastStop last stop of the route segment
     40         * @param ways ways PTWays that belong to this route segment
     41         * @param relation the route relation for which this route segment is created
     42         */
    2743        public PTRouteSegment(PTStop firstStop, PTStop lastStop, List<PTWay> ways, Relation relation) {
    2844                this.firstStop = firstStop;
     
    3450        }
    3551
     52        /**
     53         * Returns the PTWays of this route segment
     54         * @return
     55         */
    3656        public List<PTWay> getPTWays() {
    3757                return this.ptways;
    3858        }
    3959
     60        /**
     61         * Sets the PTWays of this route segment to the given list
     62         * @param ptwayList
     63         */
    4064        public void setPTWays(List<PTWay> ptwayList) {
    4165                this.ptways = ptwayList;
     
    4367        }
    4468
     69        /**
     70         * Returns the first stop of this route segment
     71         * @return
     72         */
    4573        public PTStop getFirstStop() {
    4674                return this.firstStop;
    4775        }
    48 
     76       
     77        /**
     78         * Returns the last stop of this route segment
     79         * @return
     80         */
    4981        public PTStop getLastStop() {
    5082                return this.lastStop;
    5183        }
    5284
     85        /**
     86         * Returns the first PTWay of this route segment
     87         * @return
     88         */
    5389        public PTWay getFirstPTWay() {
    5490                if (ptways.isEmpty()) {
     
    5894        }
    5995
     96        /**
     97         * Returns the last PTWay of this route segment
     98         * @return
     99         */
    60100        public PTWay getLastPTWay() {
    61101                if (ptways.isEmpty()) {
     
    65105        }
    66106       
     107        /**
     108         * Returns the first way of this route segment
     109         * @return
     110         */
    67111        public Way getFirstWay() {
    68112                if (ptways.isEmpty()) {
     
    72116        }
    73117       
     118        /**
     119         * Returns the last way of this route segment
     120         * @return
     121         */
    74122        public Way getLastWay() {
    75123                if (ptways.isEmpty()) {
     
    114162        }
    115163
     164        /**
     165         * Returns the fix variants stored for this route segment
     166         * @return
     167         */
    116168        public List<List<PTWay>> getFixVariants() {
    117169                return this.fixVariants;
    118170        }
    119171       
     172        /**
     173         * Returns the route relation for which this route segment was created
     174         * @return
     175         */
    120176        public Relation getRelation() {
    121177                return this.relation;
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java

    r32734 r32874  
    1212import org.openstreetmap.josm.data.osm.RelationMember;
    1313
     14/**
     15 * Model a stop with one or two elements (platform and/or stop_position)
     16 *
     17 * @author darya
     18 *
     19 */
    1420public class PTStop extends RelationMember {
    1521
     22        /* stop_position element of this stop */
    1623        private Node stopPosition = null;
     24
     25        /* platform element of this stop */
    1726        private OsmPrimitive platform = null;
    1827
     28        /* the name of this stop */
    1929        private String name = "";
    2030
     31        /**
     32         * Constructor
     33         *
     34         * @param other
     35         * @throws IllegalArgumentException
     36         *             if the given relation member does not fit to the data model
     37         *             used in the plugin
     38         */
    2139        public PTStop(RelationMember other) throws IllegalArgumentException {
    2240
     
    111129        }
    112130
     131        /**
     132         * Returns the name of this stop
     133         * @return
     134         */
    113135        protected String getName() {
    114136                return this.name;
    115137        }
    116138
     139        /**
     140         * Sets the stop_position for this stop to the given node
     141         * @param newStopPosition
     142         */
    117143        public void setStopPosition(Node newStopPosition) {
    118144
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTWay.java

    r32747 r32874  
    118118                return endNodes;
    119119        }
    120        
     120
     121        /**
     122         * Checks if this PTWay contains an unsplit roundabout (i.e. a way that
     123         * touches itself) among its ways
     124         *
     125         * @return
     126         */
    121127        public boolean containsUnsplitRoundabout() {
    122                
     128
    123129                List<Way> ways = this.getWays();
    124                 for (Way way: ways) {
     130                for (Way way : ways) {
    125131                        if (way.firstNode() == way.lastNode()) {
    126132                                return true;
     
    129135                return false;
    130136        }
    131        
     137
     138        /**
     139         * Checks if the first Way of this PTWay is an unsplit roundabout (i.e. a
     140         * way that touches itself)
     141         *
     142         * @return
     143         */
    132144        public boolean startsWithUnsplitRoundabout() {
    133145                if (this.ways.get(0).firstNode() == this.ways.get(0).lastNode()) {
     
    136148                return false;
    137149        }
    138        
     150
     151        /**
     152         * Checks if the last Way of this PTWay is an unsplit roundabout (i.e. a way
     153         * that touches itself)
     154         *
     155         * @return
     156         */
    139157        public boolean endsWithUnsplitRoundabout() {
    140                 if (this.ways.get(this.ways.size() - 1).firstNode() == this.ways.get(this.ways.size()-1).lastNode()) {
     158                if (this.ways.get(this.ways.size() - 1).firstNode() == this.ways.get(this.ways.size() - 1).lastNode()) {
    141159                        return true;
    142160                }
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/DownloadReferrersDialog.java

    r32621 r32874  
    77import javax.swing.JPanel;
    88
     9/**
     10 * Dialog that asks the user whether referrers should be downloaded
     11 * @author darya
     12 *
     13 */
    914public class DownloadReferrersDialog extends JPanel {
    1015
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/IncompleteMembersDownloadDialog.java

    r32871 r32874  
    77import javax.swing.JPanel;
    88
     9/**
     10 * Dialog that asks the user whether the incomplete relation members should be
     11 * downloaded.
     12 *
     13 * @author darya
     14 *
     15 */
    916public class IncompleteMembersDownloadDialog extends JPanel {
    1017
     
    2633
    2734        public IncompleteMembersDownloadDialog() {
    28                
     35
    2936                selectedOption = Integer.MIN_VALUE;
    30                 message = tr("Route relations have incomplete members.\nThey need to be downloaded to proceed with validation.\nDo you want to download them?");
     37                message = tr(
     38                                "Route relations have incomplete members.\nThey need to be downloaded to proceed with validation.\nDo you want to download them?");
    3139                checkbox = new JCheckBox(tr("Remember my choice and do not ask me again in this session"));
    3240                options = new String[2];
     
    5361                }
    5462
    55                
    56                 Object[] params = {message, checkbox};
    57                 selectedOption = JOptionPane.showOptionDialog(this, params, tr("PT_Assistant Fetch Request"), JOptionPane.YES_NO_OPTION,
    58                                 JOptionPane.QUESTION_MESSAGE, null, options, 0);
    59                
     63                Object[] params = { message, checkbox };
     64                selectedOption = JOptionPane.showOptionDialog(this, params, tr("PT_Assistant Fetch Request"),
     65                                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, 0);
     66
    6067                if (checkbox.isSelected()) {
    6168                        if (selectedOption == JOptionPane.YES_OPTION) {
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java

    r32801 r32874  
    3838import org.openstreetmap.josm.tools.ImageProvider;
    3939
     40/**
     41 * Layer that visualizes the routes in a more convenient way
     42 *
     43 * @author darya
     44 *
     45 */
    4046public class PTAssistantLayer extends Layer
    4147                implements SelectionChangedListener, PropertyChangeListener, LayerChangeListener {
     
    6167        }
    6268
     69        /**
     70         * Adds a primitive (route) to be displayed in this layer
     71         *
     72         * @param primitive
     73         */
    6374        public void addPrimitive(OsmPrimitive primitive) {
    6475                this.primitives.add(primitive);
    6576        }
    6677
     78        /**
     79         * Clears all primitives (routes) from being displayed.
     80         */
    6781        public void clear() {
    6882                this.primitives.clear();
     
    8296        public void addFixVariants(List<List<PTWay>> fixVariants) {
    8397                HashMap<List<PTWay>, Character> fixVariantLetterMap = new HashMap<>();
    84                
     98
    8599                char alphabet = 'A';
    86100                for (int i = 0; i < 5 && i < fixVariants.size(); i++) {
     
    91105                }
    92106
    93                 for (Character currentFixVariantLetter: this.fixVariants.keySet()) {
     107                for (Character currentFixVariantLetter : this.fixVariants.keySet()) {
    94108                        List<PTWay> fixVariant = this.fixVariants.get(currentFixVariantLetter);
    95109                        for (PTWay ptway : fixVariant) {
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java

    r32801 r32874  
    2525import org.openstreetmap.josm.tools.Pair;
    2626
     27/**
     28 * Visits the primitives to be visualized in the pt_assistant layer
     29 *
     30 * @author darya
     31 *
     32 */
    2733public class PTAssistantPaintVisitor extends PaintVisitor {
    2834
     
    3238        private final MapView mv;
    3339
     40        /**
     41         * Constructor
     42         *
     43         * @param g
     44         * @param mv
     45         */
    3446        public PTAssistantPaintVisitor(Graphics g, MapView mv) {
    3547                super(g, mv);
     
    141153        }
    142154
     155        /**
     156         * Variation of the visit method that allows a special visualization of
     157         * oneway roads
     158         *
     159         * @param nodes
     160         * @param oneway
     161         */
    143162        public void visit(List<Node> nodes, int oneway) {
    144163                Node lastN = null;
     
    270289        }
    271290
     291        /**
     292         * Draws s stop_position as a blue circle; draws a platform as a blue square
     293         *
     294         * @param primitive
     295         */
    272296        protected void drawStop(OsmPrimitive primitive) {
    273297
     
    287311        }
    288312
     313        /**
     314         * Draws the labels for the stops, which include the ordered position of the
     315         * stop in the route and the ref numbers of other routes that use this stop
     316         *
     317         * @param primitive
     318         * @param label
     319         */
    289320        protected void drawStopLabel(OsmPrimitive primitive, String label) {
    290321
     
    342373        }
    343374
     375        /**
     376         * Compares route ref numbers
     377         * @author darya
     378         *
     379         */
    344380        private class RefTagComparator implements Comparator<String> {
    345381
     
    398434
    399435        /**
    400          *
     436         * Visualizes the fix variants, assigns colors to them based on their order
    401437         * @param fixVariants
    402438         */
     
    538574        }
    539575
     576        /**
     577         * Visuallizes the letters for each fix variant
     578         * @param letter
     579         * @param color
     580         * @param letterX
     581         * @param letterY
     582         */
    540583        private void drawFixVariantLetter(String letter, Color color, double letterX, double letterY) {
    541584                g.setColor(color);
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPreferenceSetting.java

    r32872 r32874  
    1414import org.openstreetmap.josm.tools.ImageProvider;
    1515
     16/**
     17 * Displays the settings of the pt_assistant plugin under Preferences
     18 * @author darya
     19 *
     20 */
    1621public class PTAssistantPreferenceSetting implements SubPreferenceSetting {
    1722
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/ProceedDialog.java

    r32871 r32874  
    1515import javax.swing.SwingUtilities;
    1616
     17/**
     18 * Dialog that asks the user how to proceed after the first stage of testing
     19 * (i.e. if the errors found in the first stage of testing should be fixed
     20 * before continuing with the testing).
     21 *
     22 * @author darya
     23 *
     24 */
    1725public class ProceedDialog extends JPanel {
    1826
     
    4452
    4553                if (true) {
    46                         JLabel label2 = new JLabel("     " + trn("{0} direction error", "{0} direction errors", numberOfDirectionErrors, numberOfDirectionErrors));
     54                        JLabel label2 = new JLabel("     " + trn("{0} direction error", "{0} direction errors",
     55                                        numberOfDirectionErrors, numberOfDirectionErrors));
    4756                        panel.add(label2);
    4857                        label2.setAlignmentX(Component.LEFT_ALIGNMENT);
     
    5059
    5160                if (numberOfRoadTypeErrors != 0) {
    52                         JLabel label3 = new JLabel("     " + trn("{0} road type error", "{0} road type errors", numberOfRoadTypeErrors, numberOfRoadTypeErrors));
     61                        JLabel label3 = new JLabel("     " + trn("{0} road type error", "{0} road type errors",
     62                                        numberOfRoadTypeErrors, numberOfRoadTypeErrors));
    5363                        panel.add(label3);
    5464                        label3.setAlignmentX(Component.LEFT_ALIGNMENT);
     
    6777                fixOptionButtonGroup.add(radioButtonDontFix);
    6878                panel.add(radioButtonFixAutomatically);
    69 //              panel.add(radioButtonFixManually);
     79                // panel.add(radioButtonFixManually);
    7080                panel.add(radioButtonDontFix);
    7181                radioButtonFixAutomatically.setAlignmentX(Component.LEFT_ALIGNMENT);
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java

    r32656 r32874  
    236236        }
    237237
     238        /**
     239         * Checks if this way is suitable for public transport (not only for buses)
     240         * @param way
     241         * @return
     242         */
    238243        public static boolean isWaySuitableForPublicTransport(Way way) {
    239244
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/Checker.java

    r32793 r32874  
    135135
    136136                if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP
    137                                 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
     137                                && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION
     138                                && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_CONSTRUCTION
     139                                && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE) {
    138140                        return null;
    139141                }
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java

    r32871 r32874  
    5454 public static final String PATH_TO_STOP_AREA_MANY_PLATFORMS = "test/data/stop-area-many-platforms.osm";
    5555
     56 
    5657 public static final String PATH_TO_SEGMENT_TEST = "test/data/segment-test.osm";
    57  public static final String PATH_TO_REPEAT_FIX = "test/data/repeat-fix.osm";
    5858
    5959  /**
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentCheckerTest.java

    r32871 r32874  
    1313
    1414public class SegmentCheckerTest extends AbstractTest {
    15 
     15       
    1616        @Test
    17         public void testStopByStopTest() {
    18 
     17        public void test() {
     18               
     19               
    1920                File file = new File(AbstractTest.PATH_TO_SEGMENT_TEST);
    2021                DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
    2122                PTAssistantValidatorTest test = new PTAssistantValidatorTest();
    22 
     23               
    2324                Relation route = null;
    24 
    25                 for (Relation r : ds.getRelations()) {
     25               
     26                for (Relation r: ds.getRelations()) {
    2627                        if (RouteUtils.isTwoDirectionRoute(r)) {
    2728                                route = r;
     
    2930                        }
    3031                }
    31 
    32                 SegmentChecker.reset();
     32               
    3333                SegmentChecker segmentChecker = new SegmentChecker(route, test);
    3434                segmentChecker.performStopByStopTest();
    3535                assertEquals(SegmentChecker.getCorrectSegmentCount(), 27);
    3636                assertEquals(segmentChecker.getErrors().size(), 0);
    37         }
    38 
    39         /**
    40          * Tests the stop-by-stop test
    41          */
    42         @Test
    43         public void testRepeatLastFix() {
    44                 File file = new File(AbstractTest.PATH_TO_REPEAT_FIX);
    45                 DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
    46                 PTAssistantValidatorTest test = new PTAssistantValidatorTest();
    47 
    48                 Relation route123 = null;
    49                 Relation route130 = null;
    50                 Relation route168 = null;
    51                 Relation route184 = null;
    52 
    53                 for (Relation r : ds.getRelations()) {
    54                         if (r.getId() == 5379737) {
    55                                 route123 = r;
    56                         } else if (r.getId() == 5379738) {
    57                                 route130 = r;
    58                         } else if (r.getId() == 5379739) {
    59                                 route168 = r;
    60                         } else if (r.getId() == 5379740) {
    61                                 route184 = r;
    62                         }
    63                 }
    64 
    65                 SegmentChecker.reset();
    66                 SegmentChecker segmentChecker123 = new SegmentChecker(route123, test);
    67                 SegmentChecker segmentChecker130 = new SegmentChecker(route130, test);
    68                 SegmentChecker segmentChecker168 = new SegmentChecker(route168, test);
    69                 SegmentChecker segmentChecker184 = new SegmentChecker(route184, test);
    70                 segmentChecker123.performStopByStopTest();
    71 //              TestError error123 = segmentChecker123.getErrors().get(0);
    72 //              PTRouteSegment wrongSegment123 = SegmentChecker.getWrongSegment(error123);
    73                 segmentChecker130.performStopByStopTest();
    74                 segmentChecker168.performStopByStopTest();
    75                 segmentChecker184.performStopByStopTest();
    76 
    77                 // Check the error number:
    78                 assertEquals(segmentChecker123.getErrors().size(), 1);
    79                 assertEquals(segmentChecker130.getErrors().size(), 1);
    80                 assertEquals(segmentChecker168.getErrors().size(), 1);
    81                 assertEquals(segmentChecker184.getErrors().size(), 0);
     37               
     38               
     39               
     40               
    8241        }
    8342}
Note: See TracChangeset for help on using the changeset viewer.