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

The following are Jave code examples for showing how to use drawArc() of the java.awt.Graphics class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Genetic-Ingress-Attack-Optimizer   File: XMP.java   View Source Code Vote up 6 votes
@Override
public void paint(Graphics g) {
	long range = Util.metersToPixels(maxRangesMeter[level-1]);
	
	g.setColor(Color.red);
	g.drawArc( (int)(x-range), (int)(y-range), (int)range*2, (int)range*2, 0, 360);
	
	int[] xPoints = {
			(int)Math.round(x+sprite_width*1*Math.cos(Math.PI/2)),
			(int)Math.round(x+sprite_width*0.3*Math.cos(3*Math.PI/4)),
			(int)Math.round(x+sprite_width*1*Math.cos(5*Math.PI/4)),
			(int)Math.round(x+sprite_width*0.3*Math.cos(3*Math.PI/2)),
			(int)Math.round(x+sprite_width*1*Math.cos(7*Math.PI/4)),
			(int)Math.round(x+sprite_width*0.3*Math.cos(Math.PI/4))
			};
	int[] yPoints = {
			(int)Math.round(y-sprite_height*1*Math.sin(Math.PI/2)),
			(int)Math.round(y-sprite_height*0.3*Math.sin(3*Math.PI/4)),
			(int)Math.round(y-sprite_height*1*Math.sin(5*Math.PI/4)),
			(int)Math.round(y-sprite_height*0.3*Math.sin(3*Math.PI/2)),
			(int)Math.round(y-sprite_height*1*Math.sin(7*Math.PI/4)),
			(int)Math.round(y-sprite_height*0.3*Math.sin(Math.PI/4))
			};
	
	g.fillPolygon(xPoints, yPoints, 6);
}
 
Example 2
Project: jmt   File: SampleQNAnimation.java   View Source Code Vote up 6 votes
private void createOverlayImage() {
	int height = getBounds().height * 2, width = getBounds().width * 2, qLength = width - (height * 4) / 5, qHeight = (height * 4) / 5, yOffs = (height - qHeight) / 2;
	overlayedShading = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Color[] shades = new Color[7], lights = new Color[7];
	for (int i = 0; i < shades.length; i++) {
		shades[i] = new Color(0, 0, 0, 160 - (i * 160) / shades.length);
		lights[i] = new Color(255, 255, 255, 200 - (i * 200) / lights.length);
	}
	Graphics g = overlayedShading.getGraphics();
	for (int i = 0; i < shades.length; i++) {
		g.setColor(lights[i]);
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i - yOffs, i + yOffs, i + yOffs }, 3);
		g.drawArc(width - height + i, i, height - 2 * i, height - 2 * i, 45 + 4 * i, 180 - 8 * i);
		g.setColor(shades[i]);
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i - yOffs, height - i - yOffs, i + yOffs }, 2);
		g.drawArc(width - height + i, i, height - 2 * i, height - 2 * i, 225 + 4 * i, 180 - 8 * i);
	}
	overlayedShading = overlayedShading.getScaledInstance(getBounds().width, getBounds().height, Image.SCALE_SMOOTH);
}
 
Example 3
Project: QN-ACTR-Release   File: SampleQNAnimation.java   View Source Code Vote up 6 votes
private void createOverlayImage() {
	int height = getBounds().height * 2, width = getBounds().width * 2, qLength = width - (height * 4) / 5, qHeight = (height * 4) / 5, yOffs = (height - qHeight) / 2;
	overlayedShading = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Color[] shades = new Color[7], lights = new Color[7];
	for (int i = 0; i < shades.length; i++) {
		shades[i] = new Color(0, 0, 0, 160 - (i * 160) / shades.length);
		lights[i] = new Color(255, 255, 255, 200 - (i * 200) / lights.length);
	}
	Graphics g = overlayedShading.getGraphics();
	for (int i = 0; i < shades.length; i++) {
		g.setColor(lights[i]);
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i - yOffs, i + yOffs, i + yOffs }, 3);
		g.drawArc(width - height + i, i, height - 2 * i, height - 2 * i, 45 + 4 * i, 180 - 8 * i);
		g.setColor(shades[i]);
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i - yOffs, height - i - yOffs, i + yOffs }, 2);
		g.drawArc(width - height + i, i, height - 2 * i, height - 2 * i, 225 + 4 * i, 180 - 8 * i);
	}
	overlayedShading = overlayedShading.getScaledInstance(getBounds().width, getBounds().height, Image.SCALE_SMOOTH);
}
 
Example 4
Project: OpenJSharp   File: Clock.java   View Source Code Vote up 6 votes
@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
Project: jdk8u-jdk   File: Clock.java   View Source Code Vote up 6 votes
@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
Project: openjdk-jdk10   File: Clock.java   View Source Code Vote up 6 votes
@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 7
Project: jmt   File: KMeansInfoClustering.java   View Source Code Vote up 5 votes
public void paintIcon(Component c, Graphics g, int x, int y) {
	float len = angle.length;

	centreX = x + (DIAMETRO / 2);
	centreY = y + (DIAMETRO / 2);

	for (int i = 0; i < len - 1; i++) {
		g.setColor(JavaWatColor.getColor(i));
		g.fillArc(x, y, DIAMETRO, DIAMETRO, angle[i], angle[i + 1] - angle[i]);
		g.setColor(Color.BLACK);
		g.drawArc(x, y, DIAMETRO, DIAMETRO, angle[i], angle[i + 1] - angle[i]);
	}
}
 
