Example usage for java.awt Graphics drawArc

List of usage examples for java.awt Graphics drawArc

Introduction

In this page you can find the example usage for java.awt Graphics drawArc.

Prototype

public abstract void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle);

Source Link

Document

Draws the outline of a circular or elliptical arc covering the specified rectangle.

Usage

From source file:GraphicsUtil.java

static public void drawCenteredArc(Graphics g, int x, int y, int r, int start, int dist) {
    g.drawArc(x - r, y - r, 2 * r, 2 * r, start, dist);
}

From source file:Main.java

public void paint(Graphics g) {
    g.drawArc(25, 25, 120, 120, 45, 270);
}

From source file:MyCanvas.java

public void paint(Graphics g) {
    g.drawArc(10, 10, 200, 200, 50, 50);
}

From source file:MainClass.java

public void paint(Graphics g) {
    g.drawArc(10, 40, 70, 70, 0, 75);
    g.fillArc(100, 40, 70, 70, 0, 75);/*  w  w w  . j av a2s  . c  om*/
    g.drawArc(10, 100, 70, 80, 0, 175);
    g.fillArc(100, 100, 70, 90, 0, 270);
    g.drawArc(200, 80, 80, 80, 0, 180);
}

From source file:MainClass.java

public void paint(Graphics g) {
    g.drawArc(25, 25, 120, 120, 45, 270);

}

From source file:MainClass.java

public void paint(Graphics g) {
    g.setColor(Color.yellow);
    g.drawArc(5, 15, 50, 75, 25, 165);
}

From source file:OvalBorder.java

public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    width--;/*from   ww w  .j a v  a 2 s .com*/
    height--;

    g.setColor(lightColor);
    g.drawLine(x, y + height - ovalHeight, x, y + ovalHeight);
    g.drawArc(x, y, 2 * ovalWidth, 2 * ovalHeight, 180, -90);
    g.drawLine(x + ovalWidth, y, x + width - ovalWidth, y);
    g.drawArc(x + width - 2 * ovalWidth, y, 2 * ovalWidth, 2 * ovalHeight, 90, -90);

    g.setColor(darkColor);
    g.drawLine(x + width, y + ovalHeight, x + width, y + height - ovalHeight);
    g.drawArc(x + width - 2 * ovalWidth, y + height - 2 * ovalHeight, 2 * ovalWidth, 2 * ovalHeight, 0, -90);
    g.drawLine(x + ovalWidth, y + height, x + width - ovalWidth, y + height);
    g.drawArc(x, y + height - 2 * ovalHeight, 2 * ovalWidth, 2 * ovalHeight, -90, -90);
}

From source file:CopyAreaPerformance.java

private void drawSmiley(Graphics g, Color faceColor, int x, int y) {
    // fill face color
    g.setColor(faceColor);/*  w  ww  . j  a v  a 2  s .  c  o m*/
    g.fillOval(x, y, SMILEY_SIZE, SMILEY_SIZE);
    g.setColor(Color.BLACK);
    // draw head
    g.drawOval(x, y, SMILEY_SIZE, SMILEY_SIZE);
    // draw smile
    g.drawArc(x + (int) ((SMILEY_SIZE * .2)), (int) (y + (SMILEY_SIZE * .2)), (int) (SMILEY_SIZE * .6),
            (int) (SMILEY_SIZE * .6), 200, 140);
    // draw eyes
    int eyeSize = Math.max(2, (int) (SMILEY_SIZE * .1));
    g.fillOval(x + (int) ((SMILEY_SIZE * .5) - (SMILEY_SIZE * .1) - eyeSize), y + (int) (SMILEY_SIZE * .3),
            eyeSize, eyeSize);
    g.fillOval(x + (int) ((SMILEY_SIZE * .5) + (SMILEY_SIZE * .1)), y + (int) (SMILEY_SIZE * .3), eyeSize,
            eyeSize);
}

From source file:com.jcraft.weirdx.Draw.java

