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