Skip to content

Commit

Permalink
offset now displayed in scientific notation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristopher Guzman committed Nov 29, 2016
1 parent 805862a commit 179c8cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/main/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/view/view.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Font name="Avenir Black Oblique" size="21.0" />
</font>
</Label>
<Slider fx:id="offsetSlider" blockIncrement="1.0E-16" layoutX="103.0" layoutY="316.0" max="9.0E-16" min="1.0E-18" prefHeight="16.0" prefWidth="410.0" value="1.0E-16" />
<Slider fx:id="offsetSlider" blockIncrement="1.0" layoutX="103.0" layoutY="316.0" majorTickUnit="2.0" max="900.0" min="1.0" prefHeight="16.0" prefWidth="410.0" value="350.0" />
<Label fx:id="zoomLabel" alignment="CENTER" contentDisplay="CENTER" layoutX="55.0" layoutY="393.0" prefHeight="51.0" prefWidth="490.0" text="Zoom: 0.3x" textAlignment="CENTER" textFill="WHITE" wrapText="true">
<font>
<Font name="Avenir Black Oblique" size="21.0" />
Expand Down

0 comments on commit 179c8cb

Please sign in to comment.