SHARE
TWEET

Untitled

pawnee Nov 14th, 2019 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Main extends Application {
  2.  
  3.     private final Canvas canvas = new Canvas(770, 800);
  4.  
  5.     @Override
  6.     public void start(Stage primaryStage) throws Exception {
  7.         FXMLLoader loader = new FXMLLoader(getClass().getResource("/nawa.fxml"));
  8.         Controller c = new Controller(canvas.getGraphicsContext2D());
  9.         loader.setController(c);
  10.         AnchorPane root = loader.load();
  11.  
  12.         primaryStage.setTitle("Waypoints");
  13.         primaryStage.setScene(new Scene(root));
  14.  
  15.         Stage field = new Stage();
  16.         FlowPane pane = new FlowPane();
  17.         pane.getChildren().add(canvas);
  18.         field.setScene(new Scene(pane));
  19.         field.show();
  20.         primaryStage.show();
  21.     }
  22.  
  23.     public static void main(String[] args) {
  24.         launch(args);
  25.     }
  26. }
  27.  
  28. aypoint;
  29.     @FXML
  30.     private TextField XPos;
  31.     @FXML
  32.     private TextField YPos;
  33.  
  34.     private double input_x = 15;
  35.     private double input_y = 15;
  36.     private int x = 0;
  37.     private int y = 0;
  38.     private int index = 0;
  39.     private final int radius = 20;
  40.  
  41.     private HashMap<Integer, String> waypoints = new HashMap<>();
  42.     private GraphicsContext gc;
  43.  
  44.     public Controller(GraphicsContext gc) {
  45.         this.gc = gc;
  46.     }
  47.  
  48.     @FXML
  49.     public void Handler(ActionEvent event) {
  50.         if (event.getSource() == addWaypoint) {
  51.             try {
  52.                 input_x = Integer.parseInt(XPos.getText());
  53.                 input_y = Integer.parseInt(YPos.getText());
  54.                 System.out.println(input_x + " - " + input_y);
  55.             } catch (NumberFormatException e) {
  56.                 input_x = 0;
  57.                 input_y = 0;
  58.             }
  59.  
  60.             calculatePositions();
  61.             drawWaypoints(x, y, gc);
  62. //            drawField(gc);
  63. //            waypoints.put(index, x + ";" + y);
  64. //            index++;
  65.         }
  66.     }
  67.  
  68.     // and all the rest
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top