Skip to content

Commit 26d5132

Browse files
committed
CSSTUDIO-3425 Use org.csstudio.javafx.rtplot.internal.util.Log10.log10() instead of Math.log10().
1 parent ebbbb8d commit 26d5132

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

app/display/linearmeter/src/main/java/org/csstudio/display/extra/widgets/linearmeter/LinearMeterScale.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import org.csstudio.javafx.rtplot.internal.*;
77
import org.csstudio.javafx.rtplot.internal.util.GraphicsUtils;
88

9+
import static org.csstudio.javafx.rtplot.internal.util.Log10.log10;
10+
911

1012
public class LinearMeterScale extends NumericAxis
1113
{
@@ -105,12 +107,12 @@ public void paint(Graphics2D gc, Rectangle plot_bounds)
105107

106108
for (MajorTick<Double> tick : ticks.getMajorTicks()) {
107109
if (isLogarithmic()) {
108-
gc.drawLine((int) ((start_x + this.scale * (Math.log10(tick.getValue()) - Math.log10(offset)) )),
110+
gc.drawLine((int) ((start_x + this.scale * (log10(tick.getValue()) - log10(offset)) )),
109111
(int) ((start_y - 0.5 * TICK_LENGTH)),
110-
(int) ((start_x + this.scale * (Math.log10(tick.getValue()) - Math.log10(offset)) )),
112+
(int) ((start_x + this.scale * (log10(tick.getValue()) - log10(offset)) )),
111113
(int) ((start_y + 0.5 * TICK_LENGTH)));
112114
drawTickLabel(gc,
113-
(int) ((start_x + this.scale * (Math.log10(tick.getValue()) - Math.log10(offset)) - scale_font_fontMetrics.stringWidth(tick.getLabel())/2)),
115+
(int) ((start_x + this.scale * (log10(tick.getValue()) - log10(offset)) - scale_font_fontMetrics.stringWidth(tick.getLabel())/2)),
114116
(int) (start_y + 0.5 * TICK_LENGTH + 2 + Math.round(Math.ceil((72.0 * (scale_font_fontMetrics.getAscent())) / 96.0))),
115117
tick.getLabel());
116118
}
@@ -129,12 +131,12 @@ public void paint(Graphics2D gc, Rectangle plot_bounds)
129131
for (MajorTick<Double> tick : ticks.getMajorTicks()) {
130132
if (isLogarithmic()) {
131133
gc.drawLine((int) (start_x - 0.5 * TICK_LENGTH),
132-
(int) (start_y - this.scale * (Math.log10(tick.getValue()) - Math.log10(offset))),
134+
(int) (start_y - this.scale * (log10(tick.getValue()) - log10(offset))),
133135
(int) (start_x + 0.5 * TICK_LENGTH),
134-
(int) (start_y - this.scale * (Math.log10(tick.getValue()) - Math.log10(offset))));
136+
(int) (start_y - this.scale * (log10(tick.getValue()) - log10(offset))));
135137
drawTickLabel(gc,
136138
(int) (start_x + 4),
137-
(int) (start_y - this.scale * (Math.log10(tick.getValue()) - Math.log10(offset)) + Math.round((72.0 * scale_font.getSize()) / (96.0 * 2.0))),
139+
(int) (start_y - this.scale * (log10(tick.getValue()) - log10(offset)) + Math.round((72.0 * scale_font.getSize()) / (96.0 * 2.0))),
138140
tick.getLabel());
139141
}
140142
else {

app/display/linearmeter/src/main/java/org/csstudio/display/extra/widgets/linearmeter/RTLinearMeter.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package org.csstudio.display.extra.widgets.linearmeter;
33

44
import static org.csstudio.javafx.rtplot.Activator.logger;
5+
import static org.csstudio.javafx.rtplot.internal.util.Log10.log10;
56

67
import java.awt.BasicStroke;
78
import java.awt.Canvas;
@@ -759,15 +760,15 @@ private Optional<Integer> computeIndicatorPosition(double value) {
759760
return withReadLock(() -> {
760761
if (linearMeterScale.isHorizontal()) {
761762
if (linearMeterScale.isLogarithmic()) {
762-
return Optional.of((int) Math.round(marginLeft + pixelsPerScaleUnit * (Math.log10(value) - Math.log10(linearMeterScale.getValueRange().getLow()))));
763+
return Optional.of((int) Math.round(marginLeft + pixelsPerScaleUnit * (log10(value) - log10(linearMeterScale.getValueRange().getLow()))));
763764
}
764765
else {
765766
return Optional.of((int) Math.round(marginLeft + pixelsPerScaleUnit * (value - linearMeterScale.getValueRange().getLow())));
766767
}
767768
}
768769
else {
769770
if (linearMeterScale.isLogarithmic()) {
770-
return Optional.of((int) Math.round(linearMeterScale.getBounds().height - marginBelow - pixelsPerScaleUnit * (Math.log10(value) - Math.log10(linearMeterScale.getValueRange().getLow()))));
771+
return Optional.of((int) Math.round(linearMeterScale.getBounds().height - marginBelow - pixelsPerScaleUnit * (log10(value) - log10(linearMeterScale.getValueRange().getLow()))));
771772
}
772773
else {
773774
return Optional.of((int) Math.round(linearMeterScale.getBounds().height - marginBelow - pixelsPerScaleUnit * (value - linearMeterScale.getValueRange().getLow())));
@@ -1343,7 +1344,7 @@ private void layout() {
13431344
}
13441345

13451346
if (linearMeterScale.isLogarithmic()) {
1346-
pixelsPerScaleUnit = (linearMeterScale.getBounds().width - marginLeft - marginRight - 1) / (Math.log10(linearMeterScale.getValueRange().getHigh()) - Math.log10(linearMeterScale.getValueRange().getLow()));
1347+
pixelsPerScaleUnit = (linearMeterScale.getBounds().width - marginLeft - marginRight - 1) / (log10(linearMeterScale.getValueRange().getHigh()) - log10(linearMeterScale.getValueRange().getLow()));
13471348
}
13481349
else {
13491350
pixelsPerScaleUnit = (linearMeterScale.getBounds().width - marginLeft - marginRight - 1) / (linearMeterScale.getValueRange().getHigh() - linearMeterScale.getValueRange().getLow());
@@ -1357,10 +1358,10 @@ private void layout() {
13571358
double x_hiHiRectangle;
13581359
if (linearMeterScale.isLogarithmic()) {
13591360
x_loLoRectangle = marginLeft;
1360-
x_lowRectangle = marginLeft + pixelsPerScaleUnit * (Math.log10(displayedLoLo) - Math.log10(linearMeterScale.getValueRange().getLow()));
1361-
x_normalRectangle = marginLeft + pixelsPerScaleUnit * (Math.log10(displayedLow) - Math.log10(linearMeterScale.getValueRange().getLow()));
1362-
x_highRectangle = marginLeft + pixelsPerScaleUnit * (Math.log10(displayedHigh) - Math.log10(linearMeterScale.getValueRange().getLow()));
1363-
x_hiHiRectangle = marginLeft + pixelsPerScaleUnit * (Math.log10(displayedHiHi) - Math.log10(linearMeterScale.getValueRange().getLow()));
1361+
x_lowRectangle = marginLeft + pixelsPerScaleUnit * (log10(displayedLoLo) - log10(linearMeterScale.getValueRange().getLow()));
1362+
x_normalRectangle = marginLeft + pixelsPerScaleUnit * (log10(displayedLow) - log10(linearMeterScale.getValueRange().getLow()));
1363+
x_highRectangle = marginLeft + pixelsPerScaleUnit * (log10(displayedHigh) - log10(linearMeterScale.getValueRange().getLow()));
1364+
x_hiHiRectangle = marginLeft + pixelsPerScaleUnit * (log10(displayedHiHi) - log10(linearMeterScale.getValueRange().getLow()));
13641365
}
13651366
else {
13661367
x_loLoRectangle = marginLeft;
@@ -1393,7 +1394,7 @@ private void layout() {
13931394

13941395
int hihiWidth;
13951396
if (linearMeterScale.isLogarithmic()) {
1396-
hihiWidth = (int) (Math.round(pixelsPerScaleUnit * (Math.log10(linearMeterScale.getValueRange().getHigh()) - Math.log10(displayedHiHi))));
1397+
hihiWidth = (int) (Math.round(pixelsPerScaleUnit * (log10(linearMeterScale.getValueRange().getHigh()) - log10(displayedHiHi))));
13971398
}
13981399
else {
13991400
hihiWidth = (int) (Math.round(pixelsPerScaleUnit * (linearMeterScale.getValueRange().getHigh() - displayedHiHi)));
@@ -1428,7 +1429,7 @@ private void layout() {
14281429
}
14291430

14301431
if (linearMeterScale.isLogarithmic()) {
1431-
pixelsPerScaleUnit = (linearMeterScale.getBounds().height - marginAbove - marginBelow - 1) / (Math.log10(linearMeterScale.getValueRange().getHigh()) - Math.log10(linearMeterScale.getValueRange().getLow()));
1432+
pixelsPerScaleUnit = (linearMeterScale.getBounds().height - marginAbove - marginBelow - 1) / (log10(linearMeterScale.getValueRange().getHigh()) - log10(linearMeterScale.getValueRange().getLow()));
14321433
}
14331434
else {
14341435
pixelsPerScaleUnit = (linearMeterScale.getBounds().height - marginAbove - marginBelow - 1) / (linearMeterScale.getValueRange().getHigh() - linearMeterScale.getValueRange().getLow());
@@ -1440,10 +1441,10 @@ private void layout() {
14401441
double y_normalRectangle;
14411442
double y_highRectangle;
14421443
if (linearMeterScale.isLogarithmic()) {
1443-
y_loLoRectangle = marginAbove + pixelsPerScaleUnit * (Math.log10(linearMeterScale.getValueRange().getHigh()) - Math.log10(displayedLoLo));
1444-
y_lowRectangle = marginAbove + pixelsPerScaleUnit * (Math.log10(linearMeterScale.getValueRange().getHigh()) - Math.log10(displayedLow));
1445-
y_normalRectangle = marginAbove + pixelsPerScaleUnit * (Math.log10(linearMeterScale.getValueRange().getHigh()) - Math.log10(displayedHigh));
1446-
y_highRectangle = marginAbove + pixelsPerScaleUnit * (Math.log10(linearMeterScale.getValueRange().getHigh()) - Math.log10(displayedHiHi));
1444+
y_loLoRectangle = marginAbove + pixelsPerScaleUnit * (log10(linearMeterScale.getValueRange().getHigh()) - log10(displayedLoLo));
1445+
y_lowRectangle = marginAbove + pixelsPerScaleUnit * (log10(linearMeterScale.getValueRange().getHigh()) - log10(displayedLow));
1446+
y_normalRectangle = marginAbove + pixelsPerScaleUnit * (log10(linearMeterScale.getValueRange().getHigh()) - log10(displayedHigh));
1447+
y_highRectangle = marginAbove + pixelsPerScaleUnit * (log10(linearMeterScale.getValueRange().getHigh()) - log10(displayedHiHi));
14471448
}
14481449
else {
14491450
y_loLoRectangle = marginAbove + pixelsPerScaleUnit * (linearMeterScale.getValueRange().getHigh() - displayedLoLo);

0 commit comments

Comments
 (0)