Changeset 26316 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-07-13T10:40:46+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/LaneGui.java
r26182 r26316 2 2 3 3 import static java.lang.Math.max; 4 import static java.lang.Math.min; 4 5 import static org.openstreetmap.josm.plugins.turnlanes.gui.GuiUtil.area; 5 6 … … 88 89 final double newLength = getModel().getOutgoingRoadEnd().isFromEnd() ? offset : getRoad().getLength() 89 90 - offset; 90 91 length = newLength; 92 if (updateModel && newLength > 0) { 93 getModel().setLength(newLength * getRoad().getContainer().getMpp()); 91 final double adjustedLength = min(max(newLength, 0.1), getRoad().getLength()); 92 93 length = adjustedLength; 94 if (updateModel) { 95 getModel().setLength(adjustedLength * getRoad().getContainer().getMpp()); 94 96 } 95 97 … … 326 328 327 329 outer = inner.offset(W, SL, SL + AL, 0); 328 area(area, inner.subpath(0, L ), outer.subpath(0, L + WW));329 330 lengthSlider.move(inner.getPoint(L ));330 area(area, inner.subpath(0, L, true), outer.subpath(0, L + WW, true)); 331 332 lengthSlider.move(inner.getPoint(L, true)); 331 333 332 334 if (L > leftLength) { 333 innerLine.append(inner.subpath( max(0, leftLength + WW), L).getIterator(), leftLength >= 0335 innerLine.append(inner.subpath(leftLength + WW, L, true).getIterator(), leftLength >= 0 334 336 || getModel().getOutgoingRoadEnd().isFromEnd()); 335 final Point2D op = outer.getPoint(L + WW );337 final Point2D op = outer.getPoint(L + WW, true); 336 338 innerLine.lineTo(op.getX(), op.getY()); 337 339 } 338 340 } else if (getModel().getKind() == Lane.Kind.EXTRA_RIGHT) { 339 341 outer = inner.offset(W, L, L + WW, 0); 340 area(area, inner.subpath(0, L + WW ), outer.subpath(0, L));341 342 lengthSlider.move(outer.getPoint(L ));342 area(area, inner.subpath(0, L + WW, true), outer.subpath(0, L, true)); 343 344 lengthSlider.move(outer.getPoint(L, true)); 343 345 } else { 344 346 outer = inner.offset(W, -1, -1, W); … … 346 348 347 349 if (leftLength < L) { 348 innerLine.append(inner.subpath( max(0, leftLength + WW), L).getIterator(), leftLength >= 0350 innerLine.append(inner.subpath(leftLength + WW, L, true).getIterator(), leftLength >= 0 349 351 || getModel().getOutgoingRoadEnd().isFromEnd()); 350 352 } -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/Path.java
r26154 r26316 209 209 @Override 210 210 public SimplePathIterator getIterator() { 211 return new SimplePathIterator(previous.getIteratorInternal(angle), PathIterator.SEG_LINETO, endX, endY, 0, 0, 0,212 0);211 return new SimplePathIterator(previous.getIteratorInternal(angle), PathIterator.SEG_LINETO, endX, endY, 0, 212 0, 0, 0); 213 213 } 214 214 … … 217 217 final double PL = previous.getLength(); 218 218 final double ML = PL + length; 219 220 if (from > ML) { 221 throw new IllegalArgumentException("from > length"); 222 } else if (to > ML) { 223 throw new IllegalArgumentException("to > length"); 224 } 219 225 220 226 if (to < PL) { … … 229 235 return new Line(new Start(start.getX(), start.getY(), angle), end.getX(), end.getY(), EL - from); 230 236 } else { 231 return new Line(previous.subpath(from, to), end.getX(), end.getY(), EL - PL);237 return new Line(previous.subpath(from, PL), end.getX(), end.getY(), EL - PL); 232 238 } 233 239 } … … 237 243 final double PL = previous.getLength(); 238 244 final double ML = PL + length; 245 246 if (offset > ML) { 247 throw new IllegalArgumentException("offset > length"); 248 } 239 249 240 250 if (offset <= ML && offset >= PL) { … … 376 386 final double w2 = we - (m2 - ML) * (we - ws) / (m2 - m1); 377 387 378 return new Curve(prev, fromRadius - s * w1, toRadius - s * w2, offsetAngle(prev, angle), length, fromAngle); 388 return new Curve(prev, fromRadius - s * w1, toRadius - s * w2, offsetAngle(prev, angle), length, 389 fromAngle); 379 390 } 380 391 } … … 408 419 final double ML = PL + length; 409 420 421 if (from > ML) { 422 throw new IllegalArgumentException("from > length"); 423 } else if (to > ML) { 424 throw new IllegalArgumentException("to > length"); 425 } 426 410 427 if (to < PL) { 411 428 return previous.subpath(from, to); … … 427 444 return new Curve(new Start(start.getX(), start.getY(), fa), fromR, toR, a, l, fa); 428 445 } else { 429 return new Curve(previous.subpath(from, to), fromR, toR, a, l, fromAngle);446 return new Curve(previous.subpath(from, PL), fromR, toR, a, l, fromAngle); 430 447 } 431 448 } … … 457 474 458 475 return new SimplePathIterator(previous.getIteratorInternal(getEndAngle()), PathIterator.SEG_CUBICTO, // 459 cp1.getX(), cp1.getY(), cp2.getX(), cp2.getY(), endX, endY //476 cp1.getX(), cp1.getY(), cp2.getX(), cp2.getY(), endX, endY // 460 477 ); 461 478 … … 574 591 public abstract Path subpath(double from, double to); 575 592 593 public Path subpath(double from, double to, boolean fixArgs) { 594 if (fixArgs) { 595 from = min(max(from, 0), getLength()); 596 to = min(max(to, 0), getLength()); 597 } 598 599 return subpath(from, to); 600 } 601 576 602 public abstract Point2D getPoint(double offset); 603 604 public Point2D getPoint(double offset, boolean fixArgs) { 605 if (fixArgs) { 606 offset = min(max(offset, 0), getLength()); 607 } 608 609 return getPoint(offset); 610 } 577 611 }
Note:
See TracChangeset
for help on using the changeset viewer.