Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main extends Application {
- private final Canvas canvas = new Canvas(770, 800);
- @Override
- public void start(Stage primaryStage) throws Exception {
- FXMLLoader loader = new FXMLLoader(getClass().getResource("/nawa.fxml"));
- Controller c = new Controller(canvas.getGraphicsContext2D());
- loader.setController(c);
- AnchorPane root = loader.load();
- primaryStage.setTitle("Waypoints");
- primaryStage.setScene(new Scene(root));
- Stage field = new Stage();
- FlowPane pane = new FlowPane();
- pane.getChildren().add(canvas);
- field.setScene(new Scene(pane));
- field.show();
- primaryStage.show();
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
- aypoint;
- @FXML
- private TextField XPos;
- @FXML
- private TextField YPos;
- private double input_x = 15;
- private double input_y = 15;
- private int x = 0;
- private int y = 0;
- private int index = 0;
- private final int radius = 20;
- private HashMap<Integer, String> waypoints = new HashMap<>();
- private GraphicsContext gc;
- public Controller(GraphicsContext gc) {
- this.gc = gc;
- }
- @FXML
- public void Handler(ActionEvent event) {
- if (event.getSource() == addWaypoint) {
- try {
- input_x = Integer.parseInt(XPos.getText());
- input_y = Integer.parseInt(YPos.getText());
- System.out.println(input_x + " - " + input_y);
- } catch (NumberFormatException e) {
- input_x = 0;
- input_y = 0;
- }
- calculatePositions();
- drawWaypoints(x, y, gc);
- // drawField(gc);
- // waypoints.put(index, x + ";" + y);
- // index++;
- }
- }
- // and all the rest
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement