Changeset 32601 in osm for applications/editors
- Timestamp:
- 2016-07-07T23:55:57+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/indoor_sweepline
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoor_sweepline/.project
r32479 r32601 17 17 </arguments> 18 18 </buildCommand> 19 <buildCommand> 20 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 21 <arguments> 22 </arguments> 23 </buildCommand> 19 24 </buildSpec> 20 25 <natures> 21 26 <nature>org.eclipse.jdt.core.javanature</nature> 27 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 22 28 </natures> 23 29 </projectDescription> -
applications/editors/josm/plugins/indoor_sweepline/build.xml
r32479 r32601 5 5 <property name="commit.message" value="Commit message"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="10 279"/>7 <property name="plugin.main.version" value="10420"/> 8 8 9 9 <property name="plugin.author" value="Roland M. Olbricht"/> -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/Beam.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 3 4 import java.util.Vector; 4 5 5 6 public class Beam 7 { 8 public Beam(Vector<Double> blueprint, double blueprintOffset, CorridorPart.ReachableSide defaultSide) 9 { 6 public class Beam { 7 8 public Beam(Vector<Double> blueprint, double blueprintOffset, CorridorPart.ReachableSide defaultSide) { 10 9 offset = blueprintOffset; 11 10 parts = new Vector<>(); 12 11 13 12 setDefaultSide_(defaultSide); 14 if (defaultSide == CorridorPart.ReachableSide.RIGHT) 15 { 16 for (int i = 1; i < blueprint.size(); i += 2) 17 { 13 if (defaultSide == CorridorPart.ReachableSide.RIGHT) { 14 for (int i = 1; i < blueprint.size(); i += 2) { 18 15 addCorridorPart_(true, CorridorPart.Type.WALL, 19 16 blueprint.elementAt(i).doubleValue() - blueprint.elementAt(i-1).doubleValue()); … … 22 19 blueprint.elementAt(i+1).doubleValue() - blueprint.elementAt(i).doubleValue()); 23 20 } 24 } 25 else 26 { 27 for (int i = 1; i < blueprint.size(); i += 2) 28 { 21 } else { 22 for (int i = 1; i < blueprint.size(); i += 2) { 29 23 addCorridorPart_(true, CorridorPart.Type.PASSAGE, 30 24 blueprint.elementAt(i).doubleValue() - blueprint.elementAt(i-1).doubleValue()); … … 37 31 } 38 32 39 40 private void setDefaultSide_(CorridorPart.ReachableSide defaultSide) 41 { 33 private void setDefaultSide_(CorridorPart.ReachableSide defaultSide) { 42 34 this.defaultSide = defaultSide; 43 35 } 44 36 45 public void setDefaultSide(CorridorPart.ReachableSide defaultSide) 46 { 37 public void setDefaultSide(CorridorPart.ReachableSide defaultSide) { 47 38 setDefaultSide_(defaultSide); 48 39 adjustStripCache(); 49 40 } 50 41 51 52 public Vector<CorridorPart> getBeamParts() 53 { 42 public Vector<CorridorPart> getBeamParts() { 54 43 return parts; 55 44 } 56 45 57 58 public double getBeamOffset() 59 { 46 public double getBeamOffset() { 60 47 return offset; 61 48 } 62 49 63 public void setBeamOffset(double beamOffset) 64 { 50 public void setBeamOffset(double beamOffset) { 65 51 offset = beamOffset; 66 52 } 67 53 68 69 private void addCorridorPart_(boolean append, CorridorPart.Type type, double width) 70 { 54 private void addCorridorPart_(boolean append, CorridorPart.Type type, double width) { 71 55 CorridorPart.ReachableSide side = defaultSide == CorridorPart.ReachableSide.RIGHT ? 72 56 defaultSide : CorridorPart.ReachableSide.ALL; … … 78 62 } 79 63 80 public void addCorridorPart(boolean append, double width) 81 { 64 public void addCorridorPart(boolean append, double width) { 82 65 addCorridorPart_(append, 83 66 defaultSide == CorridorPart.ReachableSide.RIGHT ? CorridorPart.Type.WALL : CorridorPart.Type.PASSAGE, … … 86 69 } 87 70 88 89 public void setCorridorPartWidth(int partIndex, double value) 90 { 71 public void setCorridorPartWidth(int partIndex, double value) { 91 72 parts.elementAt(partIndex).width = value; 92 73 adjustStripCache(); 93 74 } 94 75 95 96 public void setCorridorPartType(int partIndex, CorridorPart.Type type) 97 { 76 public void setCorridorPartType(int partIndex, CorridorPart.Type type) { 98 77 parts.elementAt(partIndex).setType(type, defaultSide); 99 78 enforceSideCoherence(); … … 101 80 } 102 81 103 104 public void setCorridorPartSide(int partIndex, CorridorPart.ReachableSide side) 105 { 82 public void setCorridorPartSide(int partIndex, CorridorPart.ReachableSide side) { 106 83 parts.elementAt(partIndex).setSide(side, defaultSide); 107 84 enforceSideCoherence(); … … 109 86 } 110 87 111 112 private void enforceSideCoherence() 113 { 114 for (int i = 1; i < parts.size(); ++i) 115 { 88 private void enforceSideCoherence() { 89 for (int i = 1; i < parts.size(); ++i) { 116 90 if (parts.elementAt(i).getSide() != CorridorPart.ReachableSide.ALL 117 91 && parts.elementAt(i-1).getSide() != CorridorPart.ReachableSide.ALL) … … 120 94 } 121 95 122 123 private boolean isVoidAbove(int i) 124 { 96 private boolean isVoidAbove(int i) { 125 97 return i == 0 || parts.elementAt(i-1).getType() == CorridorPart.Type.VOID 126 98 || (parts.elementAt(i-1).getSide() == CorridorPart.ReachableSide.RIGHT … … 130 102 } 131 103 132 private boolean isVoidBelow(int i) 133 { 104 private boolean isVoidBelow(int i) { 134 105 return i == parts.size() || parts.elementAt(i).getType() == CorridorPart.Type.VOID 135 106 || (parts.elementAt(i).getSide() == CorridorPart.ReachableSide.RIGHT … … 139 110 } 140 111 141 private boolean isPassageAbove(int i) 142 { 112 private boolean isPassageAbove(int i) { 143 113 return i > 0 144 114 && parts.elementAt(i-1).getType() == CorridorPart.Type.PASSAGE … … 146 116 } 147 117 148 private boolean isPassageBelow(int i) 149 { 118 private boolean isPassageBelow(int i) { 150 119 return i < parts.size() 151 120 && parts.elementAt(i).getType() == CorridorPart.Type.PASSAGE … … 153 122 } 154 123 155 private boolean isReachableLeft(int i) 156 { 124 private boolean isReachableLeft(int i) { 157 125 if (defaultSide == CorridorPart.ReachableSide.RIGHT) 158 126 return false; … … 162 130 } 163 131 164 165 private void connectTwoPos(StripPosition newPos, boolean toLeft) 166 { 132 private void connectTwoPos(StripPosition newPos, boolean toLeft) { 167 133 StripPosition other = null; 168 if (rhsStrips.size() > 0 && rhsStrips.elementAt(rhsStrips.size()-1).connectedTo == -1) 169 { 134 if (rhsStrips.size() > 0 && rhsStrips.elementAt(rhsStrips.size()-1).connectedTo == -1) { 170 135 newPos.connectedToSameSide = !toLeft; 171 136 newPos.connectedTo = rhsStrips.size()-1; 172 137 other = rhsStrips.elementAt(rhsStrips.size()-1); 173 } 174 else 175 { 138 } else { 176 139 newPos.connectedToSameSide = toLeft; 177 140 newPos.connectedTo = lhsStrips.size()-1; … … 180 143 181 144 other.connectedToSameSide = newPos.connectedToSameSide; 182 if (toLeft) 183 { 145 if (toLeft) { 184 146 other.connectedTo = lhsStrips.size(); 185 147 lhsStrips.add(newPos); 186 } 187 else 188 { 148 } else { 189 149 other.connectedTo = rhsStrips.size(); 190 150 rhsStrips.add(newPos); … … 192 152 } 193 153 194 195 private class StripPosition 196 { 197 StripPosition(int nodeIndex, double offset) 198 { 154 private class StripPosition { 155 StripPosition(int nodeIndex, double offset) { 199 156 this.nodeIndex = nodeIndex; 200 157 this.offset = offset; … … 209 166 } 210 167 211 212 168 private double offset; 213 169 private Vector<CorridorPart> parts; … … 215 171 private Vector<StripPosition> rhsStrips; 216 172 217 218 private void adjustStripCache() 219 { 173 private void adjustStripCache() { 220 174 lhsStrips = new Vector<>(); 221 175 rhsStrips = new Vector<>(); … … 223 177 double offset = 0; 224 178 225 for (int i = 0; i <= parts.size(); ++i) 226 { 227 if (isVoidBelow(i)) 228 { 229 if (isPassageAbove(i)) 230 { 179 for (int i = 0; i <= parts.size(); ++i) { 180 if (isVoidBelow(i)) { 181 if (isPassageAbove(i)) { 231 182 StripPosition lhs = new StripPosition(i, offset); 232 183 StripPosition rhs = new StripPosition(i, offset); … … 239 190 lhsStrips.add(lhs); 240 191 rhsStrips.add(rhs); 241 } 242 else if (!isVoidAbove(i)) 192 } else if (!isVoidAbove(i)) 243 193 connectTwoPos(new StripPosition(i, offset), isReachableLeft(i-1)); 244 } 245 else if (isPassageBelow(i)) 246 { 247 if (isVoidAbove(i)) 248 { 194 } else if (isPassageBelow(i)) { 195 if (isVoidAbove(i)) { 249 196 StripPosition lhs = new StripPosition(i, offset); 250 197 StripPosition rhs = new StripPosition(i, offset); … … 257 204 lhsStrips.add(lhs); 258 205 rhsStrips.add(rhs); 259 } 260 else if (!isPassageAbove(i)) 206 } else if (!isPassageAbove(i)) 261 207 connectTwoPos(new StripPosition(i, offset), !isReachableLeft(i-1)); 262 } 263 else 264 { 265 if (isVoidAbove(i)) 266 { 208 } else { 209 if (isVoidAbove(i)) { 267 210 if (isReachableLeft(i)) 268 211 lhsStrips.add(new StripPosition(i, offset)); 269 212 else 270 213 rhsStrips.add(new StripPosition(i, offset)); 271 } 272 else if (isPassageAbove(i)) 273 { 214 } else if (isPassageAbove(i)) { 274 215 if (isReachableLeft(i)) 275 216 rhsStrips.add(new StripPosition(i, offset)); … … 284 225 } 285 226 286 287 public Vector<Double> leftHandSideStrips() 288 { 227 public Vector<Double> leftHandSideStrips() { 289 228 Vector<Double> offsets = new Vector<>(); 290 for (StripPosition pos : lhsStrips) 229 for (StripPosition pos : lhsStrips) { 291 230 offsets.add(pos.offset); 231 } 292 232 293 233 return offsets; 294 234 } 295 235 296 297 public Vector<Double> rightHandSideStrips() 298 { 236 public Vector<Double> rightHandSideStrips() { 299 237 Vector<Double> offsets = new Vector<>(); 300 for (StripPosition pos : rhsStrips) 238 for (StripPosition pos : rhsStrips) { 301 239 offsets.add(pos.offset); 240 } 302 241 303 242 return offsets; 304 243 } 305 244 306 307 public int getBeamPartIndex(boolean toTheLeft, int i) 308 { 245 public int getBeamPartIndex(boolean toTheLeft, int i) { 309 246 if (toTheLeft) 310 247 return lhsStrips.elementAt(i).nodeIndex; … … 313 250 } 314 251 315 316 252 public boolean appendNodes(IndoorSweeplineModel.SweepPolygonCursor cursor, boolean fromRight, 317 BeamGeography geography, String level) 318 { 319 if (fromRight) 320 { 253 BeamGeography geography, String level) { 254 if (fromRight) { 321 255 StripPosition pos = rhsStrips.elementAt(cursor.partIndex); 322 256 StripPosition to = pos.connectedToSameSide ? … … 330 264 331 265 return !pos.connectedToSameSide; 332 } 333 else 334 { 266 } else { 335 267 StripPosition pos = lhsStrips.elementAt(cursor.partIndex); 336 268 StripPosition to = pos.connectedToSameSide ? … … 347 279 } 348 280 349 350 281 private CorridorPart.ReachableSide defaultSide; 351 282 } -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/BeamGeography.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 7 8 import org.openstreetmap.josm.data.osm.Node; 8 9 10 public class BeamGeography { 9 11 10 public class BeamGeography 11 { 12 public BeamGeography(DataSet dataSet, ModelGeography target) 13 { 12 public BeamGeography(DataSet dataSet, ModelGeography target) { 14 13 partsGeography = new Vector<>(); 15 14 nodes = new Vector<>(); … … 18 17 } 19 18 20 21 public void appendNodes(int from, int to, String level) 22 { 23 if (from <= to) 24 { 25 for (int i = from; i < to; ++i) 26 { 19 public void appendNodes(int from, int to, String level) { 20 if (from <= to) { 21 for (int i = from; i < to; ++i) { 27 22 target.appendNode(nodes.elementAt(i)); 28 23 CorridorPart part = parts.elementAt(i); … … 31 26 } 32 27 target.appendNode(nodes.elementAt(to)); 33 } 34 else 35 { 36 for (int i = from; i > to; --i) 37 { 28 } else { 29 for (int i = from; i > to; --i) { 38 30 target.appendNode(nodes.elementAt(i)); 39 31 CorridorPart part = parts.elementAt(i-1); … … 45 37 } 46 38 47 48 public void adjustNodes(LatLon pivot, Vector<CorridorPart> parts, double beamOffset) 49 { 39 public void adjustNodes(LatLon pivot, Vector<CorridorPart> parts, double beamOffset) { 50 40 double offset = -beamOffset; 51 41 this.parts = parts; … … 53 43 adjustNode(0, new LatLon(addMetersToLat(pivot, offset), pivot.lon())); 54 44 55 for (int i = 0; i < parts.size(); ++i) 56 { 45 for (int i = 0; i < parts.size(); ++i) { 57 46 adjustPartGeography(i); 58 47 offset += parts.elementAt(i).width; … … 63 52 } 64 53 65 66 private void adjustNode(int i, LatLon coor) 67 { 54 private void adjustNode(int i, LatLon coor) { 68 55 if (nodes.size() <= i) 69 56 nodes.setSize(i+1); 70 57 Node node = nodes.elementAt(i); 71 if (node == null) 72 { 58 if (node == null) { 73 59 node = new Node(coor); 74 60 dataSet.addPrimitive(node); 75 61 nodes.setElementAt(node, i); 76 } 77 else 62 } else 78 63 node.setCoor(coor); 79 64 } 80 65 81 82 private void adjustPartGeography(int i) 83 { 66 private void adjustPartGeography(int i) { 84 67 if (partsGeography.size() <= i) 85 68 partsGeography.setSize(i+1); 86 69 CorridorGeography partGeography = partsGeography.elementAt(i); 87 if (partGeography == null) 88 { 70 if (partGeography == null) { 89 71 partGeography = new CorridorGeography(dataSet); 90 72 partsGeography.setElementAt(partGeography, i); … … 92 74 } 93 75 94 95 public LatLon coorAt(int i) 96 { 76 public LatLon coorAt(int i) { 97 77 return nodes.elementAt(i).getCoor(); 98 78 } 99 100 79 101 80 private Vector<CorridorPart> parts; … … 105 84 private Vector<Node> nodes; 106 85 107 108 private static double addMetersToLat(LatLon latLon, double south) 109 { 86 private static double addMetersToLat(LatLon latLon, double south) { 110 87 return latLon.lat() - south *(360./4e7); 111 88 } -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/CorridorGeography.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 8 9 import org.openstreetmap.josm.data.osm.Way; 9 10 11 public class CorridorGeography { 10 12 11 public class CorridorGeography 12 { 13 public CorridorGeography(DataSet dataSet) 14 { 13 public CorridorGeography(DataSet dataSet) { 15 14 this.dataSet = dataSet; 16 15 } 17 16 18 19 17 private static final double MIN_LENGTH = 10.; 20 18 21 22 19 private void setExtraElements(CorridorPart.ReachableSide side, LatLon from, LatLon to, 23 boolean extraWayUp, double minLength) 24 { 20 boolean extraWayUp, double minLength) { 25 21 LatLon middleCoor = new LatLon((from.lat() + to.lat())/2., 26 22 (from.lon() + to.lon())/2.); 27 if (middleNode == null) 28 { 23 if (middleNode == null) { 29 24 middleNode = new Node(middleCoor); 30 25 dataSet.addPrimitive(middleNode); 31 } 32 else 26 } else 33 27 middleNode.setCoor(middleCoor); 34 28 35 29 LatLon start = from; 36 if (side == CorridorPart.ReachableSide.LEFT) 37 { 30 if (side == CorridorPart.ReachableSide.LEFT) { 38 31 if (middleCoor.lat() < start.lat()) 39 32 start = to; 40 } 41 else if (side == CorridorPart.ReachableSide.RIGHT) 42 { 33 } else if (side == CorridorPart.ReachableSide.RIGHT) { 43 34 if (start.lat() < middleCoor.lat()) 44 35 start = to; 45 } 46 else if (side == CorridorPart.ReachableSide.FRONT) 47 { 36 } else if (side == CorridorPart.ReachableSide.FRONT) { 48 37 if (start.lon() < middleCoor.lon()) 49 38 start = to; 50 } 51 else if (side == CorridorPart.ReachableSide.BACK) 52 { 39 } else if (side == CorridorPart.ReachableSide.BACK) { 53 40 if (middleCoor.lon() < start.lon()) 54 41 start = to; … … 61 48 LatLon detachedCoor = new LatLon(middleCoor.lat() + (start.lon() - middleCoor.lon()) * scale * lengthFactor, 62 49 middleCoor.lon() - (start.lat() - middleCoor.lat()) / scale * lengthFactor); 63 if (detachedNode == null) 64 { 50 if (detachedNode == null) { 65 51 detachedNode = new Node(detachedCoor); 66 52 dataSet.addPrimitive(detachedNode); 67 } 68 else 53 } else 69 54 detachedNode.setCoor(detachedCoor); 70 55 71 56 Vector<Node> extraWayNodes = new Vector<>(); 72 if (extraWayUp) 73 { 57 if (extraWayUp) { 74 58 extraWayNodes.add(middleNode); 75 59 extraWayNodes.add(detachedNode); 76 } 77 else 78 { 60 } else { 79 61 extraWayNodes.add(detachedNode); 80 62 extraWayNodes.add(middleNode); 81 63 } 82 if (extraWay == null) 83 { 64 if (extraWay == null) { 84 65 extraWay = new Way(); 85 66 extraWay.setNodes(extraWayNodes); 86 67 dataSet.addPrimitive(extraWay); 87 } 88 else 68 } else 89 69 extraWay.setNodes(extraWayNodes); 90 70 } 91 71 92 93 72 public void appendNodes(CorridorPart.Type type, CorridorPart.ReachableSide side, String level, 94 LatLon from, LatLon to, ModelGeography target) 95 { 96 if (type == CorridorPart.Type.STAIRS_UP || type == CorridorPart.Type.STAIRS_DOWN) 97 { 73 LatLon from, LatLon to, ModelGeography target) { 74 if (type == CorridorPart.Type.STAIRS_UP || type == CorridorPart.Type.STAIRS_DOWN) { 98 75 setExtraElements(side, from, to, type == CorridorPart.Type.STAIRS_UP, MIN_LENGTH); 99 76 target.appendNode(middleNode); … … 105 82 extraWay.put("incline", "up"); 106 83 extraWay.put("level", level); 107 } 108 else if (type == CorridorPart.Type.ESCALATOR_UP_LEAVING 84 } else if (type == CorridorPart.Type.ESCALATOR_UP_LEAVING 109 85 || type == CorridorPart.Type.ESCALATOR_UP_ARRIVING 110 86 || type == CorridorPart.Type.ESCALATOR_UP_BIDIRECTIONAL 111 87 || type == CorridorPart.Type.ESCALATOR_DOWN_LEAVING 112 88 || type == CorridorPart.Type.ESCALATOR_DOWN_ARRIVING 113 || type == CorridorPart.Type.ESCALATOR_DOWN_BIDIRECTIONAL) 114 { 89 || type == CorridorPart.Type.ESCALATOR_DOWN_BIDIRECTIONAL) { 115 90 setExtraElements(side, from, to, 116 91 type == CorridorPart.Type.ESCALATOR_UP_LEAVING … … 133 108 extraWay.put("conveying", "reversible"); 134 109 extraWay.put("level", level); 135 } 136 else if (type == CorridorPart.Type.ELEVATOR) 137 { 110 } else if (type == CorridorPart.Type.ELEVATOR) { 138 111 setExtraElements(side, from, to, true, 0.); 139 112 target.appendNode(middleNode); … … 145 118 extraWay.put("highway", "footway"); 146 119 extraWay.put("level", level); 147 } 148 else 149 { 150 if (extraWay != null) 151 { 120 } else { 121 if (extraWay != null) { 152 122 extraWay.setDeleted(true); 153 123 extraWay = null; 154 124 } 155 if (middleNode != null) 156 { 125 if (middleNode != null) { 157 126 middleNode.setDeleted(true); 158 127 middleNode = null; 159 128 } 160 if (detachedNode != null) 161 { 129 if (detachedNode != null) { 162 130 detachedNode.setDeleted(true); 163 131 detachedNode = null; … … 166 134 } 167 135 168 169 136 private DataSet dataSet; 170 137 private Node middleNode; -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/CorridorPart.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 3 public class CorridorPart 4 { 5 public enum Type 6 { 7 VOID, 8 PASSAGE, 9 WALL, 10 STAIRS_UP, 11 STAIRS_DOWN, 12 ESCALATOR_UP_LEAVING, 13 ESCALATOR_UP_ARRIVING, 14 ESCALATOR_UP_BIDIRECTIONAL, 15 ESCALATOR_DOWN_LEAVING, 16 ESCALATOR_DOWN_ARRIVING, 17 ESCALATOR_DOWN_BIDIRECTIONAL, 18 ELEVATOR 4 public class CorridorPart { 5 6 public enum Type { 7 VOID, 8 PASSAGE, 9 WALL, 10 STAIRS_UP, 11 STAIRS_DOWN, 12 ESCALATOR_UP_LEAVING, 13 ESCALATOR_UP_ARRIVING, 14 ESCALATOR_UP_BIDIRECTIONAL, 15 ESCALATOR_DOWN_LEAVING, 16 ESCALATOR_DOWN_ARRIVING, 17 ESCALATOR_DOWN_BIDIRECTIONAL, 18 ELEVATOR 19 19 } 20 21 20 22 public enum ReachableSide 23 { 24 ALL, 25 FRONT, 26 BACK, 27 LEFT, 28 RIGHT 21 public enum ReachableSide { 22 ALL, 23 FRONT, 24 BACK, 25 LEFT, 26 RIGHT 29 27 } 30 31 28 32 public CorridorPart(double width, Type type, ReachableSide side) 33 { 34 this.width = width; 35 this.type = type; 36 this.side = side; 29 public CorridorPart(double width, Type type, ReachableSide side) { 30 this.width = width; 31 this.type = type; 32 this.side = side; 37 33 } 38 39 40 public boolean isObstacle(ReachableSide beamSide) 41 { 42 if (type == Type.VOID) 43 return false; 44 if (type == Type.PASSAGE) 45 return (beamSide != ReachableSide.ALL); 46 return true; 34 35 public boolean isObstacle(ReachableSide beamSide) { 36 if (type == Type.VOID) 37 return false; 38 if (type == Type.PASSAGE) 39 return (beamSide != ReachableSide.ALL); 40 return true; 47 41 } 48 49 50 public Type getType() 51 { 52 return type; 42 43 public Type getType() { 44 return type; 53 45 } 54 55 public void setType(Type type, ReachableSide beamSide) 56 { 57 this.type = type; 58 adjustSideType(beamSide); 46 47 public void setType(Type type, ReachableSide beamSide) { 48 this.type = type; 49 adjustSideType(beamSide); 59 50 } 60 61 62 public ReachableSide getSide() 63 { 64 return side; 51 52 public ReachableSide getSide() { 53 return side; 65 54 } 66 67 public void setSide(ReachableSide side, ReachableSide beamSide) 68 { 69 this.side = side; 70 adjustSideType(beamSide); 55 56 public void setSide(ReachableSide side, ReachableSide beamSide) { 57 this.side = side; 58 adjustSideType(beamSide); 71 59 } 72 73 60 74 61 public double width; 75 62 private Type type; 76 63 private ReachableSide side; 77 78 79 private void adjustSideType(ReachableSide beamSide) 80 { 81 if (type == Type.PASSAGE || type == Type.VOID) 82 side = ReachableSide.ALL; 83 else if (side == ReachableSide.ALL) 84 { 85 if (beamSide == ReachableSide.RIGHT) 86 side = ReachableSide.RIGHT; 87 else 88 side = ReachableSide.LEFT; 89 } 64 65 private void adjustSideType(ReachableSide beamSide) { 66 if (type == Type.PASSAGE || type == Type.VOID) 67 side = ReachableSide.ALL; 68 else if (side == ReachableSide.ALL) { 69 if (beamSide == ReachableSide.RIGHT) 70 side = ReachableSide.RIGHT; 71 else 72 side = ReachableSide.LEFT; 73 } 90 74 } 91 75 } -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweepline.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 8 9 import org.openstreetmap.josm.plugins.PluginInformation; 9 10 10 public class IndoorSweepline extends Plugin 11 { 11 public class IndoorSweepline extends Plugin { 12 12 /** 13 * Will be invoked by JOSM to bootstrap the plugin 14 * 15 * @param info information about the plugin and its local installation 16 */ 17 public IndoorSweepline(PluginInformation info) 18 { 19 super(info); 20 refreshMenu(); 13 * Will be invoked by JOSM to bootstrap the plugin 14 * 15 * @param info information about the plugin and its local installation 16 */ 17 public IndoorSweepline(PluginInformation info) { 18 super(info); 19 refreshMenu(); 21 20 } 22 21 23 public static void refreshMenu() 24 { 22 public static void refreshMenu() { 25 23 JMenu menu = Main.main.menu.moreToolsMenu; 26 24 if (menu.isVisible()) 27 28 29 25 menu.addSeparator(); 26 else 27 menu.setVisible(true); 30 28 menu.add(new JMenuItem(new IndoorSweeplineWizardAction())); 31 29 } -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweeplineController.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 13 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 14 15 16 public class IndoorSweeplineController implements LayerChangeListener { 15 17 16 public class IndoorSweeplineController implements LayerChangeListener 17 { 18 public IndoorSweeplineController(OsmDataLayer activeLayer, LatLon center) 19 { 18 public IndoorSweeplineController(OsmDataLayer activeLayer, LatLon center) { 20 19 Main.getLayerManager().addLayerChangeListener(this); 21 20 layer = activeLayer; … … 25 24 } 26 25 27 28 public IndoorSweeplineWizardDialog view() 29 { 26 public IndoorSweeplineWizardDialog view() { 30 27 return dialog; 31 28 } 32 29 33 30 @Override 34 public void layerOrderChanged(LayerOrderChangeEvent e) 35 { 31 public void layerOrderChanged(LayerOrderChangeEvent e) { 36 32 } 37 33 38 34 @Override 39 public void layerAdded(LayerAddEvent e) 40 { 35 public void layerAdded(LayerAddEvent e) { 41 36 } 42 37 43 38 @Override 44 public void layerRemoving(LayerRemoveEvent e) 45 { 39 public void layerRemoving(LayerRemoveEvent e) { 46 40 if (e.getRemovedLayer() == layer) 47 41 dialog.setVisible(false); 48 42 } 49 43 50 public int leftRightCount() 51 { 44 public int leftRightCount() { 52 45 return model.leftRightCount(); 53 46 } 54 47 55 public void addRightStructure() 56 { 48 public void addRightStructure() { 57 49 if (model.leftRightCount() % 2 == 0) 58 50 model.addBeam(); … … 61 53 } 62 54 63 public DefaultComboBoxModel<String> structures() 64 { 55 public DefaultComboBoxModel<String> structures() { 65 56 return model.structures(); 66 57 } 67 58 68 public double getStripWidth(int index) 69 { 59 public double getStripWidth(int index) { 70 60 return model.getStripWidth(index); 71 61 } 72 62 73 public void setStripWidth(int index, double value) 74 { 63 public void setStripWidth(int index, double value) { 75 64 model.setStripWidth(index, value); 76 65 } 77 66 78 public double getBeamOffset(int index) 79 { 67 public double getBeamOffset(int index) { 80 68 return model.getBeamOffset(index); 81 69 } 82 70 83 public void setBeamOffset(int index, double beamOffset) 84 { 71 public void setBeamOffset(int index, double beamOffset) { 85 72 model.setBeamOffset(index, beamOffset); 86 73 } 87 74 88 public List<CorridorPart> getBeamParts(int index) 89 { 75 public List<CorridorPart> getBeamParts(int index) { 90 76 return model.getBeamParts(index); 91 77 } 92 78 93 public void addCorridorPart(int beamIndex, boolean append, double value) 94 { 79 public void addCorridorPart(int beamIndex, boolean append, double value) { 95 80 model.addCorridorPart(beamIndex, append, value); 96 81 } 97 82 98 public void setCorridorPartWidth(int beamIndex, int partIndex, double value) 99 { 83 public void setCorridorPartWidth(int beamIndex, int partIndex, double value) { 100 84 model.setCorridorPartWidth(beamIndex, partIndex, value); 101 85 } 102 86 103 public void setCorridorPartType(int beamIndex, int partIndex, CorridorPart.Type type) 104 { 87 public void setCorridorPartType(int beamIndex, int partIndex, CorridorPart.Type type) { 105 88 model.setCorridorPartType(beamIndex, partIndex, type); 106 89 } 107 90 108 public void setCorridorPartSide(int beamIndex, int partIndex, CorridorPart.ReachableSide side) 109 { 91 public void setCorridorPartSide(int beamIndex, int partIndex, CorridorPart.ReachableSide side) { 110 92 model.setCorridorPartSide(beamIndex, partIndex, side); 111 93 } 112 94 113 public Strip getStrip(int beamIndex) 114 { 95 public Strip getStrip(int beamIndex) { 115 96 return model.getStrip(beamIndex); 116 97 } 117 98 118 public IndoorSweeplineModel.Type getType() 119 { 99 public IndoorSweeplineModel.Type getType() { 120 100 return model.getType(); 121 101 } 122 102 123 public void setType(IndoorSweeplineModel.Type type) 124 { 103 public void setType(IndoorSweeplineModel.Type type) { 125 104 model.setType(type); 126 105 } 127 106 128 public String getLevel() 129 { 107 public String getLevel() { 130 108 return model.getLevel(); 131 109 } 132 110 133 public void setLevel(String level) 134 { 111 public void setLevel(String level) { 135 112 model.setLevel(level); 136 113 } -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweeplineModel.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 9 10 import org.openstreetmap.josm.data.coor.LatLon; 10 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 11 12 12 13 13 /* TODO: … … 15 15 - keyboard shortcuts 16 16 */ 17 18 19 public class IndoorSweeplineModel 20 { 21 public enum Type 22 { 17 public class IndoorSweeplineModel { 18 public enum Type { 23 19 CORRIDOR, 24 20 PLATFORM 25 }; 26 27 28 public IndoorSweeplineModel(OsmDataLayer activeLayer, LatLon center) 29 { 21 } 22 23 public IndoorSweeplineModel(OsmDataLayer activeLayer, LatLon center) { 30 24 target = new ModelGeography(activeLayer.data, center); 31 25 … … 41 35 } 42 36 43 44 37 private ModelGeography target; 45 38 46 47 public void addBeam() 48 { 39 public void addBeam() { 49 40 CorridorPart.ReachableSide side = CorridorPart.ReachableSide.LEFT; 50 41 if (beams.size() == 0) … … 52 43 53 44 /*double width = 10.; 54 if (beams.size() > 0) 55 { 56 width = 0; 57 for (CorridorPart part : beams.elementAt(beams.size() - 1).getBeamParts()) 58 width += part.width; 59 } 60 61 double offset = 0; 62 for (int i = 0; i < strips.size(); ++i) 63 offset += strips.elementAt(i).width;*/ 64 65 if (strips.size() == 0) 66 { 45 if (beams.size() > 0) { 46 width = 0; 47 for (CorridorPart part : beams.elementAt(beams.size() - 1).getBeamParts()) 48 width += part.width; 49 } 50 51 double offset = 0; 52 for (int i = 0; i < strips.size(); ++i) 53 offset += strips.elementAt(i).width;*/ 54 55 if (strips.size() == 0) { 67 56 Vector<Double> blueprint = new Vector<>(); 68 57 blueprint.addElement(0.); 69 58 blueprint.addElement(10.); 70 59 beams.add(new Beam(blueprint, 0., side)); 71 } 72 else 60 } else 73 61 beams.add(new Beam(strips.elementAt(strips.size()-1).lhs, 74 62 beams.elementAt(beams.size()-1).getBeamOffset(), side)); … … 80 68 } 81 69 82 83 public void addStrip() 84 { 70 public void addStrip() { 85 71 strips.add(new Strip(target.getDataSet())); 86 if (beams.size() > 1) 87 { 72 if (beams.size() > 1) { 88 73 beams.elementAt(beams.size()-1).setDefaultSide(CorridorPart.ReachableSide.ALL); 89 74 strips.elementAt(strips.size()-2).rhs = beams.elementAt(strips.size()-1).leftHandSideStrips(); … … 94 79 } 95 80 96 97 public int leftRightCount() 98 { 81 public int leftRightCount() { 99 82 return beams.size() + strips.size(); 100 83 } 101 84 102 103 public DefaultComboBoxModel<String> structures() 104 { 85 public DefaultComboBoxModel<String> structures() { 105 86 structureBox.removeAllElements(); 106 87 double offset = 0; 107 for (int i = 0; i < strips.size(); ++i) 108 { 88 for (int i = 0; i < strips.size(); ++i) { 109 89 if (i < beams.size()) 110 90 structureBox.addElement(Double.toString(offset)); … … 119 99 } 120 100 121 122 public Strip getStrip(int index) 123 { 101 public Strip getStrip(int index) { 124 102 return strips.elementAt(index / 2); 125 103 } 126 104 127 128 public double getStripWidth(int index) 129 { 105 public double getStripWidth(int index) { 130 106 return strips.elementAt(index / 2).width; 131 107 } 132 108 133 134 public void setStripWidth(int index, double value) 135 { 109 public void setStripWidth(int index, double value) { 136 110 strips.elementAt(index / 2).width = value; 137 138 updateOsmModel(); 139 } 140 141 142 public double getBeamOffset(int index) 143 { 111 updateOsmModel(); 112 } 113 114 public double getBeamOffset(int index) { 144 115 return beams.elementAt(index / 2).getBeamOffset(); 145 116 } 146 117 147 public void setBeamOffset(int index, double beamOffset) 148 { 118 public void setBeamOffset(int index, double beamOffset) { 149 119 beams.elementAt(index / 2).setBeamOffset(beamOffset); 150 120 updateOsmModel(); 151 121 } 152 122 153 154 public List<CorridorPart> getBeamParts(int index) 155 { 123 public List<CorridorPart> getBeamParts(int index) { 156 124 return beams.elementAt(index / 2).getBeamParts(); 157 125 } 158 126 159 160 public void addCorridorPart(int beamIndex, boolean append, double value) 161 { 127 public void addCorridorPart(int beamIndex, boolean append, double value) { 162 128 beams.elementAt(beamIndex / 2).addCorridorPart(append, value); 163 129 if (beamIndex / 2 > 0) … … 169 135 } 170 136 171 172 public void setCorridorPartWidth(int beamIndex, int partIndex, double value) 173 { 137 public void setCorridorPartWidth(int beamIndex, int partIndex, double value) { 174 138 beams.elementAt(beamIndex / 2).setCorridorPartWidth(partIndex, value); 175 139 if (beamIndex / 2 > 0) … … 181 145 } 182 146 183 184 public void setCorridorPartType(int beamIndex, int partIndex, CorridorPart.Type type) 185 { 186 if (beamIndex % 2 == 0) 187 { 147 public void setCorridorPartType(int beamIndex, int partIndex, CorridorPart.Type type) { 148 if (beamIndex % 2 == 0) { 188 149 beams.elementAt(beamIndex / 2).setCorridorPartType(partIndex, type); 189 150 if (beamIndex / 2 > 0) … … 191 152 if (beamIndex / 2 < strips.size()) 192 153 strips.elementAt(beamIndex / 2).lhs = beams.elementAt(beamIndex / 2).rightHandSideStrips(); 193 } 194 else 195 { 154 } else { 196 155 if (type != CorridorPart.Type.PASSAGE && type != CorridorPart.Type.VOID) 197 156 strips.elementAt(beamIndex / 2).setCorridorPartType(partIndex, type); … … 201 160 } 202 161 203 204 public void setCorridorPartSide(int beamIndex, int partIndex, CorridorPart.ReachableSide side) 205 { 162 public void setCorridorPartSide(int beamIndex, int partIndex, CorridorPart.ReachableSide side) { 206 163 beams.elementAt(beamIndex / 2).setCorridorPartSide(partIndex, side); 207 164 if (beamIndex / 2 > 0) … … 213 170 } 214 171 215 216 public Type getType() 217 { 172 public Type getType() { 218 173 return type; 219 174 } 220 175 221 public void setType(Type type) 222 { 176 public void setType(Type type) { 223 177 this.type = type; 224 178 updateOsmModel(); 225 179 } 226 180 227 228 public String getLevel() 229 { 181 public String getLevel() { 230 182 return level; 231 183 } 232 184 233 public void setLevel(String level) 234 { 185 public void setLevel(String level) { 235 186 this.level = level; 236 187 updateOsmModel(); 237 188 } 238 239 189 240 190 private Vector<Beam> beams; … … 245 195 DefaultComboBoxModel<String> structureBox; 246 196 247 248 private void updateOsmModel() 249 { 197 private void updateOsmModel() { 250 198 distributeWays(); 251 199 Main.map.mapView.repaint(); 252 200 } 253 201 254 255 public class SweepPolygonCursor 256 { 257 public SweepPolygonCursor(int stripIndex, int partIndex) 258 { 202 public class SweepPolygonCursor { 203 public SweepPolygonCursor(int stripIndex, int partIndex) { 259 204 this.stripIndex = stripIndex; 260 205 this.partIndex = partIndex; 261 206 } 262 207 263 public boolean equals(SweepPolygonCursor rhs) 264 { 208 public boolean equals(SweepPolygonCursor rhs) { 265 209 return rhs != null 266 210 && stripIndex == rhs.stripIndex && partIndex == rhs.partIndex; … … 271 215 } 272 216 273 274 private void distributeWays() 275 { 217 private void distributeWays() { 276 218 target.startGeographyBuild(beams, strips); 277 219 278 220 Vector<Vector<Boolean>> stripRefs = new Vector<>(); 279 for (Strip strip : strips) 280 { 221 for (Strip strip : strips) { 281 222 Vector<Boolean> refs = new Vector<>(); 282 223 if (strip.lhs.size() < strip.rhs.size()) … … 288 229 289 230 Boolean truePtr = new Boolean(true); 290 for (int i = 0; i < stripRefs.size(); ++i) 291 { 231 for (int i = 0; i < stripRefs.size(); ++i) { 292 232 Vector<Boolean> refs = stripRefs.elementAt(i); 293 for (int j = 0; j < refs.size(); ++j) 294 { 295 if (refs.elementAt(j) == null) 296 { 233 for (int j = 0; j < refs.size(); ++j) { 234 if (refs.elementAt(j) == null) { 297 235 target.startWay(); 298 236 … … 300 238 301 239 boolean toTheLeft = true; 302 while (stripRefs.elementAt(cursor.stripIndex).elementAt(cursor.partIndex) == null) 303 { 240 while (stripRefs.elementAt(cursor.stripIndex).elementAt(cursor.partIndex) == null) { 304 241 stripRefs.elementAt(cursor.stripIndex).setElementAt(truePtr, cursor.partIndex); 305 if (toTheLeft && cursor.partIndex < strips.elementAt(cursor.stripIndex).lhs.size()) 306 { 242 if (toTheLeft && cursor.partIndex < strips.elementAt(cursor.stripIndex).lhs.size()) { 307 243 target.appendCorridorPart( 308 244 strips.elementAt(cursor.stripIndex).partAt(cursor.partIndex), … … 313 249 toTheLeft = beams.elementAt(cursor.stripIndex).appendNodes( 314 250 cursor, toTheLeft, target.beamAt(cursor.stripIndex), level); 315 } 316 else if (!toTheLeft && cursor.partIndex < strips.elementAt(cursor.stripIndex).rhs.size()) 317 { 251 } else if (!toTheLeft && cursor.partIndex < strips.elementAt(cursor.stripIndex).rhs.size()) { 318 252 target.appendCorridorPart( 319 253 strips.elementAt(cursor.stripIndex).partAt(cursor.partIndex), … … 324 258 toTheLeft = beams.elementAt(cursor.stripIndex + 1).appendNodes( 325 259 cursor, toTheLeft, target.beamAt(cursor.stripIndex + 1), level); 326 } 327 else 260 } else 328 261 toTheLeft = appendUturn(cursor, toTheLeft); 329 262 } … … 337 270 } 338 271 339 340 private boolean appendUturn(SweepPolygonCursor cursor, boolean toTheLeft) 341 { 272 private boolean appendUturn(SweepPolygonCursor cursor, boolean toTheLeft) { 342 273 Strip strip = strips.elementAt(cursor.stripIndex); 343 274 target.appendUturnNode(strip, cursor.partIndex, cursor.stripIndex, -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweeplineWizardAction.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 19 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 20 21 22 public class IndoorSweeplineWizardAction extends JosmAction implements LayerChangeListener, ActiveLayerChangeListener { 21 23 22 public class IndoorSweeplineWizardAction extends JosmAction implements LayerChangeListener, ActiveLayerChangeListener 23 { 24 public IndoorSweeplineWizardAction() 25 { 24 public IndoorSweeplineWizardAction() { 26 25 super(tr("Concourse wizard ..."), null, 27 26 tr("Opens up a wizard to create a concourse"), null, false); … … 30 29 31 30 @Override 32 public void actionPerformed(ActionEvent event) 33 { 31 public void actionPerformed(ActionEvent event) { 34 32 if (layer == null) 35 33 JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(Main.parent), … … 45 43 "No map view found."); 46 44 else 47 new IndoorSweeplineController((OsmDataLayer) layer,45 new IndoorSweeplineController((OsmDataLayer) layer, 48 46 Projections.inverseProject(Main.map.mapView.getCenter())); 49 47 } 50 48 51 49 @Override 52 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) 53 { 50 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 54 51 layer = Main.getLayerManager().getActiveLayer(); 55 52 } 56 53 57 54 @Override 58 public void layerOrderChanged(LayerOrderChangeEvent e) 59 { 55 public void layerOrderChanged(LayerOrderChangeEvent e) { 60 56 } 61 57 62 58 @Override 63 public void layerAdded(LayerAddEvent e) 64 { 59 public void layerAdded(LayerAddEvent e) { 65 60 } 66 61 67 62 @Override 68 public void layerRemoving(LayerRemoveEvent e) 69 { 63 public void layerRemoving(LayerRemoveEvent e) { 70 64 if (layer == e.getRemovedLayer()) 71 65 layer = null; -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/IndoorSweeplineWizardDialog.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 33 34 import org.openstreetmap.josm.Main; 34 35 35 36 public class IndoorSweeplineWizardDialog extends JDialog 37 { 38 public IndoorSweeplineWizardDialog(IndoorSweeplineController controller) 39 { 36 public class IndoorSweeplineWizardDialog extends JDialog { 37 38 public IndoorSweeplineWizardDialog(IndoorSweeplineController controller) { 40 39 super(JOptionPane.getFrameForComponent(Main.parent), "Indoor Sweepline Wizard", false); 41 40 … … 66 65 } 67 66 68 69 67 @Override 70 public void setVisible(boolean visible) 71 { 68 public void setVisible(boolean visible) { 72 69 if (visible) 73 70 setLocationRelativeTo(JOptionPane.getFrameForComponent(Main.parent)); … … 75 72 } 76 73 77 78 private void refresh() 79 { 74 private void refresh() { 80 75 inRefresh = true; 81 76 … … 86 81 structureBoxModel.setSelectedItem(structureBoxModel.getElementAt(beamIndex)); 87 82 88 try 89 { 90 if (beamIndex % 2 == 0) 91 { 83 try { 84 if (beamIndex % 2 == 0) { 92 85 widthOffsetLabel.setText("Offset into background:"); 93 86 stripWidth.setText(Double.toString(controller.getBeamOffset(beamIndex))); 94 } 95 else 96 { 87 } else { 97 88 widthOffsetLabel.setText("Strip width:"); 98 89 stripWidth.setText(Double.toString(controller.getStripWidth(beamIndex))); 99 90 } 100 } 101 catch (IllegalStateException ex) 102 { 103 } 104 105 try 106 { 91 } catch (IllegalStateException ex) { 92 Main.trace(ex); 93 } 94 95 try { 107 96 level.setText(controller.getLevel()); 108 } 109 catch (IllegalStateException ex) 110 { 97 } catch (IllegalStateException ex) { 98 Main.trace(ex); 111 99 } 112 100 113 101 typeBoxModel.setSelectedItem(structureTypeToString(controller.getType())); 114 102 115 116 103 structureTableModel.setRowCount(0); 117 if (beamIndex % 2 == 0) 118 { 104 if (beamIndex % 2 == 0) { 119 105 Vector<Object> row = new Vector<>(); 120 106 row.addElement(""); … … 124 110 125 111 List<CorridorPart> parts = controller.getBeamParts(beamIndex); 126 for (CorridorPart part : parts) 127 { 112 for (CorridorPart part : parts) { 128 113 row = new Vector<>(); 129 114 row.addElement(Double.toString(part.width)); … … 138 123 structureTableModel.addRow(row); 139 124 structureTableModel.isBeam = true; 140 } 141 else 142 { 125 } else { 143 126 Strip strip = controller.getStrip(beamIndex); 144 for (int i = 0; i < strip.lhs.size() || i < strip.rhs.size(); ++i) 145 { 127 for (int i = 0; i < strip.lhs.size() || i < strip.rhs.size(); ++i) { 146 128 Vector<Object> row = new Vector<>(); 147 129 String position = i < strip.lhs.size() ? strip.lhs.elementAt(i).toString() : "X"; … … 160 142 } 161 143 162 163 private String corridorPartTypeToString(CorridorPart.Type type) 164 { 144 private String corridorPartTypeToString(CorridorPart.Type type) { 165 145 if (type == CorridorPart.Type.VOID) 166 146 return "void"; … … 190 170 } 191 171 192 193 private CorridorPart.Type parseCorridorPartType(String val) 194 { 172 private CorridorPart.Type parseCorridorPartType(String val) { 195 173 if (val == "void") 196 174 return CorridorPart.Type.VOID; … … 220 198 } 221 199 222 223 private String corridorPartSideToString(CorridorPart.ReachableSide side) 224 { 200 private String corridorPartSideToString(CorridorPart.ReachableSide side) { 225 201 if (side == CorridorPart.ReachableSide.ALL) 226 202 return "all"; … … 236 212 } 237 213 238 239 private CorridorPart.ReachableSide parseCorridorPartSide(String val) 240 { 214 private CorridorPart.ReachableSide parseCorridorPartSide(String val) { 241 215 if (val == "all") 242 216 return CorridorPart.ReachableSide.ALL; … … 252 226 } 253 227 254 255 private String structureTypeToString(IndoorSweeplineModel.Type type) 256 { 228 private String structureTypeToString(IndoorSweeplineModel.Type type) { 257 229 if (type == IndoorSweeplineModel.Type.CORRIDOR) 258 230 return "corridor"; … … 262 234 } 263 235 264 265 private JComboBox<String> structureBox() 266 { 236 private JComboBox<String> structureBox() { 267 237 JComboBox<String> structureBox = new JComboBox<>(controller.structures()); 268 238 structureBox.addActionListener(new StructureBoxListener()); 269 239 return structureBox; 270 240 } 271 272 241 273 242 private IndoorSweeplineController controller; … … 279 248 boolean inRefresh; 280 249 281 282 private JComboBox<String> typeBox() 283 { 284 if (typeBoxModel == null) 285 { 250 private JComboBox<String> typeBox() { 251 if (typeBoxModel == null) { 286 252 typeBoxModel = new DefaultComboBoxModel<>(); 287 253 typeBoxModel.addElement("corridor"); … … 295 261 private DefaultComboBoxModel<String> typeBoxModel; 296 262 297 298 private class TypeBoxListener implements ActionListener 299 { 300 @Override 301 public void actionPerformed(ActionEvent e) 302 { 263 private class TypeBoxListener implements ActionListener { 264 @Override 265 public void actionPerformed(ActionEvent e) { 303 266 if (inRefresh) 304 267 return; 305 268 306 269 @SuppressWarnings("unchecked") 307 String entry = (String) ((JComboBox<String>)e.getSource()).getSelectedItem();270 String entry = (String) ((JComboBox<String>) e.getSource()).getSelectedItem(); 308 271 if (entry == "corridor") 309 272 controller.setType(IndoorSweeplineModel.Type.CORRIDOR); … … 315 278 } 316 279 317 318 private class PrevAction extends AbstractAction 319 { 320 public PrevAction() 321 { 280 private class PrevAction extends AbstractAction { 281 PrevAction() { 322 282 super("Prev"); 323 283 } 324 284 325 285 @Override 326 public void actionPerformed(ActionEvent e) 327 { 286 public void actionPerformed(ActionEvent e) { 328 287 if (inRefresh) 329 288 return; … … 335 294 } 336 295 337 338 private class NextAction extends AbstractAction 339 { 340 public NextAction() 341 { 296 private class NextAction extends AbstractAction { 297 NextAction() { 342 298 super("Next"); 343 299 } 344 300 345 301 @Override 346 public void actionPerformed(ActionEvent e) 347 { 302 public void actionPerformed(ActionEvent e) { 348 303 if (inRefresh) 349 304 return; … … 356 311 } 357 312 358 359 private class StructureBoxListener implements ActionListener 360 { 361 @Override 362 public void actionPerformed(ActionEvent e) 363 { 313 private class StructureBoxListener implements ActionListener { 314 @Override 315 public void actionPerformed(ActionEvent e) { 364 316 if (inRefresh) 365 317 return; 366 318 367 319 @SuppressWarnings("unchecked") 368 String entry = (String) ((JComboBox<String>)e.getSource()).getSelectedItem();320 String entry = (String) ((JComboBox<String>) e.getSource()).getSelectedItem(); 369 321 DefaultComboBoxModel<String> structureBoxModel = controller.structures(); 370 for (int i = 0; i < structureBoxModel.getSize(); ++i) 371 { 322 for (int i = 0; i < structureBoxModel.getSize(); ++i) { 372 323 if (structureBoxModel.getElementAt(i).equals(entry)) 373 324 beamIndex = i; … … 377 328 } 378 329 379 380 330 private JLabel widthOffsetLabel; 381 331 382 private JLabel makeWidthLabel() 383 { 332 private JLabel makeWidthLabel() { 384 333 widthOffsetLabel = new JLabel(tr("Offset into background:")); 385 334 return widthOffsetLabel; 386 335 } 387 336 388 389 337 private JTextField stripWidth; 390 338 391 private JTextField makeWidthField() 392 { 339 private JTextField makeWidthField() { 393 340 stripWidth = new JTextField(5); 394 341 stripWidth.getDocument().addDocumentListener(new StripWidthListener()); … … 396 343 } 397 344 398 399 private class StripWidthListener implements DocumentListener 400 { 401 @Override 402 public void changedUpdate(DocumentEvent e) 403 { 345 private class StripWidthListener implements DocumentListener { 346 @Override 347 public void changedUpdate(DocumentEvent e) { 404 348 update(e); 405 349 } 406 350 407 351 @Override 408 public void insertUpdate(DocumentEvent e) 409 { 352 public void insertUpdate(DocumentEvent e) { 410 353 update(e); 411 354 } 412 355 413 356 @Override 414 public void removeUpdate(DocumentEvent e) 415 { 357 public void removeUpdate(DocumentEvent e) { 416 358 update(e); 417 359 } 418 360 419 420 private void update(DocumentEvent e) 421 { 422 if (inRefresh) 423 return; 424 425 try 426 { 361 private void update(DocumentEvent e) { 362 if (inRefresh) 363 return; 364 365 try { 427 366 if (beamIndex % 2 == 0) 428 367 controller.setBeamOffset(beamIndex, Double.parseDouble(stripWidth.getText())); 429 368 else 430 369 controller.setStripWidth(beamIndex, Double.parseDouble(stripWidth.getText())); 370 } catch (NumberFormatException ex) { 371 Main.trace(ex); 431 372 } 432 catch (NumberFormatException ex) 433 { 434 } 435 436 refresh(); 437 } 438 } 439 373 374 refresh(); 375 } 376 } 440 377 441 378 private JTextField level; 442 379 443 private JTextField makeLevelField() 444 { 380 private JTextField makeLevelField() { 445 381 level = new JTextField(5); 446 382 level.getDocument().addDocumentListener(new LevelFieldListener()); … … 448 384 } 449 385 450 451 private class LevelFieldListener implements DocumentListener 452 { 453 @Override 454 public void changedUpdate(DocumentEvent e) 455 { 386 private class LevelFieldListener implements DocumentListener { 387 @Override 388 public void changedUpdate(DocumentEvent e) { 456 389 update(e); 457 390 } 458 391 459 392 @Override 460 public void insertUpdate(DocumentEvent e) 461 { 393 public void insertUpdate(DocumentEvent e) { 462 394 update(e); 463 395 } 464 396 465 397 @Override 466 public void removeUpdate(DocumentEvent e) 467 { 398 public void removeUpdate(DocumentEvent e) { 468 399 update(e); 469 400 } 470 401 471 472 private void update(DocumentEvent e) 473 { 402 private void update(DocumentEvent e) { 474 403 if (inRefresh) 475 404 return; … … 481 410 } 482 411 483 484 private class StructureTableModel extends DefaultTableModel 485 { 486 @Override 487 public boolean isCellEditable(int row, int column) 488 { 412 private class StructureTableModel extends DefaultTableModel { 413 @Override 414 public boolean isCellEditable(int row, int column) { 489 415 return isBeam || column == 1; 490 416 } … … 495 421 private StructureTableModel structureTableModel; 496 422 497 private JScrollPane makeStructureTable() 498 { 423 private JScrollPane makeStructureTable() { 499 424 structureTableModel = new StructureTableModel(); 500 425 structureTableModel.addColumn("Width"); … … 531 456 } 532 457 533 private class StructureTableListener implements TableModelListener 534 { 535 @Override 536 public void tableChanged(TableModelEvent e) 537 { 458 private class StructureTableListener implements TableModelListener { 459 @Override 460 public void tableChanged(TableModelEvent e) { 538 461 if (inRefresh) 539 462 return; … … 541 464 int column = e.getColumn(); 542 465 int row = e.getFirstRow(); 543 if (column == 0 && beamIndex % 2 == 0) 544 { 545 try 546 { 466 if (column == 0 && beamIndex % 2 == 0) { 467 try { 547 468 if (row == 0 || row == structureTableModel.getRowCount() - 1) 548 469 controller.addCorridorPart(beamIndex, row != 0, 549 Double.parseDouble(((TableModel) e.getSource()).getValueAt(row, column).toString()));470 Double.parseDouble(((TableModel) e.getSource()).getValueAt(row, column).toString())); 550 471 else 551 472 controller.setCorridorPartWidth(beamIndex, row - 1, 552 Double.parseDouble(((TableModel)e.getSource()).getValueAt(row, column).toString())); 473 Double.parseDouble(((TableModel) e.getSource()).getValueAt(row, column).toString())); 474 } catch (NumberFormatException ex) { 475 Main.trace(ex); 553 476 } 554 catch (NumberFormatException ex) 555 { 556 } 557 } 558 else if (column == 1 && beamIndex % 2 == 0) 559 { 477 } else if (column == 1 && beamIndex % 2 == 0) { 560 478 if (row > 0 && row < structureTableModel.getRowCount() - 1) 561 479 controller.setCorridorPartType(beamIndex, row - 1, 562 parseCorridorPartType(((TableModel)e.getSource()).getValueAt(row, column).toString())); 563 } 564 else if (column == 1 && beamIndex % 2 == 1) 565 { 480 parseCorridorPartType(((TableModel) e.getSource()).getValueAt(row, column).toString())); 481 } else if (column == 1 && beamIndex % 2 == 1) { 566 482 controller.setCorridorPartType(beamIndex, row, 567 parseCorridorPartType(((TableModel)e.getSource()).getValueAt(row, column).toString())); 568 } 569 else if (column == 2 && beamIndex % 2 == 0) 570 { 483 parseCorridorPartType(((TableModel) e.getSource()).getValueAt(row, column).toString())); 484 } else if (column == 2 && beamIndex % 2 == 0) { 571 485 if (row > 0 && row < structureTableModel.getRowCount() - 1) 572 486 controller.setCorridorPartSide(beamIndex, row - 1, 573 parseCorridorPartSide(((TableModel) e.getSource()).getValueAt(row, column).toString()));487 parseCorridorPartSide(((TableModel) e.getSource()).getValueAt(row, column).toString())); 574 488 } 575 489 … … 578 492 } 579 493 580 581 private class GridbagPanel extends JPanel 582 { 583 public GridbagPanel() 584 { 494 private class GridbagPanel extends JPanel { 495 GridbagPanel() { 585 496 gridbag = new GridBagLayout(); 586 497 layoutCons = new GridBagConstraints(); … … 588 499 } 589 500 590 public void add(Component comp, int gridx, int gridy, int gridwidth, int gridheight) 591 { 501 public void add(Component comp, int gridx, int gridy, int gridwidth, int gridheight) { 592 502 layoutCons.gridx = gridx; 593 503 layoutCons.gridy = gridy; -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/ModelGeography.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 … … 12 13 import org.openstreetmap.josm.data.osm.Way; 13 14 14 15 public class ModelGeography 16 { 17 public ModelGeography(DataSet dataSet, LatLon center) 18 { 15 public class ModelGeography { 16 17 public ModelGeography(DataSet dataSet, LatLon center) { 19 18 beamsGeography = new Vector<>(); 20 19 … … 32 31 } 33 32 34 35 33 private Vector<BeamGeography> beamsGeography; 36 34 … … 47 45 private Vector<RelationMember> members; 48 46 49 50 public void appendNode(Node node) 51 { 47 public void appendNode(Node node) { 52 48 nodes.add(node); 53 49 } 54 50 55 56 public DataSet getDataSet() 57 { 51 public DataSet getDataSet() { 58 52 return dataSet; 59 53 } 60 54 61 62 public BeamGeography beamAt(int i) 63 { 55 public BeamGeography beamAt(int i) { 64 56 return beamsGeography.elementAt(i); 65 57 } 66 58 67 68 public void startGeographyBuild(Vector<Beam> beams, Vector<Strip> strips) 69 { 59 public void startGeographyBuild(Vector<Beam> beams, Vector<Strip> strips) { 70 60 if (beamsGeography.size() < beams.size()) 71 61 beamsGeography.setSize(beams.size()); 72 62 73 63 double offset = 0; 74 for (int i = 0; i < beams.size(); ++i) 75 { 64 for (int i = 0; i < beams.size(); ++i) { 76 65 if (beamsGeography.elementAt(i) == null) 77 66 beamsGeography.setElementAt(new BeamGeography(dataSet, this), i); … … 91 80 } 92 81 93 94 public void startWay() 95 { 82 public void startWay() { 96 83 nodes = new Vector<>(); 97 84 } 98 85 99 100 public void finishWay(Strip strip, int partIndex, boolean isOuter, String level) 101 { 102 if (nodes.size() > 0) 103 { 86 public void finishWay(Strip strip, int partIndex, boolean isOuter, String level) { 87 if (nodes.size() > 0) { 104 88 CorridorPart part = strip.partAt(partIndex); 105 89 strip.geographyAt(partIndex).appendNodes(part.getType(), part.getSide(), level, … … 112 96 } 113 97 114 115 98 public void appendCorridorPart(CorridorPart part, CorridorGeography partGeography, int beamIndex, int partIndex, 116 String level) 117 { 99 String level) { 118 100 if (nodes.size() > 0) 119 101 partGeography.appendNodes(part.getType(), part.getSide(), level, … … 122 104 } 123 105 124 125 106 public void appendUturnNode(Strip strip, int partIndex, int stripIndex, int beamNodeIndex, boolean toTheLeft, 126 String level) 127 { 107 String level) { 128 108 if (toTheLeft) 129 109 assignCoor(addMeterOffset(beamsGeography.elementAt(stripIndex + 1).coorAt(beamNodeIndex), … … 133 113 0, strip.width / 2.)); 134 114 135 if (nodes.size() > 0) 136 { 115 if (nodes.size() > 0) { 137 116 CorridorPart part = strip.partAt(partIndex); 138 117 strip.geographyAt(partIndex).appendNodes(part.getType(), part.getSide(), level, … … 143 122 } 144 123 145 146 public void finishGeographyBuild(IndoorSweeplineModel.Type type, String level) 147 { 148 for (int i = nodePoolCount; i < nodePool.size(); ++i) 124 public void finishGeographyBuild(IndoorSweeplineModel.Type type, String level) { 125 for (int i = nodePoolCount; i < nodePool.size(); ++i) { 149 126 nodePool.elementAt(i).setDeleted(true); 127 } 150 128 nodePool.setSize(nodePoolCount); 151 129 152 for (int i = wayPoolCount; i < wayPool.size(); ++i) 130 for (int i = wayPoolCount; i < wayPool.size(); ++i) { 153 131 wayPool.elementAt(i).setDeleted(true); 132 } 154 133 wayPool.setSize(wayPoolCount); 155 134 … … 157 136 } 158 137 159 160 private static LatLon addMeterOffset(LatLon latLon, double south, double east) 161 { 138 private static LatLon addMeterOffset(LatLon latLon, double south, double east) { 162 139 double scale = Math.cos(latLon.lat() * (Math.PI/180.)); 163 140 return new LatLon(latLon.lat() - south *(360./4e7), latLon.lon() + east / scale *(360./4e7)); 164 141 } 165 142 166 167 private static double addMetersToLon(LatLon latLon, double east) 168 { 143 private static double addMetersToLon(LatLon latLon, double east) { 169 144 double scale = Math.cos(latLon.lat() * (Math.PI/180.)); 170 145 return latLon.lon() + east / scale *(360./4e7); 171 146 } 172 147 173 174 private void assignCoor(LatLon latLon) 175 { 148 private void assignCoor(LatLon latLon) { 176 149 if (nodePoolCount < nodePool.size()) 177 150 nodePool.elementAt(nodePoolCount).setCoor(latLon); 178 else 179 { 151 else { 180 152 Node node = new Node(latLon); 181 153 dataSet.addPrimitive(node); … … 184 156 } 185 157 186 187 private void assignNds(List<Node> nodes) 188 { 158 private void assignNds(List<Node> nodes) { 189 159 if (wayPoolCount < wayPool.size()) 190 160 wayPool.elementAt(wayPoolCount).setNodes(nodes); 191 else 192 { 161 else { 193 162 Way way = new Way(); 194 163 way.setNodes(nodes); … … 198 167 } 199 168 200 201 private static void addPolygonTags(IndoorSweeplineModel.Type type, String level, OsmPrimitive obj) 202 { 203 if (type == IndoorSweeplineModel.Type.PLATFORM) 204 { 169 private static void addPolygonTags(IndoorSweeplineModel.Type type, String level, OsmPrimitive obj) { 170 if (type == IndoorSweeplineModel.Type.PLATFORM) { 205 171 obj.put("railway", "platform"); 206 172 obj.put("public_transport", "platform"); 207 173 obj.put("area", "yes"); 208 174 obj.put("level", level); 209 } 210 else 211 { 175 } else { 212 176 obj.put("highway", "pedestrian"); 213 177 obj.put("indoor", "corridor"); … … 217 181 } 218 182 219 220 private void adjustMultipolygonRelation(IndoorSweeplineModel.Type type, String level) 221 { 222 if (members.size() > 1) 223 { 183 private void adjustMultipolygonRelation(IndoorSweeplineModel.Type type, String level) { 184 if (members.size() > 1) { 224 185 if (wayPool.size() > 0) 225 186 wayPool.elementAt(0).removeAll(); 226 187 227 if (multipolygon == null) 228 { 188 if (multipolygon == null) { 229 189 multipolygon = new Relation(); 230 190 dataSet.addPrimitive(multipolygon); … … 236 196 237 197 multipolygon.setMembers(members); 238 } 239 else 240 { 241 if (multipolygon != null) 242 { 198 } else { 199 if (multipolygon != null) { 243 200 multipolygon.setDeleted(true); 244 201 multipolygon = null; 245 202 } 246 203 247 if (wayPool.size() == 1) 248 { 204 if (wayPool.size() == 1) { 249 205 wayPool.elementAt(0).removeAll(); 250 206 addPolygonTags(type, level, wayPool.elementAt(0)); -
applications/editors/josm/plugins/indoor_sweepline/src/indoor_sweepline/Strip.java
r32479 r32601 1 // License: GPL. For details, see LICENSE file. 1 2 package indoor_sweepline; 2 3 3 4 4 import java.util.Vector; … … 6 6 import org.openstreetmap.josm.data.osm.DataSet; 7 7 8 public class Strip { 8 9 9 public class Strip 10 { 11 public Strip(DataSet dataSet) 12 { 10 public Strip(DataSet dataSet) { 13 11 width = 10.; 14 12 parts = new Vector<>(); … … 20 18 } 21 19 22 23 public void setCorridorPartType(int partIndex, CorridorPart.Type type) 24 { 25 while (parts.size() <= partIndex) 26 { 20 public void setCorridorPartType(int partIndex, CorridorPart.Type type) { 21 while (parts.size() <= partIndex) { 27 22 parts.add(new CorridorPart(0., CorridorPart.Type.WALL, 28 23 parts.size() % 2 == 0 ? CorridorPart.ReachableSide.FRONT : … … 33 28 } 34 29 35 36 public CorridorPart partAt(int i) 37 { 38 while (parts.size() <= i) 39 { 30 public CorridorPart partAt(int i) { 31 while (parts.size() <= i) { 40 32 parts.add(new CorridorPart(0., CorridorPart.Type.WALL, 41 33 parts.size() % 2 == 0 ? CorridorPart.ReachableSide.FRONT : … … 46 38 } 47 39 48 49 public CorridorGeography geographyAt(int i) 50 { 51 while (parts.size() <= i) 52 { 40 public CorridorGeography geographyAt(int i) { 41 while (parts.size() <= i) { 53 42 parts.add(new CorridorPart(0., CorridorPart.Type.WALL, 54 43 parts.size() % 2 == 0 ? CorridorPart.ReachableSide.FRONT : … … 58 47 return partsGeography.elementAt(i); 59 48 } 60 61 49 62 50 public double width;
Note:
See TracChangeset
for help on using the changeset viewer.