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

The following are Jave code examples for showing how to use fillArc() 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: jmt   File: DefaultIconsToolkit.java   View Source Code Vote up 7 votes
@Override
public Image getStationIcon(String type, Rectangle bounds) {
	int qLength = 60, height = 40, width = 100;
	BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	for (int i = 0, monoChannel = 0; i < 10; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi.getScaledInstance(bounds.width, bounds.height, Image.SCALE_SMOOTH);
}
 
Example 2
Project: QN-ACTR-Release   File: DefaultIcons.java   View Source Code Vote up 7 votes
public static Image getStationIcon(String type, Rectangle bounds) {
	BufferedImage bi = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	int qLength = bounds.width * 3 / 5, height = bounds.height, width = bounds.width;
	for (int i = 0, monoChannel = 0; i < 5; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel, 255));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel, 255));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi;
}
 
Example 3
Project: org.alloytools.alloy   File: GraphViewer.java   View Source Code Vote up 7 votes
/** This method is called by Swing to draw this component. */
@Override
public void paintComponent(final Graphics gr) {
	super.paintComponent(gr);
	Graphics2D g2 = (Graphics2D) gr;
	AffineTransform oldAF = (AffineTransform) (g2.getTransform().clone());
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	g2.scale(scale, scale);
	Object sel = (selected != null ? selected : highlight);
	GraphNode c = null;
	if (sel instanceof GraphNode && ((GraphNode) sel).shape() == null) {
		c = (GraphNode) sel;
		sel = c.ins.get(0);
	}
	graph.draw(new Artist(g2), scale, sel, true);
	if (c != null) {
		gr.setColor(((GraphEdge) sel).color());
		gr.fillArc(c.x() - 5 - graph.getLeft(), c.y() - 5 - graph.getTop(), 10, 10, 0, 360);
	}
	g2.setTransform(oldAF);
}
 
Example 4
Project: Genetic-Ingress-Attack-Optimizer   File: Portal.java   View Source Code Vote up 6 votes
@Override
public void paint(Graphics g) {
	int rx = (int) Math.round(x);
	int ry = (int) Math.round(y);
	
	try {
		// Draw portal sprite
		g.drawImage(ImageIO.read(this.getClass().getResourceAsStream("/img/portalTexture.png")), rx-sprite_width/2, ry-sprite_height/2, sprite_width, sprite_height, null);	
					
		// Draw shields
		int alpha = Math.min((int)Math.round(this.shieldMitigation()*2.55), 255);
		g.setColor(new Color(255, 142, 247, alpha));
		g.fillArc(rx-sprite_width/2, ry-sprite_height/2, sprite_width, sprite_height, 0, 360);
		
		// Draw links
		g.setColor(Color.GREEN);
		for(Portal p: links){
			g.drawLine(rx, ry, (int) Math.round(p.getX()), (int) Math.round(p.getY()));	
		}
		
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 5
Project: jmt   File: DefaultIcons.java   View Source Code Vote up 6 votes
public static Image getStationIcon(String type, Rectangle bounds) {
	BufferedImage bi = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	int qLength = bounds.width * 3 / 5, height = bounds.height, width = bounds.width;
	for (int i = 0, monoChannel = 0; i < 5; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel, 255));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel, 255));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi;
}
 
Example 6
Project: javase   File: PaintFillColor.java   View Source Code Vote up 6 votes
public void paint(Graphics g) {
	super.paint(g);
	g.setColor(Color.blue);
	g.setFont(new Font("宋体", Font.BOLD, 20));
	g.drawRect(100, 300, 150, 100);
	g.drawRoundRect(300, 200, 200, 200, 200, 200);
	/*
	 * x - 要绘制矩形的 x 坐标。 y - 要绘制矩形的 y 坐标。 width - 要绘制矩形的宽度。 height -
	 * 要绘制矩形的高度。 arcWidth - 4 个角弧度的水平直径。 arcHeight - 4 个角弧度的垂直直径。
	 */
	g.setColor(Color.red);
	g.fillRect(100, 100, 100, 100);
	g.setColor(Color.green);
	g.fillOval(200, 100, 150, 150);
	// 填充夜色 圆形填充

	g.fill3DRect(150, 450, 50, 50, false);
	g.fillArc(200, 450, 50, 50, 50, 50);
	g.fillRect(250, 450, 50, 50);
	g.fillRoundRect(300, 450, 50, 50, 50, 50);
	g.drawString("如果", 400, 150);
}
 
