コード例 #1
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (drawOverlay) {
      g = g.create();
      AntialiasingManager.activateAntialiasing(g);

      try {
        // Paint a roll over fade out.
        FadeTracker fadeTracker = FadeTracker.getInstance();

        float visibility = 0.0f;
        if (fadeTracker.isTracked(this, FadeKind.ROLLOVER)) {
          visibility = fadeTracker.getFade(this, FadeKind.ROLLOVER);
          visibility /= 4;
        } else visibility = 0.5f;

        // Draw black overlay
        g.setColor(new Color(0.0f, 0.0f, 0.0f, visibility));
        g.fillRoundRect(1, 1, width - 2, height - 2, 10, 10);

        // Draw arrow
        g.setColor(Color.WHITE);

        int[] arrowX = new int[] {width - 17, width - 7, width - 12};
        int[] arrowY = new int[] {height - 12, height - 12, height - 7};
        g.fillPolygon(arrowX, arrowY, arrowX.length);
      } finally {
        g.dispose();
      }
    }
  }
コード例 #2
0
ファイル: Board.java プロジェクト: ankeshs/hex
  public void drawHexBoard(Graphics g) {
    g.setColor(Color.BLACK);
    double mx1, mx2, mx3, mx4, my1, my2, my3, my4; // Margin attributes

    mx1 = data.a[0][0].x - bst.scale * (r3 / 2 + 0.5);
    mx2 = data.a[0][bst.getOrder() - 1].x + bst.scale * (r3 + 1);
    mx3 = data.a[bst.getOrder() - 1][0].x - bst.scale * (r3 + 1);
    mx4 = data.a[bst.getOrder() - 1][bst.getOrder() - 1].x + bst.scale * (r3 / 2 + 0.5);
    my1 = data.a[0][0].y - bst.scale * 1.5;
    my2 = data.a[0][bst.getOrder() - 1].y - bst.scale * 1.5;
    my3 = data.a[bst.getOrder() - 1][0].y + bst.scale * 1.5;
    my4 = data.a[bst.getOrder() - 1][bst.getOrder() - 1].y + bst.scale * 1.5;

    g.fillPolygon(
        getIntArray(new double[] {mx1, mx2, mx4, mx3}),
        getIntArray(new double[] {my1, my2, my4, my3}),
        4);
    switch (gst.theme) {
      case 0:
        g.setColor(Color.RED);
        break;
      case 1:
        g.setColor(Color.BLACK);
        break;
      case 2:
        g.setColor(Color.YELLOW);
        break;
    }
    g.fillPolygon(
        getIntArray(new double[] {mx1 + 1, mx3 + 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my1 + 1, my3 - 1, (my2 + my3) / 2}),
        3);
    g.fillPolygon(
        getIntArray(new double[] {mx2 - 1, mx4 - 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my2 + 1, my4 - 1, (my2 + my3) / 2}),
        3);
    switch (gst.theme) {
      case 0:
        g.setColor(Color.BLUE);
        break;
      case 1:
        g.setColor(new Color(1, 175, 1));
        break;
      case 2:
        g.setColor(Color.lightGray);
    }
    g.fillPolygon(
        getIntArray(new double[] {mx1 + 1, mx2 - 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my1 + 1, my2 + 1, (my2 + my3) / 2}),
        3);
    g.fillPolygon(
        getIntArray(new double[] {mx3 + 1, mx4 - 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my3 - 1, my4 - 1, (my2 + my3) / 2}),
        3);

    for (int i = 0; i < bst.getOrder(); i++)
      for (int j = 0; j < bst.getOrder(); j++) {
        g.setColor(Color.BLACK);
        g.fillPolygon(getIntArray(data.a[i][j].polyX), getIntArray(data.a[i][j].polyY), 6);
        g.setColor(Color.WHITE);
        g.fillPolygon(getIntArray(data.a[i][j].polyXIn()), getIntArray(data.a[i][j].polyYIn()), 6);
        g.setColor(Color.BLACK);
        double x = data.a[i][j].x, y = data.a[i][j].y;
        g.drawLine((int) x, (int) y, (int) x + 1, (int) y + 1);
        circle(g, x, y, data.a[i][j].getState());
      }
    if (ptm == null) return;
    if (ptm.length == 0) return;
    for (int i = 0; i < ptm.length; i++) {
      g.setColor(Color.YELLOW);
      g.fillPolygon(
          getIntArray(data.a[ptm[i][0]][ptm[i][1]].polyXIn()),
          getIntArray(data.a[ptm[i][0]][ptm[i][1]].polyYIn()),
          6);
      g.setColor(Color.BLACK);
      double x = data.a[ptm[i][0]][ptm[i][1]].x, y = data.a[ptm[i][0]][ptm[i][1]].y;
      circle(g, x, y, data.a[ptm[i][0]][ptm[i][1]].getState());
    }
  }