|
19 | 19 | import java.util.concurrent.TimeoutException; |
20 | 20 | import java.util.logging.Level; |
21 | 21 |
|
| 22 | +import javafx.util.Pair; |
22 | 23 | import org.csstudio.javafx.rtplot.Axis; |
23 | 24 | import org.csstudio.javafx.rtplot.AxisRange; |
24 | 25 | import org.csstudio.javafx.rtplot.Messages; |
@@ -490,32 +491,26 @@ public void autoscale() |
490 | 491 | } |
491 | 492 | } |
492 | 493 | if (axis.isLogarithmic()) |
493 | | - { // Perform adjustment in log space. |
494 | | - // But first, refuse to deal with <= 0 |
495 | | - if (low <= 0.0) |
496 | | - low = 1; |
497 | | - if (high <= low) |
498 | | - high = low * 100.0; |
499 | | - low = Log10.log10(low); |
500 | | - high = Log10.log10(high); |
501 | | - } |
502 | | - final ValueRange rounded = roundValueRange(low, high); |
503 | | - low = rounded.getLow(); |
504 | | - high = rounded.getHigh(); |
505 | | - if (axis.isLogarithmic()) |
506 | 494 | { |
507 | | - low = Log10.pow10(low); |
508 | | - high = Log10.pow10(high); |
| 495 | + low = Log10.pow10(Math.floor(Log10.log10(low))); // Note: may set "low" to 0.0. |
| 496 | + high = Log10.pow10(Math.ceil(Log10.log10(high))); |
| 497 | + Pair<Double, Double> adjustedRange = axis.ticks.adjustRange(low, high); |
| 498 | + low = adjustedRange.getKey(); |
| 499 | + high = adjustedRange.getValue(); |
| 500 | + |
509 | 501 | } |
510 | | - else |
511 | | - { // Stretch range a little bit |
| 502 | + else { |
| 503 | + final ValueRange rounded = roundValueRange(low, high); |
| 504 | + low = rounded.getLow(); |
| 505 | + high = rounded.getHigh(); |
| 506 | + // Stretch range a little bit |
512 | 507 | // (but not for log scale, where low just above 0 |
513 | 508 | // could be stretched to <= 0) |
514 | 509 | final double headroom = (high - low) * 0.05; |
515 | 510 | low -= headroom; |
516 | 511 | high += headroom; |
517 | | - |
518 | 512 | } |
| 513 | + |
519 | 514 | // Autoscale happens 'all the time'. |
520 | 515 | // Do not use undo, but notify listeners. |
521 | 516 | if (low != high) |
|
0 commit comments