當前位置: 首頁>>代碼示例>>Java>>正文


Java Graphics2D.fillArc方法代碼示例

本文整理匯總了Java中java.awt.Graphics2D.fillArc方法的典型用法代碼示例。如果您正苦於以下問題:Java Graphics2D.fillArc方法的具體用法?Java Graphics2D.fillArc怎麽用?Java Graphics2D.fillArc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Graphics2D的用法示例。


在下文中一共展示了Graphics2D.fillArc方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: RenderEllipseRotated

import java.awt.Graphics2D; //導入方法依賴的package包/類
public static synchronized void RenderEllipseRotated(Graphics g, Vector2 position, Vector2 size, float degrees, float rotation, Color c)
{
	Graphics2D g2d = (Graphics2D)g;
	AffineTransform old = g2d.getTransform();
	g2d.rotate(rotation, position.x + (size.x/2), position.y + (size.y/2));
	g2d.setColor(c);
	g2d.fillArc((int)position.x, (int)position.y, (int)size.x, (int)size.y, 0, (int)degrees);
	g2d.setTransform(old);
}
 
開發者ID:Joshuagollaher,項目名稱:HawkEngine,代碼行數:10,代碼來源:Renderer.java

示例2: paintBorder

import java.awt.Graphics2D; //導入方法依賴的package包/類
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Graphics2D g2 = (Graphics2D)g;

        g2.setPaint(fillColor);
        // NOTE: fillRoundRect seems to have poor performance on Linux
//            g2.fillRoundRect(x + halfBorderStrokeWidth, y + halfBorderStrokeWidth,
//                             width - borderStrokeWidth, height - borderStrokeWidth,
//                             arcRadius * 2, arcRadius * 2);

        int arcRadius2 = arcRadius * 2;
        int arcRadius2p1 = arcRadius2 + 1;

        g2.fillArc(x, y, arcRadius2, arcRadius2, 90, 90);
        g2.fillArc(x + width - arcRadius2p1, y, arcRadius2, arcRadius2, 0, 90);
        g2.fillArc(x, y + height - arcRadius2p1, arcRadius2, arcRadius2, 180, 90);
        g2.fillArc(x + width - arcRadius2p1, y + height - arcRadius2p1, arcRadius2, arcRadius2, 270, 90);

        g2.fillRect(x + arcRadius, y, width - arcRadius2p1, height);
        g2.fillRect(x, y + arcRadius, arcRadius, height - arcRadius2p1);
        g2.fillRect(x + width - arcRadius - 1, y + arcRadius, arcRadius, height - arcRadius2p1);

        Object aa = null;
        Object sc = null;
        if (!forceSpeed) {
            aa = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
            sc = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        }

        g2.setStroke(borderStroke);
        g2.setPaint(lineColor);
        g2.drawRoundRect(x + halfBorderStrokeWidth, y + halfBorderStrokeWidth,
                         width - borderStrokeWidth, height - borderStrokeWidth,
                         arcRadius * 2, arcRadius * 2);

        if (!forceSpeed) {
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa);
            g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, sc);
        }
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:42,代碼來源:RoundBorder.java

示例3: main

import java.awt.Graphics2D; //導入方法依賴的package包/類
public static void main(String[] args) {
	DrawFrame df = DrawFrame.create("MyDrawing", 200, 300);
	Graphics2D g = df.getGraphics2D();
	
	float linewidth = 5.0f;	// line width = 5 pixels
	g.setStroke(new BasicStroke(linewidth));
	
	g.setColor(Color.BLUE);
	g.drawLine(40, 10, 10, 40);
	g.draw(new Line2D.Double(70.2, 10.3, 100.4, 40.5));

	g.fillOval(10, 60, 30, 30);
	g.drawOval(60, 60, 30, 30);
	g.fillRoundRect(110, 60, 30, 30, 10, 10);
	g.drawRoundRect(160, 60, 30, 30, 10, 10);

	g.setColor(Color.GREEN.darker());
	g.fillArc(10, 110, 30, 30, 45, 240);
	g.fillArc(60, 110, 30, 30, 45 + 240, 360 - 240);
	g.fillArc(110, 110, 30, 30, 90, 270);
	g.fillArc(160, 110, 30, 30, 270, 270);

	g.setColor(Color.MAGENTA);
	g.drawArc(10, 160, 30, 30, 45, 240);
	g.drawArc(60, 160, 30, 30, 45 + 240, 360 - 240);
	g.drawArc(110, 160, 30, 30, 90, 270);
	g.drawArc(160, 160, 30, 30, 270, 270);

	g.setColor(Color.ORANGE);
	g.fillPolygon(new int[] { 10, 40, 10, 40 }, new int[] { 210, 210, 240, 240 }, 4);
	g.drawPolygon(new int[] { 60, 90, 60, 90 }, new int[] { 210, 210, 240, 240 }, 4);
	g.drawPolyline(new int[] { 110, 140, 110, 140 }, new int[] { 210, 210, 240, 240 }, 4);
	g.drawPolyline(new int[] { 160, 160, 190, 190 }, new int[] {240, 210, 240, 210 }, 4);

	// Printing texts
	g.setColor(Color.BLACK);
	g.setFont(new Font("Monospaced", Font.PLAIN, 14));
	g.drawString("Drawn with JGraphix", 10, 275);

	df.refresh();

	System.out.println("done.");
}
 
開發者ID:imagingbook,項目名稱:JGraphix,代碼行數:44,代碼來源:JGraphix_Example_1.java


注:本文中的java.awt.Graphics2D.fillArc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。