title: Proper way to move a JavaFx8 node around
body: <p>I am working on an app which needs to move nodes around on a pane. </p>
  
  <p>I've just recently started learning javaFx 8 so I have bare understanding of the workflow, but while I managed to get a working draggable node code working, it uses node.setTranslateX() and .setTranslateY().</p>
  
  <p>This is all fine, until I tried to make the node snap to a grid that divides the scene area in both 10 height and width subdivisions.</p>
  
  <p>Whenever I try to use modulos to get some sort of snapping going on, I'm stuck with the fact that I'm calling Translation transformation. I'd like to directly set the coordinates of the node myself. I've tried node.relocate(x,y) to no avail. As for node.setX() or node.setY(). These do no seem to do much.</p>
  
  <p>So basically, I have two questions:</p>
  
  <ul>
  <li>Is there a way to directly set the coordinates of a node ? If yes, how ?</li>
  <li>What is the correct way to snap a node to a grid while dragging it with the mouse ?</li>
  </ul>
  
  <p>My current code uses these methods to drag the node around:</p>
  
  <pre><code>public class Boat extends ImageView {
      private int size ;
      private String name ;
      private Double dragDeltaX, dragDeltaY;
  
      //Constructor etc here//
  
      this.setOnMousePressed(event -&gt; {
          this.setCursor(Cursor.CLOSED_HAND);
          dragDeltaX = this.getLayoutX() + event.getX();
          dragDeltaY = this.getLayoutY() + event.getY();
      });
  
      this.setOnMouseReleased(event -&gt; {
          this.setCursor(Cursor.OPEN_HAND);
          this.relocate(event.getSceneX(), event.getSceneY());
      });
  
      this.setOnMouseDragged(event -&gt; {
          this.setTranslateX(event.getSceneX() - dragDeltaX);
          this.setTranslateY(event.getSceneY() - dragDeltaY);
      });
  
      this.setOnMouseEntered(event -&gt; {
          this.setCursor(Cursor.OPEN_HAND);
      });
  }
  </code></pre>
  
  <p>Thanks in advance for the help,</p>