User:Simpsons contributor/CreateAnimated

package cellularautomaton;

import java.io.File; import java.io.FileNotFoundException; import java.io.IOException;

/** * Creates an animated gif of x frames representing the evolution of a cellular automaton * @author George Miller */

public class CreateAnimated {   private CreateAnimatedFromString create = new CreateAnimatedFromString; private CreateStringOfImages string = new CreateStringOfImages; private FileHandling handle = new FileHandling; public void wireWorld(String firstGeneration, String saveName, int numberOfGenerations,                          boolean delete) throws FileNotFoundException, IOException {       //Create temp folder String randomFileName = randomName(6); String directoryLocation = "C:/Users/George Miller/Pictures" + randomFileName + "/"; File dirTest = new File(directoryLocation); boolean exists = true; do       { //Check to make sure that folder doesn't exist if(dirTest.isDirectory == true) {               randomFileName = randomName(6); directoryLocation = "C:/Users/George Miller/Pictures" + randomFileName + "/"; dirTest = new File(directoryLocation); }           else exists = false; } while (exists == true); //Create that directory dirTest.mkdir; string.wireWorld(numberOfGenerations, firstGeneration, directoryLocation); create.createImage(directoryLocation, saveName, 0, numberOfGenerations); if(delete == true) handle.deleteDirectory(directoryLocation); }   public void wireWorldColorChange(String firstGeneration, String saveName, int numberOfGenerations,                                     ColorPair [] colors, boolean delete) throws FileNotFoundException, IOException {       //Create temp folder String randomFileName = randomName(6); String directoryLocation = "C:/Users/George Miller/Pictures/" + randomFileName + "/"; File dirTest = new File(directoryLocation); boolean exists = true; do       { //Check to make sure that folder doesn't exist if(dirTest.isDirectory == true) {               randomFileName = randomName(6); directoryLocation = "C:/Users/George Miller/Pictures/" + randomFileName + "/"; dirTest = new File(directoryLocation); }           else exists = false; } while (exists == true); //Create that directory dirTest.mkdir; string.wireWorldColorChange(numberOfGenerations, firstGeneration, directoryLocation, colors); create.createImage(directoryLocation, saveName, 0, numberOfGenerations); if(delete == true) handle.deleteDirectory(directoryLocation); }   private String randomName(int length) {       String name = new String; for(int i=0; i<=length; i++) {           int random = (int) (10 * Math.random); name += random; } //End of random name create return "Z " + name; } }