Esempio n. 1
0
  /** Overrides <code>Graphics.draw3DRect</code>. */
  public void draw3DRect(int x, int y, int width, int height, boolean raised) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info()
          .log(
              toShortString()
                  + " Drawing 3D rect: "
                  + new Rectangle(x, y, width, height)
                  + " Raised bezel: "
                  + raised);
    }
    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.draw3DRect(x, y, width, height, raised);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      Color oldColor = getColor();
      int i, count = (info.flashCount * 2) - 1;

      for (i = 0; i < count; i++) {
        graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
        graphics.draw3DRect(x, y, width, height, raised);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
      graphics.setColor(oldColor);
    }
    graphics.draw3DRect(x, y, width, height, raised);
  }
Esempio n. 2
0
  public void draw(Graphics g) {
    animate();

    g.setColor(Color.black);
    g.fillRect(0, 0, dim.width, dim.height);
    g.setColor(Color.white);

    numpaint++;
    DebugPrinter dbg = new DebugPrinter(g, 50, 60);
    dbg.print(
        "Spring-mass demo by yigal irani, drag balls or create new ones by clicking inside box");
    dbg.print("frame", numpaint);
    dbg.print("fps", 1 / timer.time_diff);

    Point top_left = point_by_vec(new Vec(-1, 1));
    g.draw3DRect(top_left.x, top_left.y, screen_dist(2), screen_dist(2), true);
    for (int i = 0; i < springs.size(); i++) {
      Spring spring = springs.get2(i);
      Point p1 = point_by_vec(balls.get2(spring.start).pos);
      Point p2 = point_by_vec(balls.get2(spring.end).pos);
      g.drawLine(p1.x, p1.y, p2.x, p2.y);
    }
    for (int i = 0; i < balls.size(); i++) {
      Ball ball = balls.get2(i);
      Point p = point_by_vec(ball.pos);
      int screen_radius = screen_dist(RADIUS);
      g.setColor(Color.blue);
      g.fillOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.setColor(Color.white);
      g.drawOval(p.x - screen_radius, p.y - screen_radius, screen_radius * 2, screen_radius * 2);

      g.drawString("" + i, p.x, p.y);
    }
  }
Esempio n. 3
0
    public void paint(Graphics g) {
      Dimension dim = getSize();

      g.draw3DRect(1, 1, dim.width - 3, dim.height - 3, true);
      g.setColor(Color.black);
      g.drawRect(0, 0, dim.width - 1, dim.height - 1);
    }
 public void doPaintSquare(Graphics g) {
   int h = height;
   g.setColor(bgColor);
   int bx = text.length() == 0 ? 0 : 2;
   int by = text.length() == 0 ? 0 : (h - boxWidth) / 2 + 1;
   g.fillRect(bx + 2, by + 2, boxWidth - 4, boxWidth - 4);
   if (state || pressState) {
     Color c = Color.LightGray;
     if (!pressState) {
       if (!state) c = bgColor;
       else c = Color.Black;
     }
     Pen oldpen = g.setPen(new Pen(c, Pen.SOLID, 2));
     g.drawLine(bx + 4, by + boxWidth - 5, bx + boxWidth - 5, by + 4);
     g.drawLine(bx + 4, by + boxWidth - 5, bx + 4, by + boxWidth - 10);
     //				g.drawLine(bx+3,by+3,bx+boxWidth-5,by+boxWidth-5);
     //				g.drawLine(bx+3,by+boxWidth-5,bx+boxWidth-5,by+3);
     g.setPen(oldpen);
   }
   g.draw3DRect(
       new Rect(bx, by, boxWidth, boxWidth),
       ButtonObject.checkboxEdge,
       true,
       null,
       Color.DarkGray);
 }
Esempio n. 5
0
  @Override
  public synchronized void paint(Graphics g) {
    Dimension d = getSize();

    // Create the offscreen graphics context
    if (offGrfx == null || (offSize.width != d.width) || (offSize.height != d.height)) {
      offSize = d;
      offImage = createImage(d.width, d.height);
      offGrfx = offImage.getGraphics();
    }

    // Paint the background with 3D effects
    offGrfx.setColor(getBackground());
    offGrfx.fillRect(1, 1, d.width - 2, d.height - 2);
    offGrfx.draw3DRect(0, 0, d.width - 1, d.height - 1, raised);
    offGrfx.setColor(getForeground());

    // Paint the clock
    if (digital) {
      drawDigitalClock(offGrfx);
    } else {
      drawAnalogClock(offGrfx);
    }

    // Paint the image onto the screen
    g.drawImage(offImage, 0, 0, null);
  }
