package expressions; import painter.SPainter; import shapes.SCircle; import shapes.SSquare; import javax.swing.*; import java.awt.*; import static java.lang.Math.*; import static java.lang.StrictMath.PI; public class ShapesThing { //* Now I'm gonna make a square has an inscribed circle having an inscribed rhombus (diamond) inside. //*Step#0: Method call - main method and the related object call and the referred command call for the loaded obj. public ShapesThing() {paintTheImage();} private void paintTheImage() { //* Step#1: Computation on a square SPainter ComplexMatter = new SPainter("ComplexMatter", 600,600); SSquare BoundarySquare = new SSquare(400); ComplexMatter.setBrushWidth(5); ComplexMatter.setColor(Color.getColor("Ash Gray",Color.blue)); ComplexMatter.draw(BoundarySquare); System.out.println("Boundary Square = " + BoundarySquare.toString()); System.out.println("Area of the boundary square = " + BoundarySquare.area()); System.out.println("Perimeter of the boundary square = " + BoundarySquare.perimeter()); System.out.println("Diagonal of the boundary square = " + BoundarySquare.diagonal()); //* Step#2: Computation on an inscribed circle SCircle disk = BoundarySquare.inscribingCircle(); ComplexMatter.setBrushWidth(3); ComplexMatter.setColor(Color.getColor("Yellow",Color.YELLOW)); ComplexMatter.draw(BoundarySquare.inscribingCircle()); //* Maybe the disk I've defined not necessarily required statement. System.out.println("Disk = " + disk.toString()); //* Maybe it was useful naming for a sake of the print-stream command calls System.out.println(("Area of the disk = " + disk.area())); System.out.println("Perimeter of the disk = " + disk.perimeter()); System.out.println("Diameter of the disk = " + disk.diameter()); System.out.println("Radius of the disk = " + disk.radius()); // and for creating the later inscribed/circumscribed shapes as well. //* Step#3: Computation on an inscribed rhombus inside the inscribed circle. SSquare innersquare = disk.inscribingSquare(); ComplexMatter.setHeading(45); ComplexMatter.setBrushWidth(1); ComplexMatter.setColor(Color.magenta); ComplexMatter.paint(innersquare); System.out.println("inner square = " + innersquare.toString()); System.out.println("Area of the inner square = " + innersquare.area()); System.out.println("Perimeter of the inner square = " + innersquare.perimeter()); System.out.println("Diagonal of the inner square = " + innersquare.diagonal()); //* Step#4: Post this on the personal WP via Emacs } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new ShapesThing(); } }); } }