CS1 Standard Demo Page

The following text was written to the standard output stream when the Invention1 program was executed from Netbeans.

/*
 * Invention1
 */
package npw;

import java.awt.Color;
import java.util.Random;
import java.util.Scanner;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import painter.SPainter;
import shapes.SCircle;
import shapes.SSquare;

/**
 *
 * @author dmaslows
 */
public class Invention1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new Invention1();
            }
        });
    }

    public Invention1() {
        paintTheImage();
    }

    private void paintTheImage() {
        int nrofrows = 25;
        int nrofcolumns = 25;
        int sizeofsquare = 25;
        int height = nrofrows * sizeofsquare;
        int width = nrofcolumns * sizeofsquare;
        SPainter miro = new SPainter("Invention1", width + 50, height + 50);
        miro.setBrushWidth(4);
        SSquare square = new SSquare(sizeofsquare);
        SCircle c = new SCircle(34);
        paintRectangle(miro, square, nrofrows, nrofcolumns);
        paintOneCircle(miro, c);
        SSquare s = new SSquare(35);
        miro.setColor(Color.CYAN);
        miro.mlt(200);
        miro.paint(s);
        miro.mbk(100);
        miro.paint(s);
        miro.mfd(50);
        miro.paint(s);
        miro.mlt(50);
        miro.paint(s);
        miro.mrt(200);
        miro.paint(s);
        miro.mbk(100);
        miro.paint(s);
        miro.mfd(50);
        miro.paint(s);
        miro.mrt(50);
        miro.paint(s);

    }

    private static void paintRectangle(SPainter miro, SSquare square, int nrofrows, int nrofcolumns) {
        miro.mlt(1);
        miro.mbk(1);
        int i = 1;
        while (i <= nrofrows) {
            paintOneRow(miro, nrofcolumns, square);
            miro.mfd(-3);

            i = i + 1;

        }
        miro.mfd(-3);

    }

    private static void paintOneRow(SPainter miro, int nrofcolumns, SSquare square) {
        int i = 1;
        while (i <= nrofcolumns) {
            paintOneSquare(miro, square);

            i = i + 1;

        }
        miro.mlt(+3);
        miro.mrt(-2);

    }

    private static void paintOneSquare(SPainter miro, SSquare square) {
        miro.setColor(Color.MAGENTA);
        miro.paint(square);
        miro.setColor(Color.BLACK);
        miro.draw(square);
    }

    private static void paintOneCircle(SPainter miro, SCircle c) {
        int sideLength = 700;
        int decrement = (sideLength / 2);
        Color a = Color.CYAN;
        Color b = Color.darkGray;
        int i = 1;
        if (i % 2 == 1) {
            miro.setColor(a);
        } else {
            miro.setColor(b);
        }
        miro.paint(c);
        c.shrink(decrement);
        miro.setColor(Color.CYAN);

        miro.moveToCenter();
        miro.paint(c);
        miro.setColor(Color.BLACK);
        miro.draw(c);
        c.x2();
    }
}