示例#1
0
  /** paints the Spinner */
  public void paint(Graphics g) {
    int start_angle = 90;
    int done_angle = (int) (percentDone * 360);

    g.setColor(getBackground());
    g.fillArc(3, 3, getSize().width - 8, getSize().height - 8, 0, 360);

    g.setColor(getForeground());
    g.fillArc(3, 3, getSize().width - 8, getSize().height - 8, start_angle, done_angle);

    g.setColor(Color.black);
    g.drawArc(3, 3, getSize().width - 8, getSize().height - 8, 0, 360);
  }
示例#2
0
  /**
   * Draws and arc which looks like a curve.<br>
   * An ARC is a "piece" of an OVAL.<br>
   * The first 5 parameters (g and 4 ints) are the same as drawOval.<br>
   * There are 2 additional parameters for the starting degree value and finishing degree of the
   * arc. <br>
   * 0 degrees is at the 12:00 position and the degrees progress in a CLOCKWISE fashion. <br>
   * (90 degrees is at 3:00, 180 degrees is at 6:00, 270 degrees is at 9:00, 360 degrees is back at
   * 12:00).
   */
  public static void drawArc(
      Graphics g, int centerX, int centerY, int hRadius, int vRadius, int start, int finish) {
    int hDiameter = 2 * hRadius;
    int vDiameter = 2 * vRadius;

    if (finish < start) finish += 360;
    int newStart = 90 - start; // shifts starting position from 3:00 to 12:00
    int newFinish =
        start
            - finish; // as opposed to finish-start.  Subtracting backwards changes from
                      // counter-clockwise to clockwise.

    g.drawArc(centerX - hRadius, centerY - vRadius, hDiameter, vDiameter, newStart, newFinish);
  }
示例#3
0
  /**
   * @param g
   * @param col
   * @param row
   * @param iDir
   */
  void DrawBoundary(Graphics g, int col, int row, int iDir) {
    int x, y;

    x = col * 16;
    y = row * 16;

    switch (iDir) {
      case ctables.LEFT:
        // draw lower half segment
        if (iMaze[row + 1][col] != WALL)
          // down empty
          if (iMaze[row + 1][col - 1] != WALL)
          // left-down empty
          {
            // arc(x-8,y+8,270,0,6);
            g.drawArc(x - 8 - 6, y + 8 - 6, 12, 12, 270, 100);
          } else {
            g.drawLine(x - 2, y + 8, x - 2, y + 16);
          }
        else {
          g.drawLine(x - 2, y + 8, x - 2, y + 17);
          g.drawLine(x - 2, y + 17, x + 7, y + 17);
        }

        // Draw upper half segment
        if (iMaze[row - 1][col] != WALL)
          // upper empty
          if (iMaze[row - 1][col - 1] != WALL)
          // upper-left empty
          {
            // arc(x-8,y+7,0,90,6);
            g.drawArc(x - 8 - 6, y + 7 - 6, 12, 12, 0, 100);
          } else {
            g.drawLine(x - 2, y, x - 2, y + 7);
          }
        else {
          g.drawLine(x - 2, y - 2, x - 2, y + 7);
          g.drawLine(x - 2, y - 2, x + 7, y - 2);
        }
        break;

      case ctables.RIGHT:
        // draw lower half segment
        if (iMaze[row + 1][col] != WALL)
          // down empty
          if (iMaze[row + 1][col + 1] != WALL)
          // down-right empty
          {
            // arc(x+16+7,y+8,180,270,6);
            g.drawArc(x + 16 + 7 - 6, y + 8 - 6, 12, 12, 180, 100);
          } else {
            g.drawLine(x + 17, y + 8, x + 17, y + 15);
          }
        else {
          g.drawLine(x + 8, y + 17, x + 17, y + 17);
          g.drawLine(x + 17, y + 8, x + 17, y + 17);
        }
        // Draw upper half segment
        if (iMaze[row - 1][col] != WALL)
          // upper empty
          if (iMaze[row - 1][col + 1] != WALL)
          // upper-right empty
          {
            // arc(x+16+7,y+7,90,180,6);
            g.drawArc(x + 16 + 7 - 6, y + 7 - 6, 12, 12, 90, 100);
          } else {
            g.drawLine(x + 17, y, x + 17, y + 7);
          }
        else {
          g.drawLine(x + 8, y - 2, x + 17, y - 2);
          g.drawLine(x + 17, y - 2, x + 17, y + 7);
        }
        break;

      case ctables.UP:
        // draw left half segment
        if (iMaze[row][col - 1] != WALL)
          // left empty
          if (iMaze[row - 1][col - 1] != WALL)
          // left-upper empty
          {
            // arc(x+7,y-8,180,270,6);
            g.drawArc(x + 7 - 6, y - 8 - 6, 12, 12, 180, 100);
          } else {
            g.drawLine(x, y - 2, x + 7, y - 2);
          }

        // Draw right half segment
        if (iMaze[row][col + 1] != WALL)
          // right empty
          if (iMaze[row - 1][col + 1] != WALL)
          // right-upper empty
          {
            // arc(x+8,y-8,270,0,6);
            g.drawArc(x + 8 - 6, y - 8 - 6, 12, 12, 270, 100);
          } else {
            g.drawLine(x + 8, y - 2, x + 16, y - 2);
          }
        break;

      case ctables.DOWN:
        // draw left half segment
        if (iMaze[row][col - 1] != WALL)
          // left empty
          if (iMaze[row + 1][col - 1] != WALL)
          // left-down empty
          {
            // arc(x+7,y+16+7,90,180,6);
            g.drawArc(x + 7 - 6, y + 16 + 7 - 6, 12, 12, 90, 100);
          } else {
            g.drawLine(x, y + 17, x + 7, y + 17);
          }

        // Draw right half segment
        if (iMaze[row][col + 1] != WALL)
          // right empty
          if (iMaze[row + 1][col + 1] != WALL)
          // right-down empty
          {
            // arc(x+8,y+16+7,0,90,6);
            g.drawArc(x + 8 - 6, y + 16 + 7 - 6, 12, 12, 0, 100);
          } else {
            g.drawLine(x + 8, y + 17, x + 15, y + 17);
          }
        break;
    }
  }