Exemplo n.º 1
0
  private void drawPlayer(
      Graphics g,
      Location<Float> location,
      CluedoCharacter character,
      double step,
      boolean drawTransparent) {

    double diameter = step * PlayerDiameterRatio;

    final double characterBorderRatio = 1.2f;

    g.setColor(new Color(0.f, 0.f, 0.f, drawTransparent ? 0.2f : 1.f)); // Draw the black outline
    g.fillOval(
        round(location.x - diameter * characterBorderRatio / 2),
        round(location.y - diameter * characterBorderRatio / 2),
        round(diameter * characterBorderRatio),
        round(diameter * characterBorderRatio));

    // Draw the character.
    g.setColor(
        new Color(
            character.colour().getRed(),
            character.colour().getGreen(),
            character.colour().getBlue(),
            drawTransparent ? 50 : 255));
    g.fillOval(
        round(location.x - diameter / 2),
        round(location.y - diameter / 2),
        round(diameter),
        round(diameter));
  }
Exemplo n.º 2
0
    public void paint(Graphics g) {
      g.setColor(Color.black);
      g.fillRect(0, 0, (int) getSize().getWidth(), (int) getSize().getHeight());

      int color_strength = 0;
      for (int i = 0; i < pheroMap.length; i++)
        for (int j = 0; j < pheroMap[i].length; j++) {
          if (pheroMap[i][j] == null) System.err.println(i + " " + j);
          if (pheroMap[i][j].getWallProbability() != 0) {
            color_strength =
                (int) (pheroMap[i][j].getWallProbability() * 100.0 * COLOR_SCALE_FACTOR);
            if (color_strength > 255) color_strength = 255;

            if (pheroMap[i][j].getWallProbability() > 0.55) {
              g.setColor(new Color(255, 255 - color_strength, 255 - color_strength));
            }
            if (pheroMap[i][j].getWallProbability() < 0.55) {
              g.setColor(
                  new Color(255 - color_strength, 255 - color_strength, 255 - color_strength));
            }
            if (pheroMap[i][j].getWallProbability() == 0.55) {
              g.setColor(new Color(255, 255, 255));
            }
            g.fillRect(
                i * square_side,
                (pheroMap[i].length - j - 1) * square_side,
                square_side,
                square_side);
          }
        }

      g.setColor(Color.black);
      for (int y = square_side * 10; y < getSize().getHeight(); y += square_side * 10)
        g.drawLine(0, y, (int) getSize().getWidth() - 1, y);
      for (int x = square_side * 10; x < getSize().getWidth(); x += square_side * 10)
        g.drawLine(x, 0, x, (int) getSize().getHeight());

      if (points != null) {
        for (Point2D pt : points) {
          g.setColor(Color.yellow);
          g.fillOval(
              (int) (pt.getX() * 10 * square_side) - 12,
              (int) ((pheroMap[0].length - (pt.getY() * 10)) * square_side) - 12,
              25,
              25);
        }
      }

      g.setColor(Color.blue);
      g.fillOval(
          (int) (rob_x) * square_side - 20,
          (int) ((pheroMap[0].length - 10) - (rob_y)) * square_side - 20,
          ROBOT_RADIUS,
          ROBOT_RADIUS);

      // g.setColor(new Color(0, 0, 0));
      // g.fillRect( 24*2*square_side, 12*2*square_side, square_side, square_side);
    }
