Java examples for 2D Graphics:Arc
draw Impedance Arc
//package com.java2s; import java.awt.Color; import java.awt.Graphics; public class Main { public static void drawImpedanceArc(Graphics g, int x, int y) { g.setColor(Color.YELLOW); int r = 0; if (y < 200) { r = (int) ((double) (200000 - 800 * x - 400 * y + x * x + y * y) / (400 - 2 * y)); y = 200 - r;/*from ww w. j a va 2 s .c o m*/ } if (y > 200) { r = (int) ((double) (200000 - 800 * x - 400 * y + x * x + y * y) / (2 * y - 400)); y = 200 + r; } drawArcThroughCenter(g, x, y, r); } public static void drawArcThroughCenter(Graphics g, int x, int y, int r) { int tmp_x; int tmp_y; int tmp_width; int tmp_height; if (y < 200) { tmp_x = 400 - r; tmp_y = 200 - 2 * r; tmp_width = 2 * r; tmp_height = 2 * r; double angleTmp = (180 / Math.PI) * (Math.acos(((double) r * r - 40000) / (r * r + 40000))); int angle = (int) Math.rint(angleTmp); g.drawArc(tmp_x, tmp_y, tmp_width, tmp_height, 270 - angle, angle); } else { tmp_x = 400 - r; tmp_y = 200; tmp_width = 2 * r; tmp_height = 2 * r; double angleTmp = (180 / Math.PI) * (Math.acos(((double) r * r - 40000) / (r * r + 40000))); int angle = (int) Math.rint(angleTmp); g.drawArc(tmp_x, tmp_y, tmp_width, tmp_height, 90, angle); } } }