Java examples for java.awt:Graphics2D
draw Resistance Circle
//package com.java2s; import java.awt.Color; import java.awt.Graphics; public class Main { public static void drawResistanceCircle(Graphics g, int x, int y) { g.setColor(Color.RED);/*ww w .j av a 2 s.c o m*/ int r = (int) ((double) x * x + y * y - 800 * x - 400 * y + 200000) / (800 - 2 * x); int tmp_x = 400 - r; int tmp_y = 200; drawCircleThroughCenter(g, tmp_x, tmp_y, r); } public static void drawCircleThroughCenter(Graphics g, int x, int y, int r) { int tmp_x = x - r; int tmp_y = y - r; int tmp_width = 2 * r; int tmp_height = 2 * r; g.drawOval(tmp_x, tmp_y, tmp_width, tmp_height); } }