/* Copyright 2001 Michael R. Wick */ package Scopes; import Shapes.*; import java.util.*; import java.awt.Point; import java.awt.Color; import Factories.*; import Strategies.*; import Views.*; import Util.*; public class Kaleidoscope { protected static Randomizer r = new Randomizer(); protected ShapeVector theShapes; protected Vector theViews; protected ShapeFactory theFactory; protected ShapeMutationStrategy theStrategy; public Kaleidoscope(ShapeFactory factory, ShapeMutationStrategy strategy) { theShapes = new ShapeVector(); theViews = new Vector(); theFactory = factory; theStrategy = strategy; } public ShapeIterator getShapes(){ return (theShapes.iterator() ); } public void register( KaleidoscopeView v ) { theViews.addElement(v); } public void turn(){ // Mutate the existing shapes. for( int i = 0; i < theShapes.size() ; i++){ theStrategy.mutate( theShapes.elementAt(i) ); } // Add new shape from factory. theShapes.addElement( theFactory.createShape() ); // Update the views for(int i = 0; i < theViews.size(); i++){ ((KaleidoscopeView)( theViews.elementAt(i) )).update(); } } }