title: JavaFX ImageView rotation changes drag and drop
body: <p>So I have an ImageView that can be dragged and dropped using the mouse and rotated 90 degrees with a button click. Both of these things work when done independently (so the ImageView can be rotated or moved, not both). When i rotate the ImageView and attempt to move it, it seems to move randomly. </p>
  
  <p>I rotate the ImageView using:</p>
  
  <pre><code>imageView.setRotate(90);
  </code></pre>
  
  <p>This results in the seemingly random movement i was talking about.</p>
  
  <p>I also tried to rotate the ImageView using:</p>
  
  <pre><code>imageView.getTransforms().add(new Rotate(rotation, position + (width / 2), position + (height / 2));
  </code></pre>
  
  <p>Position being the images position on screen. Width and height being the ImageView's width and height. </p>
  
  <p>This worked for the most part (the ImageView no longer moves in an unexpected way), however now it can be moved and placed outside the bounds of the Pane (javafx.scene.layout.Pane), which is its parent. </p>
  
  <p>The way the ImageView is kept within the bounds is:</p>
  
  <pre><code>imageView.setOnMouseDragged(new EventHandler&lt;MouseEvent&gt;(){
              public void handle(MouseEvent e) {
                  if(!e.isPrimaryButtonDown()) return;
  
                  ImageView iv = (ImageView) e.getSource();
  
                  if(e.getX() &gt; iv.getParent().getTranslateX()) iv.setX(e.getX());
                  if(e.getY() &gt; iv.getParent().getTranslateY()) iv.setY(e.getY());
              }
          });
  </code></pre>
  
  <p>The Parent to this is the Pane stated earlier. This works fine up until the ImageView is rotated.</p>
  
  <p>I'm not sure where to go from here so I'm grateful for any help. Thanks.</p>
  
  <hr>
  
  <p>EDIT TO ORIGINAL QUESTION:</p>
  
  <p>Using the second method of rotation :</p>
  
  <pre><code>imageView.getTransforms().add(new Rotate(rotation, position + (width / 2), position + (height / 2));
  </code></pre>
  
  <p>This method works apart from the fact that the translations for x and y change i rotate the ImageView. For example if i move my mouse right on an image that is rotated 90 degrees then then the position for e.getX() in my MouseDraggedEvent doesn't change but e.getY() decreases. This indicates that the way e.getX() and e.getY() are dependent on the rotation of the ImageView. </p>
  
  <p>Is there a way to rotate without effecting the ImageView's x and y coords?</p>