Esempio n. 1
1
 public void paint(Graphics g) {
   imageLabel.setLocation(textField.getX() - 8, 2);
   super.paint(g);
   //    System.out.println( "panel paint" ) ;
 }
  @Override
  public void paint(Graphics g) {
    super.paint(g);
    connectUsers("Select * from users");
    CustomButton.setGraphics(g);
    ScaledPoint.setWindowDimensions(getWidth(), getHeight());

    if (help) // display help message
    {
      showHelp(g);
      return;
    }

    // Draw main GUI components
    drawStoreBG(g);
    drawStoreName(g);
    drawStoreImage(g);
    drawStoreMessage(g);
    drawInventory(g);
    drawBalance(g);
    drawPageIndicator(g);

    deactivateButtons();
    CustomButton.draw();
  }
 public void paint(Graphics g) {
   super.paint(g);
   if (mouseIn) {
     g.setColor(Color.blue);
     g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
   }
 }
Esempio n. 4
0
    /** paint class for drawing rectangles */
    public void paint(Graphics g) {

      // call superclass
      super.paint(g);

      // draw Fractal
      drawFractal(g, point, level, width, height);
    }
Esempio n. 5
0
  public void paint(Graphics g) {
    super.paint(g);

    Dimension size = getSize();
    double w = size.getWidth() - 50;
    double h = size.getHeight() + 20;

    try {
      readFile();
    } catch (IOException e) {
      System.err.println("IO issue");
    }

    barWidth = ((int) (w / numBars)) - 20;
    pos = 5;

    int xPos[] = {pos, pos, pos, pos};
    int yPos[] = {pos, pos, pos, pos};

    maxVal = maxValue(values);
    double barH, ratio;

    for (int i = 0; i < numBars - 1; i++) {
      Color col[] = new Color[numBars];
      for (int j = 0; j < numBars - 1; j++) {
        col[j] = new Color((int) (Math.random() * 0x1000000));
      }

      ratio = (double) values[i] / (double) maxVal;
      barH = ((h) * ratio) - 10;

      xPos[0] = pos;
      xPos[2] = pos + barWidth;
      xPos[1] = xPos[0];
      xPos[3] = xPos[2];
      yPos[0] = (int) h;
      yPos[1] = (int) barH;
      yPos[2] = yPos[1];
      yPos[3] = yPos[0];

      System.out.println(
          "xPos:" + xPos[1] + " yPos:" + yPos[0] + " h:" + h + " barH:" + barH + " ratio:" + ratio
              + " pos:" + pos);

      int stringPtsY[] = {
        ((i + 1) * 20) + 180, ((i + 1) * 20) + 200, ((i + 1) * 20) + 200, ((i + 1) * 20) + 180
      };
      int stringPtsX[] = {600, 600, 580, 580};

      g.setColor(col[i]);
      g.fillPolygon(xPos, yPos, xPos.length);

      g.fillPolygon(stringPtsX, stringPtsY, 4);
      g.setColor(Color.black);
      g.drawString(labels[i], 610, ((i + 1) * 20) + 195);
      pos = pos + barWidth + 10;
    }
  }
