diff --git a/src/cancergrowth/Cell.java b/src/cancergrowth/Cell.java index 9233e0c..0458323 100644 --- a/src/cancergrowth/Cell.java +++ b/src/cancergrowth/Cell.java @@ -18,25 +18,25 @@ import java.util.Scanner; public class Cell extends Object { - private int xval; + private int xval; // Declare variables like position, cycle timing private int yval; private ArrayList stages = new ArrayList(); private int currentStage; private int currentTime; private static final BufferedImage p0; - private static BufferedImage[] p1 = new BufferedImage[12]; + private static BufferedImage[] p1 = new BufferedImage[12]; // Create cell images before the widnow opens private static final BufferedImage p2; private static final BufferedImage p3; - private static final BufferedImage p4; + private static final BufferedImage p4; static { boolean transparent = true; for (int count = 0; count < p1.length; count++) { - BufferedImage g1 = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB); + BufferedImage g1 = new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB); // Use buffers to preload all possible images Graphics gg1 = g1.getGraphics(); - if (transparent) + if (transparent) // Check if we want transparency { gg1.setColor(new Color(255, 0, 0, 127)); } @@ -48,7 +48,7 @@ public class Cell extends Object int pos; width = (int) ((count + 1) * 2 + 22.5); pos = (50 - width) / 2; - gg1.fillOval(pos, pos, width, width); + gg1.fillOval(pos, pos, width, width); // Draw and fill an oval with a border and text in the middle gg1.setColor(Color.BLACK); gg1.drawOval(pos, pos, width, width); gg1.drawString("G1", 18, 30); @@ -117,7 +117,7 @@ public class Cell extends Object p0 = g0; } - public Cell(int x, int y) + public Cell(int x, int y) // Constructor { xval = x; yval = y; @@ -143,10 +143,10 @@ public class Cell extends Object { return myColor; }*/ - public Cell performTime(boolean run) + public Cell performTime(boolean run) // Perform the simulation for this cell { - if (!run || currentStage == 4) - { + if (!run || currentStage == 4) // If we are gonna kill the cells, a protein is received and the cells enter gap0. + { // They are then eaten by a macrophage (white blood cell), represented by pacman. if (run) { currentStage = 0; @@ -156,39 +156,39 @@ public class Cell extends Object int random = (int) (Math.random() * 10); if (random == 0) { - currentStage = 4; + currentStage = 4; // gap0 = stage 4 in my code } return this; } } - this.currentTime++; + this.currentTime++; // increase elapsed time Cell newcell = this; //System.out.println("Increased Current Time to:" + this.currentTime); - if (this.currentTime > stages.get(this.currentStage)) + if (this.currentTime > stages.get(this.currentStage)) // Check if it's time to change phases { - if (currentStage == 3) + if (currentStage == 3) { - // SPLIT - int width = (int) (-50 + Math.random() * 101); + // If we need to split this code runs + int width = (int) (-50 + Math.random() * 101); //randomize splitting direction int height = (int) (-50 + Math.random() * 101); while (width < 20 && width > -20) - { - width = (int) (-50 + Math.random() * 101); + { // continue randomization if the cell don't split far enough (inside each other) + width = (int) (-50 + Math.random() * 101); } while (height < 20 && height > -20) { height = (int) (-50 + Math.random() * 101); } - newcell = new Cell(xval + width, yval + height); + newcell = new Cell(xval + width, yval + height); // create a daughter cell //stages = new ArrayList(); //stages.add(10 + (int) Math.random() * 3 - 1); //stages.add(7 + (int) Math.random() * 3 - 1); //stages.add(3 + (int) Math.random() * 3 - 1); //stages.add(1 + (int) Math.random() * 2); - xval -= width; + xval -= width; yval -= height; - currentStage = 0; + currentStage = 0; // have this cell become a daughter cell currentTime = 1; } else @@ -204,7 +204,7 @@ public class Cell extends Object } public Image getImage() - { + { // return the static images if (currentStage == 0) { return p1[currentTime];