Java examples for java.awt:Graphics2D
draw Reflection Coefficient Circle
//package com.java2s; import java.awt.Color; import java.awt.Graphics; public class Main { public static void drawReflectionCoefficientCircle(Graphics g, int x, int y) { g.setColor(Color.GREEN);//from ww w . ja v a2s .co m int r = (int) Math.sqrt((double) (x - 200) * (x - 200) + (y - 200) * (y - 200)); drawCircleThroughCenter(g, 200, 200, r); g.drawLine(x, y, 200, 200); } 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); } }