1 /* 2 * Assignment 1, Problem 3: Program for Dots 3 */ 4 package NPW; 5 6 import painter.SPainter; 7 import shapes.SCircle; 8 9 import javax.swing.*; 10 import java.awt.*; 11 import java.awt.geom.Point2D; 12 13 public class Dots { 14 private void paintTheImage() { 15 SPainter picasso = new SPainter("Dots", 800, 800); 16 17 SCircle blackdot = new SCircle(50); 18 paintblackdot(picasso, blackdot); 19 20 SCircle greendot = new SCircle(75); 21 paintgreendot(picasso, greendot); 22 23 SCircle bluedot = new SCircle(100); 24 paintbluedot(picasso, bluedot); 25 26 SCircle yellowdot = new SCircle(80); 27 paintyellowdot(picasso, yellowdot); 28 29 } 30 31 private void paintyellowdot(SPainter picasso, SCircle yellowdot) { 32 Point2D.Double leftyellow = new Point2D.Double(200,600); 33 Point2D.Double rightyellow = new Point2D.Double(600,600); 34 picasso.setColor(Color.yellow); 35 picasso.setPosition(leftyellow); 36 picasso.paint(yellowdot); 37 picasso.setPosition(rightyellow); 38 picasso.paint(yellowdot); 39 } 40 41 private void paintbluedot(SPainter picasso, SCircle bluedot) { 42 Point2D.Double leftblue = new Point2D.Double(200,400); 43 Point2D.Double rightblue = new Point2D.Double(600,400); 44 picasso.setColor(Color.BLUE); 45 picasso.setPosition(leftblue); 46 picasso.paint(bluedot); 47 picasso.setPosition(rightblue); 48 picasso.paint(bluedot); 49 50 } 51 52 private void paintgreendot(SPainter picasso, SCircle greendot) { 53 Point2D.Double leftgreen = new Point2D.Double(100,100); 54 Point2D.Double rightgreen = new Point2D.Double(700,100); 55 picasso.setColor(Color.GREEN); 56 picasso.setPosition(leftgreen); 57 picasso.paint(greendot); 58 picasso.setPosition(rightgreen); 59 picasso.paint(greendot); 60 61 } 62 63 private void paintblackdot(SPainter picasso, SCircle blackdot) { 64 Point2D.Double upblack = new Point2D.Double(200,200); 65 Point2D.Double downblack = new Point2D.Double(600,200); 66 picasso.setColor(Color.BLACK); 67 picasso.paint(blackdot); 68 picasso.setPosition(upblack); 69 picasso.paint(blackdot); 70 picasso.setPosition(downblack); 71 picasso.paint(blackdot); 72 } 73 // Required Infrastructure 74 75 public Dots() { 76 paintTheImage(); 77 } 78 public static void main(String[] args) { 79 SwingUtilities.invokeLater(new Runnable() { 80 public void run() { 81 new Dots(); 82 } 83 }); 84 } 85 } 86