@Override
 public void repaint(Graphics graphics) {
   if (show) {
     final FontMetrics fm = graphics.getFontMetrics();
     graphics.setFont(calibri);
     for (GroundItem groundItem : ctx.groundItems.select().select(displayFilter)) {
       graphics.setColor(Color.BLACK);
       final Point center = groundItem.centerPoint();
       final String displayString =
           groundItem.name()
               + " x"
               + groundItem.stackSize()
               + " - $"
               + format.format((priceMap.get(groundItem.id()) * groundItem.stackSize()));
       final int width = fm.stringWidth(displayString);
       final int height = fm.getHeight();
       graphics.fillRoundRect(
           center.x - (width / 2), center.y + (height / 2), width + 4, height + 5, 10, 10);
       graphics.setColor(Color.WHITE);
       graphics.drawString(
           displayString, center.x - (width / 2) + 2, center.y + (height / 2) + height);
     }
   }
 }
Beispiel #2
0
  @Override
  public void repaint(Graphics g) {
    if (tiles.size() >= 2) {
      g.setColor(new Color(255, 255, 255, 255));
      Tile[] t = new Tile[tiles.size()];
      tiles.toArray(t);
      Area a = new Area(t);
      for (int i = 0; i < a.getPolygon().npoints; i++) {
        Point p =
            new Point(
                tiles.get(i).matrix(ctx).bounds().xpoints[0],
                tiles.get(i).matrix(ctx).bounds().ypoints[0]);
        Point pp;
        if (i == a.getPolygon().npoints - 1)
          pp =
              new Point(
                  tiles.get(0).matrix(ctx).bounds().xpoints[0],
                  tiles.get(0).matrix(ctx).bounds().ypoints[0]);
        else
          pp =
              new Point(
                  tiles.get(i + 1).matrix(ctx).bounds().xpoints[0],
                  tiles.get(i + 1).matrix(ctx).bounds().ypoints[0]);
        g.drawLine(p.x, p.y, pp.x, pp.y);
      }
      g.drawPolygon(a.getPolygon());

      if (a.contains(ctx.players.local())) {
        g.setColor(new Color(0, 255, 0, 100));
      } else {
        g.setColor(new Color(255, 0, 0, 100));
      }
      g.fillPolygon(ctx.players.local().tile().matrix(ctx).bounds());
    } else {
      g.setColor(new Color(255, 0, 0, 100));
      g.fillPolygon(ctx.players.local().tile().matrix(ctx).bounds());
    }
    for (int i = 0; i < tiles.size(); i++) {
      if (i == gui.tileList.getSelectedIndex()) g.setColor(Color.yellow);
      else g.setColor(new Color(0, 0, 255, 150));
      g.fillPolygon(tiles.get(i).matrix(ctx).bounds());
    }
  }