Exemplo n.º 3
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    g.drawOval(5, 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
    g.setColor(Color.red);
    g.drawOval(getWidth() / 2 + 5, 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
    g.setColor(Color.yellow);
    g.fillOval(5, getHeight() / 2 + 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
    g.setColor(Color.orange);
    g.fillOval(getWidth() / 2 + 5, getHeight() / 2 + 5, getWidth() / 2 - 10, getHeight() / 2 - 10);
  }
Exemplo n.º 4
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    calcSizes();
    drawAxes(g);
    calcMaxes();
    calcTickIncrements();
    drawXTicks(g);
    drawYTicks(g);

    int t = 0;
    int prevX = 0, prevY1 = 0, prevY2 = 0;

    for (DataPair pair : data) {

      int h = pair.getH();
      int p = pair.getP();

      // calculate where to put the dots
      int x = xVal(t, maxT);
      int y1 = yVal(h, maxH);
      int y2 = yVal(p, maxP);

      // draw herbivore dot
      g.setColor(Color.BLUE);
      g.fillOval(x, y1, 2 * r, 2 * r);

      // draw a line connecting this dot to the last
      if (prevX != 0) {
        g.drawLine(prevX + r, prevY1 + r, x + r, y1 + r);
      }

      // draw predator dot
      g.setColor(Color.RED);
      g.fillOval(x, y2, 2 * r, 2 * r);

      // draw a line connecting this dot to the last
      if (prevX != 0) {
        g.drawLine(prevX + r, prevY2 + r, x + r, y2 + r);
      }

      // remember these dots
      prevX = x;
      prevY1 = y1;
      prevY2 = y2;

      g.setColor(Color.BLACK);

      t++;
    }
  }
  @Override
  public void paint(Graphics g) {
    System.out.println("Thread invoked the paint() " + Thread.currentThread().getName());
    g.setColor(Color.BLACK);
    g.setFont(textFont);
    g.drawString(timeMessage, 0, 15);
    g.fillOval(0, 20, 100, 100);

    g.setColor(Color.WHITE);
    g.fillOval(3, 23, 94, 94);

    g.setColor(Color.BLUE);
    g.fillArc(2, 22, 96, 96, 90, -arcLen);
  }
  // Paint the round background and label.
  protected void paintComponent(Graphics g) {
    if (getModel().isArmed()) {
      // You might want to make the highlight color
      // a property of the RoundButton class.
      g.setColor(Color.lightGray);
    } else {
      g.setColor(getBackground());
    }
    g.fillOval(0, 0, getSize().width - 1, getSize().height - 1);

    // This call will paint the label and the
    // focus rectangle.
    super.paintComponent(g);
  }
Exemplo n.º 7
0
  /** Wartet auf einen Mausklick und gibt die Koordinaten von diesem zurück. */
  @SneakyThrows
  private Point getMouseClick() {
    if (mouseAdapter == null) {
      mouseAdapter =
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              synchronized (ScenePane.this) {
                lastClick = new Point(e.getX(), e.getY());
                ScenePane.this.notifyAll();
              }
            }
          };
      addMouseListener(mouseAdapter);
    }

    synchronized (this) {
      lastClick = null;
      while (lastClick == null) {
        wait();
      }
      Graphics g = getGraphics();
      g.setColor(Color.CYAN);
      g.fillOval(lastClick.x - 5, lastClick.y - 5, 11, 11);
      return lastClick;
    }
  }
Exemplo n.º 8
0
 @Override
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(CANVAS_BACKGROUND);
   g.setColor(LINE_COLOR);
   g.fillOval(x, y, size, size); // draw the ball
 }
Exemplo n.º 9
0
  public void paintComponent(Graphics g) {

    GradientPaint gradient = new GradientPaint(70, 70, Color.blue, 150, 150, Color.orange);
    Image image = new ImageIcon("a.jpg").getImage();
    Random generator = new Random();

    int x1 = generator.nextInt(200) + 1;
    int y1 = generator.nextInt(200) + 1;
    int x2 = x1 + generator.nextInt(100) + 1;
    int y2 = x1 + generator.nextInt(100) + 1;

    g.setColor(Color.blue);
    g.fillRect(70, 70, 200, 100);

    g.setColor(Color.black);
    g.fillOval(80, 80, 170, 70);

    Graphics2D g2d = (Graphics2D) g;

    g.setColor(Color.yellow);
    g2d.fill3DRect(10, 10, 100, 100, true);

    g.drawImage(image, 300, 300, this);

    g2d.setPaint(gradient);
    g2d.fillOval(x1, y1, x2, y2);
  }
Exemplo n.º 10
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(Color.black);
   add(l);
   add(s);
   drawSpecialLines(g);
   g.setColor(Color.white);
   g.fillOval(30, 100, 75, 75);
   g.setColor(Color.blue);
   g.fillRect(getWidth() / 2, getHeight() / 2, (int) bl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 40, (int) gl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 80, (int) ll, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 120, (int) sl, 10);
   g.drawImage(bullet.getImage(), 30, getHeight() / 2 - 10, 20, 20, null);
   g.drawImage(grenade.getImage(), 30, getHeight() / 2 + 40 - 10, 20, 20, null);
   g.drawImage(laser.getImage(), 30, getHeight() / 2 + 80 - 10, 20, 20, null);
   g.drawImage(shotgun.getImage(), 30, getHeight() / 2 + 120 - 10, 20, 20, null);
   g.setColor(Color.yellow);
   if (gunTrack == 0) {
     g.drawRect(30, getHeight() / 2 - 10, 20, 20);
   } else if (gunTrack == 1) {
     g.drawRect(30, getHeight() / 2 + 40 - 10, 20, 20);
   } else if (gunTrack == 2) {
     g.drawRect(30, getHeight() / 2 + 80 - 10, 20, 20);
   } else {
     g.drawRect(30, getHeight() / 2 + 120 - 10, 20, 20);
   }
 }
Exemplo n.º 11
0
 public void drawTo(Graphics g, Line line) {
   if (!calc.tileOnMap(t1) || !calc.tileOnMap(t2)) return;
   if (calc.tileOnMap(line.getTile1()) && calc.tileOnMap(line.getTile2())) {
     Point p1 = calc.tileToMinimap(t1);
     Point p2 = calc.tileToMinimap(t2);
     Point p3 = calc.tileToMinimap(line.getTile2());
     Point p4 = calc.tileToMinimap(line.getTile1());
     GeneralPath path = new GeneralPath();
     path.moveTo(p1.x, p1.y);
     path.lineTo(p2.x, p2.y);
     path.lineTo(p3.x, p3.y);
     path.lineTo(p4.x, p4.y);
     path.closePath();
     g.setColor(POLY_FILL);
     ((Graphics2D) g).fill(path);
     ((Graphics2D) g).draw(path);
   }
   Point last = null, p;
   g.setColor(Color.ORANGE);
   for (RSTile t : pathList) {
     if (calc.tileOnMap(t)) {
       p = calc.tileToMinimap(t);
       g.fillOval(p.x - 2, p.y - 2, 5, 5);
       if (last != null) g.drawLine(p.x, p.y, last.x, last.y);
       last = p;
     } else last = null;
   }
 }
Exemplo n.º 12
0
    @Override
    public void paintComponent(Graphics g) {
      super.paintComponent(g);

      AnAction action = getAction();
      if (action instanceof ActivateCard) {
        Rectangle bounds = getBounds();

        Icon icon = AllIcons.Actions.Forward; // AllIcons.Icons.Ide.NextStepGrayed;
        int y = (bounds.height - icon.getIconHeight()) / 2;
        int x = bounds.width - icon.getIconWidth() - 15;

        if (getPopState() == POPPED) {
          final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
          g.setColor(WelcomeScreenColors.CAPTION_BACKGROUND);
          g.fillOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6);

          g.setColor(WelcomeScreenColors.GROUP_ICON_BORDER_COLOR);
          g.drawOval(x - 3, y - 3, icon.getIconWidth() + 6, icon.getIconHeight() + 6);
          config.restore();
        } else {
          icon = IconLoader.getDisabledIcon(icon);
        }

        icon.paintIcon(this, g, x, y);
      }
    }
Exemplo n.º 13
0
 // färger, se sid 43 i boken
 // grafiska metoder, sid 248 i boken
 public void paintComponent(Graphics g) { // för att vara säker på att
   // "super"-klassen gör sitt
   // anropar vi den metoden, innan
   // vi skriver eller ritar
   super.paintComponent(g);
   g.drawLine(185, 10, 195, 40); // x1,y1 till x2,y2
   g.drawLine(200, 10, 200, 40);
   g.drawLine(215, 10, 205, 40);
   g.setColor(Color.white);
   g.fillOval(50, 30, 300, 150); // x,y,b,h (x,y för ö v h)
   g.setColor(Color.red);
   g.drawArc(100, 100, 200, 50, 180, 180); // x,y,b,h,s,l
   g.setColor(Color.yellow);
   g.fillRect(200, 100, 30, 30);
   g.fill3DRect(150, 50, 30, 50, true); // true upphöjd figur
   g.fill3DRect(250, 50, 30, 50, true);
   // skriv ut en textsträng, samt ange läget i avståndet från
   // övre vänstra hörnet i x-led åt höger och i y-led neråt
   g.drawString("** Tjenare kompis !! **", 20, 20);
   f = new Font("Arial", Font.BOLD, 30);
   setBackground(Color.cyan);
   g.setFont(f);
   g.setColor(new Color(255, 175, 175));
   g.drawString("YEEEEEEEES!!", 100, 250);
 }
Exemplo n.º 14
0
 /**
  * Draw character in minimap
  *
  * @param g Graphics
  * @param Dx X Displacement
  * @param Dy Y Displacement
  */
 public void MapDraw(Graphics g, int Dx, int Dy, double Scale, Color col) {
   // Color
   g.setColor(col.darker().darker().darker());
   g.drawOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
   g.setColor(col);
   g.fillOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
 }
Exemplo n.º 15
0
    private void displayTree(Graphics g, AVLTree.TreeNode root, int x, int y, int gap) {
      if (root != null) {
        // Display root
        if (setOfHighlightedNodes.contains(root)) {
          g.setColor(Color.GREEN);
          g.fillOval(x - radius, y - radius, 2 * radius, 2 * radius);
          g.setColor(Color.BLACK);
        } else {
          g.drawOval(x - radius, y - radius, 2 * radius, 2 * radius);
        }

        g.drawString(root.element + "", x - 6, y + 4);

        // Draw a line to the left node
        if (root.left != null) connectLeftChild(g, x - gap, y + virticalGap, x, y);

        // Draw left subtree
        displayTree(g, root.left, x - gap, y + virticalGap, gap / 2);

        // Draw a line to the right node
        if (root.right != null) connectRightChild(g, x + gap, y + virticalGap, x, y);

        // Draw right subtree
        displayTree(g, root.right, x + gap, y + virticalGap, gap / 2);
      }
    }
Exemplo n.º 16
0
 public void draw(Graphics g) {
   if (running) {
     g.setColor(color);
     synchronized (pos) {
       g.fillOval(pos.x, pos.y, SIZE, SIZE);
     }
   }
 }
Exemplo n.º 17
0
 public void paintComponent(Graphics g) {
   super.paintComponent(
       g); // do what paintComponent does, and i will tell you what to do from now on
   for (int i = list.size(); i > 0; i--) {
     g.fillOval(800 + list.get(i - 1).getX(), 800 + list.get(i - 1).getY(), 10, 10);
     System.out.println("X: " + list.get(i - 1).getX() + " Y: " + list.get(i - 1).getY());
   }
 }
Exemplo n.º 18
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.LIGHT_GRAY);
    g.fillRect(0, 0, 600, 400);

    g.setColor(color);
    g.fillOval(a, b, 70, 70);
  }
Exemplo n.º 19
0
 @Override
 public void mouseDragged(MouseEvent me) {
   Graphics g = getGraphics();
   g.setColor(bg);
   x = me.getX();
   y = me.getY();
   g.setColor(Color.RED);
   g.fillOval(x - 12, y - 10, 30, 30);
 }
Exemplo n.º 20
0
 public void mouseClicked(MouseEvent me) {
   Graphics g = getGraphics();
   g.setColor(bg);
   // g.fillRect(x, y, 30, 30);
   x = me.getX();
   y = me.getY();
   g.setColor(Color.RED);
   g.fillOval(x - 12, y - 10, 30, 30);
 }
Exemplo n.º 21
0
 public void paintComponent(Graphics g) {
   if (position == null) return;
   int x = (int) position.getX();
   int y = (int) position.getY();
   if (parent.inFirstPath(this)) {
     g.setColor(Color.yellow);
     g.fillOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
   } else if (parent.inQueue(this)) {
     g.setColor(Color.orange);
     g.fillOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
   }
   g.setColor(getColor());
   g.drawOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
   if (parent.isGoalNode(this)) g.setColor(Color.green);
   else if (parent.isStartNode(this)) g.setColor(Color.blue);
   g.drawString(toString(), x, y);
   if (!parent.getHideHeur()) g.drawString(model.getHeuristic() + "", x + RADIUS, y + RADIUS);
 }
Exemplo n.º 22
0
 @Override
 public void paint(Graphics g) {
   super.paint(g);
   for (Ball b : ballsList) {
     g.setColor(b.getColor());
     g.fillOval(b.getX(), b.getY(), b.getSize(), b.getSize());
     b.move(getWidth(), getHeight());
   }
 }
