package se1021.lab2; /** * SE1021 Lab 2 * Shape Creator Application main class * December 9, 2009 */ import java.awt.Color; import se1021.lab2.shapes.*; import edu.msoe.se1010.winPlotter.WinPlotter; /** * @author hornick * This class creates shapes and "tells" them to draw themselves in a provided WinPlotter window. */ public class ShapeCreatorApp { /** * @param args not used */ public static void main(String[] args) { WinPlotter p = new WinPlotter(); // create the WinPlotter object initWinPlotter(p); // delegate initialization of the WinPlotter object to a method // For ornaments, create some generic shapes and draw them Shape s1 = new Shape(60, 15, Color.orange); s1.draw(p); Shape s2 = new Shape(88, 18, Color.red); s2.draw(p); Shape s3 = new Shape(85, 23, Color.blue); s3.draw(p); Shape s4 = new Shape(77, 29, Color.yellow); s4.draw(p); Shape s5 = new Shape(70, 35, Color.magenta); s5.draw(p); Shape s6 = new Shape(72, 42, Color.cyan); s6.draw(p); // next, create some triangles to form the tree Shape t1 = new Triangle(50, 10, 50, 25, Color.green); t1.draw(p); Shape t2 = new Triangle(55, 20, 40, 20, Color.green); t2.draw(p); Shape t3 = new Triangle(60, 30, 30, 15, Color.green); t3.draw(p); Shape t4 = new Triangle(65, 40, 20, 10, Color.green); t4.draw(p); // here's the trunk Shape r1 = new Rectangle(70, 0, 10, 20, Color.ORANGE ); r1.draw(p); // the "star" Shape c1 = new Circle( 75, 55, 5, Color.red ); Shape c2 = new Circle( 75, 55, 4, Color.orange ); Shape c3 = new Circle( 75, 55, 3, Color.yellow ); Shape c4 = new Circle( 75, 55, 2, Color.white ); c1.draw(p); c2.draw(p); c3.draw(p); c4.draw(p); // The good stuff... Shape present1 = new LabeledRectangle(0, 0, 48, 20, Color.BLUE, "To: Mark"); Shape present2 = new LabeledRectangle(5, 20, 20, 20, Color.CYAN, "To: Mark"); Shape present3 = new LabeledTriangle(27, 20, 20, 10, Color.YELLOW, "To: Mark"); present3.draw(p); present2.draw(p); present1.setColor(Color.red); // reset the color to red present1.draw(p); } /** * This method initializes the WinPlotter object */ public static void initWinPlotter(WinPlotter p) { p.setWindowTitle("A Christmas Wish..."); p.setWindowSize(800, 600); // set window size p.setPlotBoundaries(-5, -5, 105, 75); // set logical boundaries p.setGrid(true, 10, 10, Color.GRAY); // setup a grid // set the background to black p.setBackgroundColor( Color.black.getRed(), Color.black.getGreen(), Color.black.getBlue() ); } }