diff --git a/src/main/Controller.java b/src/main/Controller.java new file mode 100644 index 0000000..3dc786e --- /dev/null +++ b/src/main/Controller.java @@ -0,0 +1,54 @@ +package main; + +/** + * Created by kristopherguzman on 11/19/16. + */ + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.fxml.FXML; +import javafx.scene.Scene; +import javafx.scene.canvas.Canvas; +import javafx.scene.control.Label; +import javafx.scene.control.Slider; +import javafx.scene.control.SplitPane; +import javafx.scene.layout.AnchorPane; + +import java.text.DecimalFormat; + +public class Controller { + + @FXML private AnchorPane controlPanel; + @FXML private AnchorPane canvasPanel; + @FXML private SplitPane rootPane; + @FXML private Canvas canvas; + @FXML private Slider offsetSlider; + @FXML private Slider zoomSlider; + @FXML private Label offsetLabel; + @FXML private Label zoomLabel; + + private double MIN_OFFSET = 0.000000000000000001; //10^-18 + private double MAX_OFFSET = 0.0000000000000009; //9x10^-16 + private int maxResolution = 100; + + private DecimalFormat df = new DecimalFormat(".##"); + + @FXML private void initialize() { + + offsetSlider.valueProperty().addListener(((observable, oldValue, newValue) -> { + offsetLabel.setText("Offset: " + newValue); + })); + + 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"); + })); + + } + + + +} diff --git a/src/main/Main.java b/src/main/Main.java index 8302cfe..31bcbce 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -1,7 +1,9 @@ package main; import javafx.application.Application; +import javafx.fxml.FXMLLoader; import javafx.scene.Group; +import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; @@ -22,58 +24,17 @@ public static void main(String[] args) { } - public void start(Stage primaryStage) { + public void start(Stage primaryStage) throws Exception { - primaryStage.setTitle("Test"); - Group root = new Group(); - Canvas canvas = new Canvas(800, 600); - root.getChildren().add(canvas); - GraphicsContext gc = canvas.getGraphicsContext2D(); - for(int i = 0; i <= 360; i+= 10) { - gc.setLineWidth(5); - gc.beginPath(); - gc.moveTo(400, 300); - double x = 400 + (400 * Math.cos(Math.toRadians(i))); - double y = 300 + (300 * Math.sin(Math.toRadians(i))) - 50; - System.out.println("X: " + x + "Y: " + y + " i: " + i); - gc.lineTo(x,y); - gc.stroke(); - gc.closePath(); - - } - - for(int i = 5; i <= 360; i+= 10) { - - gc.setStroke(Color.GREEN); - gc.setLineWidth(3); - gc.beginPath(); - gc.moveTo(400, 300); - double x = 400 + (400 * Math.cos(Math.toRadians(i))); - double y = 300 + (300 * Math.sin(Math.toRadians(i))) - 50; - System.out.println("X: " + x + "Y: " + y + " i: " + i); - gc.lineTo(x,y); - gc.stroke(); - gc.closePath(); - - } - - for(double i = 2.5; i <= 360; i+= 5) { - - gc.setStroke(Color.RED); - gc.setLineWidth(2); - gc.beginPath(); - gc.moveTo(400, 300); - double x = 400 + (400 * Math.cos(Math.toRadians(i))); - double y = 300 + (300 * Math.sin(Math.toRadians(i))) - 50; - System.out.println("X: " + x + "Y: " + y + " i: " + i); - gc.lineTo(x,y); - gc.stroke(); - gc.closePath(); - - } - - primaryStage.setScene(new Scene(root)); + FXMLLoader loader = new FXMLLoader(); + Parent root = FXMLLoader.load(getClass().getResource("../view/view.fxml")); + primaryStage.setTitle("Nonrobust CCW"); + Scene scene = new Scene(root); + primaryStage.setScene(scene); + primaryStage.setResizable(false); primaryStage.show(); + } + } diff --git a/src/view/view.fxml b/src/view/view.fxml new file mode 100644 index 0000000..1793676 --- /dev/null +++ b/src/view/view.fxml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +