Example #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);
  }
Example #2
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);
    }
Example #3
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);
  }
  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);
    }
  }
 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);
   }
 }
Example #6
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);
   }*/
 }
Example #7
0
  private static void paintRectangle(Graphics g, RemoteRectangle rectangle, boolean fill) {

    try {
      Rectangle bounds = rectangle.getBounds();
      if (fill) g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
      else
        // g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
        g.draw3DRect(bounds.x, bounds.y, bounds.width, bounds.height, false);
    } catch (Exception e) {
      e.printStackTrace();
      // System.out.println(e);
    }
  }
Example #8
0
 @Override
 public void paintComponent(Graphics g) {
   g.clearRect(0, 0, this.getWidth(), this.getHeight());
   int cc = 150 / this.titleSize;
   for (int i = 0; i < Animation.getInstance().getTileSetsCount(); i++) {
     g.setColor(Color.WHITE);
     g.fillRect(i * viewSize.width, titleSize, viewSize.width - 1, viewSize.height - 1);
     g.setColor(Color.LIGHT_GRAY);
     for (int y = titleSize / 8; y < (titleSize + viewSize.height) / 8; y++) {
       for (int x = i * viewSize.width / 8; x < (i + 1) * viewSize.width / 8; x++) {
         if ((y + x) % 2 == 1) {
           g.fillRect(x * 8, y * 8, 8, 8);
         }
       }
     }
     Animation.getInstance()
         .getTileSet(i)
         .paintPreview(
             g, i * this.viewSize.width + 2, this.titleSize + 2, this.viewSize.width - 4);
     Color labelColor = Color.BLACK;
     if (this.selectedIndex == i) {
       labelColor = Color.BLUE;
     }
     for (int j = 0; j < this.titleSize; j++) {
       g.setColor(
           new Color(
               labelColor.getRed(), labelColor.getGreen(), labelColor.getBlue(), 105 + j * cc));
       g.drawLine(
           i * this.viewSize.width,
           j + 1,
           i * this.viewSize.width + this.viewSize.width - this.titleSize + j,
           j + 1);
     }
     if (this.selectedIndex == i) {
       g.setColor(Color.BLUE);
     } else {
       g.setColor(Color.BLACK);
     }
     g.draw3DRect(
         i * (this.viewSize.width),
         this.titleSize,
         this.viewSize.width - 1,
         this.viewSize.height - 1,
         true);
     g.setColor(Color.WHITE);
     g.drawString(
         Animation.getInstance().getTileSet(i).getName(),
         i * (this.viewSize.width) + 2,
         this.titleSize - 2);
   }
 }
 @Override
 /** */
 public void paint(Graphics g) {
   if (bounds != null) {
     if (connectIcon != null) {
       g.drawImage(connectIcon.getImage(), bounds.x, bounds.y, bounds.width, bounds.height, null);
     } else if (handleEnabled) {
       g.setColor(Color.BLACK);
       g.draw3DRect(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1, true);
       g.setColor(Color.LIGHT_GRAY);
       g.fill3DRect(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2, true);
       g.setColor(Color.BLUE);
       g.drawRect(bounds.x + bounds.width / 2 - 1, bounds.y + bounds.height / 2 - 1, 1, 1);
     }
   }
 }
Example #10
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);
     }
   }
 }
Example #12
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;
    }
  }
  // display various lines, rectangles and ovals
  public void paintComponent(Graphics g) {
    super.paintComponent(g); // call superclass's paint method

    this.setBackground(Color.WHITE);

    g.setColor(Color.RED);
    g.drawLine(5, 30, 380, 30);

    g.setColor(Color.BLUE);
    g.drawRect(5, 40, 90, 55);
    g.fillRect(100, 40, 90, 55);

    g.setColor(Color.BLACK);
    g.fillRoundRect(195, 40, 90, 55, 50, 50);
    g.drawRoundRect(290, 40, 90, 55, 20, 20);

    g.setColor(Color.GREEN);
    g.draw3DRect(5, 100, 90, 55, true);
    g.fill3DRect(100, 100, 90, 55, false);

    g.setColor(Color.MAGENTA);
    g.drawOval(195, 100, 90, 55);
    g.fillOval(290, 100, 90, 55);
  } // end method paintComponent
Example #14
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);
 }
Example #15
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 paintComponent(Graphics g) {
   g.drawImage(MainFrame.background, 0, 0, this.getWidth(), this.getHeight(), null);
   g.draw3DRect(63, 126 - 30, 306, 465, false);
   this.repaint();
 }