Ignore:
Timestamp:
2016-06-29T03:02:38+02:00 (8 years ago)
Author:
darya
Message:

minor styling change

Location:
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
Files:
3 edited

Legend:

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

    r32427 r32434  
    7373                                @Override
    7474                                public void run() {
    75                                         Main.getLayerManager().getEditDataSet().beginUpdate();
     75                                        Main.main.getCurrentDataSet().beginUpdate();
    7676                                }
    7777                        });
     
    8989                                        @Override
    9090                                        public void run() {
    91                                                 Main.getLayerManager().getEditDataSet().endUpdate();
     91                                                Main.main.getCurrentDataSet().endUpdate();
    9292                                        }
    9393                                });
     
    100100                                        Main.map.repaint();
    101101                                        // tree.resetErrors();
    102                                         Main.getLayerManager().getEditDataSet().fireSelectionChanged();
     102                                        Main.main.getCurrentDataSet().fireSelectionChanged();
    103103                                }
    104104                        });
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java

    r32430 r32434  
    11package org.openstreetmap.josm.plugins.pt_assistant.gui;
    22
     3import java.awt.Graphics;
    34import java.awt.Graphics2D;
    45import java.awt.KeyboardFocusManager;
     
    3233
    3334        private List<OsmPrimitive> primitives = new ArrayList<>();
     35        private PTAssistantPaintVisitor paintVisitor;
    3436
    3537        public PTAssistantLayer() {
    3638                super("pt_assistant layer");
    37 
    3839                 KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);
    3940
     
    5152        public void paint(final Graphics2D g, final MapView mv, Bounds bounds) {
    5253
    53                 PTAssistantPaintVisitor paintVisitor = new PTAssistantPaintVisitor(g, mv);
     54                paintVisitor = new PTAssistantPaintVisitor(g, mv);
    5455                for (OsmPrimitive primitive : primitives) {
    5556                        paintVisitor.visit(primitive);
     
    103104        }
    104105
     106        /**
     107         * Listens to a selection change
     108         */
    105109        @Override
    106110        public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
     
    147151                               
    148152                                if (RouteUtils.isTwoDirectionRoute(relation)) {
     153
    149154                                        this.primitives.clear();
    150155                                        this.primitives.add(relation);
     
    152157                                                Main.getLayerManager().addLayer(this);
    153158                                        }
    154 //                                      Main.map.repaint();
     159                                        Graphics g = paintVisitor.getGraphics();
     160                                        paintVisitor = new PTAssistantPaintVisitor(g, Main.map.mapView);
     161                                        for (OsmPrimitive primitive : primitives) {
     162                                                paintVisitor.visit(primitive);
     163
     164                                        }
     165                                        Main.map.repaint();
    155166                                }
    156167
    157168                        }
    158 
    159 //                      System.out.println("focusedWindow: ");
    160 //                      System.out.println("GET NEW VALUE: " + evt.getNewValue().getClass());
    161 //                      System.out.println("");
    162169                }
    163170        }
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java

    r32415 r32434  
    22
    33import java.awt.Color;
     4import java.awt.Font;
    45import java.awt.Graphics;
    56import java.awt.Point;
     
    3435                for (RelationMember rm : r.getMembers()) {
    3536                        if (RouteUtils.isPTStop(rm)) {
    36                                 drawStop(rm.getMember(), Color.BLUE, Color.BLACK, (new Integer(stopCount)).toString());
     37                                String label = "";
     38                                if (r.hasKey("ref")) {
     39                                        label = label + r.get("ref");
     40                                } else if (r.hasKey("name")) {
     41                                        label = label + r.get("name");
     42                                }
     43                                label = label + "." + stopCount;
     44                                drawStop(rm.getMember(), Color.BLUE, Color.BLACK,  label);
    3745                                stopCount++;
    3846                        } else if (RouteUtils.isPTWay(rm)) {
     
    6270                                continue;
    6371                        }
    64                         drawSegment(lastN, n, Color.BLUE);
     72                        drawSegment(lastN, n, new Color(208, 80, 208, 179));
    6573                        lastN = n;
    6674                }
     
    93101
    94102                double t = Math.atan2((double) p2.x - p1.x, (double) p2.y - p1.y);
    95                 double cosT = 5 * Math.cos(t);
    96                 double sinT = 5 * Math.sin(t);
     103                double cosT = 8 * Math.cos(t);
     104                double sinT = 8 * Math.sin(t);
     105               
     106               
     107                int[] xPoints = {(int)(p1.x+cosT), (int)(p2.x+cosT), (int)(p2.x-cosT), (int)(p1.x-cosT)};
     108                int[] yPoints = {(int)(p1.y-sinT), (int)(p2.y-sinT), (int)(p2.y+sinT), (int)(p1.y+sinT)};
     109                g.setColor(color);
     110                g.fillPolygon(xPoints, yPoints, 4);
     111                g.fillOval((int)(p1.x-8), (int)(p1.y-8), 16, 16);
     112                g.fillOval((int)(p2.x-8), (int)(p2.y-8), 16, 16);
     113               
    97114
    98                 g.setColor(color);
    99                 g.drawLine((int) (p1.x + cosT), (int) (p1.y - sinT), (int) (p2.x + cosT), (int) (p2.y - sinT));
    100                 g.drawLine((int) (p1.x - cosT), (int) (p1.y + sinT), (int) (p2.x - cosT), (int) (p2.y + sinT));
     115//              g.drawLine((int) (p1.x - cosT), (int) (p1.y - sinT), (int) (p2.x + cosT), (int) (p2.y - sinT));
     116//              g.drawLine((int) (p1.x - cosT), (int) (p1.y + sinT), (int) (p2.x - cosT), (int) (p2.y + sinT));
    101117
    102118        }
     
    127143
    128144                g.setColor(fillColor);
    129                 // g.drawRect(p.x-10, p.y-10, 20, 20);
    130145                g.fillOval(p.x - 5, p.y - 5, 10, 10);
    131146                g.setColor(outlineColor);
     
    133148
    134149                g.setColor(Color.WHITE);
     150                Font stringFont = new Font( "SansSerif", Font.PLAIN, 18 );
     151                g.setFont(stringFont);
    135152                g.drawString(label, p.x - 20, p.y - 20);
    136153        }
     154       
     155        protected Graphics getGraphics() {
     156                return this.g;
     157        }
     158       
    137159}
Note: See TracChangeset for help on using the changeset viewer.