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

The following examples show how to use java.awt.Graphics#drawArc() . 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 check out the related API usage on the sidebar.
Example 1
Source File: Clock.java    From openjdk-jdk9 with 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 File: Clock.java    From openjdk-8-source with 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
Source File: Clock.java    From openjdk-8 with 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 4
Source File: Clock.java    From jdk8u_jdk with 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
Source File: Clock.java    From jdk8u-dev-jdk with 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 6
Source File: BrainPicture.java    From frog with 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 7
Source File: XComponentPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 8
Source File: XComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 9
Source File: XComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: BrainPicture.java    From frog with 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 11
Source File: XComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 12
Source File: XComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 13
Source File: XComponentPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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 14
Source File: XComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: XComponentPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 16
Source File: XComponentPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 17
Source File: BrainPicture.java    From frog with 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 18
Source File: PainterDin.java    From Logisim with 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 19
Source File: ScaleTest.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 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
Source File: MotifIconFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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);

    }
}