public void paint(Graphics g){
//Downcast the Graphics object to a
// Graphics2D object
Graphics2D g2 = (Graphics2D)g;
//Scale device space to produce inches on
// the screen based on actual screen
// resolution.
g2.scale((double)res/72,(double)res/72);
//Translate origin to center of Frame
g2.translate((hSize/2)*ds,(vSize/2)*ds);
//Draw x-axis
g2.draw(new Line2D.Double(
-1.5*ds,0.0,1.5*ds,0.0));
//Draw y-axis
g2.draw(new Line2D.Double(
0.0,-1.5*ds,0.0,1.5*ds));
//Draw a big circle underneath all of the
// ellipses.
g2.setStroke(new BasicStroke(0.1f*ds));
Ellipse2D.Double bigCircle =
new Ellipse2D.Double(
-1.5*ds,-1.5*ds,3.0*ds,3.0*ds);
g2.draw(bigCircle);
//Declare a reference variable for the ellipses
Ellipse2D.Double theEllipse;
Figure 1
|