コード例 #1
0
  // Draw four blazes of a fan
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    int xCenter = getSize().width / 2;
    int yCenter = getSize().height / 2;
    int radius = (int) (Math.min(getSize().width, getSize().height) * 0.4);

    int x = xCenter - radius;
    int y = yCenter - radius;

    g.fillArc(x, y, 2 * radius, 2 * radius, 0, 30);
    g.fillArc(x, y, 2 * radius, 2 * radius, 90, 30);
    g.fillArc(x, y, 2 * radius, 2 * radius, 180, 30);
    g.fillArc(x, y, 2 * radius, 2 * radius, 270, 30);
  }
コード例 #2
0
  @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);
  }
コード例 #3
0
ファイル: Expo.java プロジェクト: Dominik-Licari/schoolwork
  /**
   * Draws a "solid" arc which will look either like a pie wedge or Pac-man.<br>
   * A FILLED ARC is a "piece" of a SOLID 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 fillArc(
      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 oppose to finish-start.  Subtracting backwards changes from
                      // counter-clockwise to clockwise.

    g.fillArc(centerX - hRadius, centerY - vRadius, hDiameter, vDiameter, newStart, newFinish);
  }