Changeset 32477 in osm for applications/editors


Ignore:
Timestamp:
2016-07-01T02:43:04+02:00 (9 years ago)
Author:
darya
Message:

styling changes

File:
1 edited

Legend:

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

    r32457 r32477  
    1010import org.openstreetmap.josm.data.osm.Node;
    1111import org.openstreetmap.josm.data.osm.OsmPrimitive;
     12import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1213import org.openstreetmap.josm.data.osm.Relation;
    1314import org.openstreetmap.josm.data.osm.RelationMember;
     
    3940                for (RelationMember rm : r.getMembers()) {
    4041
    41                         if (RouteUtils.isPTStop(rm)) {
     42                        // if (rm.getMember().isIncomplete() && (rm.isNode() ||
     43                        // rm.hasRole("stop") || rm.hasRole("stop_entry_only")
     44                        // || rm.hasRole("stop_exit_only") || rm.hasRole("platform") ||
     45                        // rm.hasRole("platform_entry_only")
     46                        // || rm.hasRole("platform_exit_only"))) {
     47                        //
     48                        // if (stopOrderMap.containsKey(rm.getUniqueId())) {
     49                        // label = stopOrderMap.get(rm.getUniqueId());
     50                        // label = label + ";" + stopCount;
     51                        // } else {
     52                        //
     53                        // }
     54                        // }
     55
     56                        if (RouteUtils.isPTStop(rm) || (rm.getMember().isIncomplete() && (rm.isNode() || rm.hasRole("stop")
     57                                        || rm.hasRole("stop_entry_only") || rm.hasRole("stop_exit_only") || rm.hasRole("platform")
     58                                        || rm.hasRole("platform_entry_only") || rm.hasRole("platform_exit_only")))) {
    4259
    4360                                String label = "";
    4461
    45                                 if (stopOrderMap.containsKey(rm.getMember().getId())) {
    46                                         label = stopOrderMap.get(rm.getMember().getId());
     62                                if (stopOrderMap.containsKey(rm.getUniqueId())) {
     63                                        label = stopOrderMap.get(rm.getUniqueId());
    4764                                        label = label + ";" + stopCount;
    4865                                } else {
     
    5168                                        } else if (r.hasKey("name")) {
    5269                                                label = label + r.get("name");
     70                                        } else {
     71                                                label = "NA";
    5372                                        }
    54                                         label = label + ":" + stopCount;
    55                                 }
    56 
    57                                 stopOrderMap.put(rm.getMember().getId(), label);
    58                                 drawStop(rm.getMember(), label);
     73                                        label = label + " - " + stopCount;
     74                                }
     75
     76                                stopOrderMap.put(rm.getUniqueId(), label);
     77                                drawStopLabel(rm.getMember(), label);
     78                                if (!rm.getMember().isIncomplete()) {
     79                                        drawStop(rm.getMember(), label);
     80                                }
     81
    5982                                stopCount++;
    6083
     
    200223                                        int[] yDrawTriangle = { (int) (middleY - sinTriangle), (int) (middleY + sinTriangle),
    201224                                                        (int) (middleY - 2 * cosTriangle) };
    202                                         g.fillPolygon(xDrawTriangle, yDrawTriangle, 3);
     225                                        g.drawPolygon(xDrawTriangle, yDrawTriangle, 3);
    203226                                }
    204227                        }
     
    216239                                        int[] yDrawTriangle = { (int) (middleY - sinTriangle), (int) (middleY + sinTriangle),
    217240                                                        (int) (middleY + 2 * cosTriangle) };
    218                                         g.fillPolygon(xDrawTriangle, yDrawTriangle, 3);
     241                                        g.drawPolygon(xDrawTriangle, yDrawTriangle, 3);
    219242                                }
    220243                        }
     
    253276                Point p = mv.getPoint(n);
    254277
    255                 g.setColor(Color.WHITE);
    256                 Font stringFont = new Font("SansSerif", Font.PLAIN, 24);
    257                 g.setFont(stringFont);
    258                 g.drawString(label, p.x + 20, p.y - 20);
    259 
    260278                Color fillColor = null;
    261279
     
    275293        }
    276294
     295        protected void drawStopLabel(OsmPrimitive primitive, String label) {
     296
     297                // find the point to which the stop visualization will be linked:
     298                Node n = new Node(primitive.getBBox().getCenter());
     299
     300                Point p = mv.getPoint(n);
     301
     302                g.setColor(Color.WHITE);
     303                Font stringFont = new Font("SansSerif", Font.PLAIN, 24);
     304                g.setFont(stringFont);
     305                g.drawString(label, p.x + 20, p.y - 20);
     306               
     307                // get the parents of the primitive that are routes:
     308                String parentsLabel = "";
     309                for (OsmPrimitive parent: primitive.getReferrers()) {
     310                        if (parent.getType().equals(OsmPrimitiveType.RELATION)) {
     311                                Relation relation = (Relation) parent;
     312                                if (RouteUtils.isTwoDirectionRoute(relation)) {
     313                                        parentsLabel = parentsLabel + relation.get("ref") + ";";
     314                                }
     315                        }
     316                }
     317                if (!parentsLabel.equals("")) {
     318                        // remove the last semicolon:
     319                        parentsLabel = parentsLabel.substring(0, parentsLabel.length()-1);
     320                        g.setColor(new Color(200, 200, 200));
     321                        Font parentLabelFont = new Font("SansSerif", Font.ITALIC, 20);
     322                        g.setFont(parentLabelFont);
     323                        g.drawString(parentsLabel, p.x + 20, p.y);
     324                }
     325               
     326        }
     327       
     328//      protected void drawStopParentLabel(OsmPrimitive primitive, String label) {
     329//              // find the point to which the stop visualization will be linked:
     330//              Node n = new Node(primitive.getBBox().getCenter());
     331//
     332//              Point p = mv.getPoint(n);
     333//
     334//              g.setColor(Color.WHITE);
     335//              Font stringFont = new Font("SansSerif", Font.PLAIN, 24);
     336//              g.setFont(stringFont);
     337//              g.drawString(label, p.x - 20, p.y - 20);
     338//      }
     339
    277340        protected Graphics getGraphics() {
    278341                return this.g;
Note: See TracChangeset for help on using the changeset viewer.