当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.drawArc方法代码示例

本文整理汇总了Java中java.awt.Graphics.drawArc方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawArc方法的具体用法?Java Graphics.drawArc怎么用?Java Graphics.drawArc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.drawArc方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@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);
}
 
开发者ID:gDanix,项目名称:Genetic-Ingress-Attack-Optimizer,代码行数:27,代码来源:XMP.java

示例2: createOverlayImage

import java.awt.Graphics; //导入方法依赖的package包/类
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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:20,代码来源:SampleQNAnimation.java

示例3: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Clock.java

示例4: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
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]);
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:14,代码来源:KMeansInfoClustering.java

示例5: paintComponent

import java.awt.Graphics; //导入方法依赖的package包/类
@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);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:33,代码来源:ArcsJPanel.java

示例6: draw3DOval

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:XComponentPeer.java

示例7: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
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);

    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:MotifIconFactory.java

示例8: paint

import java.awt.Graphics; //导入方法依赖的package包/类
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;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:53,代码来源:PainterDin.java

示例9: drawCenteredArc

import java.awt.Graphics; //导入方法依赖的package包/类
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);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:4,代码来源:GraphicsUtil.java

示例10: renderEdge

import java.awt.Graphics; //导入方法依赖的package包/类
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 );
		}
	}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:54,代码来源:CircleRenderer.java


注:本文中的java.awt.Graphics.drawArc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。