Example 8
Project: QN-ACTR-Release   File: KMeansInfoClustering.java   View Source Code Vote up 5 votes
public void paintIcon(Component c, Graphics g, int x, int y) {
	float len = angle.length;

	centreX = x + (DIAMETRO / 2);
	centreY = y + (DIAMETRO / 2);

	for (int i = 0; i < len - 1; i++) {
		g.setColor(JavaWatColor.getColor(i));
		g.fillArc(x, y, DIAMETRO, DIAMETRO, angle[i], angle[i + 1] - angle[i]);
		g.setColor(Color.BLACK);
		g.drawArc(x, y, DIAMETRO, DIAMETRO, angle[i], angle[i + 1] - angle[i]);
	}
}
 
Example 9
Project: LivroJavaComoProgramar10Edicao   File: ArcsJPanel.java   View Source Code Vote up 5 votes
@Override
public void paintComponent(Graphics g)
{
   super.paintComponent(g);  

   // start at 0 and sweep 360 degrees
   g.setColor(Color.RED);
   g.drawRect(15, 35, 80, 80);
   g.setColor(Color.BLACK);
   g.drawArc(15, 35, 80, 80, 0, 360);

   // start at 0 and sweep 110 degrees
   g.setColor(Color.RED);
   g.drawRect(100, 35, 80, 80);
   g.setColor(Color.BLACK);
   g.drawArc(100, 35, 80, 80, 0, 110);

   // start at 0 and sweep -270 degrees
   g.setColor(Color.RED);
   g.drawRect(185, 35, 80, 80);
   g.setColor(Color.BLACK);
   g.drawArc(185, 35, 80, 80, 0, -270);

   // start at 0 and sweep 360 degrees
   g.fillArc(15, 120, 80, 40, 0, 360);

   // start at 270 and sweep -90 degrees
   g.fillArc(100, 120, 80, 40, 270, -90);
              
   // start at 0 and sweep -270 degrees
   g.fillArc(185, 120, 80, 40, 0, -270);
}
 
Example 10
Project: OpenJSharp   File: XComponentPeer.java   View Source Code Vote up 5 votes
/**
 * 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 11
Project: OpenJSharp   File: XComponentPeer.java   View Source Code Vote up 5 votes
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
Project: jdk8u-jdk   File: XComponentPeer.java   View Source Code Vote up 5 votes
/**
 * 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
Project: jdk8u-jdk   File: XComponentPeer.java   View Source Code Vote up 5 votes
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
Project: openjdk-jdk10   File: XComponentPeer.java   View Source Code Vote up 5 votes
/**
 * 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
Project: openjdk-jdk10   File: XComponentPeer.java   View Source Code Vote up 5 votes
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
Project: openjdk-jdk10   File: MotifIconFactory.java   View Source Code Vote up 4 votes
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);

    }
}
 
Example 17
Project: Logisim   File: PainterDin.java   View Source Code Vote up 4 votes
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
Project: Logisim   File: GraphicsUtil.java   View Source Code Vote up 4 votes
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);
}
 
Example 19
Project: cuttlefish   File: CircleRenderer.java   View Source Code Vote up 4 votes
public void renderEdge(Graphics g, VisEdge ec) {
		try {
			CircleEdge cve = (CircleEdge) ec;

//			g.setColor( Color.green );
//			plainDraw( g, ec );
			
			double r = cve.getRadius();
			
			
			Coordinates tl = cve.getCenter();

//			g.setColor( Color.lightGray );
//			g.drawArc(
//					(int) (tl.getX() - r),
//					(int) (tl.getY() - r),
//					(int) (2 * r),
//					(int) (2 * r),
//					0,
//					360);
			
			if (selected(ec.getEdge())) {
				g.setColor(Color.red);
			} else {
				g.setColor(Color.black);
			}
			
			double theta = cve.getStartAngle();
			int angle = (int) ( theta * 180 / Math.PI ) ;
			
			Color c = new Color( 247,210,130, 50 );
			g.setColor( c );
			g.fillArc(
					(int) (tl.getX() - r),
					(int) (tl.getY() - r),
					(int) (2 * r),
					(int) (2 * r),
					- angle,
					180);

			g.setColor(new Color(247,210,130));
			g.drawArc(
				(int) (tl.getX() - r),
				(int) (tl.getY() - r),
				(int) (2 * r),
				(int) (2 * r),
				- angle,
				180);
		} catch (ClassCastException cce) {
			g.setColor(Color.lightGray);
			plainDraw( g, ec );
		}
	}