Exemplo n.º 23
0
  public void drawTank(int x, int y, Graphics g, int direct, int type) {

    switch (type) {
      case 0:
        g.setColor(Color.YELLOW); // 0 定义为英雄 颜色设置成黄色
        break;
      case 1:
        g.setColor(Color.BLUE); // 1定义为敌人 颜色设置成CYAN色
        break;
    }

    switch (direct) {
      case 0: // 0定位为向上
        g.fill3DRect(x, y, 5, 30, false); // 画出左边矩形	
        g.fill3DRect(x + 15, y, 5, 30, false); // 画出右边矩形
        g.fill3DRect(x + 5, y + 5, 10, 20, false); // 画出中间矩形
        g.fillOval(x + 5, y + 9, 10, 10); // 画出中间圆
        g.drawLine(x + 10, y + 15, x + 10, y);
        break;

      case 1: // 定义1为向右
        g.fill3DRect(x, y, 30, 5, false); // 画出上部矩形	
        g.fill3DRect(x, y + 15, 30, 5, false); // 画出下部矩形
        g.fill3DRect(x + 5, y + 5, 20, 10, false); // 画出中间矩形
        g.fillOval(x + 10, y + 5, 10, 10); // 画出中间圆
        g.drawLine(x + 15, y + 10, x + 30, y + 10);
        break;
      case 2: // 向下
        g.fill3DRect(x, y, 5, 30, false); // 画出左边矩形	
        g.fill3DRect(x + 15, y, 5, 30, false); // 画出右边矩形
        g.fill3DRect(x + 5, y + 5, 10, 20, false); // 画出中间矩形
        g.fillOval(x + 5, y + 9, 10, 10); // 画出中间圆
        g.drawLine(x + 10, y + 15, x + 10, y + 30);
        break;

      case 3:
        g.fill3DRect(x, y, 30, 5, false); // 画出上部矩形	
        g.fill3DRect(x, y + 15, 30, 5, false); // 画出下部矩形
        g.fill3DRect(x + 5, y + 5, 20, 10, false); // 画出中间矩形
        g.fillOval(x + 10, y + 5, 10, 10); // 画出中间圆
        g.drawLine(x + 15, y + 10, x, y + 10);
        break;
    }
  }
Exemplo n.º 24
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int borderSize = 10;
    int radius = 3;
    double x_scale = (double) (this.getWidth() - borderSize * 2) / maxX;
    double y_scale = (double) (this.getHeight() - borderSize * 2) / maxY;
    double scale = Math.min(x_scale, y_scale);

    if (lastRoutine != null) {
      g.setColor(Color.red);
      for (int i = 0; i < lastRoutine.getSize(); i++) {
        g.fillOval(
            (int) (lastRoutine.getX(i) * scale - radius),
            (int) (lastRoutine.getY(i) * scale - radius),
            2 * radius,
            2 * radius);
        if (i != 0) {
          g.drawLine(
              (int) (lastRoutine.getX(i) * scale),
              (int) (lastRoutine.getY(i) * scale),
              (int) (lastRoutine.getX(i - 1) * scale),
              (int) (lastRoutine.getY(i - 1) * scale));
        }
      }
    }
    if (currentRoutine != null) {
      g.setColor(Color.black);
      for (int i = 0; i < currentRoutine.getSize(); i++) {
        g.fillOval(
            (int) (currentRoutine.getX(i) * scale - radius),
            (int) (currentRoutine.getY(i) * scale - radius),
            2 * radius,
            2 * radius);
        if (i != 0) {
          g.drawLine(
              (int) (currentRoutine.getX(i) * scale),
              (int) (currentRoutine.getY(i) * scale),
              (int) (currentRoutine.getX(i - 1) * scale),
              (int) (currentRoutine.getY(i - 1) * scale));
        }
      }
      lastRoutine = currentRoutine;
    }
  }
