Changeset 33265 in osm for applications/editors/josm/plugins/reltoolbox/src
- Timestamp:
- 2017-04-17T19:27:17+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/reltoolbox/src/relcontext
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java
r32398 r33265 150 150 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f * opacity)); 151 151 152 drawRelations(g, mv, bbox, chosenRelation );152 drawRelations(g, mv, bbox, chosenRelation, new HashSet<>()); 153 153 154 154 g.setComposite(oldComposite); … … 156 156 } 157 157 158 private void drawRelations(Graphics2D g, MapView mv, Bounds bbox, Relation rel) { 159 for (OsmPrimitive element : rel.getMemberPrimitives()) { 160 if (element.getType() == OsmPrimitiveType.NODE) { 161 Node node = (Node) element; 162 Point center = mv.getPoint(node); 163 g.drawOval(center.x - 4, center.y - 4, 9, 9); 164 } else if (element.getType() == OsmPrimitiveType.WAY) { 165 Way way = (Way) element; 166 if (way.getNodesCount() >= 2) { 167 GeneralPath b = new GeneralPath(); 168 Point p = mv.getPoint(way.getNode(0)); 169 b.moveTo(p.x, p.y); 170 for (int i = 1; i < way.getNodesCount(); i++) { 171 p = mv.getPoint(way.getNode(i)); 172 b.lineTo(p.x, p.y); 158 private void drawRelations(Graphics2D g, MapView mv, Bounds bbox, Relation rel, Set<Relation> visitedRelations) { 159 if (!visitedRelations.contains(rel)) { 160 visitedRelations.add(rel); 161 for (OsmPrimitive element : rel.getMemberPrimitives()) { 162 if (element.getType() == OsmPrimitiveType.NODE) { 163 Node node = (Node) element; 164 Point center = mv.getPoint(node); 165 g.drawOval(center.x - 4, center.y - 4, 9, 9); 166 } else if (element.getType() == OsmPrimitiveType.WAY) { 167 Way way = (Way) element; 168 if (way.getNodesCount() >= 2) { 169 GeneralPath b = new GeneralPath(); 170 Point p = mv.getPoint(way.getNode(0)); 171 b.moveTo(p.x, p.y); 172 for (int i = 1; i < way.getNodesCount(); i++) { 173 p = mv.getPoint(way.getNode(i)); 174 b.lineTo(p.x, p.y); 175 } 176 g.draw(b); 173 177 } 174 g.draw(b); 178 } else if (element.getType() == OsmPrimitiveType.RELATION) { 179 Color oldColor = g.getColor(); 180 g.setColor(Color.magenta); 181 drawRelations(g, mv, bbox, (Relation) element, visitedRelations); 182 g.setColor(oldColor); 175 183 } 176 } else if (element.getType() == OsmPrimitiveType.RELATION) { 177 Color oldColor = g.getColor(); 178 g.setColor(Color.magenta); 179 drawRelations(g, mv, bbox, (Relation) element); 180 g.setColor(oldColor); 184 // todo: closedway, multipolygon - ? 181 185 } 182 // todo: closedway, multipolygon - ?183 186 } 184 187 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java
r32398 r33265 24 24 import java.io.InputStream; 25 25 import java.io.InputStreamReader; 26 import java.nio.charset.StandardCharsets; 26 27 import java.util.ArrayList; 27 28 import java.util.Collection; … … 438 439 ClassLoader classLoader = RelContextDialog.class.getClassLoader(); 439 440 try (InputStream possibleRolesStream = classLoader.getResourceAsStream(POSSIBLE_ROLES_FILE); 440 BufferedReader r = new BufferedReader(new InputStreamReader(possibleRolesStream ));441 BufferedReader r = new BufferedReader(new InputStreamReader(possibleRolesStream, StandardCharsets.UTF_8)); 441 442 ) { 442 443 while (r.ready()) { … … 530 531 } 531 532 532 private class ChosenRelationPopupMenu extends JPopupMenu {533 private static class ChosenRelationPopupMenu extends JPopupMenu { 533 534 ChosenRelationPopupMenu(ChosenRelation chosenRelation) { 534 535 add(new SelectMembersAction(chosenRelation)); … … 578 579 } 579 580 580 private class MultipolygonSettingsPopup extends JPopupMenu implements ActionListener {581 private static class MultipolygonSettingsPopup extends JPopupMenu implements ActionListener { 581 582 MultipolygonSettingsPopup() { 582 583 addMenuItem("boundary", tr("Create administrative boundary relations")); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/FindRelationAction.java
r32398 r33265 202 202 * I admit, some of it was copypasted from {@link org.openstreetmap.josm.gui.dialogs.RelationListDialog.RelationListModel}. 203 203 */ 204 protected class FindRelationListModel extends AbstractListModel<Relation> {204 protected static class FindRelationListModel extends AbstractListModel<Relation> { 205 205 private final ArrayList<Relation> relations = new ArrayList<>(); 206 206 private DefaultListSelectionModel selectionModel; -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java
r33060 r33265 90 90 for (JoinedPolygon p : mpc.outerWays) { 91 91 92 ArrayList<JoinedPolygon> myInnerWays = new ArrayList< JoinedPolygon>();92 ArrayList<JoinedPolygon> myInnerWays = new ArrayList<>(); 93 93 for (JoinedPolygon i : mpc.innerWays) { 94 94 // if the first point of any inner ring is contained in this 95 // outer ring, then this inner ring belongs to us. This 95 // outer ring, then this inner ring belongs to us. This 96 96 // assumption only works if multipolygons have valid geometries 97 97 EastNorth en = i.ways.get(0).firstNode().getEastNorth(); … … 102 102 103 103 if (!myInnerWays.isEmpty()) { 104 // this ring has inner rings, so we leave a multipolygon in 105 // place and don't reconstruct the rings. 104 // this ring has inner rings, so we leave a multipolygon in 105 // place and don't reconstruct the rings. 106 106 Relation n = null; 107 107 if (relationReused) { … … 131 131 132 132 // move all tags from relation and common tags from ways 133 // start with all tags from first way but only if area tags are 134 // present 133 // start with all tags from first way but only if area tags are present 135 134 Map<String, String> tags = p.ways.get(0).getKeys(); 136 135 if (!p.ways.get(0).hasAreaTags()) { … … 209 208 if (newRelation == null || !"multipolygon".equals(newRelation.get("type")) || newRelation.getMembersCount() == 0) 210 209 return false; 211 else {210 else 212 211 return true; 213 }214 212 } 215 213 }
Note:
See TracChangeset
for help on using the changeset viewer.