import java.awt.Color; import java.util.*; import uwcse.io.*; import uwcse.graphics.*; import javax.swing.*; /** * A class to create and manipulate graphics elements stored in an ArrayList */ public class GraphicsElements { /** Maximum number of disks in a pile of disks */ public static final int MAXIMUM_NUMBER_OF_DISKS = 100; /** Maximum number of rows (or columns) in a square checkered board */ public static final int MAXIMUM_NUMBER_OF_ROWS = 50; /** Maximum number of points in a Sierpinski triangle */ public static final int MAXIMUM_NUMBER_OF_POINTS = 10000; /** Width of the window (from ViewWindow) */ public static final int WIDTH = ViewWindow.WINDOW_WIDTH; /** Height of the window (from ViewWindow) */ public static final int HEIGHT = ViewWindow.WINDOW_HEIGHT; // Put your other instance fields here (if you need any) /** * Create a top view of a pile of disks of decreasing diameters (from bottom * to top). Use filled circles. The color of each disk is random. The pile * should fill the window.
* Store the circles in an ArrayList and return that ArrayList (the disk at * the bottom should be the first element of the ArrayList)
* The number of disks is given by the user (use a dialog box). If that * number is less than or equal to 0 or greater than * MAXIMUM_NUMBER_OF_DISKS, display an error message (use * JOptionPane.showMessageDialog)and ask for it again. */ public ArrayList createAPileOfDisks() { } /** * Create a square checkered board. Create a Rectangle for each square on * the board. Store the Rectangles in an ArrayList and return that * ArrayList. Use two colors only to paint the squares.
* The board should cover most of the window. The number of rows (=number of * columns) is given by the user (use a dialog box). If that number is less * than or equal to 0 or greater than MAXIMUM_NUMBER_OF_ROWS, display an * error message (use JOptionPane.showMessageDialog)and ask for it again. */ public ArrayList createACheckeredBoard() { } /** * Create a Sierpinski triangle. Create a filled Oval (circle of radius 1) * for each point of the triangle. Store the Ovals in an ArrayList and * return that ArrayList. Use one color only to paint the Ovals.
* The triangle should cover most of the window.
* The number of points is given by the user (use a dialog box). If that * number is less than or equal to 0 or greater than * MAXIMUM_NUMBER_OF_POINTS, display an error message (use * JOptionPane.showMessageDialog)and ask for it again. */ public ArrayList createASierpinskiTriangle() { } /** * Rotate the colors in the pile of disks. Set the color of each disk to the * color of the disk just above it. For the top disk, set its color to the * color of the bottom disk (e.g. with 3 disks, if the colors are from * bottom to top, red, blue, yellow, the new colors of the disks are from * bottom to top, blue, yellow, red).
* Precondition: graphicsList describes a pile of disks */ public ArrayList rotateColorsInPileOfDisks(ArrayList graphicsList) { } /** * Flip the 2 colors of the checkboard
* Precondition: graphicsList describes a checkered board */ public ArrayList flipColorsInCheckeredBoard(ArrayList graphicsList) { } /** * Change the color of the Sierpinski triangle (all circles should change to * the same color). Switch between 3 colors (e.g. blue->red->green, if the * triangle was blue, make it red, if it was red, make it green, if it was * green make it blue).
* Precondition: graphicsList describes a Sierpinski triangle */ public ArrayList changeColorsInSierpinskiTriangle(ArrayList graphicsList) { } /** * Return the color at location (x,y) in the pile of disks. If (x,y) is not * part of the pile of disks, return null.
* Precondition: graphicsList describes a pile of disks */ public Color getColorInPileOfDisks(int x, int y, ArrayList graphicsList) { } /** * Return the color at location (x,y) in the checkered board. If (x,y) is * not part of the board, return null.
* Precondition: graphicsList describes a checkered board */ public Color getColorInCheckeredBoard(int x, int y, ArrayList graphicsList) { } /** * Return the color at location (x,y) in the Sierpinski triangle. If (x,y) * is not part of the pile of disks, return null.
* Precondition: graphicsList describes a Sierpinski triangle */ public Color getColorInSierpinskiTriangle(int x, int y, ArrayList graphicsList) { } }