From 179c8cbeaec08b5613da579d3840e54703d83c62 Mon Sep 17 00:00:00 2001 From: Kristopher Guzman Date: Mon, 28 Nov 2016 22:10:52 -0500 Subject: [PATCH] offset now displayed in scientific notation --- src/main/Controller.java | 11 ++++++++++- src/view/view.fxml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/Controller.java b/src/main/Controller.java index 3dc786e..e80414f 100644 --- a/src/main/Controller.java +++ b/src/main/Controller.java @@ -14,6 +14,7 @@ import javafx.scene.control.SplitPane; import javafx.scene.layout.AnchorPane; +import java.math.BigDecimal; import java.text.DecimalFormat; public class Controller { @@ -30,13 +31,21 @@ public class Controller { private double MIN_OFFSET = 0.000000000000000001; //10^-18 private double MAX_OFFSET = 0.0000000000000009; //9x10^-16 private int maxResolution = 100; + private BigDecimal maxAsBigDecimal = new BigDecimal("0.000000000000000001").setScale(18, BigDecimal.ROUND_HALF_EVEN); private DecimalFormat df = new DecimalFormat(".##"); + private DecimalFormat offsetFormat = new DecimalFormat("0.0E0"); @FXML private void initialize() { + offsetLabel.setText("Offset: " + offsetFormat.format(0.00000000000000035)); + offsetSlider.valueProperty().addListener(((observable, oldValue, newValue) -> { - offsetLabel.setText("Offset: " + newValue); + + BigDecimal result = maxAsBigDecimal.multiply(new BigDecimal(newValue.toString())); + offsetLabel.setText("Offset: " + offsetFormat.format(result)); + + })); zoomLabel.setText("0.1x"); diff --git a/src/view/view.fxml b/src/view/view.fxml index 1793676..37da885 100644 --- a/src/view/view.fxml +++ b/src/view/view.fxml @@ -30,7 +30,7 @@ - +