Esempio n. 6
0
 public void paint(Graphics g) {
   Dimension size = getSize();
   int top = VGAP;
   int bottom = size.height - 1 - VGAP;
   int height = bottom - top;
   g.setColor(getBackground());
   for (int i = 0, x = HGAP; i < columns; i++, x += WIDTH + STEP) {
     g.draw3DRect(x, top, WIDTH, height, true);
   }
 }
Esempio n. 7
0
 /** *************************************************************************************** */
 public void drawCell(Graphics g, boolean setPiece) {
   if (color != null) {
     g.setColor(color);
     g.fill3DRect(x, y, CELL_HEIGHT, CELL_WIDTH, true);
   } else {
     g.draw3DRect(x, y, CELL_HEIGHT, CELL_WIDTH, true);
   }
   /*if (p != null)
   {
   	p.drawPiece(g, x, y, setPiece);
   }*/
 }
Esempio n. 8
0
  //	重写paint方法
  public void paint(Graphics g) {
    super.paint(g);
    //		float lineWidth = 3.0f;
    //	    ((Graphics2D)g).setStroke(new BasicStroke(lineWidth));
    //		将坦克的活动区域填充为默认黑色
    g.fillRect(0, 0, 800, 600);
    this.drawTank(hero.getX(), hero.getY(), g, hero.getDirection(), 1);

    for (int i = 0; i < hero.bombs.size(); i++) {
      Bomb myBomb = hero.bombs.get(i);
      // 画出一颗子弹
      if (myBomb != null && myBomb.isLive == true) {
        //			float lineWidth = 2.0f;
        //			((Graphics2D) g).setStroke(new BasicStroke(lineWidth));//设置线条为粗线
        g.draw3DRect(myBomb.x, myBomb.y, 2, 2, true);
      }
      if (myBomb.isLive == false) {
        hero.bombs.remove(myBomb);
      }
    }
    //		画出爆炸
    for (int i = 0; i < baozhas.size(); i++) {
      BaoZha bz = baozhas.get(i);
      System.out.println("baozhas.size()= " + baozhas.size());
      if (bz.life > 5) {
        g.drawImage(image3, bz.x, bz.y, 30, 30, this);
      } else if (bz.life > 3) {
        g.drawImage(image2, bz.x, bz.y, 30, 30, this);
      } else {
        g.drawImage(image1, bz.x, bz.y, 30, 30, this);
      }
      bz.liftDown();
      if (bz.life == 0) {
        baozhas.remove(bz);
      }
    }

    //		画出敌人的坦克
    for (int i = 0; i < ets.size(); i++) {
      EnemyTank et = ets.get(i);
      if (et.isLive) {

        this.drawTank(et.getX(), et.getY(), g, et.getDirection(), 0);
      }
    }
  }
 public void TopDraw(Graphics g) {
   // draws 1st card in foundation
   if (getSizeDeck() > 0) {
     CardClass temporaryCard = getCard(0);
     temporaryCard.setCentre(getDeckCentreX(), getDeckCentreY());
     temporaryCard.draw(g);
   }
   // if foundation empty - a large suit shape is drawn instead
   else {
     g.setColor(Color.white);
     g.fill3DRect(getDeckCentreX() - 35, getDeckCentreY() - 50, 70, 100, true);
     g.setColor(Color.black);
     g.draw3DRect(getDeckCentreX() - 35, getDeckCentreY() - 50, 70, 100, true);
     if (Suitfoundation == 'h') {
       HeartClass heart = new HeartClass();
       heart.setHeight(30);
       heart.setCentre(getDeckCentreX(), getDeckCentreY());
       heart.setColor(Color.red);
       heart.draw(g);
     } else if (Suitfoundation == 'd') {
       DiamondClass diamond = new DiamondClass();
       diamond.setHeight(30);
       diamond.setCentre(getDeckCentreX(), getDeckCentreY());
       diamond.setColor(Color.red);
       diamond.draw(g);
     } else if (Suitfoundation == 's') {
       SpadeClass spade = new SpadeClass();
       spade.setHeight(30);
       spade.setCentre(getDeckCentreX(), getDeckCentreY());
       spade.setColor(Color.black);
       spade.draw(g);
     } else if (Suitfoundation == 'c') {
       ClubClass club = new ClubClass();
       club.setHeight(30);
       club.setCentre(getDeckCentreX(), getDeckCentreY());
       club.setColor(Color.black);
       club.draw(g);
     }
   }
 }
