#Rotate ImageView

1 messages · Page 1 of 1 (latest)

fervent plank
#

I have an GridPane like 3x3. Every cell in the gridpane is a stackpanne which has an imageView inside.
The pane has to rotate left or right, when you click on the cell.

My problem is, when i click on a cell and the image should rotateLeft the Image does not rotate and fit the cell in height and width.

//Code 
public void rotateLeft(int x, int y) {

        this.paneGameField[x][y].setRotate(-90);
        setRotated(this.paneGameField[x][y].getRotate() == -90 ,(ImageView) this.paneGameField[x]        [y].getChildren().get(0),this.paneGameField[x][y]);
    }

 private void setRotated(boolean rotated, ImageView targetNode, Pane parent) {
        double angle;
        if (rotated) {
            angle = 90;
            targetNode.fitWidthProperty().bind(parent.heightProperty());
            targetNode.fitHeightProperty().bind(parent.widthProperty());
        } else {
            angle = 0;
            targetNode.fitWidthProperty().bind(parent.widthProperty());
            targetNode.fitHeightProperty().bind(parent.heightProperty());
        }
        targetNode.setRotate(angle);

    }

feral muralBOT
# fervent plank I have an GridPane like 3x3. Every cell in the gridpane is a stackpanne which ha...

Detected code, here are some useful tools:

Formatted code
//Code 
public void rotateLeft(int x, int y) {
  this .paneGameField[x] [y] .setRotate( - 90);
  setRotated(this .paneGameField[x] [y] .getRotate() ==  - 90, (ImageView) this .paneGameField[x] [y] .getChildren().get(0), this .paneGameField[x] [y] );
}
private void setRotated(boolean rotated, ImageView targetNode, Pane parent) {
  double angle;
  if (rotated) {
    angle = 90;
    targetNode.fitWidthProperty().bind(parent.heightProperty());
    targetNode.fitHeightProperty().bind(parent.widthProperty());
  }
  else {
    angle = 0;
    targetNode.fitWidthProperty().bind(parent.widthProperty());
    targetNode.fitHeightProperty().bind(parent.heightProperty());
  }
  targetNode.setRotate(angle);
}
#

<@&987246487241105418> please have a look, thanks.

feral muralBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.