package opartgui;
import java.awt.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.applet.Applet;
import java.awt.geom.*;
import java.awt.image.*;
import java.awt.image.BufferedImage;

public class Pause{
      int x, y;
      int w = 600;
      int h = 600;
      int turnaround = 19;
      int circleQuantity = 30;
      int circleSize = 30;
      int colourChange = 20;
      Rectangle area;
      BufferedImage displayImage;
      Graphics2D dispGc;
      boolean invert = false;
      int changes[] = {4,2,1,1};

      public Pause(){

      }

      protected void createDisplayImage(){
        displayImage = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
        setOffScrGc();
      }

      protected void setOffScrGc(){
        if (displayImage != null){
             dispGc = displayImage.createGraphics();
             dispGc.fillRect(0,0,600,600);
             dispGc.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        }
      }

      public BufferedImage doDraw(int changeOneField,
                       int changeTwoField,
                       int changeThreeField,
                       int changeFourField,
                       int circleSizeField,
                       int circleQuantityField,
                       int turnaroundField, int colourChangeField){
       	changes[0] = changeOneField;
       	changes[1] = changeTwoField;
       	changes[2] = changeThreeField;
        changes[3] = changeFourField;
        circleSize = circleSizeField;
        colourChange = colourChangeField;
        circleQuantity = (circleQuantityField*2);
       	turnaround = turnaroundField;
        displayImage = (imageDraw());
        return displayImage;
      }

      public BufferedImage imageDraw(){
             createDisplayImage();
             int i,j;
             int xcurrent=20;
             boolean pt = false;
             int blkint = 5;
             for(j=1;j<circleQuantity;j++){
                int circletmp = circleSize;
                     for(i=1;i<circleQuantity;i++){
	                        if(i>=(turnaround-11) && i<(turnaround-7)){circleSize = circleSize-changes[0];}
                                if(i>=(turnaround-7) && i<(turnaround-5)){circleSize = circleSize-changes[1];}
                                if(i>=(turnaround-5) && i<(turnaround-3)){circleSize = circleSize-changes[2];}
                                if(i>=(turnaround-3) && i<(turnaround-1)){circleSize = circleSize-changes[3];}
                                if(i>=turnaround && i<(turnaround+2)){circleSize = circleSize+changes[3];}
                                if(i>=(turnaround+2) && i<(turnaround+4)){circleSize = circleSize+changes[2];}
                                if(i>=(turnaround+4) && i<(turnaround+6)){circleSize = circleSize+changes[1];}
                                if(i>=(turnaround+6) && i<(turnaround+10)){circleSize = circleSize+changes[0];}
                                if(i-j>=(turnaround-19) && i-j<(turnaround-15)){blkint = blkint +colourChange;}
                                if(i-j>=(turnaround-15) && i-j<(turnaround-13)){blkint = blkint +colourChange;}
                                if(i-j>=(turnaround-13) && i-j<(turnaround-11)){blkint = blkint +colourChange;}
                                if(i-j>=(turnaround-11) && i-j<(turnaround-9)){blkint = blkint +colourChange;}
                                if(i-j>=(turnaround-9) && i-j<(turnaround-6)){blkint = blkint -colourChange;}
                                if(i-j>=(turnaround-6) && i-j<(turnaround-4)){blkint = blkint -colourChange;}
                                if(i-j>=(turnaround-4) && i-j<(turnaround-2)){blkint = blkint -colourChange;}
                                if(i-j>=(turnaround-2) && i-j<(turnaround+2)){blkint = blkint -colourChange;}
                                dispGc.setColor(new Color(250,250,250));
                                if (blkint < 0)blkint = 1;
                                if (blkint > 255) blkint = 254;
                                if (pt==false){
                                   dispGc.setColor(new Color(blkint,blkint,blkint));
                                }
		                dispGc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                                dispGc.fill(new Ellipse2D.Double(xcurrent,20+(circletmp*(j-1)),circleSize,circletmp));
                                if (pt==false){
                                              	pt = true;
                                }
                                else{
                                    	pt=false;
                                }
                                xcurrent = xcurrent + circleSize;
                     }
                     blkint = 5;
                     xcurrent = 20;
                     circleSize = circletmp;
             }
             return displayImage;
        }

}
