| C:\upload\java\Life\source\java\Vars.java |
import java.awt.*;
final class Vars implements Constants, Strings
{
private PopupWindow error;
private boolean instantiationsSucceeded;
private int rows, columns;
private static Frame parentFrame;
private static int mouseX, mouseY;
private static boolean mouseClicked;
private static boolean editingGame;
private static boolean justEditedBoard;
private static Cursor handCursor;
private static Cursor defaultCursor;
private static int minNumberOfColumns, minNumberOfRows,
maxNumberOfColumns, maxNumberOfRows;
private static int pixelsPerCell,
minPixelsPerCell,
maxPixelsPerCell;
private static int generation;
private static int [][] lastGeneration;
private static int [][] thisGeneration;
private static int [][] nextGeneration;
private static int [][][] oldBoards;
private static int appletWidth, appletHeight;
private static Point appletLocation;
private static int boardWidth, boardHeight;
private static int farthestLeftAComponentLives;
private static boolean waitForTimeDelay;
private static boolean clickLiveCellsViaMouse;
private static int probability;
private static int timeBetweenGenerations;
private static Point genNumLocation;
private static Point keepGoingButtonLocation;
private static Point editGameButtonLocation;
private static Point quitGameButtonLocation;
Vars(Frame parentFrame, ScreenLocations screenLocations)
{
this.parentFrame = parentFrame;
error = new PopupWindow(this.parentFrame, screenLocations, ERROR_WINDOW_NAME);
pixelsPerCell = GARBAGE_VALUE;
columns = GARBAGE_VALUE;
rows = GARBAGE_VALUE;
maxNumberOfColumns = GARBAGE_VALUE;
maxNumberOfRows = GARBAGE_VALUE;
maxPixelsPerCell = GARBAGE_VALUE;
minPixelsPerCell = GARBAGE_VALUE;
minNumberOfRows = GARBAGE_VALUE;
minNumberOfColumns = GARBAGE_VALUE;
timeBetweenGenerations = GARBAGE_VALUE;
probability = GARBAGE_VALUE;
appletWidth = GARBAGE_VALUE;
appletHeight = GARBAGE_VALUE;
boardWidth = GARBAGE_VALUE;
boardHeight = GARBAGE_VALUE;
farthestLeftAComponentLives = GARBAGE_VALUE;
mouseX = GARBAGE_VALUE;
mouseY = GARBAGE_VALUE;
appletLocation = new Point(GARBAGE_VALUE, GARBAGE_VALUE);
thisGeneration = null;
nextGeneration = null;
oldBoards = null;
parentFrame = null;
handCursor = null;
defaultCursor = null;
waitForTimeDelay = false;
clickLiveCellsViaMouse = false;
mouseClicked = false;
editingGame = false;
justEditedBoard = false;
genNumLocation = null;
keepGoingButtonLocation = null;
editGameButtonLocation = null;
quitGameButtonLocation = null;
instantiationsSucceeded = false;
SetHandCursor(new Cursor(Cursor.HAND_CURSOR));
SetDefaultCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
protected void MakeBoards()
{
int height = rows + 2;
int width = columns + 2;
boolean skipInstantiations = false;
if ((thisGeneration != null) &&
(nextGeneration != null) &&
(oldBoards != null))
{
skipInstantiations =
(thisGeneration.length == height) &&
(thisGeneration[0].length == width) &&
(nextGeneration.length == height) &&
(nextGeneration[0].length == width) &&
(oldBoards[0].length == height) &&
(oldBoards[0][0].length == width);
}
if (!skipInstantiations)
{
thisGeneration = new int[height][columns + 2];
nextGeneration = new int[height][columns + 2];
oldBoards = new int[NUMBER_OF_OLDBOARDS][height][width];
}
else
{
;
}
}
protected final void SetRows(int rows)
{
this.rows = rows;
}
protected final int GetRows()
{
return rows;
}
protected final void SetColumns(int columns)
{
this.columns = columns;
}
protected final int GetColumns()
{
return columns;
}
protected final void SetMaxNumberOfRows(int maxNumberOfRows)
{
this.maxNumberOfRows = maxNumberOfRows;
}
protected final int GetMaxNumberOfRows()
{
return maxNumberOfRows;
}
protected final void SetMinNumberOfRows(int minNumberOfRows)
{
this.minNumberOfRows = minNumberOfRows;
}
protected final int GetMinNumberOfRows()
{
return minNumberOfRows;
}
protected final void SetMinNumberOfColumns(int minNumberOfColumns)
{
this.minNumberOfColumns = minNumberOfColumns;
}
protected final int GetMinNumberOfColumns()
{
return minNumberOfColumns;
}
protected final void SetMaxNumberOfColumns(int maxNumberOfColumns)
{
this.maxNumberOfColumns = maxNumberOfColumns;
}
protected final int GetMaxNumberOfColumns()
{
return maxNumberOfColumns;
}
protected final void SetPixelsPerCell(int pixelsPerCell)
{
this.pixelsPerCell = pixelsPerCell;
}
protected final int GetPixelsPerCell()
{
return pixelsPerCell;
}
protected final void SetMinPixelsPerCell(int minPixelsPerCell)
{
this.minPixelsPerCell = minPixelsPerCell;
}
protected final int GetMinPixelsPerCell()
{
return minPixelsPerCell;
}
protected final void SetMaxPixelsPerCell(int maxPixelsPerCell)
{
this.maxPixelsPerCell = maxPixelsPerCell;
}
protected final int GetMaxPixelsPerCell()
{
return maxPixelsPerCell;
}
protected final void SetAppletLocation(Point appletLocation)
{
this.appletLocation = appletLocation;
}
protected final Point GetAppletLocation()
{
return appletLocation;
}
protected final void SetAppletWidth(int appletWidth)
{
this.appletWidth = appletWidth;
}
protected final int GetAppletWidth()
{
return appletWidth;
}
protected final void SetAppletHeight(int appletHeight)
{
this.appletHeight = appletHeight;
}
protected final int GetAppletHeight()
{
return appletHeight;
}
protected final void SetFarthestLeftAComponentLives(int farthestLeftAComponentLives)
{
this.farthestLeftAComponentLives = farthestLeftAComponentLives;
}
protected final int GetFarthestLeftAComponentLives()
{
return farthestLeftAComponentLives;
}
protected final void SetBoardWidth(int boardWidth)
{
this.boardWidth = boardWidth;
}
protected final int GetBoardWidth()
{
return boardWidth;
}
protected final void SetBoardHeight(int boardHeight)
{
this.boardHeight = boardHeight;
}
protected final int GetBoardHeight()
{
return boardHeight;
}
protected final void SetProbability(int probability)
{
this.probability = probability;
}
protected final int GetProbability()
{
return probability;
}
protected final void SetTimeBetweenGenerations(int timeBetweenGenerations)
{
this.timeBetweenGenerations = timeBetweenGenerations;
}
protected final int GetTimeBetweenGenerations()
{
return timeBetweenGenerations;
}
protected final void SetGenerationNumber(int generation)
{
this.generation = generation;
}
protected final void BumpGenerationNumber()
{
generation++;
}
protected final int GetGenerationNumber()
{
return generation;
}
protected final void SetMouseX(int mouseX)
{
this.mouseX = mouseX;
}
protected final int GetMouseX()
{
return mouseX;
}
protected final void SetMouseY(int mouseY)
{
this.mouseY = mouseY;
}
protected final int GetMouseY()
{
return mouseY;
}
protected final int [][] GetLastGeneration()
{
int index;
if (generation % oldBoards.length == 0)
{
index = oldBoards.length - 1;
}
else
{
index = generation % oldBoards.length - 1;
}
return oldBoards[index];
}
protected final void SetThisGeneration(int [][] thisGeneration)
{
this.thisGeneration = thisGeneration;
}
protected final int [][] GetThisGeneration()
{
return thisGeneration;
}
protected final void SetNextGeneration(int [][] nextGeneration)
{
this.nextGeneration = nextGeneration;
}
protected final int [][] GetNextGeneration()
{
return nextGeneration;
}
protected final void SetOldBoards(int [][][] oldBoards)
{
this.oldBoards = oldBoards;
}
protected final int [][][] GetOldBoards()
{
return oldBoards;
}
protected final void SetWaitForTimeDelay(boolean waitForTimeDelay)
{
this.waitForTimeDelay = waitForTimeDelay;
}
protected final boolean GetWaitForTimeDelay()
{
return waitForTimeDelay;
}
protected final void SetClickLiveCellsViaMouse(boolean clickLiveCellsViaMouse)
{
this.clickLiveCellsViaMouse = clickLiveCellsViaMouse;
}
protected final boolean GetClickLiveCellsViaMouse()
{
return clickLiveCellsViaMouse;
}
protected final void SetMouseClicked(boolean mouseClicked)
{
this.mouseClicked = mouseClicked;
}
protected final boolean GetMouseClicked()
{
return mouseClicked;
}
protected final void SetEditingGame(boolean editingGame)
{
this.editingGame = editingGame;
}
protected final boolean GetEditingGame()
{
return editingGame;
}
protected final void SetJustEditedBoard(boolean justEditedBoard)
{
this.justEditedBoard = justEditedBoard;
}
protected final boolean GetJustEditedBoard()
{
return justEditedBoard;
}
protected final void SetHandCursor(Cursor handCursor)
{
this.handCursor = handCursor;
}
protected final Cursor GetHandCursor()
{
return handCursor;
}
protected final void SetDefaultCursor(Cursor defaultCursor)
{
this.defaultCursor = defaultCursor;
}
protected final Cursor GetDefaultCursor()
{
return defaultCursor;
}
protected final void SetGenNumLocation(Point genNumLocation)
{
this.genNumLocation = genNumLocation;
}
protected final void SetKeepGoingButtonLocation(Point keepGoingButtonLocation)
{
this.keepGoingButtonLocation = keepGoingButtonLocation;
}
protected final void SetEditGameButtonLocation(Point editGameButtonLocation)
{
this.editGameButtonLocation = editGameButtonLocation;
}
protected final void SetQuitGameButtonLocation(Point quitGameButtonLocation)
{
this.quitGameButtonLocation = quitGameButtonLocation;
}
protected final Point GetGenNumLocation()
{
return genNumLocation;
}
protected final Point GetKeepGoingButtonLocation()
{
return keepGoingButtonLocation;
}
protected final Point GetEditGameButtonLocation()
{
return editGameButtonLocation;
}
protected final Point GetQuitGameButtonLocation()
{
return quitGameButtonLocation;
}
protected final void SetParentFrame(Frame parentFrame)
{
this.parentFrame = parentFrame;
}
protected final Frame GetParentFrame()
{
return parentFrame;
}
}