Exemplo n.º 25
0
 void circle(Graphics g, double x, double y, int st) {
   switch (st) {
     case Block.BLANK:
       return;
     case Block.RED_BEAD:
       switch (gst.theme) {
         case 0:
           g.setColor(Color.RED);
           break;
         case 1:
           g.setColor(Color.BLACK);
           break;
         case 2:
           g.drawImage(
               gold,
               (int) (x - bst.scale * r3 / 2 * 0.75),
               (int) (y - bst.scale * r3 / 2 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               Color.WHITE,
               null);
           return;
       }
       break;
     case Block.BLUE_BEAD:
       switch (gst.theme) {
         case 0:
           g.setColor(Color.BLUE);
           break;
         case 1:
           g.setColor(new Color(1, 175, 1));
           break;
         case 2:
           g.drawImage(
               silver,
               (int) (x - bst.scale * r3 / 2 * 0.75),
               (int) (y - bst.scale * r3 / 2 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               Color.WHITE,
               null);
           return;
       }
       break;
     case Block.RED_PATH:
     case Block.BLUE_PATH:
       g.setColor(Color.GREEN);
       break;
   }
   g.fillOval(
       (int) (x - bst.scale * r3 / 2 * 0.75),
       (int) (y - bst.scale * r3 / 2 * 0.75),
       (int) (bst.scale * r3 * 0.75),
       (int) (bst.scale * r3 * 0.75));
 }
Exemplo n.º 26
0
 public void paintLogo(Graphics g, Color color, int size, int posX, int posY) {
   if (g == null) return;
   super.paint(g);
   g.setColor(color);
   g.fillRect(posX, posY, size, size);
   if (color == Color.WHITE) g.setColor(Color.LIGHT_GRAY);
   else g.setColor(Color.WHITE);
   g.fillOval(posX + 5, posY + 5, size - 10, size - 10);
   g.setColor(Color.BLACK);
   g.fillRect(posX + (size / 2) - 5, posY + (size / 2) - 5, 10, 10);
 }
Exemplo n.º 27
0
 public void paint(Graphics g) {
   for (int i = 0; i < circleCount; i++) {
     g.setColor(Ccolors[i]);
     g.fillOval(
         circles[i].getX(), circles[i].getY(), circles[i].getRadius(), circles[i].getRadius());
   }
   for (int i = 0; i < squareCount; i++) {
     g.setColor(Scolors[i]);
     g.fillRect(squares[i].getX(), squares[i].getY(), squares[i].getSide(), squares[i].getSide());
   }
 }
Exemplo n.º 28
0
  // Draws this die when rolling with a random number of dots
  private void drawRolling(Graphics g) {
    int x = xCenter - dieSize / 2 + (int) (3 * Math.random()) - 1;
    int y = yCenter - dieSize / 2 + (int) (3 * Math.random()) - 1;
    g.setColor(Color.RED);

    if (x % 2 != 0) g.fillRoundRect(x, y, dieSize, dieSize, dieSize / 4, dieSize / 4);
    else g.fillOval(x - 2, y - 2, dieSize + 4, dieSize + 4);

    Die die = new Die();
    die.roll();
    drawDots(g, x, y, die.getNumDots());
  }
Exemplo n.º 29
0
 /**
  * Adds pixel to queue and calls repaint() whenever we have MAX_ITEMS pixels in the queue or
  * when MAX_TIME msecs have elapsed (whichever comes first). The advantage compared to just
  * calling repaint() after adding a pixel to the queue is that repaint() can most often draw
  * multiple points at the same time.
  */
 public void drawPoint(DrawCommand c) {
   if (c == null || gr == null) return;
   Color col = new Color(c.rgb);
   gr.setColor(col);
   gr.fillOval(c.x, c.y, 10, 10);
   repaint();
   if (state != null) {
     synchronized (state) {
       state.put(new Point(c.x, c.y), col);
     }
   }
 }
Exemplo n.º 30
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   g.setColor(Color.GREEN);
   g.drawString("Round" + count, 10, 10);
   for (int i = 0; i < array.length; i++) {
     for (int j = 0; j < array[i].length; j++) {
       if (array[i][j] == 0) {
         g.setColor(Color.ORANGE);
         g.drawOval(j * 10 + 5, i * 10 + 15, 10, 10);
         g.fillOval(j * 10 + 5, i * 10 + 15, 10, 10);
       } else g.setColor(Color.RED);
       g.drawOval(j * 10 + 5, i * 10 + 15, 10, 10);
       g.fillOval(j * 10 + 5, i * 10 + 15, 10, 10);
     }
   }
   g.setColor(Color.BLUE);
   if (stateMes.length() > 13) {
     g.drawString(stateMes.substring(0, 13), 10, array.length * 10 + 30);
     g.drawString(stateMes.substring(14, stateMes.length()), 10, array.length * 10 + 40);
   } else g.drawString(stateMes, 10, array.length * 10 + 30);
   repaint();
 }