1 2 package npw; 3 4 import java.awt.Color; 5 import javax.swing.SwingUtilities; 6 import painter.SPainter; 7 import shapes.SCircle; 8 import shapes.SSquare; 9 10 public class KanizsaSquare { 11 // THE SOLUTION TO THE KANIZSA SQUARE PROBLEM 12 private void paintTheImage() { 13 SPainter Phuong = new SPainter("Kanizsa Square",400,400); 14 SCircle dot = new SCircle(75); 15 paintBlueCircle(Phuong,dot); 16 paintRedCircle(Phuong,dot); 17 paintGreenCircles(Phuong,dot); 18 SSquare square = new SSquare(200); 19 paintWhiteSquare(Phuong,square); 20 21 } 22 23 private void paintBlueCircle(SPainter phuong, SCircle dot) { 24 phuong.mlt(100); phuong.mfd(100); phuong.setColor(Color.BLUE); phuong.paint(dot); 25 phuong.mrt(100); phuong.mbk(100); 26 } 27 private void paintRedCircle(SPainter phuong, SCircle dot) { 28 phuong.mrt(100); phuong.mbk(100);phuong.setColor(Color.RED); 29 phuong.paint(dot);phuong.mlt(100);phuong.mfd(100); 30 } 31 private void paintGreenCircles(SPainter phuong, SCircle dot) { 32 phuong.mrt(100); phuong.mfd(100); phuong.setColor(Color.GREEN); 33 phuong.paint(dot); phuong.mlt(100); phuong.mbk(100); 34 phuong.mlt(100); phuong.mbk(100); phuong.paint(dot); 35 phuong.moveToCenter(); 36 } 37 private void paintWhiteSquare(SPainter phuong, SSquare square) { 38 phuong.setColor(Color.WHITE); phuong.paint(square); 39 } 40 // REQUIRED INFRASTRUCTURE 41 public KanizsaSquare(){ 42 paintTheImage(); 43 } 44 45 public static void main(String[] args) { 46 SwingUtilities.invokeLater(new Runnable() { 47 public void run() { 48 new KanizsaSquare(); 49 } 50 }); 51 } 52 } 53 54