Java Code Examples for java.awt.Graphics#drawArc()

The following examples show how to use java.awt.Graphics#drawArc() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: jdk8u_jdk   File: Clock.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void paint(Graphics g) {
    g.setFont(clockFaceFont);
    // Draw the circle and numbers
    g.setColor(handColor);
    g.drawArc(xcenter - 50, ycenter - 50, 100, 100, 0, 360);
    g.setColor(numberColor);
    g.drawString("9", xcenter - 45, ycenter + 3);
    g.drawString("3", xcenter + 40, ycenter + 3);
    g.drawString("12", xcenter - 5, ycenter - 37);
    g.drawString("6", xcenter - 3, ycenter + 45);

    // Draw date and hands
    g.setColor(numberColor);
    g.drawString(lastdate, 5, 125);
    g.drawLine(xcenter, ycenter, lastxs, lastys);
    g.setColor(handColor);
    g.drawLine(xcenter, ycenter - 1, lastxm, lastym);
    g.drawLine(xcenter - 1, ycenter, lastxm, lastym);
    g.drawLine(xcenter, ycenter - 1, lastxh, lastyh);
    g.drawLine(xcenter - 1, ycenter, lastxh, lastyh);
}
 
Example 2
Source Project: openjdk-jdk9   File: Clock.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void paint(Graphics g) {
    g.setFont(clockFaceFont);
    // Draw the circle and numbers
    g.setColor(handColor);
    g.drawArc(xcenter - 50, ycenter - 50, 100, 100, 0, 360);
    g.setColor(numberColor);
    g.drawString("9", xcenter - 45, ycenter + 3);
    g.drawString("3", xcenter + 40, ycenter + 3);
    g.drawString("12", xcenter - 5, ycenter - 37);
    g.drawString("6", xcenter - 3, ycenter + 45);

    // Draw date and hands
    g.setColor(numberColor);
    g.drawString(lastdate, 5, 125);
    g.drawLine(xcenter, ycenter, lastxs, lastys);
    g.setColor(handColor);
    g.drawLine(xcenter, ycenter - 1, lastxm, lastym);
    g.drawLine(xcenter - 1, ycenter, lastxm, lastym);
    g.drawLine(xcenter, ycenter - 1, lastxh, lastyh);
    g.drawLine(xcenter - 1, ycenter, lastxh, lastyh);
}
 
Example 3
@Override
public void paint(Graphics g) {
    g.setFont(clockFaceFont);
    // Draw the circle and numbers
    g.setColor(handColor);
    g.drawArc(xcenter - 50, ycenter - 50, 100, 100, 0, 360);
    g.setColor(numberColor);
    g.drawString("9", xcenter - 45, ycenter + 3);
    g.drawString("3", xcenter + 40, ycenter + 3);
    g.drawString("12", xcenter - 5, ycenter - 37);
    g.drawString("6", xcenter - 3, ycenter + 45);

    // Draw date and hands
    g.setColor(numberColor);
    g.drawString(lastdate, 5, 125);
    g.drawLine(xcenter, ycenter, lastxs, lastys);
    g.setColor(handColor);
    g.drawLine(xcenter, ycenter - 1, lastxm, lastym);
    g.drawLine(xcenter - 1, ycenter, lastxm, lastym);
    g.drawLine(xcenter, ycenter - 1, lastxh, lastyh);
    g.drawLine(xcenter - 1, ycenter, lastxh, lastyh);
}
 
