Changeset 32436 in osm for applications/editors/josm/plugins/pt_assistant/src
- Timestamp:
- 2016-06-29T03:09:52+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
r32435 r32436 1 1 package org.openstreetmap.josm.plugins.pt_assistant.gui; 2 2 3 import java.awt.Graphics; 3 4 import java.awt.Graphics2D; 4 5 import java.awt.KeyboardFocusManager; … … 32 33 33 34 private List<OsmPrimitive> primitives = new ArrayList<>(); 35 private PTAssistantPaintVisitor paintVisitor; 34 36 35 37 public PTAssistantLayer() { 36 38 super("pt_assistant layer"); 37 38 39 KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this); 39 40 … … 51 52 public void paint(final Graphics2D g, final MapView mv, Bounds bounds) { 52 53 53 PTAssistantPaintVisitorpaintVisitor = new PTAssistantPaintVisitor(g, mv);54 paintVisitor = new PTAssistantPaintVisitor(g, mv); 54 55 for (OsmPrimitive primitive : primitives) { 55 56 paintVisitor.visit(primitive); … … 103 104 } 104 105 106 /** 107 * Listens to a selection change 108 */ 105 109 @Override 106 110 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { … … 147 151 148 152 if (RouteUtils.isTwoDirectionRoute(relation)) { 153 149 154 this.primitives.clear(); 150 155 this.primitives.add(relation); … … 152 157 Main.getLayerManager().addLayer(this); 153 158 } 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(); 155 166 } 156 167 157 168 } 158 159 // System.out.println("focusedWindow: ");160 // System.out.println("GET NEW VALUE: " + evt.getNewValue().getClass());161 // System.out.println("");162 169 } 163 170 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java
r32435 r32436 2 2 3 3 import java.awt.Color; 4 import java.awt.Font; 4 5 import java.awt.Graphics; 5 6 import java.awt.Point; … … 34 35 for (RelationMember rm : r.getMembers()) { 35 36 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); 37 45 stopCount++; 38 46 } else if (RouteUtils.isPTWay(rm)) { … … 62 70 continue; 63 71 } 64 drawSegment(lastN, n, Color.BLUE);72 drawSegment(lastN, n, new Color(208, 80, 208, 179)); 65 73 lastN = n; 66 74 } … … 93 101 94 102 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 97 114 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)); 101 117 102 118 } … … 127 143 128 144 g.setColor(fillColor); 129 // g.drawRect(p.x-10, p.y-10, 20, 20);130 145 g.fillOval(p.x - 5, p.y - 5, 10, 10); 131 146 g.setColor(outlineColor); … … 133 148 134 149 g.setColor(Color.WHITE); 150 Font stringFont = new Font( "SansSerif", Font.PLAIN, 18 ); 151 g.setFont(stringFont); 135 152 g.drawString(label, p.x - 20, p.y - 20); 136 153 } 154 155 protected Graphics getGraphics() { 156 return this.g; 157 } 158 137 159 }
Note:
See TracChangeset
for help on using the changeset viewer.