Esempio n. 6
0
  public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2 = (Graphics2D) g;
    int size =
        Math.min(
            MAX_SIZE,
            Math.min(
                getWidth() - imagePadding.left - imagePadding.right,
                getHeight() - imagePadding.top - imagePadding.bottom));

    g2.translate(getWidth() / 2 - size / 2, getHeight() / 2 - size / 2);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    Shape shape;

    if (mode == ColorPicker.SAT || mode == ColorPicker.BRI) {
      shape = new Ellipse2D.Float(0, 0, size, size);
    } else {
      Rectangle r = new Rectangle(0, 0, size, size);
      shape = r;
    }

    if (hasFocus()) {
      PaintUtils.paintFocus(g2, shape, 5);
    }

    if (!(shape instanceof Rectangle)) {
      // paint a circular shadow
      g2.translate(2, 2);
      g2.setColor(new Color(0, 0, 0, 20));
      g2.fill(new Ellipse2D.Float(-2, -2, size + 4, size + 4));
      g2.setColor(new Color(0, 0, 0, 40));
      g2.fill(new Ellipse2D.Float(-1, -1, size + 2, size + 2));
      g2.setColor(new Color(0, 0, 0, 80));
      g2.fill(new Ellipse2D.Float(0, 0, size, size));
      g2.translate(-2, -2);
    }

    g2.drawImage(image, 0, 0, size, size, 0, 0, size, size, null);

    if (shape instanceof Rectangle) {
      Rectangle r = (Rectangle) shape;
      PaintUtils.drawBevel(g2, r);
    } else {
      g2.setColor(new Color(0, 0, 0, 120));
      g2.draw(shape);
    }

    g2.setColor(Color.white);
    g2.setStroke(new BasicStroke(1));
    g2.draw(new Ellipse2D.Float(point.x - 3, point.y - 3, 6, 6));
    g2.setColor(Color.black);
    g2.draw(new Ellipse2D.Float(point.x - 4, point.y - 4, 8, 8));

    g.translate(-imagePadding.left, -imagePadding.top);
  }
 @Override
 public void paint(Graphics g) {
   super.paint(g);
   if (myTextField.isFocusOwner() || (getPopup() != null && getPopup().isPopupVisible())) {
     if (isUsingDarculaUIFlavor()) {
       DarculaUIUtil.paintFocusRing(g, 3, 3, getWidth() - 4, getHeight() - 4);
     }
   }
 }
    public void paint(Graphics g) {
      super.paint(g);

      if (myResizable && myDrawMacCorner) {
        g.drawImage(
            ourMacCorner,
            getX() + getWidth() - ourMacCorner.getWidth(this),
            getY() + getHeight() - ourMacCorner.getHeight(this),
            this);
      }
    }
Esempio n. 9
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);
      }
    }
  }
Esempio n. 10
0
  @Override
  public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;

    displayNames(g);
    displayWinner(g);
    g2d.drawImage(board.getImage(), board.getX(), board.getY(), null, null);

    for (int i = 0; i < 16; i++) {
      g2d.drawImage(pegs[i].getImage(), pegs[i].getX(), pegs[i].getY(), null, null);
      for (int j = 0; j < pegs[i].amountOfBeads2(); j++) {
        g2d.drawImage(
            pegs[i].beadAt(j).getImage(),
            pegs[i].beadAt(j).getX(),
            pegs[i].beadAt(j).getY(),
            null,
            null);
      }
    }

    if (availableBeads[currentBead].getImage() == null) {
      availableBeads[currentBead].loadImage();
    }

    g2d.drawImage(
        availableBeads[currentBead].getImage(),
        availableBeads[currentBead].getX(),
        availableBeads[currentBead].getY(),
        null,
        null);

    if (beadMustAnimate) {
      animationTimer = new Timer(ANIMATION_REFRESH_RATE, this); // every
      // REFRESH_RATE
      // ms
      animationTimer.setActionCommand("animation");
      animationTimer.start();
      beadMustAnimate = false;
      currentBead++;
      // creates next new bead
      availableBeads[currentBead] = new Bead(BEAD_INITIAL_X, BEAD_INITIAL_Y, 'b');
      availableBeads[currentBead].setImage(board.getBlackBeadImage());
    }
  }
Esempio n. 11
0
  @Override
  public void paint(Graphics g) {
    super.paint(g);

    // menu on game over
    if (c.getLifes() < 1) {
      showMenu = true;
    }

    this.paintBackground((Graphics2D) g);
    this.paintItems((Graphics2D) g);
    this.paintLifes((Graphics2D) g);
    this.paintScore((Graphics2D) g);
    this.paintMenu((Graphics2D) g);

    Toolkit.getDefaultToolkit().sync();
    g.dispose();
  }
  /**
   * Draw the icon at the specified location. Paints this component as an icon.
   *
   * @param c the component which can be used as observer
   * @param g the <tt>Graphics</tt> object used for painting
   * @param x the position on the X coordinate
   * @param y the position on the Y coordinate
   */
  public void paintIcon(Component c, Graphics g, int x, int y) {
    g = g.create();
    try {
      Graphics2D g2 = (Graphics2D) g;
      AntialiasingManager.activateAntialiasing(g2);

      g2.setColor(Color.WHITE);
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
      g2.fillRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10);
      g2.setColor(Color.DARK_GRAY);
      g2.drawRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10);

      // Indent component content from the border.
      g2.translate(x + 5, y + 5);

      super.paint(g2);

      g2.translate(x, y);
    } finally {
      g.dispose();
    }
  }
 public void paint(Graphics g) {
   super.paint(g);
   g.fillRect(x, y, weight, height);
 }