コード例 #1
0
 /**
  * Draws the widget.
  *
  * @param g The object that draws things.
  */
 public void draw(Graphics2D screen) {
   // Animate!
   if (System.nanoTime() - timestamp >= CENTISECOND * 50) {
     timestamp = System.nanoTime();
     if (image == frames.get(0)) {
       image = frames.get(1);
     } else {
       image = frames.get(0);
     }
   }
   ROVector2f position = body.getPosition();
   float angle = body.getRotation();
   boolean hflip = false;
   boolean vflip = false;
   if (currentDirection == Direction.WEST) {
     hflip = false;
   } else if (currentDirection == Direction.EAST) {
     hflip = true;
   } else if (currentDirection == Direction.NORTH) {
     angle += Math.PI / 2;
     vflip = false;
   } else if (currentDirection == Direction.SOUTH) {
     angle += Math.PI / 2;
     vflip = true;
   }
   drawImage(
       position.getX(),
       position.getY(),
       getWidth(),
       getHeight(),
       angle,
       hflip,
       vflip,
       image,
       screen);
 }
コード例 #2
0
ファイル: TJUnitTest.java プロジェクト: sbesson/bioformats
 private static double getTime() {
   return (double) System.nanoTime() / 1.0e9;
 }