title: How do I refresh opengl (Java JOGL) display after a specific time interval using Animator?
body: <p>I am trying to rotate a line around a center, and show the rotation using animator in java opengl. I want to make the animation happen faster, i.e. I want to clear the canvas after every .5 seconds. My guess was <em>setSwapInterval</em> is doing the trick, but it only takes an integer as a parameter so I can't really change the animation time less than 1 unit. </p>
  
  <p>This should be simple, but I couldn't figure out which parameter is actually controlling the animation time interval. </p>
  
  <p>My global variables:</p>
  
  <pre><code>double sec_theta = 0; 
  </code></pre>
  
  <p>The animator gets started in the main method:</p>
  
  <pre><code>Animator animator = new Animator(canvas);
  animator.start();
  </code></pre>
  
  <p>The display method: </p>
  
  <pre><code>@Override
  public void display(GLAutoDrawable drawable) {
      final GL2 gl = drawable.getGL().getGL2();
      gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
      sec_theta -=6;
      double r = .6;
      double x_center = 0;
      double y_center = 0;
      rotate_line(r,x_center,y_center,r-.1,0,gl);
  }
  </code></pre>
  
  <p>This is where the drawing gets done:</p>
  
  <pre><code>public void rotate_line(double r,double x_center, double y_center,double sec_x, double sec_y, GL2 gl){
          double radian = Math.toRadians(sec_theta);
          double new_x = sec_x*Math.cos(radian)-sec_y*Math.sin(radian);
          double new_y = sec_x*Math.sin(radian)+sec_y*Math.cos(radian);
          double new_x_center = x_center*Math.cos(radian)-y_center*Math.sin(radian);
          double new_y_center = x_center*Math.sin(radian)+y_center*Math.cos(radian);
          drawHand(new_x_center,new_y_center,new_x,new_y,gl);
      }
  public void drawHand(double x_center,double y_center,double end_x, double end_y, GL2 gl){
          gl.glBegin (GL2.GL_LINES);
          gl.glColor3f(1, 1, 1);
          gl.glVertex3d(x_center,y_center, 0);
          gl.glVertex3d(end_x,end_y, 0);
          gl.glEnd();
          gl.glFlush();
      }
  </code></pre>
  
  <p>The init method:</p>
  
  <pre><code>@Override
  public void init(GLAutoDrawable drawable) {
      drawable.getGL().setSwapInterval(1);
  }
  </code></pre>