static void reqPolyArc(Client c, XDrawable d, GC gc) throws IOException {
    //int foo;/*from w w w  . j  av  a  2s.  co  m*/
    int n = c.length;
    InputOutput io = c.client;

    Graphics graphics = d.getGraphics(gc, GC.GCFunction | GC.GCSubwindowMode | GC.GCLineWidth);
    if (graphics == null) {
        io.readPad(n * 4);
        return;
    }

    if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) {
        java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask());
        if (rec == null) {
            io.readPad(n * 4);
            return;
        }
    }

    n *= 4;

    short x, y, a1, a2;
    int width, height;

    int sx = d.width;
    int sy = d.height;
    int lx = 0;
    int ly = 0;

    while (n != 0) {
        x = (short) io.readShort();
        y = (short) io.readShort();
        if (x < sx)
            sx = x;
        if (y < sy)
            sy = y;

        width = /*(short)*/io.readShort();
        height = /*(short)*/io.readShort();
        if (lx < x + width)
            lx = x + width;
        if (ly < y + height)
            ly = y + height;

        a1 = (short) io.readShort();
        a2 = (short) io.readShort();
        n -= 12;
        graphics.drawArc(x, y, width, height, a1 / 64, a2 / 64);
    }

    if (d instanceof XWindow) {
        if (sx < 0)
            sx = 0;
        if (sy < 0)
            sy = 0;
        ((XWindow) d).draw(sx, sy, lx - sx + 2, ly - sy + 2);
    }
    if (gc.function == GC.GXxor || gc.function == GC.GXinvert) {
        graphics.setPaintMode();
    }
    if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) {
        d.restoreClip();
    }
}

From source file:ScaleTest_2008.java

/**
 * Paints the test image that will be downscaled and timed by the various
 * scaling methods. A different image is rendered into each of the four
 * quadrants of this image: RGB stripes, a picture, vector art, and 
 * a black and white grid./*www .j ava  2s  . c  om*/
 */
private void paintOriginalImage() {
    Graphics g = originalImage.getGraphics();
    // Erase to black
    g.setColor(Color.BLACK);
    g.fillRect(0, 0, FULL_SIZE, FULL_SIZE);

    // RGB quadrant
    for (int i = 0; i < QUAD_SIZE; i += 3) {
        int x = i;
        g.setColor(Color.RED);
        g.drawLine(x, 0, x, QUAD_SIZE);
        x++;
        g.setColor(Color.GREEN);
        g.drawLine(x, 0, x, QUAD_SIZE);
        x++;
        g.setColor(Color.BLUE);
        g.drawLine(x, 0, x, QUAD_SIZE);
    }

    // Picture quadrant
    try {
        URL url = getClass().getResource("BBGrayscale.png");
        BufferedImage picture = ImageIO.read(url);
        // Center picture in quadrant area
        int xDiff = QUAD_SIZE - picture.getWidth();
        int yDiff = QUAD_SIZE - picture.getHeight();
        g.drawImage(picture, QUAD_SIZE + xDiff / 2, yDiff / 2, null);
    } catch (Exception e) {
        System.out.println("Problem reading image file: " + e);
    }

    // Vector drawing quadrant
    g.setColor(Color.WHITE);
    g.fillRect(0, QUAD_SIZE, QUAD_SIZE, QUAD_SIZE);
    g.setColor(Color.BLACK);
    g.drawOval(2, QUAD_SIZE + 2, QUAD_SIZE - 4, QUAD_SIZE - 4);
    g.drawArc(20, QUAD_SIZE + 20, (QUAD_SIZE - 40), QUAD_SIZE - 40, 190, 160);
    int eyeSize = 7;
    int eyePos = 30 - (eyeSize / 2);
    g.fillOval(eyePos, QUAD_SIZE + eyePos, eyeSize, eyeSize);
    g.fillOval(QUAD_SIZE - eyePos - eyeSize, QUAD_SIZE + eyePos, eyeSize, eyeSize);

    // B&W grid
    g.setColor(Color.WHITE);
    g.fillRect(QUAD_SIZE + 1, QUAD_SIZE + 1, QUAD_SIZE, QUAD_SIZE);
    g.setColor(Color.BLACK);
    for (int i = 0; i < QUAD_SIZE; i += 4) {
        int pos = QUAD_SIZE + i;
        g.drawLine(pos, QUAD_SIZE + 1, pos, FULL_SIZE);
        g.drawLine(QUAD_SIZE + 1, pos, FULL_SIZE, pos);
    }

    originalImagePainted = true;
}