Changeset 32438 in osm for applications/editors


Ignore:
Timestamp:
2016-06-29T17:44:03+02:00 (8 years ago)
Author:
darya
Message:

minor styling changes

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/gui/PTAssistantLayer.java

    r32436 r32438  
    2626import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor;
    2727import org.openstreetmap.josm.gui.layer.Layer;
     28import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     29import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     30import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     31import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    2832import org.openstreetmap.josm.gui.layer.LayerPositionStrategy;
     33import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2934import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils;
    3035import org.openstreetmap.josm.tools.ImageProvider;
    3136
    32 public class PTAssistantLayer extends Layer implements SelectionChangedListener, PropertyChangeListener {
     37public class PTAssistantLayer extends Layer
     38                implements SelectionChangedListener, PropertyChangeListener, LayerChangeListener {
    3339
    3440        private List<OsmPrimitive> primitives = new ArrayList<>();
     
    3743        public PTAssistantLayer() {
    3844                super("pt_assistant layer");
    39                  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);
    40 
    41         }
    42 
     45                KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);
     46                Main.getLayerManager().addLayerChangeListener(this);
     47
     48        }
     49       
    4350        public void addPrimitive(OsmPrimitive primitive) {
    4451                this.primitives.add(primitive);
     
    105112
    106113        /**
    107          * Listens to a selection change 
     114         * Listens to a selection change
    108115         */
    109116        @Override
    110117        public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    111 
     118               
    112119                ArrayList<Relation> routes = new ArrayList<>();
    113120
     
    131138
    132139        }
    133        
    134        
     140
    135141        /**
    136          * Listens to a focus change
     142         * Listens to a focus change, sets the primitives attribute to the route
     143         * relation in the top Relation Editor and repaints the map
    137144         */
    138145        @Override
     
    146153
    147154                        if (evt.getNewValue().getClass().equals(GenericRelationEditor.class)) {
    148                                
    149                                 GenericRelationEditor editor = (GenericRelationEditor) evt.getNewValue(); 
     155
     156                                GenericRelationEditor editor = (GenericRelationEditor) evt.getNewValue();
    150157                                Relation relation = editor.getRelation();
    151                                
     158
    152159                                if (RouteUtils.isTwoDirectionRoute(relation)) {
    153160
     
    169176                }
    170177        }
     178
     179        @Override
     180        public void layerAdded(LayerAddEvent arg0) {
     181                // do nothing
     182        }
     183
     184        @Override
     185        public void layerOrderChanged(LayerOrderChangeEvent arg0) {
     186                // do nothing
     187
     188        }
     189
     190        @Override
     191        public void layerRemoving(LayerRemoveEvent event) {
     192               
     193                if (event.getRemovedLayer() instanceof OsmDataLayer) {
     194                       
     195                        this.primitives.clear();
     196                        Main.map.repaint();
     197                }
     198
     199        }
    171200}
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java

    r32436 r32438  
    2222        private final MapView mv;
    2323
    24 
    2524        public PTAssistantPaintVisitor(Graphics g, MapView mv) {
    2625                super(g, mv);
     
    4241                                }
    4342                                label = label + "." + stopCount;
    44                                 drawStop(rm.getMember(), Color.BLUE, Color.BLACK,  label);
     43                                drawStop(rm.getMember(), label);
    4544                                stopCount++;
    4645                        } else if (RouteUtils.isPTWay(rm)) {
     
    5857                        }
    5958                }
    60 
    6159
    6260        }
     
    103101                double cosT = 8 * Math.cos(t);
    104102                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)};
     103
     104                int[] xPoints = { (int) (p1.x + cosT), (int) (p2.x + cosT), (int) (p2.x - cosT), (int) (p1.x - cosT) };
     105                int[] yPoints = { (int) (p1.y - sinT), (int) (p2.y - sinT), (int) (p2.y + sinT), (int) (p1.y + sinT) };
    109106                g.setColor(color);
    110107                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                
     108                g.fillOval((int) (p1.x - 8), (int) (p1.y - 8), 16, 16);
     109                g.fillOval((int) (p2.x - 8), (int) (p2.y - 8), 16, 16);
    114110
    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));
     111                // g.drawLine((int) (p1.x - cosT), (int) (p1.y - sinT), (int) (p2.x +
     112                // cosT), (int) (p2.y - sinT));
     113                // g.drawLine((int) (p1.x - cosT), (int) (p1.y + sinT), (int) (p2.x -
     114                // cosT), (int) (p2.y + sinT));
    117115
    118116        }
     
    135133        }
    136134
    137         protected void drawStop(OsmPrimitive primitive, Color fillColor, Color outlineColor, String label) {
     135        protected void drawStop(OsmPrimitive primitive, String label) {
    138136
    139137                // find the point to which the stop visualization will be linked:
     
    141139
    142140                Point p = mv.getPoint(n);
     141               
     142                g.setColor(Color.WHITE);
     143                Font stringFont = new Font("SansSerif", Font.PLAIN, 24);
     144                g.setFont(stringFont);
     145                g.drawString(label, p.x + 20, p.y - 20);
    143146
     147                Color fillColor = null;
     148
     149                if (primitive.hasTag("bus", "yes")) {
     150                        fillColor = Color.BLUE;
     151                } else if (primitive.hasTag("tram", "yes")) {
     152                        fillColor = Color.RED;
     153                } // TODO: add more options
    144154                g.setColor(fillColor);
    145                 g.fillOval(p.x - 5, p.y - 5, 10, 10);
    146                 g.setColor(outlineColor);
    147                 g.drawOval(p.x - 5, p.y - 5, 10, 10);
    148155
    149                 g.setColor(Color.WHITE);
    150                 Font stringFont = new Font( "SansSerif", Font.PLAIN, 18 );
    151                 g.setFont(stringFont);
    152                 g.drawString(label, p.x - 20, p.y - 20);
     156                if (primitive.hasTag("public_transport", "stop_position")) {
     157                        g.fillOval(p.x - 8, p.y - 8, 16, 16);
     158                } else {
     159                        g.fillRect(p.x - 8, p.y - 8, 16, 16);
     160                }
     161
     162
    153163        }
    154        
     164
    155165        protected Graphics getGraphics() {
    156166                return this.g;
    157167        }
    158        
     168
    159169}
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssitantValidatorTest.java

    r32430 r32438  
    6868                        return;
    6969                }
    70 
     70               
    7171//              if (!Main.getLayerManager().containsLayer(layer)) {
    7272//                      Main.getLayerManager().addLayer(layer);
Note: See TracChangeset for help on using the changeset viewer.