Example 4
Source Project: openjdk-8   File: Clock.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void paint(Graphics g) {
    g.setFont(clockFaceFont);
    // Draw the circle and numbers
    g.setColor(handColor);
    g.drawArc(xcenter - 50, ycenter - 50, 100, 100, 0, 360);
    g.setColor(numberColor);
    g.drawString("9", xcenter - 45, ycenter + 3);
    g.drawString("3", xcenter + 40, ycenter + 3);
    g.drawString("12", xcenter - 5, ycenter - 37);
    g.drawString("6", xcenter - 3, ycenter + 45);

    // Draw date and hands
    g.setColor(numberColor);
    g.drawString(lastdate, 5, 125);
    g.drawLine(xcenter, ycenter, lastxs, lastys);
    g.setColor(handColor);
    g.drawLine(xcenter, ycenter - 1, lastxm, lastym);
    g.drawLine(xcenter - 1, ycenter, lastxm, lastym);
    g.drawLine(xcenter, ycenter - 1, lastxh, lastyh);
    g.drawLine(xcenter - 1, ycenter, lastxh, lastyh);
}
 
Example 5
@Override
public void paint(Graphics g) {
    g.setFont(clockFaceFont);
    // Draw the circle and numbers
    g.setColor(handColor);
    g.drawArc(xcenter - 50, ycenter - 50, 100, 100, 0, 360);
    g.setColor(numberColor);
    g.drawString("9", xcenter - 45, ycenter + 3);
    g.drawString("3", xcenter + 40, ycenter + 3);
    g.drawString("12", xcenter - 5, ycenter - 37);
    g.drawString("6", xcenter - 3, ycenter + 45);

    // Draw date and hands
    g.setColor(numberColor);
    g.drawString(lastdate, 5, 125);
    g.drawLine(xcenter, ycenter, lastxs, lastys);
    g.setColor(handColor);
    g.drawLine(xcenter, ycenter - 1, lastxm, lastym);
    g.drawLine(xcenter - 1, ycenter, lastxm, lastym);
    g.drawLine(xcenter, ycenter - 1, lastxh, lastyh);
    g.drawLine(xcenter - 1, ycenter, lastxh, lastyh);
}
 
Example 6
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 7
/**
 * Draw a 3D oval.
 */
