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();


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