Changeset 27400 in osm for applications/editors/josm
- Timestamp:
- 2012-01-04T02:11:38+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/licensechange
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/LicenseChangePlugin.java
r27206 r27400 13 13 import java.util.ArrayList; 14 14 import java.util.Collection; 15 import java.util.Collections; 15 16 import java.util.HashMap; 16 17 import java.util.List; … … 162 163 HashMap<Long, HashMap<User, Severity>> userMap = ("node".equals(qName)) ? nodeUsers : ("way".equals(qName)) ? wayUsers : relationUsers; 163 164 // we always overwrite a list that might already exist 164 userMap.put(Long.decode(atts.getValue("id")), theMap = new HashMap<User, Severity>()); 165 Long id = Long.decode(atts.getValue("id")); 166 theMap = userMap.get(id); 167 if (theMap == null) userMap.put(id, theMap = new HashMap<User, Severity>()); 165 168 } 166 169 else if ("user".equals(qName)) … … 197 200 public void visit(Node n) { 198 201 if (!nodeUsers.containsKey(n.getId())) { 199 nodesToLoad.append(","); 200 nodesToLoad.append(n.getId()); 202 if ("clean".equals(n.get("odbl"))) { 203 nodeUsers.put(new Long(n.getId()), new HashMap<User, Severity>(Collections.singletonMap(n.getUser(), Severity.CLEAN))); 204 } else { 205 nodesToLoad.append(","); 206 nodesToLoad.append(n.getId()); 207 } 201 208 } 202 209 } 203 210 public void visit(Way n) { 204 211 if (!wayUsers.containsKey(n.getId())) { 205 waysToLoad.append(","); 206 waysToLoad.append(n.getId()); 212 if ("clean".equals(n.get("odbl"))) { 213 wayUsers.put(new Long(n.getId()), new HashMap<User, Severity>(Collections.singletonMap(n.getUser(), Severity.CLEAN))); 214 } else { 215 waysToLoad.append(","); 216 waysToLoad.append(n.getId()); 217 } 207 218 } 208 219 } 209 220 public void visit(Relation n) { 210 221 if (!relationUsers.containsKey(n.getId())) { 211 relationsToLoad.append(","); 212 relationsToLoad.append(n.getId()); 222 if ("clean".equals(n.get("odbl"))) { 223 relationUsers.put(new Long(n.getId()), new HashMap<User, Severity>(Collections.singletonMap(n.getUser(), Severity.CLEAN))); 224 } else { 225 relationsToLoad.append(","); 226 relationsToLoad.append(n.getId()); 227 } 213 228 } 214 229 } -
applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/LicenseChangeVisitor.java
r25955 r27400 10 10 public interface LicenseChangeVisitor { 11 11 void visit(OsmPrimitive p); 12 void visit(WaySegment ws);13 12 void visit(List<Node> nodes); 14 13 } -
applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/LicenseProblem.java
r25955 r27400 15 15 import org.openstreetmap.josm.data.osm.Relation; 16 16 import org.openstreetmap.josm.data.osm.Way; 17 import org.openstreetmap.josm.data.osm.WaySegment;18 17 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 19 18 import org.openstreetmap.josm.gui.MapView; … … 126 125 if (o instanceof OsmPrimitive) 127 126 v.visit((OsmPrimitive) o); 128 else if (o instanceof WaySegment)129 v.visit((WaySegment) o);130 127 else if (o instanceof List<?>) { 131 128 v.visit((List<Node>)o); … … 169 166 g.setColor(color); 170 167 if (selected) { 171 g.fillOval(p.x - 5, p.y -5, 10, 10);168 g.fillOval(p.x - 6, p.y - 6, 12, 12); 172 169 } else 173 g.drawOval(p.x - 5, p.y -5, 10, 10);174 } 175 176 public void drawSegment(Point p1, Point p2, Color color) { 170 g.drawOval(p.x - 6, p.y - 6, 12, 12); 171 } 172 173 public void drawSegment(Point p1, Point p2, boolean linecapStart, boolean linecapEnd, Color color) { 177 174 g.setColor(color); 178 175 … … 182 179 int deg = (int) Math.toDegrees(t); 183 180 if (selected) { 184 int[] x = new int[] { (int) (p1.x + 5* cosT), (int) (p2.x +5* cosT), (int) (p2.x -5* cosT),185 (int) (p1.x - 5* cosT) };186 int[] y = new int[] { (int) (p1.y - 5* sinT), (int) (p2.y -5* sinT), (int) (p2.y +5* sinT),187 (int) (p1.y + 5* sinT) };181 int[] x = new int[] { (int) (p1.x + 4 * cosT), (int) (p2.x + 4 * cosT), (int) (p2.x - 4 * cosT), 182 (int) (p1.x - 4 * cosT) }; 183 int[] y = new int[] { (int) (p1.y - 4 * sinT), (int) (p2.y - 4 * sinT), (int) (p2.y + 4 * sinT), 184 (int) (p1.y + 4 * sinT) }; 188 185 g.fillPolygon(x, y, 4); 189 g.fillArc(p1.x - 5, p1.y -5, 10, 10, deg, 180);190 g.fillArc(p2.x - 5, p2.y -5, 10, 10, deg, -180);186 if (linecapStart) g.fillArc(p1.x - 4, p1.y - 4, 8, 8, deg, 180); 187 if (linecapEnd) g.fillArc(p2.x - 4, p2.y - 4, 8, 8, deg, -180); 191 188 } else { 192 g.drawLine((int) (p1.x + 5* cosT), (int) (p1.y -5* sinT), (int) (p2.x +5* cosT),193 (int) (p2.y - 5* sinT));194 g.drawLine((int) (p1.x - 5* cosT), (int) (p1.y +5* sinT), (int) (p2.x -5* cosT),195 (int) (p2.y + 5* sinT));196 g.drawArc(p1.x - 5, p1.y -5, 10, 10, deg, 180);197 g.drawArc(p2.x - 5, p2.y -5, 10, 10, deg, -180);189 g.drawLine((int) (p1.x + 4 * cosT), (int) (p1.y - 4 * sinT), (int) (p2.x + 4 * cosT), 190 (int) (p2.y - 4 * sinT)); 191 g.drawLine((int) (p1.x - 4 * cosT), (int) (p1.y + 4 * sinT), (int) (p2.x - 4 * cosT), 192 (int) (p2.y + 4 * sinT)); 193 if (linecapStart) g.drawArc(p1.x - 4, p1.y - 4, 8, 8, deg, 180); 194 if (linecapEnd) g.drawArc(p2.x - 4, p2.y - 4, 8, 8, deg, -180); 198 195 } 199 196 } … … 205 202 * @param color The color 206 203 */ 207 public void drawSegment(Node n1, Node n2, Color color) { 208 drawSegment(mv.getPoint(n1), mv.getPoint(n2), color); 204 public void drawSegment(Node n1, Node n2, boolean linecapStart, boolean linecapEnd, Color color) { 205 drawSegment(mv.getPoint(n1), mv.getPoint(n2), linecapStart, linecapEnd, color); 209 206 } 210 207 … … 222 219 public void visit(Way w) { 223 220 visit(w.getNodes()); 224 }225 226 public void visit(WaySegment ws) {227 if (ws.lowerIndex < 0 || ws.lowerIndex + 1 >= ws.way.getNodesCount())228 return;229 Node a = ws.way.getNodes().get(ws.lowerIndex), b = ws.way.getNodes().get(ws.lowerIndex + 1);230 if (isSegmentVisible(a, b)) {231 drawSegment(a, b, severity.getColor());232 }233 221 } 234 222 … … 269 257 270 258 public void visit(List<Node> nodes) { 271 Node lastN = null; 259 Node[] window = new Node[4]; 260 int index = 1; 261 window[0] = null; 272 262 for (Node n : nodes) { 273 if (lastN == null) { 274 lastN = n; 263 if (index == 1) 264 { 265 window[1] = n; 266 index = 2; 275 267 continue; 276 268 } 277 if (n.isDrawable() && isSegmentVisible(lastN, n)) { 278 drawSegment(lastN, n, severity.getColor()); 269 window[index++] = n; 270 if (index==4) 271 { 272 drawSegment(window[1], window[2], window[0] == null, !isSegmentVisible(window[2], window[3]), severity.getColor()); 273 window[0] = window[1]; 274 window[1] = window[2]; 275 window[2] = window[3]; 276 index = 3; 279 277 } 280 lastN = n;281 }278 } 279 if (window[1] != null && window[2] != null) drawSegment(window[1], window[2], window[0] == null, true, severity.getColor()); 282 280 } 283 281 } -
applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/Severity.java
r27206 r27400 11 11 /** The error severity */ 12 12 public enum Severity { 13 14 /** clean override */ 15 CLEAN(tr("overridden with odbl=clean"), "clean", 16 Main.pref.getColor(marktr("license check info"), Color.GREEN)), 13 17 14 18 /** Error messages */
Note:
See TracChangeset
for help on using the changeset viewer.