Esempio n. 10
0
  public void paint(Graphics g) {
    Rectangle r = g.getClipBounds();

    showStatus("x: " + r.x + " y: " + r.y + " w: " + r.width + " h: " + r.height);

    for (int i = 0; i < numRects; i++) {
      Point lhc = randomPoint(); // left hand corner
      Dimension size = randomDimension();

      g.setColor(colors[(int) (Math.random() * 10)]);

      if (round) {
        if (fill)
          g.fillRoundRect(
              lhc.x,
              lhc.y,
              size.width,
              size.height,
              (int) (Math.random() * 250),
              (int) (Math.random() * 250));
        else
          g.drawRoundRect(
              lhc.x,
              lhc.y,
              size.width,
              size.height,
              (int) (Math.random() * 250),
              (int) (Math.random() * 250));
      } else if (threeD) {
        g.setColor(Color.lightGray);

        if (fill) g.fill3DRect(lhc.x, lhc.y, size.width, size.height, raise);
        else g.draw3DRect(lhc.x, lhc.y, size.width, size.height, raise);
      } else {
        if (fill) g.fillRect(lhc.x, lhc.y, size.width, size.height);
        else g.drawRect(lhc.x, lhc.y, size.width, size.height);
      }
      raise = raise ? false : true;
    }
  }
Esempio n. 11
0
 public void frostCake(Color myColor, Graphics myGraphics) {
   myGraphics.setColor(myColor);
   myGraphics.fill3DRect(15, 5, 200, 200, true);
   myGraphics.draw3DRect(15, 5, 200, 190, true);
 }
Esempio n. 12
0
  public void paint(Graphics g) {
    super.paint(g);
    // 画出我的坦克(到时再封装成函数)
    g.setColor(Color.darkGray);
    g.fillRect(0, 0, 400, 300);

    // 画出提示信息
    this.showInfo(g);

    // 画出自己的坦克
    if (myTank.alive) {
      this.drawTank(myTank.getX(), myTank.getY(), g, myTank.direct, 0);
    }
    // 绘制子弹
    // 从bb中取出每一颗子弹并绘制(遍历)
    for (int i = 0; i < this.myTank.bb.size(); i++) {
      // 取出一颗子弹
      Bullet myBullet = myTank.bb.get(i);
      // 下面是画出一颗子弹
      if (myBullet != null && myBullet.alive == true) {
        g.draw3DRect(myBullet.x, myBullet.y, 2, 2, false);
      }
      // 判断子弹死亡之后从Vector移除
      if (myBullet.alive == false) {
        myTank.bb.remove(myBullet);
      }
    }
    // 画出炸弹
    for (int i = 0; i < bombs.size(); i++) {
      //            System.out.println("bombs.size()="+bombs.size());
      // 取出炸弹
      Bomb bomb = bombs.get(i); // 不需要强转,因为用了泛型
      //            System.out.println("炸弹炸弹炸弹"+bomb);
      if (bomb.life > 6) {
        // 画出最大的效果
        g.drawImage(image3, bomb.x, bomb.y, 30, 30, this);
      } else if (bomb.life > 3) {
        g.drawImage(image2, bomb.x, bomb.y, 30, 30, this);
      } else {
        g.drawImage(image1, bomb.x, bomb.y, 30, 30, this);
      }

      // 让bomb的生命值减小
      bomb.lifeDown();
      // 如果炸弹值生命值为零,就把炸弹从Vector中去掉
      if (bomb.life == 0) {
        bombs.remove(bomb);
      }
    }

    // 画出敌人的坦克
    for (int i = 0; i < enemySize; i++) {
      EnemyTank et = enemyTanks.get(i);

      if (et.alive) {
        this.drawTank(et.getX(), et.getY(), g, et.direct, 1);
        // 再画出敌人的子弹
        for (int j = 0; j < et.bb.size(); j++) {
          // 取出一颗子弹
          Bullet enemyBullet = et.bb.get(j);
          if (enemyBullet.alive) {
            g.draw3DRect(enemyBullet.x, enemyBullet.y, 1, 1, false);
          } else {
            // 如果敌人的坦克死亡就从Vector去掉
            et.bb.remove(enemyBullet);
          }
        }
      }
    }
  }
 public void draw3DRect(int x, int y, int width, int height, boolean raised) {
   super.draw3DRect(x, y, width, height, raised);
 }