From bbc8777d808e30a33886ba46be6819e3245241b9 Mon Sep 17 00:00:00 2001 From: Kristopher Guzman Date: Fri, 2 Dec 2016 14:08:35 -0500 Subject: [PATCH] line class, offset changes --- src/main/Controller.java | 17 ++++++++++++++--- src/main/Line.java | 23 +++++++++++++++++++++++ src/view/view.fxml | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/main/Line.java diff --git a/src/main/Controller.java b/src/main/Controller.java index e80414f..36d1604 100644 --- a/src/main/Controller.java +++ b/src/main/Controller.java @@ -9,10 +9,12 @@ import javafx.fxml.FXML; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; +import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.control.SplitPane; import javafx.scene.layout.AnchorPane; +import javafx.scene.paint.Color; import java.math.BigDecimal; import java.text.DecimalFormat; @@ -30,9 +32,10 @@ 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 int maxResolution = 100; + private DecimalFormat df = new DecimalFormat(".##"); private DecimalFormat offsetFormat = new DecimalFormat("0.0E0"); @@ -50,14 +53,22 @@ public class Controller { zoomLabel.setText("0.1x"); zoomSlider.setValue(10); + zoomSlider.valueProperty().addListener(((observable, oldValue, newValue) -> { + double val = newValue.doubleValue() / maxResolution; - System.out.println(val); zoomLabel.setText("Zoom: " + df.format(val) + "x"); + })); - } + GraphicsContext gc = canvas.getGraphicsContext2D(); + gc.setLineWidth(2); + gc.setStroke(Color.BLACK); + gc.moveTo(0,0); + gc.lineTo(500, 300); + gc.stroke(); + } } diff --git a/src/main/Line.java b/src/main/Line.java new file mode 100644 index 0000000..27d5521 --- /dev/null +++ b/src/main/Line.java @@ -0,0 +1,23 @@ +package main; + +import javafx.scene.canvas.Canvas; + +/** + * Created by kristopherguzman on 12/2/16. + */ +public class Line { + + private int start; + private int end; + + public void setStart(); + + public Line(Canvas canvas, int thickness, int from, int to) { + + this.start = canvas.widthProperty().intValue() - start; + this.end = canvas.heightProperty().intValue() - end; + + } + + +} diff --git a/src/view/view.fxml b/src/view/view.fxml index 37da885..962ab26 100644 --- a/src/view/view.fxml +++ b/src/view/view.fxml @@ -36,7 +36,7 @@ - +