public void draw3DOval(Graphics g, Color colors[],
                       int x, int y, int w, int h, boolean raised)
    {
    Color c = g.getColor();
    g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 8
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 9
/**
 * Draw a 3D oval.
 */
public void draw3DOval(Graphics g, Color colors[],
                       int x, int y, int w, int h, boolean raised)
    {
    Color c = g.getColor();
    g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 10
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 11
/**
 * Draw a 3D oval.
 */
public void draw3DOval(Graphics g, Color colors[],
                       int x, int y, int w, int h, boolean raised)
    {
    Color c = g.getColor();
    g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 12
Source Project: frog   File: BrainPicture.java    License: Apache License 2.0 5 votes vote down vote up
public void drawCircle( Zone z) {Graphics g = this.getGraphics();
g.setColor(color);
	float rate = brainDispWidth / brainWidth;
	int x = Math.round(z.x * rate);
	int y = Math.round(z.y * rate);
	g.drawArc(x - 5, y - 5, 10, 10, 0, 360);
}
 
Example 13
Source Project: frog   File: BrainPicture.java    License: Apache License 2.0 5 votes vote down vote up
public void drawCircle( Zone z) {Graphics g = this.getGraphics();
g.setColor(color);
	float rate = brainDispWidth / brainWidth;
	int x = Math.round(z.x * rate);
	int y = Math.round(z.y * rate);
	g.drawArc(x - 5, y - 5, 10, 10, 0, 360);
}
 
Example 14
/**
 * Draw a 3D oval.
 */
public void draw3DOval(Graphics g, Color colors[],
                       int x, int y, int w, int h, boolean raised)
    {
    Color c = g.getColor();
    g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 15
/**
 * Draw a 3D oval.
 */
public void draw3DOval(Graphics g, Color colors[],
                       int x, int y, int w, int h, boolean raised)
    {
    Color c = g.getColor();
    g.setColor(raised ? colors[HIGHLIGHT_COLOR] : colors[SHADOW_COLOR]);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? colors[SHADOW_COLOR] : colors[HIGHLIGHT_COLOR]);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 16
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
Example 17
Source Project: Logisim   File: PainterDin.java    License: GNU General Public License v3.0 4 votes vote down vote up
private static void paint(InstancePainter painter, int width, int height, boolean drawBubble, int dinType) {
	Graphics g = painter.getGraphics();
	int xMid = -width;
	int y0 = -height / 2;
	if (drawBubble) {
		width -= 8;
	}
	int diam = Math.min(height, 2 * width);
	if (dinType == AND) {
		; // nothing to do
	} else if (dinType == OR) {
		paintOrLines(painter, width, height, drawBubble);
	} else if (dinType == XOR || dinType == XNOR) {
		int elen = Math.min(diam / 2 - 10, 20);
		int ex0 = xMid + (diam / 2 - elen) / 2;
		int ex1 = ex0 + elen;
		g.drawLine(ex0, -5, ex1, -5);
		g.drawLine(ex0, 0, ex1, 0);
		g.drawLine(ex0, 5, ex1, 5);
		if (dinType == XOR) {
			int exMid = ex0 + elen / 2;
			g.drawLine(exMid, -8, exMid, 8);
		}
	} else {
		throw new IllegalArgumentException("unrecognized shape");
	}

	GraphicsUtil.switchToWidth(g, 2);
	int x0 = xMid - diam / 2;
	Color oldColor = g.getColor();
	if (painter.getShowState()) {
		Value val = painter.getPort(0);
		g.setColor(val.getColor());
	}
	g.drawLine(x0 + diam, 0, 0, 0);
	g.setColor(oldColor);
	if (height <= diam) {
		g.drawArc(x0, y0, diam, diam, -90, 180);
	} else {
		int x1 = x0 + diam;
		int yy0 = -(height - diam) / 2;
		int yy1 = (height - diam) / 2;
		g.drawArc(x0, y0, diam, diam, 0, 90);
		g.drawLine(x1, yy0, x1, yy1);
		g.drawArc(x0, y0 + height - diam, diam, diam, -90, 90);
	}
	g.drawLine(xMid, y0, xMid, y0 + height);
	if (drawBubble) {
		g.fillOval(x0 + diam - 4, -4, 8, 8);
		xMid += 4;
	}
}
 
Example 18
Source Project: frog   File: BrainPicture.java    License: Apache License 2.0 4 votes vote down vote up
void drawCircle(Graphics g, Zone z) {
	float rate = brainDispWidth / brainWidth;
	int x = Math.round(z.x * rate);
	int y = Math.round(z.y * rate);
	g.drawArc(x - 5, y - 5, 10, 10, 0, 360);
}
 
Example 19
/**
 * 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.
 */
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("images/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;
}
 
Example 20
public void paintIcon(Component c, Graphics g, int x, int y) {
    // fill interior
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    int w = getIconWidth();
    int h = getIconHeight();

    boolean isPressed = model.isPressed();
    boolean isArmed = model.isArmed();
    boolean isEnabled = model.isEnabled();
    boolean isSelected = model.isSelected();

    boolean checkIn = ((isPressed &&
                        !isArmed   &&
                        isSelected) ||
                       (isPressed &&
                        isArmed   &&
                        !isSelected)
                       ||
                       (!isPressed  &&
                        isArmed    &&
                        isSelected  ||
                        (!isPressed &&
                         !isArmed  &&
                         isSelected)));

    if (checkIn){
        g.setColor(shadow);
        g.drawArc(x, y, w - 1, h - 1, 45, 180);
        g.setColor(highlight);
        g.drawArc(x, y, w - 1, h - 1, 45, -180);
        g.setColor(dot);
        g.fillOval(x + 3, y + 3, 7, 7);
    }
    else {
        g.setColor(highlight);
        g.drawArc(x, y, w - 1, h - 1, 45, 180);

        g.setColor(shadow);
        g.drawArc(x, y, w - 1, h - 1, 45, -180);

    }
}