1 package NPW; 2 import java.awt.Color; 3 import javax.swing.SwingUtilities; 4 import painter.SPainter; 5 import shapes.SSquare; 6 import shapes.SCircle; 7 8 9 public class KanizsaSquare { 10 11 private void paintTheImage (){ 12 SPainter y = new SPainter("Kanizsa Square",500,500); 13 SCircle dot = new SCircle(75); 14 paintBlueCircle(y, dot); 15 paintRedCircle(y, dot); 16 paintGreenCircles(y, dot); 17 18 SSquare square = new SSquare(200); 19 paintWhiteSquare(y, square); 20 21 } 22 23 private void paintBlueCircle(SPainter y, SCircle dot) { 24 y.mlt(90); 25 y.mfd (100); 26 y.setColor(Color.BLUE); 27 y.paint(dot); 28 29 } 30 31 private void paintRedCircle(SPainter y, SCircle dot) { 32 y.moveToCenter(); 33 y.mrt(90); 34 y.mbk (100); 35 y.setColor(Color.RED); 36 y.paint(dot); 37 } 38 39 private void paintWhiteSquare(SPainter y, SSquare square) { 40 y.moveToCenter(); 41 y.setColor(Color.white); 42 y.paint(square); 43 } 44 45 private void paintGreenCircles(SPainter y, SCircle dot) { 46 y.moveToCenter(); 47 y.mlt(90); 48 y.mbk (100); 49 y.setColor(Color.GREEN); 50 y.paint(dot); 51 y.moveToCenter(); 52 y.mrt(90); 53 y.mfd (100); 54 y.setColor(Color.GREEN); 55 y.paint(dot); 56 } 57 58 59 public KanizsaSquare() { 60 paintTheImage(); 61 } 62 63 64 public static void main(String[] args) { 65 SwingUtilities.invokeLater(new Runnable() { 66 public void run() { 67 new KanizsaSquare(); 68 } 69 70 }); 71 72 } 73 }