hey so i have lego nxt with has a gyroscope that gives me angles.
i have managed that the net sends me the value's.
But now i want to have a rectangle on the screen with rotates according to the gyroscope value.
i have this code now.

Java Code:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;

import javax.swing.JComponent;
import javax.swing.JFrame;


class MyCanvas extends JComponent {
  public void paint(Graphics g) {
	   Graphics2D graphics2 = (Graphics2D) g;
       Rectangle2D rectangle = new Rectangle2D.Float(100, 100, 240, 160);
       AffineTransform orig = graphics2.getTransform();
       graphics2.rotate(Math.toRadians(45),100,100);
       graphics2.draw(rectangle);
  }

}

public class Main {
  public static void main(String[] a) {
    JFrame window = new JFrame();
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setBounds(30, 30, 300, 300);
    window.getContentPane().add(new MyCanvas());
    window.setVisible(true);
 
  }
}
but how would i rotate the rectangle to a value that i get in the main class?