User:Simpsons contributor/Mandelbrot set creator. Self made

package mandelbrot;

import java.awt.Color;

public class Processor {     private int width, height, maxIteration, multiple; private double xMin, xMax, yMin, yMax; private double planeWidth, planeHeight; private String saveName; private int sumProcess; public void runWithMinMax(double widthIn, double heightIn, double xMinIn, double xMaxIn,                      double yMinIn, double yMaxIn, int maxIterationIn, int multipleIn,                      String saveLocation) {       width = convert(widthIn); height = convert(heightIn); xMin = xMinIn; xMax = xMaxIn; yMin = yMinIn; yMax = yMaxIn; maxIteration = maxIterationIn; multiple = multipleIn; saveName = saveLocation; run; }   public void runWithCentreOnlyWidth(double widthIn, double heightIn, double planeWidthIn,                               double centreXIn, double centreYIn,                               int maxIterationIn, int multipleIn, String saveLocation) {       width = convert(widthIn); height = convert(heightIn); planeHeight = (heightIn / widthIn) * planeWidthIn; planeWidth = planeWidthIn; xMin = centreXIn - (planeWidth / 2); xMax = centreXIn + (planeWidth / 2); yMin = centreYIn - (planeHeight / 2); yMax = centreYIn + (planeHeight / 2); multiple = multipleIn; maxIteration = maxIterationIn; saveName = saveLocation; run; }   public void runWithCentreOnlyHeight(int widthIn, int heightIn, double planeHeightIn,                              double centreXIn, double centreYIn,                              int maxIterationIn, int multipleIn, String saveLocation) {       width = convert(widthIn); height = convert(heightIn); planeWidth = (widthIn / heightIn) * planeHeightIn; planeHeight = planeHeightIn; xMin = centreXIn - (planeWidth / 2); xMax = centreXIn + (planeWidth / 2); yMin = centreYIn - (planeHeight / 2); yMax = centreYIn + (planeHeight / 2); multiple = multipleIn; maxIteration = maxIterationIn; saveName = saveLocation; run; }   public void runWithCentre(int widthIn, int heightIn, double planeHeightIn,                                double planeWidthIn, double centreXIn, double centreYIn,                               int maxIterationIn, int multipleIn, String saveLocation) {       width = convert(widthIn); height = convert(heightIn); planeWidth = planeWidthIn; planeHeight = planeHeightIn; xMin = centreXIn - (planeWidth / 2); xMax = centreXIn + (planeWidth / 2); yMin = centreYIn - (planeHeight / 2); yMax = centreYIn + (planeHeight / 2); multiple = multipleIn; maxIteration = maxIterationIn; saveName = saveLocation; run; }   private void run {                 ImageHolder image = new ImageHolder(width, height); double xLength, yLength; double xDifference, yDifference; double xLocation, yLocation; sumProcess = 0; /*Create a new complex plane and ImageHolder * based upon the width and height dimensions*/ image = new ImageHolder(width, height); /*The complex number plane has the dimensions of the image * [width] [height]. The values of the complex numbers in        * the complex number plane is different. Use the values of        * xMin, xMax, yMin and yMax to fill the plane with the * actual values of the plane. */       //Work out the length width of the complex plane xLength = xMax - xMin; yLength = yMax - yMin; /*Work out the difference on the x and y axes that results from * the move from one pixel to the next */ xDifference = xLength / width; yDifference = yLength / height; /*Set xLocation and Ylocation to xMin and yMin and then sweep * through the complex plane in an x-y fashion setting each real * and imaginary value on the way */ xLocation = xMin; yLocation = yMin; //Make main image and save for(int x=0; x<width; x++) {           for(int y=0; y<height; y++) {                                         Color color = getColor(xLocation, yLocation); image.setRGB(x, height-y-1, color); yLocation = yLocation + yDifference; }           yLocation = yMin; xLocation = xLocation + xDifference; } //End of nested for loops image.save(saveName, "png"); }   private int convert(double input) {       Number number = input; return number.intValue; }   private Color getColor(double xLocation, double yLocation) {       int counter = 0, red = 0, green = 0, blue = 0; Complex valueN = new Complex; Complex valueNPlus1 = new Complex; ComplexOperations operations = new ComplexOperations; double real, imaginary, z, colour; //Create new complex and set it to coordinates valueN.setReal(xLocation); valueN.setImaginary(yLocation); valueNPlus1.setReal(xLocation); valueNPlus1.setImaginary(yLocation); //Get values real = valueN.realDouble; imaginary = valueN.imaginaryDouble; while(real*real + imaginary*imaginary <= 4 &&              counter < maxIteration) {            //Create (n+1) complex: x(n+1) = x(n)^2 + c             valueNPlus1 = operations.multiply(valueNPlus1, valueNPlus1); valueNPlus1 = operations.add(valueNPlus1, valueN); //Get values real = valueNPlus1.realDouble; imaginary = valueNPlus1.imaginaryDouble; //Advance counters by one counter++; sumProcess++; }          if(counter == maxIteration) return new Color(0, 0, 0); else //Non-black {            z = Math.sqrt(real*real + imaginary*imaginary); colour = counter + 1 - (Math.log(Math.log(z)) / Math.log(2)); //Convert "iteration" to new "colour" value Number colourNumber = multiple * colour; counter = colourNumber.intValue; if(counter <= 255) {                red = 255; blue = 0; green = counter; }            if(counter > 255 && counter <= 510) {                green = 255; blue = 0; red = 510 - counter; }            if(counter > 510 && counter <= 765) {                green = 255; red = 0; blue = counter - 510; }             if(counter > 765 && counter <= 1020) {                blue = 255; red = 0; green = 1020 - counter; }            if(counter > 1020 && counter <= 1275) {                blue = 255; green = 0; red = counter - 1020; }            if(counter > 1275) {                red = 255; blue = 255; green = 0; }            return new Color(red, green, blue); } //End of colour determine }   public int getSumProcess {       return sumProcess; } }