예제 #1
0
  public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setColor(Color.black);
    g2.fillRect(0, 0, 10, 70);
    g2.fillRect(60, 0, 10, 70);
    g2.fillRect(120, 0, 10, 70);

    g2.fillRect(0, 0, 130, 10);
    g2.fillRect(0, 60, 130, 10);

    g2.fillRect(70, 30, 50, 10);
    g2.fillRect(90, 10, 10, 50);

    fill(g2, fullRect, RoadDirection.CENTER);
    fill(g2, nw, RoadDirection.NW);
    fill(g2, ne, RoadDirection.NE);
    fill(g2, sw, RoadDirection.SW);
    fill(g2, se, RoadDirection.SE);

    g2.setFont(Font.decode("Arial-10"));
    g2.setColor(Color.black);
    SwingUtils.drawCenteredString(g, "CENTER", (int) fullRectStrPos.x, (int) fullRectStrPos.y);
    SwingUtils.drawCenteredString(g, "NW", (int) nwStrPos.x, (int) nwStrPos.y);
    SwingUtils.drawCenteredString(g, "NE", (int) neStrPos.x, (int) neStrPos.y);
    SwingUtils.drawCenteredString(g, "SW", (int) swStrPos.x, (int) swStrPos.y);
    SwingUtils.drawCenteredString(g, "SE", (int) seStrPos.x, (int) seStrPos.y);
  }
예제 #2
0
    protected BufferedImage makeImage() {
      BufferedImage image =
          new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_4BYTE_ABGR);
      Graphics2D g = image.createGraphics();

      g.setPaint(Color.WHITE);
      g.fill3DRect(0, 0, IMAGE_SIZE, IMAGE_SIZE, false);

      g.setPaint(Color.RED);
      g.setFont(Font.decode("ARIAL-BOLD-50"));

      g.drawString(Long.toString(++this.counter) + " frames", 10, IMAGE_SIZE / 4);
      g.drawString(
          Long.toString((System.currentTimeMillis() - start) / 1000) + " sec", 10, IMAGE_SIZE / 2);
      g.drawString(
          "Heap:" + Long.toString(Runtime.getRuntime().totalMemory()), 10, 3 * IMAGE_SIZE / 4);

      g.dispose();

      return image;
    }