Target.java
1    /* 
2     * Program to paint a target icon (3 circle shapes of different sizes on top of each other) 
3     * in the context of the Nonrepresentational Painting World (NPW) 
4     */
5    
6    package npw;
7    
8    import java.awt.Color;
9    import javax.swing.SwingUtilities;
10   import painter.SPainter;
11   import shapes.SCircle;
12   
13   public class Target {
14       //THE SOLUTION TO THE TARGET PROBLEM
15       private void paintTheTarget() {
16           SPainter targetPainter = new SPainter("Target", 1000, 1000);
17   
18           //Create circles of descending size sharing same center point, they will stack to create a target icon
19           SCircle bottomCircle = new SCircle(300);
20           SCircle middleCircle = new SCircle(200);
21           SCircle topCircle = new SCircle(100);
22   
23           //set color for lowest level circle (r=300, d=600) and paint it red
24           targetPainter.setColor(Color.RED);
25           targetPainter.paint(bottomCircle);
26   
27           //set color for middle level circle (r=200, d=400) and paint it white
28           targetPainter.setColor(Color.WHITE);
29           targetPainter.paint(middleCircle);
30   
31           //set color for top level circle (r=100, d=200) and paint it red
32           targetPainter.setColor(Color.RED);
33           targetPainter.paint(topCircle);
34   
35           /* 
36           * Diameter of the lowest level circle is 3x the size of the highest level circle (600 = 3(200)) 
37           * Diameter of the middle level circle is 2x the size of the highest level circle (400 = 2(200)) 
38            */
39       }
40   
41       //REQUIRED INFRASTRUCTURE
42       public Target() {
43           paintTheTarget();
44       }
45   
46       public static void main(String[] args) {
47           SwingUtilities.invokeLater(new Runnable() {
48               public void run() {
49                   new Target();
50               }
51           });
52       }
53   }