Example 7
Project: QN-ACTR-Release   File: DefaultIconsToolkit.java   View Source Code Vote up 6 votes
@Override
public Image getStationIcon(String type, Rectangle bounds) {
	int qLength = 60, height = 40, width = 100;
	BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	for (int i = 0, monoChannel = 0; i < 10; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi.getScaledInstance(bounds.width, bounds.height, Image.SCALE_SMOOTH);
}
 
Example 8
Project: LivroJavaComoProgramar10Edicao   File: DrawRainbow.java   View Source Code Vote up 6 votes
public void paintComponent(Graphics g)
{
   super.paintComponent(g);
   
   int radius = 20; // radius of an arc
   
   // draw the rainbow near the bottom-center
   int centerX = getWidth() / 2;
   int centerY = getHeight() - 10;

   // draws filled arcs starting with the outermost
   for (int counter = colors.length; counter > 0; counter--)
   {
      // set the color for the current arc
      g.setColor(colors[counter - 1]);
      
      // fill the arc from 0 to 180 degrees
      g.fillArc(centerX - counter * radius,
         centerY - counter * radius, 
         counter * radius * 2, counter * radius * 2, 0, 180);
   } 
}
 
Example 9
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 10
Project: jmt   File: SampleQNAnimation.java   View Source Code Vote up 5 votes
private void createCPU(Graphics g) {
	cpuPhase = (cpuPhase - 6) % 360;
	int width = getBounds().width, height = getBounds().height, x = getBounds().x, y = getBounds().y, turn = colors.length;
	g.setColor(Color.WHITE);
	g.fillOval(width - height + x + 1, y + 1, height - 2, height - 2);
	for (int i = 0; i < turn; i++) {
		g.setColor(colors[i % colors.length]);
		g.fillArc(width - height + x, y, height, height, (int) cpuPhase + (i * 360) / turn, 360 / turn);
	}
}
 
Example 11
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 12
Project: QN-ACTR-Release   File: SampleQNAnimation.java   View Source Code Vote up 5 votes
private void createCPU(Graphics g) {
	cpuPhase = (cpuPhase - 6) % 360;
	int width = getBounds().width, height = getBounds().height, x = getBounds().x, y = getBounds().y, turn = colors.length;
	g.setColor(Color.WHITE);
	g.fillOval(width - height + x + 1, y + 1, height - 2, height - 2);
	for (int i = 0; i < turn; i++) {
		g.setColor(colors[i % colors.length]);
		g.fillArc(width - height + x, y, height, height, (int) cpuPhase + (i * 360) / turn, 360 / turn);
	}
}
 
Example 13
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 14
Project: Tarski   File: GraphViewer.java   View Source Code Vote up 5 votes
/** This method is called by Swing to draw this component. */
@Override public void paintComponent(final Graphics gr) {
    super.paintComponent(gr);
    Graphics2D g2 = (Graphics2D)gr;
    AffineTransform oldAF = (AffineTransform) (g2.getTransform().clone());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.scale(scale, scale);
    Object sel=(selected!=null ? selected : highlight);
    GraphNode c=null;
    if (sel instanceof GraphNode && ((GraphNode)sel).shape()==null) { c = (GraphNode)sel; sel = c.ins.get(0); }
    graph.draw(new Artist(g2), scale, sel, true);
    if (c!=null) { gr.setColor(((GraphEdge)sel).color()); gr.fillArc(c.x()-5-graph.getLeft(), c.y()-5-graph.getTop(), 10, 10, 0, 360); }
    g2.setTransform(oldAF);
}
 
Example 15
Project: Tarski   File: GraphViewer.java   View Source Code Vote up 5 votes
/** This method is called by Swing to draw this component. */
@Override public void paintComponent(final Graphics gr) {
    super.paintComponent(gr);
    Graphics2D g2 = (Graphics2D)gr;
    AffineTransform oldAF = (AffineTransform) (g2.getTransform().clone());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.scale(scale, scale);
    Object sel=(selected!=null ? selected : highlight);
    GraphNode c=null;
    if (sel instanceof GraphNode && ((GraphNode)sel).shape()==null) { c = (GraphNode)sel; sel = c.ins.get(0); }
    graph.draw(new Artist(g2), scale, sel, true);
    if (c!=null) { gr.setColor(((GraphEdge)sel).color()); gr.fillArc(c.x()-5-graph.getLeft(), c.y()-5-graph.getTop(), 10, 10, 0, 360); }
    g2.setTransform(oldAF);
}
 
Example 16
Project: myster   File: ProgressWindow.java   View Source Code Vote up 5 votes
private void updateIcon() {
    //if (true==true) return;
    if (piChart == null)
        piChart = createImage(32, 32);
    if (piChart == null)
        return; //How does this happen??
    double percent = 0;

    percent = (getValue() < getMin() || getValue() > getMax() ? 0
            : ((double) (getValue() - getMin())) / ((double) (getMax() - getMin())));

    int int_temp = (int) (percent * 100);

    if (int_temp == lastPercent)
        return;

    lastPercent = int_temp;

    Graphics gp = piChart.getGraphics();
    gp.setColor(Color.white);
    gp.fillRect(0, 0, 32, 32);
    gp.setColor(new Color(240, 240, 240));
    gp.fillArc(1, 1, 30, 30, 90, 360);
    gp.setColor(getBarColor());
    gp.fillArc(1, 1, 30, 30, 90, -(int) (percent * 360));
    //gp.setColor(Color.black);
    //gp.drawString(""+((int)(percent/100-1))+"%", 1, 16);

    setIconImage(piChart);
}
 
Example 17
Project: HawkEngine   File: Renderer.java   View Source Code Vote up 4 votes
public static void RenderEllipse(Graphics g, Vector2 position, Vector2 size, int angle, Color c)
{
	g.setColor(c);
	g.fillArc((int)position.x, (int)position.y, (int)size.x, (int)size.y, 0, angle);
}
 
Example 18
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 );
		}
	}