Use double-precision diameter labels
This commit is contained in:
parent
9d3c6d8364
commit
5cafd87608
@ -69,9 +69,14 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
for( int i = 0; i < motorDiameters.length; i++ ) {
|
for( int i = 0; i < motorDiameters.length; i++ ) {
|
||||||
// Round the labels, because for imperial units, the labels can otherwise overlap
|
// Round the labels, because for imperial units, the labels can otherwise overlap
|
||||||
double diam = unit.toUnit(motorDiameters[i]);
|
double diam = unit.toUnit(motorDiameters[i]);
|
||||||
diam = unit.round(diam);
|
double diamRounded = unit.round(diam * 10) / 10; // 10 multiplication for 2-decimal precision
|
||||||
diam = unit.fromUnit(diam);
|
diam = unit.fromUnit(diamRounded);
|
||||||
diameterLabels.put( i, new JLabel(unit.toString(diam)));
|
String formatted = unit.toString(diam);
|
||||||
|
// Remove the leading zero for numbers between 0 and 1
|
||||||
|
if (diamRounded > 0 && diamRounded < 1) {
|
||||||
|
formatted = formatted.substring(1);
|
||||||
|
}
|
||||||
|
diameterLabels.put( i, new JLabel(formatted));
|
||||||
}
|
}
|
||||||
diameterLabels.get( motorDiameters.length-1).setText("+");
|
diameterLabels.get( motorDiameters.length-1).setText("+");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user