Rotating a shape

Hi,
I have a problem what I’m trying to do is make my fillRect() Rotate constantly as it moves around a point
What i mean by this is, I have wrote the trigonometry so the fillRect() moves around a point constantly and then what I am trying to do is make the shape rotate as it goes around the point any help would be apprecited


import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
/**
 *
 * @author Administrator
 */
public class PhysicGUI extends JFrame
{
    
    private Trigonometry trig;
    private MoveAnim move;
    private Timer timer;

    private int x;
    private int y;    
    
    private double hypotenese;
    private double cosine;
    private double sine;
    private double counter;
    private int radianCounter;

    public PhysicGUI()
    {
        super();
        setSize( 500, 500 );
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        trig = new Trigonometry();
        move = new MoveAnim();
        timer = new Timer( 500, move );

        x = 250;
        y = 250;

        hypotenese = 60;
        sine = 0;
        cosine = 0;
        counter = 0;
        radianCounter = 0;
        timer.start();
    }

    public void paint( Graphics g )
    {
        super.paint( g );     
        Graphics2D g2d = ( Graphics2D )g;
        g2d.translate( 15, 15 );
        g2d.rotate( radianCounter++, x , y  );
        g2d.fillRect( x + ( int )trig.getCosine() ,
                    y + ( int )trig.getSine(), 30, 30 );
    }

    public void move()
    {
        double radian =  Math.toRadians( counter );
        cosine = Math.cos( radian ) * hypotenese;
        sine = Math.sin( radian ) * hypotenese;
        counter = counter + 30;

        if( counter > 360 )
        {
            counter = 0;
        }

    }    

    public class MoveAnim implements ActionListener
    {
        public void actionPerformed(ActionEvent e)
        {
            repaint();
            move();
        }
    }

    public static void main( String[]args )
    {
        PhysicGUI gui = new PhysicGUI();
        gui.setVisible( true );        
    }



}




Why are you translating by (15,15) before the call to rotate?
I assume the position of the point is (250,250)?

Hi,
Yes the x , y are 250 I was just kinda using stuff I found on the internet I don’t think translate should even be used?

Well the call to rotate already translates for you.
From the javadocs, rotate(theta,x,y) is the same as doing:
translate(x,y);
rotate(theta);
translate(-x,-y);

affine transformations?