Jump to content

Running Processing in Eclipse as an Application

mvanegas's Photo
Posted Jan 19 2011 12:56 PM
3663 Views

I am running Processing in eclipse as an application but using its "--present" mode. When I run as an application, my screen background becomes black, and my canvas is drawn in the center of the screen. Inside my setup() method, I begin with size(1260, 920), which draws the canvas in the center of the black background. What I want is to draw my canvas on the top left of my screen.

Translate() only moves all the components within the always-centered canvas. What method can I use to move my entire canvas to the left?





import java.io.File;
import java.net.URL;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;

import java.applet.AudioClip;
import java.awt.Canvas;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.*;

import ddf.minim.AudioPlayer;
import ddf.minim.Minim;

import processing.core.*;

import sun.audio.*; //import the sun.audio package
import java.io.*;

import mpe.client.*;

//http://www.javaworld.com/javatips/jw-javatip24.html
//http://download.oracle.com/javase/tutorial/sound/playing.html


/*
* Classes needed for experiment:rod10
* Gauges.java (main)
* meter.java
* E0.java, E1.java, E2.java, E3.java
* Modal.java
* ChatBox2.java
* RatingGUI.java
* ReadFile.java
*/

/*
* Before Finalizing experiment, ensure time constraints are correct
* ChatBox2, line 52: change initial delay to how often chat messages appear (1111)
* Gauges.java: change ratingGUI appearance time (2222)
* Gauges.java: change scram() to goOff at time set by parameter 1 (3333)
*/


public class Gauge extends PApplet {
public static void main(String args[]) {
PApplet.main(new String[] {"--present", "Gauge" });

}

public Gauge(){
System.out.println("gauges ONE");

}

PApplet applet;
public static String newLine = System.getProperty("line.separator"); //a variable that makes a new line
protected static final String textFieldString = "JTextField"; //
JTextArea textArea = new JTextArea();
//String SubjectNumber = modal.getSubjectNumber();
//String Parameter1 = modal.getTestParameter1();
//String Parameter2 = modal.getTestParameter2();
String LogFile;
public String getTitle(){
return LogFile;
}
//public static String hey = "this is"+SubjectNumber;

static String Subnum;
static String Par1;
static String Par2;
static String Par3;

Gauge gauge;

// Create all variables//
int prbx1, prbx2, prbx3, prbx4, prbx5, prbx6, prby1, prby2, prby3, prby4,
prby5, prby6, prbx7, prby7;
int plbx1, plbx2, plbx3, plbx4, plbx5, plbx6, plby1, plby2, plby3, plby4,
plby5, plby6, plby7, plbx7;
int vhbx1, vhby1, vhbx2, vhby2, vhbx3, vhby3, vhbx4, vhby4, vvbx1, vvby1,
vvbx2, vvby2, vvbx3, vvby3, vvbx4, vvby4;
int tcx1, tcx2, tcx3, tcx4, tcy1, tcy2, tcy3, tcy4;
int siax, siay, sibx, siby;
int vilx1, vilx2, vilx3, vilx4, vily1, vily2, vily3, vily4;
int rodUpx, rodUpy, rodDownx, rodDowny, rodAutox, rodAutoy, rod10x, rod10y,
rod5x, rod5y, rod1x, rod1y;
int wa1x, wa1y, wa2x, wa2y, wa3x, wa3y, wa4x, wa4y, wb1x, wb1y, wb2x, wb2y,
wb3x, wb3y, wb4x, wb4y, warnx, warny;
int turbx1, turby1, trapx1, trapy1, guage1x1, guage1y1, guagesx1, guagesy1,
rodinx, rodiny, reactorx, reactory, joint1x, joint1y, joint2x,
joint2y, sgx1, sgx2, sgx3, sgx4, sgy1, sgy2, sgy3, sgy4;
double rodlevel = 0;
int rodspeed = 0;

int redOn = color(241, 35, 55);
int greenOn = color(24, 239, 30);
int yellowOn = color(251, 245, 26);
int redOff = color(113, 13, 22);
int greenOff = color(27, 95, 3);
int yellowOff = color(133, 151, 4);
int white = color(255, 255, 255);
public final int black = color(0, 0, 0);

boolean prb1Over = false;
boolean prb2Over = false;
boolean prb3Over = false;
boolean prb4Over = false;
boolean prb5Over = false;
boolean prb6Over = false;
boolean prb7Over = false;

boolean plb1Over = false;
boolean plb2Over = false;
boolean plb3Over = false;
boolean plb4Over = false;
boolean plb5Over = false;
boolean plb6Over = false;
boolean plb7Over = false;

boolean vhb1Over = false;
boolean vhb2Over = false;
boolean vhb3Over = false;
boolean vhb4Over = false;
boolean vvb1Over = false;
boolean vvb2Over = false;
boolean vvb3Over = false;
boolean vvb4Over = false;

boolean tc1Over = false;
boolean tc2Over = false;
boolean tc3Over = false;
boolean tc4Over = false;
boolean siaOver = false;
boolean sibOver = false;

boolean vil1Over = false;
boolean vil2Over = false;
boolean vil3Over = false;
boolean vil4Over = false;

boolean rodUpOver = false;
boolean rodDownOver = false;
boolean rodAutoOver = false;
boolean rod10Over = false;
boolean rod5Over = false;
boolean rod1Over = false;

boolean wa1Over = false;
boolean wa2Over = false;
boolean wa3Over = false;
boolean wa4Over = false;
boolean wb1Over = false;
boolean wb2Over = false;
boolean wb3Over = false;
boolean wb4Over = false;

boolean prb1On = true;
boolean prb2On = true;
boolean prb3On = true;
boolean prb4On = true;
boolean prb5On = true;
boolean prb6On = true;
boolean prb7On = false;

boolean plb1On = true;
boolean plb2On = true;
boolean plb3On = true;
boolean plb4On = true;
boolean plb5On = true;
boolean plb6On = true;
boolean plb7On = false;

boolean vhb1On = true;
boolean vhb2On = true;
boolean vhb3On = true;
boolean vhb4On = true;
boolean vvb1On = true;
boolean vvb2On = true;
boolean vvb3On = true;
boolean vvb4On = true;

boolean tc1On = true;
boolean tc2On = true;
boolean tc3On = true;
boolean tc4On = true;
boolean siaOn = true;
boolean sibOn = true;

boolean wa1On = false;
boolean wa2On = false;
boolean wa3On = false;
boolean wa4On = false;
boolean wb1On = false;
boolean wb2On = false;
boolean wb3On = false;
boolean wb4On = false;

int vil1On = 2;
int vil2On = 2;
int vil3On = 2;
int vil4On = 2;

boolean rod10On = false;
boolean rod5On = false;
boolean rod1On = false;
boolean autoOn = true;
boolean rodDownClicked = false;
boolean rodUpClicked = false;
boolean rodUp = false;

int lineCt = 0;

boolean A1 = false;
boolean A2 = false;
boolean A3 = false;
boolean A4 = false;
boolean B1 = false;
boolean B2 = false;
boolean B3 = false;
boolean B4 = false;

boolean rodAutoOn = false;
boolean NeutronFluxDrop = false;
int TimeScram = 0;
int TotalPower;

boolean SG1ruptured = false;
boolean SG2ruptured = false;
boolean SG3ruptured = false;
boolean SG4ruptured = false;

// variables that change for the three events
boolean SGPress1Dropping = false;
boolean SGPress1Rising = false;
boolean E1wentOff = false;
boolean E2wentOff = false;
boolean E3wentOff = false;
boolean E1complete = false;
boolean E2complete = false;
boolean E3complete = false;
static boolean E1Alarm = false;


/////////////////////////////defining interface variables
double RodPosition;




//playing a sound
// Open an input stream to the audio file.
AlarmThread thread1;






/// run the rating gui
ActionListener powerPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
BufferedWriter Writer;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" Total Power Output: " + TotalPower + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};


ActionListener eventPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
BufferedWriter Writer;
if(Par1.equals("1")){ // modal.getTestParameter1().equals("1")){
E1wentOff = true;
thread1.start();
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Event Occured" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(Par1.equals("2")){ // modal.getTestParameter1().equals("2")){
E2wentOff = true;
thread1.start();
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Event Occured" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(Par1.equals("3")){ // modal.getTestParameter1().equals("3")){
E3wentOff = true;
thread1.start();
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Event Occured" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};


// E-0
public void scram(){
TimeScram = (int)System.currentTimeMillis();
//1
warningsAdd("scram"); //Scram + Turbine warnings on!
//warningsAdd("turbine");
//2
rodlevel = 100; //Drop the rods!
//3 - A3 lit, just use conditions
prb7On = true;
plb7On = true;
//4 SI trains activated (red)
siaOn = false;
sibOn = false;

tc1On = false; //Auto trip (off) the turbines
tc2On = false;
tc3On = false;
tc4On = false;

NeutronFluxDrop = true; //Neutron Flux - Dropping


rodAutoOn = false;
}


public int value(boolean B){
int ans = -1;
if(b == true)
ans = 1;
if(b == false)
ans = 0;
return ans;
}
public int value(int i){
int ans = -1; //mine: 0=green, 1=yellow, 2=red
if(i==2) // want: green/on=2 and red/off = 0
ans = 0;
if(i==1)
ans = 1;
if(i==0)
ans = 2;
return ans;
}




// Determines if an asked SITRAIN(letter) is open or closed
public double SITrain(String B){
double a = 0;
if (b.equals("A")){
if (siaOn == true) a = 1;
else a = 0;}
if (b.equals("B")){
if (sibOn == true) a = 1;
else a = 0;}
return a;
}

// Determines if an asked SGCoolantPump# is open or closed
public double SGCoolantPumpValue(int pumpNum){
double a = 0;
if(pumpNum == 1){
if (prb2On == true) a = 1;
else a = 0;}
if(pumpNum == 2){
if (plb3On == true) a = 1;
else a = 0;}
if(pumpNum == 3){
if (prb4On == true) a = 1;
else a = 0;}
if(pumpNum == 4){
if (plb6On == true) a = 1;
else a = 0;}
return a;
}

//ReminderChime Alarm = new ReminderChime();
//Thread myThread = new Thread( Alarm );

public void setup() {


StartT = System.currentTimeMillis();

size(1260, 920);
smooth();
colorConfig();
config();
backIllustrate();


minim = new Minim(this);
thread1 = new AlarmThread(7000, "a");


}

public String getSubjectNumber(){
return Subnum;
}
public void draw() {
if(this.getSize().getHeight()!=920 || this.getSize().getWidth() != 1260){
this.setSize(1260, 920);
}

update(mouseX, mouseY);

if (prb1On) { // Pump Right Button 1
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpR(prbx1, prby1);

if (prb2On) { // Pump Right Button 2
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpR(prbx2, prby2);

if (prb3On) { // Pump Right Button 3
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpR(prbx3, prby3);

if (prb4On) { // Pump Right Button 4
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpR(prbx4, prby4);

if (prb5On) { // Pump
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpR(prbx5, prby5);

if (prb6On) {
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpR(prbx6, prby6);

if (prb7On) { // Pump below SI train A
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpR(prbx7, prby7);

if (plb1On) { // below below SI train A
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpL(plbx1, plby1);

if (plb2On) { //top right most pump
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpL(plbx2, plby2);

if (plb3On) {
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpL(plbx3, plby3);

if (plb4On) {
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpL(plbx4, plby4);

if (plb5On) {
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpL(plbx5, plby5);

if (plb6On) {
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpL(plbx6, plby6);

if (plb7On) { //Pump below SI train B
fill(redOn);
stroke(0);
} else {
fill(greenOn);
stroke(0);
}

pumpL(plbx7, plby7);

if (vhb1On) {
fill(greenOn);
stroke(0);
} else {
fill(redOn);
stroke(0);
}

hvalve(vhbx1, vhby1);

if (vhb2On) {
fill(greenOn);
stroke(0);
} else {
fill(redOn);
stroke(0);
}

hvalve(vhbx2, vhby2);

if (vhb3On) { //lower left horiz
fill(greenOn);
stroke(0);
} else {
fill(redOn);
stroke(0);
}


hvalve(vhbx3, vhby3);

if (vhb4On) { //Lower right horiz
fill(greenOn);
stroke(0);
} else {
fill(redOn);
stroke(0);
}

hvalve(vhbx4, vhby4);

if (tc1On) { //top left turbine control
fill(greenOn);
stroke(0);
rect(tcx1 + 32, tcy1 + 35, 22, 10);
fill(redOff);
rect(tcx1 + 5, tcy1 + 35, 22, 10);
;
} else {
fill(redOn);
stroke(0);
rect(tcx1 + 5, tcy1 + 35, 22, 10);
;
fill(greenOff);
rect(tcx1 + 32, tcy1 + 35, 22, 10);
}

if (tc2On) { //top right turbine control
fill(greenOn);
stroke(0);
rect(tcx2 + 32, tcy2 + 35, 22, 10);
fill(redOff);
rect(tcx2 + 5, tcy2 + 35, 22, 10);
;
} else {
fill(redOn);
stroke(0);
rect(tcx2 + 5, tcy2 + 35, 22, 10);
;
fill(greenOff);
rect(tcx2 + 32, tcy2 + 35, 22, 10);
}

if (tc3On) {
fill(greenOn); //bottom left turbine control
stroke(0);
rect(tcx3 + 32, tcy3 + 35, 22, 10);
fill(redOff);
rect(tcx3 + 5, tcy3 + 35, 22, 10);
;
} else {
fill(redOn);
stroke(0);
rect(tcx3 + 5, tcy3 + 35, 22, 10);
;
fill(greenOff);
rect(tcx3 + 32, tcy3 + 35, 22, 10);
}

if (tc4On) {
fill(greenOn);
stroke(0);
rect(tcx4 + 32, tcy4 + 35, 22, 10);
fill(redOff);
rect(tcx4 + 5, tcy4 + 35, 22, 10);
;
} else {
fill(redOn);
stroke(0);
rect(tcx4 + 5, tcy4 + 35, 22, 10);
;
fill(greenOff);
rect(tcx4 + 32, tcy4 + 35, 22, 10);
}

if (siaOn) { //SI Train A
fill(greenOn);
stroke(0);
rect(siax + 32, siay + 35, 22, 10);
fill(redOff);
rect(siax + 5, siay + 35, 22, 10);
;
} else {
fill(redOn);
stroke(0);
rect(siax + 5, siay + 35, 22, 10);
;
fill(greenOff);
rect(siax + 32, siay + 35, 22, 10);
}

if (sibOn) { //SI Train B
fill(greenOn);
stroke(0);
rect(sibx + 32, siby + 35, 22, 10);
fill(redOff);
rect(sibx + 5, siby + 35, 22, 10);
;
} else {
fill(redOn);
stroke(0);
rect(sibx + 5, siby + 35, 22, 10);
;
fill(greenOff);
rect(sibx + 32, siby + 35, 22, 10);
}

if (vil1On % 3 == 0) { //Top left street light
stroke(0);
fill(redOff);
rect(vilx1, vily1, 22, 10);
fill(yellowOff);
rect(vilx1, vily1 + 12, 22, 10);
fill(greenOn);
rect(vilx1, vily1 + 24, 22, 10);
vvalve(vvbx1, vvby1);
} else if (vil1On % 3 == 1) {
stroke(0);
fill(redOff);
rect(vilx1, vily1, 22, 10);
fill(yellowOn);
vvalve(vvbx1, vvby1);
rect(vilx1, vily1 + 12, 22, 10);
fill(greenOff);
rect(vilx1, vily1 + 24, 22, 10);
} else if (vil1On % 3 == 2) {
stroke(0);
fill(redOn);
vvalve(vvbx1, vvby1);
rect(vilx1, vily1, 22, 10);
fill(yellowOff);
rect(vilx1, vily1 + 12, 22, 10);
fill(greenOff);
rect(vilx1, vily1 + 24, 22, 10);
}

if (vil2On % 3 == 0) { //Top right street light
stroke(0);
fill(redOff);
rect(vilx2, vily2, 22, 10);
fill(yellowOff);
rect(vilx2, vily2 + 12, 22, 10);
fill(greenOn);
vvalve(vvbx2, vvby2);
rect(vilx2, vily2 + 24, 22, 10);
} else if (vil2On % 3 == 1) {
stroke(0);
fill(redOff);
rect(vilx2, vily2, 22, 10);
fill(yellowOn);
vvalve(vvbx2, vvby2);
rect(vilx2, vily2 + 12, 22, 10);
fill(greenOff);
rect(vilx2, vily2 + 24, 22, 10);
} else if (vil2On % 3 == 2) {
stroke(0);
fill(redOn);
vvalve(vvbx2, vvby2);
rect(vilx2, vily2, 22, 10);
fill(yellowOff);
rect(vilx2, vily2 + 12, 22, 10);
fill(greenOff);
rect(vilx2, vily2 + 24, 22, 10);
}

if (vil3On % 3 == 0) { //Bottom left street light
stroke(0);
fill(redOff);
rect(vilx3, vily3, 22, 10);
fill(yellowOff);
rect(vilx3, vily3 + 12, 22, 10);
fill(greenOn);
vvalve(vvbx3, vvby3);
rect(vilx3, vily3 + 24, 22, 10);
} else if (vil3On % 3 == 1) {
stroke(0);
fill(redOff);
rect(vilx3, vily3, 22, 10);
fill(yellowOn);
rect(vilx3, vily3 + 12, 22, 10);
vvalve(vvbx3, vvby3);
fill(greenOff);
rect(vilx3, vily3 + 24, 22, 10);
} else if (vil3On % 3 == 2) {
stroke(0);
fill(redOn);
vvalve(vvbx3, vvby3);
rect(vilx3, vily3, 22, 10);
fill(yellowOff);
rect(vilx3, vily3 + 12, 22, 10);
fill(greenOff);
rect(vilx3, vily3 + 24, 22, 10);
}

if (vil4On % 3 == 0) { //bottom right street light
stroke(0);
fill(redOff);
rect(vilx4, vily4, 22, 10);
fill(yellowOff);
rect(vilx4, vily4 + 12, 22, 10);
fill(greenOn);
vvalve(vvbx4, vvby4);
rect(vilx4, vily4 + 24, 22, 10);
} else if (vil4On % 3 == 1) {
stroke(0);
fill(redOff);
rect(vilx4, vily4, 22, 10);
fill(yellowOn);
vvalve(vvbx4, vvby4);
rect(vilx4, vily4 + 12, 22, 10);
fill(greenOff);
rect(vilx4, vily4 + 24, 22, 10);
} else if (vil4On % 3 == 2) {
stroke(0);
fill(redOn);
vvalve(vvbx4, vvby4);
rect(vilx4, vily4, 22, 10);
fill(yellowOff);
rect(vilx4, vily4 + 12, 22, 10);
fill(greenOff);
rect(vilx4, vily4 + 24, 22, 10);
}

if (rodAutoOn) {
fill(180);
stroke(0);
rect(rodinx + 280, rodiny + 75, 50, 40);
fill(0);
text("AUTO", rodinx + 307, rodiny + 92);
text("ON", rodinx + 307, rodiny + 107);
} else {
fill(180);
stroke(0);
rect(rodinx + 280, rodiny + 75, 50, 40);
fill(0);
text("AUTO", rodinx + 307, rodiny + 92);
text("OFF", rodinx + 307, rodiny + 107);
}

if(rod10On){
fill(255);
rect(rod5x, rod5y, 35, 20);
rect(rod1x, rod1y, 35, 20);
fill(yellowOn);
rect(rod10x,rod10y, 35, 20);
fill(0);
text("10", rod10x + 15, rod10y + 15);
text("5", rod5x + 15, rod5y + 15);
text("1", rod1x + 15, rod1y + 15);
}
else if(rod5On){
fill(255);
rect(rod10x, rod10y, 35, 20);
rect(rod1x, rod1y, 35, 20);
fill(yellowOn);
rect(rod5x, rod5y, 35, 20);
fill(0);
text("10", rod10x + 15, rod10y + 15);
text("5", rod5x + 15, rod5y + 15);
text("1", rod1x + 15, rod1y + 15);
}
else if(rod1On){
fill(255);
rect(rod10x, rod10y, 35, 20);
rect(rod5x, rod5y, 35, 20);
fill(yellowOn);
rect(rod1x, rod1y, 35, 20);
fill(0);
text("10", rod10x + 15, rod10y + 15);
text("5", rod5x + 15, rod5y + 15);
text("1", rod1x + 15, rod1y + 15);
}



// Draw Timer
int timerx = 630;
int timery = 665;
fill(180);
rect(timerx - 50, timery - 15, 100, 20);
fill(0);

long Times = ((System.currentTimeMillis() - StartT) / 1000) % 60;
long Timem = ((System.currentTimeMillis() - StartT) / (1000*60)) % 60;
long Timeh = ((System.currentTimeMillis() - StartT) / (1000*60*60));
text("Time: "+Timeh+":"+Timem+":"+Times, timerx, timery);

//Rating GUI
BufferedWriter Writer;
if(((Timeh==0&&Timem==15&&Times==1)||
(Timeh==0&&Timem==30&&Times==1)||
(Timeh==0&&Timem==45&&Times==1)||
(Timeh==1&&Timem==0 &&Times==1)||
(Timeh==1&&Timem==15&&Times==1)||
(Timeh==1&&Timem==30&&Times==1)||
(Timeh==1&&Timem==45&&Times==1)||
(Timeh==2&&Timem==0 &&Times==1)||
(Timeh==2&&Timem==15&&Times==1)||
(Timeh==2&&Timem==30&&Times==1)||
(Timeh==2&&Timem==45&&Times==1)||
(Timeh==3&&Timem==0 &&Times==1)||
(Timeh==3&&Timem==15&&Times==1)||
(Timeh==3&&Timem==30&&Times==1)||
(Timeh==3&&Timem==45&&Times==1)) && (System.currentTimeMillis()-GuiT>5000)){

GuiT = System.currentTimeMillis();

}

/////Checks when warnings should be lit
// A3 - SI auto injection
if(prb7On==true && plb7On==true){
warningsAdd("si");
}else
warningsRemove("si");


warningsRemove("reactorc");

// B3 - Turbine Auto Trip
if(tc1On==false && tc2On==false && tc3On==false && tc4On==false)
warningsAdd("turbine");
else
warningsRemove("turbine");



////////////////////////SCENARIOS TO BE DRAWN//////////////////////////////////

updateVariables(); //updates all the variables in order to show them in the loops
rodDraw(); //initialized the first rod drawn. Needed in order for updating to occur



//Play alarm for an event
//ReminderChime.play_Sound();thread1.start
if(E1complete==true || E2complete==true || E3complete==true){
thread1.running = false;
E1complete = E2complete = E3complete = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Event Completed" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


}
long GuiT = 0;
long StartT;

public long getTime() {
long seconds = (System.currentTimeMillis() - StartT)/1000;
return seconds;
}
public String getDate() {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
return dateFormat.format(date);
}
Minim minim;
class AlarmThread extends Thread {
Boolean running;
int wait;
String id;
int count;
//Minim minim;
AudioPlayer player;

AlarmThread ( int w, String s) {
wait = w;
running = false;
id = s;
count = 0;
}

public int getCount() {
return count;
}

public void start() {
//minim = new Minim(PApplet);

running = true;
super.start();
}

public void run() {
while (running) {
// Ok, let's wait for however long we should wait
player = minim.loadFile("C:\\Documents and Settings\\nrc\\My Documents\\Nuclear\\ALARM-1.WAV", 2048);
player.play();
try {
sleep((long)(wait));
} catch (Exception e) {
}
}
}

void quit() {
running = false; // Setting running to false ends the loop in run()
// IUn case the thread is waiting. . .
interrupt();
minim.stop();
//super.stop();
}
}




void updateVariables(){
long t = ((System.currentTimeMillis() - StartT)/1000);
RodPosition = rodlevel;


if(rodspeed==10 && rodUp==true){
rodlevel = rodlevel - .005;
}
if(rodspeed==10 && rodUp==false){
rodlevel = rodlevel + .005;
}
if(rodspeed==5 && rodUp==true){
rodlevel = rodlevel - (.005/2);
}
if(rodspeed==5 && rodUp==false){
rodlevel = rodlevel + (.005/2);
}
if(rodspeed==1 && rodUp==true){
rodlevel = rodlevel - (.005/2/5);
}
if(rodspeed==1 && rodUp==false){
rodlevel = rodlevel + (.005/2/5);
}
if(rodlevel>100) rodlevel = 100;
if(rodlevel<0) rodlevel = 0;
rodDraw();


//redraw the loops with the updated variables
loop1();
loop2();
loop3();
loop4();
loop5();
//draw the turbine controls
}



// /////////////////////Determines whether the mouse is "over" a given
// button, which aids in determining whether mouse is clicking on a given
// button later/////////
void update(int x, int y) {
if (overPumpR(prbx1, prby1)) {
falsify();
prb1Over = true;
} else if (overPumpR(prbx2, prby2)) {
falsify();
prb2Over = true;
} else if (overPumpR(prbx3, prby3)) {
falsify();
prb3Over = true;
} else if (overPumpR(prbx4, prby4)) {
falsify();
prb4Over = true;
} else if (overPumpR(prbx5, prby5)) {
falsify();
prb5Over = true;
} else if (overPumpL(prbx6, prby6)) {
falsify();
prb6Over = true;
} else if (overPumpL(plbx1, plby1)) {
falsify();
plb1Over = true;
} else if (overPumpL(plbx2, plby2)) {
falsify();
plb2Over = true;
} else if (overPumpL(plbx3, plby3)) {
falsify();
plb3Over = true;
} else if (overPumpL(plbx4, plby4)) {
falsify();
plb4Over = true;
} else if (overPumpL(plbx5, plby5)) {
falsify();
plb5Over = true;
} else if (overPumpL(plbx6, plby6)) {
falsify();
plb6Over = true;
} else if (overRect(vhbx1, vhby1, 16, 10)) {
falsify();
vhb1Over = true;
} else if (overRect(vhbx2, vhby2, 16, 10)) {
falsify();
vhb2Over = true;
} else if (overRect(vhbx3, vhby3, 16, 10)) {
falsify();
vhb3Over = true;
} else if (overRect(vhbx4, vhby4, 16, 10)) {
falsify();
vhb4Over = true;
} else if (overRect(vvbx1, vvby2, 10, 16)) {
falsify();
vvb1Over = true;
} else if (overRect(vvbx2, vvby2, 10, 16)) {
falsify();
vvb2Over = true;
} else if (overRect(vvbx3, vvby3, 10, 16)) {
falsify();
vvb3Over = true;
} else if (overRect(vvbx4, vvby4, 10, 16)) {
falsify();
vvb4Over = true;
} else if (overRect(siax, siay, 60, 50)) {
falsify();
siaOver = true;
} else if (overRect(sibx, siby, 60, 50)) {
falsify();
sibOver = true;
} else if (overRect(tcx1, tcy1, 60, 50)) {
falsify();
tc1Over = true;
} else if (overRect(tcx2, tcy2, 60, 50)) {
falsify();
tc2Over = true;
} else if (overRect(tcx3, tcy3, 60, 50)) {
falsify();
tc3Over = true;
} else if (overRect(tcx4, tcy4, 60, 50)) {
falsify();
tc4Over = true;
} else if (overPumpR(prbx7, prby7)) {
falsify();
prb7Over = true;
} else if (overPumpL(plbx7, plby7)) {
falsify();
plb7Over = true;
} else if (overRect(vilx1, vily1, 22, 35)) {
falsify();
vil1Over = true;
} else if (overRect(vilx2, vily2, 22, 35)) {
falsify();
vil2Over = true;
} else if (overRect(vilx3, vily3, 22, 35)) {
falsify();
vil3Over = true;
} else if (overRect(vilx4, vily4, 22, 35)) {
falsify();
vil4Over = true;
} else if (overRect(rodUpx, rodUpy, 28, 28)) {
falsify();
rodUpOver = true;
} else if (overRect(rodDownx, rodDowny, 28, 28)) {
falsify();
rodDownOver = true;
} else if (overRect(rodAutox, rodAutoy, 60, 40)) {
falsify();
rodAutoOver = true;
}else if (overRect(rod10x, rod10y, 50, 20)) {
falsify();
rod10Over = true;
} else if (overRect(rod5x, rod5y, 50, 20)) {
falsify();
rod5Over = true;
} else if (overRect(rod1x, rod1y, 50, 20)) {
falsify();
rod1Over = true;
} else if (overRect(wa1x, wa1y, 65, 65)) {
falsify();
wa1Over = true;
} else if (overRect(wa2x, wa2y, 65, 65)) {
falsify();
wa2Over = true;
} else if (overRect(wa3x, wa3y, 65, 65)) {
falsify();
wa3Over = true;
} else if (overRect(wa4x, wa4y, 65, 65)) {
falsify();
wa4Over = true;
} else if (overRect(wb1x, wb1y, 65, 65)) {
falsify();
wb1Over = true;
} else if (overRect(wb2x, wb2y, 65, 65)) {
falsify();
wb2Over = true;
} else if (overRect(wb3x, wb3y, 65, 65)) {
falsify();
wb3Over = true;
} else if (overRect(wb4x, wb4y, 65, 65)) {
falsify();
wb4Over = true;
} else {
falsify();
}

}

public void keyPressed() {
if (key == ESC) {
key = 0; // Fools! don't let them escape!
}
}

// //////////////////////////Determines what to do when mouse is
// pressed/////////////////////////
public void mousePressed() {
BufferedWriter Writer;

if (prb1Over) {
if (prb1On){
prb1On = !prb1On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"CondenserCoolantPump1 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
prb1On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"CondenserCoolantPump1 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (prb2Over) {
if (prb2On){
prb2On = !prb2On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SecondaryCoolantPump1 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
prb2On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SecondaryCoolantPump1 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (prb3Over) {
if (prb3On){
prb3On = !prb3On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"CondenserCoolantPump3 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
prb3On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"CondenserCoolantPump3 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (prb4Over) {
if (prb4On){
prb4On = !prb4On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SecondaryCoolantPump3 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
prb4On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SecondaryCoolantPump3 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (prb5Over) {

if (prb5On){
prb5On = !prb5On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ReactorCoolantPump2 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
prb5On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ReactorCoolantPump2 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}



if (prb6Over) {

if (prb6On){
prb6On = !prb6On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ReactorCoolantPump4 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
prb6On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ReactorCoolantPump4 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (plb1Over) {

if (plb1On){
plb1On = !plb1On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ReactorCoolantPump1 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
plb1On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ReactorCoolantPump1 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (plb2Over) {

if (plb2On){
plb2On = !plb2On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"CondenserCoolantPump2 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
plb2On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"CondenserCoolantPump2 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (plb3Over) {

if (plb3On){
plb3On = !plb3On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SecondaryCoolantPump2 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
plb3On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SecondaryCoolantPump2 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (plb4Over) {

if (plb4On){
plb4On = !plb4On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ReactorCoolantPump3 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
plb4On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ReactorCoolantPump3 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (plb5Over) {

if (plb5On){
plb5On = !plb5On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"CondenserCoolantPump4 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
plb5On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"CondenserCoolantPump4 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (plb6Over) {

if (plb6On){
plb6On = !plb6On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SecondaryCoolantPump4 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
plb6On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SecondaryCoolantPump4 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (plb7Over) {

if (plb7On){
plb7On = !plb7On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SIPumpB turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
plb7On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SIPumpB turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (prb7Over) {
if (prb7On){
prb7On = !prb7On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SIPumpA turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
prb7On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SIPumpA turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (vhb1Over) {

if (vhb1On){
vhb1On = !vhb1On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamLineValve1 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vhb1On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamLineValve1 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (vhb2Over) {

if (vhb2On){
vhb2On = !vhb2On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamLineValve2 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vhb2On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamLineValve2 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (vhb3Over) {

if (vhb3On){
vhb3On = !vhb3On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamLineValve3 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vhb3On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamLineValve3 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (vhb4Over) {

if (vhb4On){
vhb4On = !vhb4On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamLineValve4 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vhb4On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamLineValve4 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (vvb1Over) {

if (vvb1On){
vvb1On = !vvb1On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamDumpValve1 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vvb1On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamDumpValve1 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (vvb2Over) {

if (vvb2On){
vvb2On = !vvb2On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamDumpValve2 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vvb2On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamDumpValve2 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (vvb3Over) {

if (vvb3On){
vvb3On = !vvb3On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamDumpValve3 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vvb3On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamDumpValve3 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (vvb4Over) {

if (vvb4On){
vvb4On = !vvb4On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SteamDumpValve4 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
vvb4On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SteamDumpValve4 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (siaOver) {
if (siaOn){
siaOn = !siaOn;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SITrainA turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
siaOn = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SITrainA turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (sibOver) {
if (sibOn){
sibOn = !sibOn;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"SITrainB turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
sibOn = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"SITrainB turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (tc2Over) {
if (tc2On){
tc2On = !tc2On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"TurbineControls2 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
tc2On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"TurbineControls2 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (tc1Over) {
if (tc1On){
tc1On = !tc1On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"TurbineControls1 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
tc1On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"TurbineControls1 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (tc3Over) {
if (tc3On){
tc3On = !tc3On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"TurbineControls3 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
tc3On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"TurbineControls3 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (tc4Over) {
if (tc4On){
tc4On = !tc4On;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"TurbineControls4 turned OFF" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
tc4On = true;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"TurbineControls4 turned ON" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (vil1Over) {
if (vil1On%3==2){
vil1On = 0;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ValveIndicatorLights1 now Green" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if (vil1On%3==0){
vil1On = 1;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights1 now Yellow" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
else if (vil1On%3==1){
vil1On = 2;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights1 now Red"+ newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (vil2Over) {
if (vil2On%3==2){
vil2On = 0;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ValveIndicatorLights2 now Green" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if (vil2On%3==0){
vil2On = 1;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights2 now Yellow" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
else if (vil2On%3==1){
vil2On = 2;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights2 now Red"+ newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (vil3Over) {
if (vil3On%3==2){
vil3On = 0;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ValveIndicatorLights3 now Green" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if (vil3On%3==0){
vil3On = 1;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights3 now Yellow" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
else if (vil3On%3==1){
vil3On = 2;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights3 now Red"+ newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }

if (vil4Over) {
if (vil4On%3==2){
vil4On = 0;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"ValveIndicatorLights4 now Green" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if (vil4On%3==0){
vil4On = 1;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights4 now Yellow" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
else if (vil4On%3==1){
vil4On = 2;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
Writer.write(getTime()+" "+"ValveIndicatorLights4 now Red"+ newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (rodDownOver){
if(rodDownClicked){
if (rodlevel > 100) rodlevel = 100;
if (rodlevel < 0) rodlevel = 0;
rodlevel = rodlevel + 2;
rodDownClicked = !rodDownClicked;
rodUp = false;
}
else{
if (rodlevel > 100) rodlevel = 100;
if (rodlevel < 0) rodlevel = 0;
rodlevel = rodlevel + 2;
rodDownClicked = true;
rodUp = false;
}
}

if (rodUpOver){
if(rodUpClicked){
if (rodlevel > 100) rodlevel = 100;
if (rodlevel < 0) rodlevel = 0;
rodlevel = rodlevel - 2;
rodUpClicked = !rodUpClicked;
rodUp = true;
}
else{
if (rodlevel > 100) rodlevel = 100;
if (rodlevel < 0) rodlevel = 0;
rodlevel = rodlevel - 2;
rodUpClicked = true;
rodUp = true;
}
}

if (rodAutoOver) {
if (rodAutoOn){
rodAutoOn = !rodAutoOn;
stroke(0);
rect(rod10x, rod10y, 35, 20);
rect(rod5x, rod5y, 35, 20);
rect(rod1x, rod1y, 35, 20);
fill(255);
rect(rod10x, rod10y, 35, 20);
rect(rod5x, rod5y, 35, 20);
rect(rod1x, rod1y, 35, 20);
fill(0);
text("10", rod10x + 15, rod10y + 15);
text("5", rod5x + 15, rod5y + 15);
text("1", rod1x + 15, rod1y + 15);
rod10On = rod5On = rod1On = false;
rodspeed = 0;

try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Rod Automation on" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
rodAutoOn = true;
rod1On = true;
rodspeed = 1;
}
}


if (rod10Over==true && rodAutoOn==true) {
if(rod10On==false){
rod10On = true;
rod5On = false;
rod1On = false;
rodspeed = 10;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Rod speed now 25" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (rod5Over==true && rodAutoOn==true) {
if(rod5On==false){
rod10On = false;
rod5On = true;
rod1On = false;
rodspeed = 5;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Rod speed now 25" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

if (rod1Over==true && rodAutoOn==true) {
if(rod1On==false){
rod10On = false;
rod5On = false;
rod1On = true;
rodspeed = 1;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Rod speed now 25" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}



if (wa1Over) {
wa1On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning A1 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (wa2Over) {
wa2On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning A2 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (wa3Over) {
wa3On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning A3 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (wa4Over) {
wa4On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning A4 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (wb1Over) {
wb1On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning B1 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (wb2Over) {
wb2On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning B2 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (wb3Over) {
wb3On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning B3 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (wb4Over) {
wb4On = false;
try{
Writer = new BufferedWriter(new FileWriter(LogFile, true));
//Write the file that will spit out that this pump has turned off.
Writer.write(getTime()+" "+"Warning B4 Turned Off" + newLine);
Writer.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}



// ////////////////Config block, for Colors////////////////////////////////
void colorConfig() {
redOn = color(255, 40, 40);
yellowOn = color(225, 225, 0);
greenOn = color(0, 235, 18);
redOff = color(139, 34, 34);
yellowOff = color(175, 175, 75);
greenOff = color(50, 131, 34);
}

// ////////////////Config block, for Positioning///////////////////////////
void config() {
// lower left corner, trapezoid 1
trapx1 = 30;
trapy1 = 60;

// Steam Generator, 1
sgx1 = 350;
sgy1 = 240;

// Turbine, upper left corner
turbx1 = 200;
turby1 = 65;

// Rod insertion
rodinx = 490;
rodiny = 160;
reactorx = 630;
reactory = 350;

// Condenser Coolant Pump, center of circle
prbx1 = 145;
prby1 = 180;
// Secondary Coolant Pump, center of circle
prbx2 = turbx1 + 90;
prby2 = turby1 + 122;
// reactor coolant pump, center of circle
prbx5 = 790;
prby5 = 434;

// Condenser Coolant Pump, center of circle
prbx3 = 145;
prby3 = 870;

// Secondary Coolant Pump, center of circle
prbx4 = 290;
prby4 = 880;

// reactor coolant pump, center of circle
prbx6 = 780;
prby6 = 554;

// reactor coolant pump, center of circle
plbx1 = 450;
plby1 = 434;

// Condenser Coolant Pump, center of circle
plbx2 = 1085;
plby2 = 180;

// Secondary Coolant Pump, center of circle
plbx3 = 970;
plby3 = 190;

// reactor coolant pump, center of circle
plbx4 = 480;
plby4 = 554;

// SI pump
prbx7 = 500;
prby7 = 385;

// SI pump
plbx7 = 760;
plby7 = 385;

// Condenser Coolant Pump, center of circle
plbx5 = 1097;
plby5 = 870;

// Secondary Coolant Pump, center of circle
plbx6 = 970;
plby6 = 880;

// Steamline Valve, triangle intersection
vhbx1 = 308;
vhby1 = 50;

// Steamdump Valve, triangle intersection
vvbx1 = 332;
vvby1 = 20;

// Steamline Valve, triangle intersection
vhbx2 = 942;
vhby2 = 50;

// Steamdump Valve, triangle intersection
vvbx2 = 918;
vvby2 = 20;

// Steamline Valve, triangle intersection
vhbx3 = 310;
vhby3 = 740;

// Steamdump Valve, triangle intersection
vvbx3 = 332;
vvby3 = 760;

// Steamline Valve, triangle intersection
vhbx4 = 942;
vhby4 = 740;

// Steamdump Valve, triangle intersection
vvbx4 = 918;
vvby4 = 760;

// Turbine Control Box, upper left corner of panel
tcx1 = 130;
tcy1 = 80;

// Turbine Control Box, upper left corner of panel
tcx2 = 1070;
tcy2 = 80;

// Turbine Control Box, upper left corner of panel
tcx3 = 130;
tcy3 = 770;

// Turbine Control Box, upper left corner of panel
tcx4 = 1070;
tcy4 = 770;

// SI Train coordinates
siax = rodinx - 30;
siay = reactory - 50;
sibx = rodinx + 260;
siby = reactory - 50;

// Valve Indicator Lights
vilx1 = 350;
vily1 = 15;
vilx2 = 888;
vily2 = 15;
vilx3 = 350;
vily3 = 750;
vilx4 = 888;
vily4 = 750;

// Rod Insertion Controls
rodUpx = rodinx + 280;
rodUpy = rodiny;
rodDownx = rodinx + 280;
rodDowny = rodiny + 35;
rodAutox = rodinx + 280;
rodAutoy = rodiny + 75;
rod10x = rodinx - 50;
rod10y = rodiny + 25;
rod5x = rodinx - 50;
rod5y = rodiny + 50;
rod1x = rodinx - 50;
rod1y = rodiny + 75;

// Warning buttons A1-B4
warnx = 490;
warny = 25;

wa1x = warnx;
wa1y = warny;
wa2x = warnx + 70;
wa2y = warny;
wa3x = warnx + 140;
wa3y = warny;
wa4x = warnx + 210;
wa4y = warny;
wb1x = warnx;
wb1y = warny + 70;
wb2x = warnx + 70;
wb2y = warny + 70;
wb3x = warnx + 140;
wb3y = warny + 70;
wb4x = warnx + 210;
wb4y = warny + 70;

// Reactor Lines
sgx1 = 350;
sgy1 = 240;
sgx2 = 890;
sgy2 = 240;
sgx3 = 350;
sgy3 = 500;
sgx4 = 890;
sgy4 = sgy3;

}

// ///////////////////The bulk of the Illustration;
// STATIC/////////////////////////

void backIllustrate() {
stroke(180);
strokeWeight(6);
fill(190);
rect(320, 400, 600, 400);
stroke(900);
rect(320 + 6, 400, 600 - 12, 12);
stroke(180);
arc(620, 400, 600, 500, PI, PI * 2);

strokeWeight(1);
loop1();
loop1TurbineControl();
loop2();
loop2TurbineControl();
loop3();
loop3TurbineControl();
loop4();
loop4TurbineControl();
loop5();

sitrains();
reactor();
rodinsert();
warnings("none"); //type the first word of the warning, lower case (si, reactorh, reactorc, scram, etc.)
chatbox();
}

void loop1TurbineControl(){
// Stationary Background
int x1 = 30;
int y1 = 60;
stroke(0);

fill(0);
text("Loop 1", 150, 210);

// Trapezoid
int x = trapx1;
int y = trapy1;
fill(160);
quad(x + 20, y - 10, x + 60, y - 10, x + 80, y + 110, x, y + 110);

// Turbine Controls
x = tcx1;
y = tcy1;
fill(200);
rect(x, y, 60, 50); //square below tower
stroke(0);
line(x + 20, y, x + 25, y - 50); //actual tower lines
line(x + 40, y, x + 35, y - 50);
line(x + 25, y - 50, x + 35, y - 50);
line(x + 20, y - 42, x + 40, y - 42);
line(x + 20, y, x + 37, y - 20);
line(x + 37, y - 20, x + 23, y - 33);
line(x + 40, y, x + 23, y - 20);
line(x + 23, y - 20, x + 37, y - 33);
fill(139, 34, 34);
rect(x + 5, y + 35, 22, 10);
fill(50, 131, 34);
rect(x + 32, y + 35, 22, 10);

// Valve Indicator Lights
x = vilx1;
y = vily1;
stroke(0);
fill(139, 34, 34);
rect(x, y, 22, 10);
fill(215, 216, 127);
rect(x, y + 12, 22, 10);
fill(50, 131, 34);
rect(x, y + 24, 22, 10);

// Cooling line
stroke(100, 200, 250);
strokeWeight(6);

int coolTurbx = turbx1 + 70;
int coolTurby = turby1 + 120;
int coolSGx1 = sgx1;
int coolSGy1 = sgy1 + 100;
int joint1x = turbx1 + 125;
int joint1y = turby1 + 120;
int joint2x = turbx1 + 125;
int joint2y = coolSGy1 + 20;

line(coolTurbx, coolTurby, joint1x, joint1y); //horiz coolant line with pump
line(joint1x, joint1y, joint2x, joint2y); //vert coolant line
line(joint2x, joint2y, coolSGx1, coolSGy1 + 20); //horiz coolant line small

strokeWeight(1);
stroke(0);

// Turbine
x = turbx1;
y = turby1;
fill(219, 229, 255);
rect(x, y, 70, 140);
fill(190);
stroke(190);
triangle(x + 13, y + 15, x + 13, y + 50, x + 40, y + 32); //turbine fan gray
triangle(x + 57, y + 15, x + 57, y + 50, x + 30, y + 32);
rect(x - 9, y + 30, 21, 5);

// Lines 1 (from trapezoid to turbine blue area)
stroke(0);
x = x1;
y = y1 + 110;
line(x + 20, y, x + 20, y + 30);
line(x + 60, y, x + 60, y + 10);
line(x + 230, y + 30, x + 20, y + 30);
line(x + 60, y + 10, x + 230, y + 10);
line(x + 20, y, x + 20, y + 30);
line(x + 230, y + 10, x + 230, y + 15);
line(x + 230, y + 30, x + 230, y + 25);
line(x + 230, y + 25, x + 180, y + 25);
line(x + 230, y + 15, x + 180, y + 15);
line(x + 180, y + 15, x + 180, y + 25);

// Lines 2
stroke(0);
x = x1 + 200;
y = y1 + 5;
line(x, y, x, y - 12);
line(x + 3, y, x + 3, y - 10);
line(x, y - 12, x + 150, y - 12);
line(x + 3, y - 10, x + 147, y - 10);
line(x + 150, y - 12, x + 150, y + 160);
line(x + 147, y - 10, x + 147, y + 160);
line(x + 105, 0, x + 105, y - 12);
line(x + 108, 0, x + 108, y - 12);


}
void loop1() {
}



void loop2TurbineControl(){
// Loop 2
int x1 = 1260 - 30;
int y1 = 60;
stroke(0);

fill(0);
text("Loop 2", 1100, 210);
// Trapezoid
int x = x1;
int y = y1;
fill(160);
quad(x - 20, y - 10, x - 60, y - 10, x - 80, y + 110, x, y + 110);

// Turbine Controls
x = x1 - 100 - 60;
y = y1 + 20;
fill(200);
rect(x, y, 60, 50);
stroke(0);
line(x + 20, y, x + 25, y - 50);
line(x + 40, y, x + 35, y - 50);
line(x + 25, y - 50, x + 35, y - 50);
line(x + 20, y - 42, x + 40, y - 42);
line(x + 20, y, x + 37, y - 20);
line(x + 37, y - 20, x + 23, y - 33);
line(x + 40, y, x + 23, y - 20);
line(x + 23, y - 20, x + 37, y - 33);
fill(139, 34, 34);
rect(x + 5, y + 35, 22, 10);
fill(50, 131, 34);
rect(x + 32, y + 35, 22, 10);

// Cooling line
stroke(100, 200, 250);
strokeWeight(6);

int turbx2 = 990;
int turby2 = 65;
int sgx2 = 890;
int sgy2 = 80;

int coolTurbx = turbx2;
int coolTurby = turby2 + 120;
int coolSGx2 = sgx2 + 5;
int coolSGy2 = sgy2 + 280;
int joint1x = turbx2 - 45;
int joint1y = turby2 + 120;
int joint2x = joint1x;
int joint2y = coolSGy2;

line(coolTurbx, coolTurby, joint1x, joint1y);
line(joint1x, joint1y, joint2x, joint2y);
line(joint2x, joint2y, coolSGx2, coolSGy2);

strokeWeight(1);
stroke(0);

// Turbine?
x = x1 - 170 - 70;
y = y1 + 5;
fill(219, 229, 255);
rect(x, y, 70, 140);
fill(190);
stroke(190);
triangle(x + 13, y + 15, x + 13, y + 50, x + 40, y + 32);
triangle(x + 57, y + 15, x + 57, y + 50, x + 30, y + 32);
rect(x + 58, y + 30, 21, 5);

// Lines 1
stroke(0);
x = x1;
y = y1 + 110;
line(x - 20, y, x - 20, y + 30);
line(x - 60, y, x - 60, y + 10);
line(x - 230, y + 30, x - 20, y + 30);
line(x - 60, y + 10, x - 230, y + 10);
line(x - 20, y, x - 20, y + 30);
line(x - 230, y + 10, x - 230, y + 15);
line(x - 230, y + 30, x - 230, y + 25);
line(x - 230, y + 25, x - 180, y + 25);
line(x - 230, y + 15, x - 180, y + 15);
line(x - 180, y + 15, x - 180, y + 25);

// Lines 2
stroke(0);
x = x1 - 200;
y = y1 + 5;
line(x, y, x, y - 12);
line(x - 3, y, x - 3, y - 10);
line(x, y - 12, x - 150, y - 12);
line(x - 3, y - 10, x - 147, y - 10);
line(x - 150, y - 12, x - 150, y + 160);
line(x - 147, y - 10, x - 147, y + 160);
line(x - 105, 0, x - 105, y - 12);
line(x - 108, 0, x - 108, y - 12);

}

void loop2() {

}

void loop3TurbineControl(){
// Stationary Background
int x1 = 30;
int y1 = 750;
stroke(0);

fill(0);
text("Loop 3", 150, 470);

// Trapezoid
int x = x1;
int y = y1;
fill(160);
quad(x + 20, y - 10, x + 60, y - 10, x + 80, y + 110, x, y + 110);

// Turbine Controls
x = x1 + 100;
y = y1 + 20;
fill(200);
rect(x, y, 60, 50);
stroke(0);
line(x + 20, y, x + 25, y - 50);
line(x + 40, y, x + 35, y - 50);
line(x + 25, y - 50, x + 35, y - 50);
line(x + 20, y - 42, x + 40, y - 42);
line(x + 20, y, x + 37, y - 20);
line(x + 37, y - 20, x + 23, y - 33);
line(x + 40, y, x + 23, y - 20);
line(x + 23, y - 20, x + 37, y - 33);
fill(139, 34, 34);
rect(x + 5, y + 35, 22, 10);
fill(50, 131, 34);
rect(x + 32, y + 35, 22, 10);

// Cooling line
stroke(100, 200, 250);
strokeWeight(6);

int turbx3 = 200;
int turby3 = 755;
int sgx3 = 355;
int sgy3 = 550;

int coolTurbx = turbx3 + 70;
int coolTurby = turby3 + 120;
int coolSGx3 = sgx3;
int coolSGy3 = sgy3 + 100;
int joint1x = turbx3 + 195;
int joint1y = turby3 + 120;
int joint2x = turbx3 + 195;
int joint2y = coolSGy3 + 20;

line(coolTurbx, coolTurby, joint1x, joint1y);
line(joint1x, joint1y, joint2x, joint2y);
line(joint2x, joint2y, coolSGx3, coolSGy3 + 20);

strokeWeight(1);
stroke(0);

// Turbine?
x = x1 + 170;
y = y1 + 5;
fill(219, 229, 255);
rect(x, y, 70, 140);
fill(190);
stroke(190);
triangle(x + 13, y + 15, x + 13, y + 50, x + 40, y + 32);
triangle(x + 57, y + 15, x + 57, y + 50, x + 30, y + 32);
rect(x - 9, y + 30, 21, 5);

// Lines 1
stroke(0);
x = x1;
y = y1 + 110;
line(x + 20, y, x + 20, y + 30);
line(x + 60, y, x + 60, y + 10);
line(x + 230, y + 30, x + 20, y + 30);
line(x + 60, y + 10, x + 230, y + 10);
line(x + 20, y, x + 20, y + 30);
line(x + 230, y + 10, x + 230, y + 15);
line(x + 230, y + 30, x + 230, y + 25);
line(x + 230, y + 25, x + 180, y + 25);
line(x + 230, y + 15, x + 180, y + 15);
line(x + 180, y + 15, x + 180, y + 25);

// Lines 2
x = x1 + 200;
y = y1 + 5;
line(x, y, x, y - 12);
line(x + 3, y, x + 3, y - 10);
line(x, y - 12, x + 147, y - 12);
line(x + 3, y - 10, x + 150, y - 10);
line(x + 150, y - 10, x + 150, y - 60);
line(x + 147, y - 12, x + 147, y - 60);
line(x + 105, y + 50, x + 105, y - 10);
line(x + 108, y + 50, x + 108, y - 10);

// Steam Generator
}

void loop3() {

}

void loop4TurbineControl(){

// Loop 4
int x1 = 1260 - 30;
int y1 = 60 + 690;
stroke(0);

fill(0);
text("Loop 4", 1100, 470);

// Trapezoid
int x = x1;
int y = y1;
fill(160);
quad(x - 20, y - 10, x - 60, y - 10, x - 80, y + 110, x, y + 110);

// Turbine Controls
x = x1 - 100 - 60;
y = y1 + 20;
fill(200);
rect(x, y, 60, 50);
stroke(0);
line(x + 20, y, x + 25, y - 50);
line(x + 40, y, x + 35, y - 50);
line(x + 25, y - 50, x + 35, y - 50);
line(x + 20, y - 42, x + 40, y - 42);
line(x + 20, y, x + 37, y - 20);
line(x + 37, y - 20, x + 23, y - 33);
line(x + 40, y, x + 23, y - 20);
line(x + 23, y - 20, x + 37, y - 33);
fill(139, 34, 34);
rect(x + 5, y + 35, 22, 10);
fill(50, 131, 34);
rect(x + 32, y + 35, 22, 10);

// Cooling line
stroke(100, 200, 250);
strokeWeight(6);

int turbx4 = 990;
int turby4 = 755;
int sgx4 = turbx4 - 125;
int sgy4 = 550;

int coolTurbx = turbx4;
int coolTurby = turby4 + 120;
int coolSGx4 = sgx4;
int coolSGy4 = sgy4 + 280;
int joint1x = turbx4 - 125;
int joint1y = turby4 + 120;
int joint2x = joint1x;
int joint2y = coolSGy4 - 200;

line(coolTurbx, coolTurby, joint1x, joint1y);
line(joint1x, joint1y, joint2x, joint2y);
line(joint2x, joint2y, coolSGx4, coolSGy4);

strokeWeight(1);
stroke(0);

// Turbine?
x = x1 - 170 - 70;
y = y1 + 5;
fill(219, 229, 255);
rect(x, y, 70, 140);
fill(190);
stroke(190);
triangle(x + 13, y + 15, x + 13, y + 50, x + 40, y + 32);
triangle(x + 57, y + 15, x + 57, y + 50, x + 30, y + 32);
rect(x + 58, y + 30, 21, 5);

// Lines 1
stroke(0);
x = x1;
y = y1 + 110;
line(x - 20, y, x - 20, y + 30);
line(x - 60, y, x - 60, y + 10);
line(x - 230, y + 30, x - 20, y + 30);
line(x - 60, y + 10, x - 230, y + 10);
line(x - 20, y, x - 20, y + 30);
line(x - 230, y + 10, x - 230, y + 15);
line(x - 230, y + 30, x - 230, y + 25);
line(x - 230, y + 25, x - 180, y + 25);
line(x - 230, y + 15, x - 180, y + 15);
line(x - 180, y + 15, x - 180, y + 25);

// Lines 2
x = x1 - 200;
y = y1 + 5;
line(x, y, x, y - 10);
line(x + 3, y, x + 3, y - 12);
line(x + 3, y - 12, x - 147, y - 12);
line(x, y - 10, x - 150, y - 10);
line(x - 147, y - 12, x - 147, y - 60);
line(x - 150, y - 10, x - 150, y - 60);
line(x - 105, y + 50, x - 105, y - 10);
line(x - 108, y + 50, x - 108, y - 10);

// Steam Generator

x1 = x1 - 250;
}

void loop4() {

}

void loop5() {

}
void sitrains() {
// SI Train A
int x = siax;
int y = siay;
fill(245);
rect(x, y, 60, 50);
stroke(0);
fill(0);
text("SI Train A", x + 5, y + 15);
/*
* fill(139,34,34); rect(x+5, y+35, 22, 10); fill(50, 131, 34);
* rect(x+32, y+35, 22, 10);
*/

// Lines
stroke(0);
fill(0);
line(siax + 10, siay + 50, siax + 10, siay + 83);
line(siax + 13, siay + 50, siax + 13, siay + 80);
line(siax + 13, siay + 80, siax + 100, siay + 80);
line(siax + 10, siay + 83, siax + 100, siay + 83);

// SI Train B
x = sibx;
y = siby;
fill(245);
rect(x, y, 60, 50);
stroke(0);
fill(0);
text("SI Train B", x + 5, y + 15);

// Lines
stroke(0);
fill(0);
line(sibx + 40, siby + 50, sibx + 40, siby + 83);
line(sibx + 37, siby + 50, sibx + 37, siby + 80);
line(sibx + 40, siby + 83, sibx - 100, siby + 83);
line(sibx + 37, siby + 80, sibx - 100, siby + 80);

}

void rodDraw(){
float displaylevel = (float) (.75 * rodlevel + 20);
if(rodlevel==0) rodlevel=0;
if(rodlevel==100) rodlevel=100;
fill(0);
rect(rodinx+30, rodiny+12, 275-30, 100-12);
fill(240, 0, 0); //rod dot colors
for (int i = 0; i < 76; i = i + 2) {
ellipse(rodinx + 38 + 3 * i, rodiny + displaylevel, 5, 5);
}
}

void rodinsert() {
stroke(0);
fill(0); //rod background color
textAlign(LEFT);
rect(rodinx, rodiny, 275, 100);
fill(200);
text("ROD INSERTION", rodinx + 90, rodiny + 10);
textAlign(RIGHT);
text("0 -", rodinx, rodiny + 10, 30, 20);
text("100 -", rodinx, rodiny + 85, 30, 20);
text(" -", rodinx, rodiny + 48, 30, 20);

// rod insert buttons
// up/down arrows
fill(180);
rect(rodinx + 280, rodiny, 28, 28);
rect(rodinx + 280, rodiny + 35, 28, 28);
fill(150);
triangle(rodinx + 282, rodiny + 25, rodinx + 305, rodiny + 25,
rodinx + 293, rodiny + 5);
triangle(rodinx + 282, rodiny + 38, rodinx + 305, rodiny + 38,
rodinx + 293, rodiny + 58);

// auto/manual block
fill(180);
stroke(0);
rect(rodinx + 280, rodiny + 75, 50, 40);
fill(0);
textAlign(LEFT);

// Rate Buttons
fill(180);
rect(rodinx - 60, rodiny, 50, 20);
fill(255);
rect(rod10x, rod10y, 35, 20);
rect(rod5x, rod5y, 35, 20);
rect(rod1x, rod1y, 35, 20);
fill(255);
rect(rod10x, rod10y, 35, 20);
rect(rod5x, rod5y, 35, 20);
rect(rod1x, rod1y, 35, 20);
fill(0);
text("Step/min", rodinx - 59, rodiny + 15);
text("10", rod10x + 10, rod10y + 15);
text("5", rod5x + 15, rod5y + 15);
text("1", rod1x + 15, rod1y + 15);

}

void warningsAdd(String light) {
if(light.equals("core")){
fill(redOn);
rect(wa1x, wa1y, 65, 65); //Core-Damage Warning
fill(black);
textAlign(CENTER);
text("Core", warnx, warny + 10, 65, 65);
text("Damage", warnx, warny + 20, 65, 65);
text("Warning", warnx, warny + 30, 65, 65);
A1 = true;
}
if(light.equals("scram")){
fill(redOn);
rect(wa2x, wa2y, 65, 65); //SCRAM Warning
fill(black);
textAlign(CENTER);
text("SCRAM", warnx + 70, warny + 30, 65, 65);
A2 = true;
}
if(light.equals("si")){
fill(redOn);
rect(wa3x, wa3y, 65, 65); //SI Auto Injection
fill(black);
textAlign(CENTER);
text("SI Auto", warnx + 140, warny + 20, 65, 65);
text("Injection", warnx + 140, warny + 35, 65, 65);
A3 = true;
}
if(light.equals("containment")){
fill(redOn);
rect(wa4x, wa4y, 65, 65); //Containment Isolation Warning
fill(black);
textAlign(CENTER);
text("Containment", warnx + 205, warny + 10, 75, 65);
text("Isolation", warnx + 210, warny + 25, 65, 65);
text("Warning", warnx + 210, warny + 40, 65, 65);
A4 = true;
}
if(light.equals("reactorh")){
fill(redOn);
rect(warnx, warny + 70, 65, 65); //Reactor High Temp Warning
fill(black);
textAlign(CENTER);
text("Reactor", warnx, warny + 75, 65, 65);
text("High Temp", warnx, warny + 90, 65, 65);
text("Warning", warnx, warny + 105, 65, 65);
B1 = true;
}
if(light.equals("reactorc")){
fill(redOn);
rect(warnx + 70, warny + 70, 65, 65); //Reactor Coolant Warning
fill(black);
textAlign(CENTER);
text("Reactor", warnx + 70, warny + 75, 65, 65);
text("Coolant", warnx + 70, warny + 90, 65, 65);
text("Warning", warnx + 70, warny + 105, 65, 65);
B2 = true;
}
if(light.equals("turbine")){
fill(redOn);
rect(warnx + 140, warny + 70, 65, 65); //Turbine Auto Trip
fill(black);
textAlign(CENTER);
text("Turbine", warnx + 140, warny + 75, 65, 65);
text("Auto Trip", warnx + 140, warny + 90, 65, 65);
B3 = true;
}
if(light.equals("power")){
fill(redOn);
rect(warnx + 210, warny + 70, 65, 65); //Power Fluctuation Warning
fill(black);
textAlign(CENTER);
text("Power", warnx + 210, warny + 75, 65, 65);
text("Fluctuation", warnx + 210, warny + 90, 65, 65);
text("Warning", warnx + 210, warny + 105, 65, 65);
B4 = true;
}
}
void warningsRemove(String light) {
if(light.equals("core")){
fill(white);
rect(wa1x, wa1y, 65, 65); //Core-Damage Warning
fill(black);
textAlign(CENTER);
text("Core", warnx, warny + 10, 65, 65);
text("Damage", warnx, warny + 20, 65, 65);
text("Warning", warnx, warny + 30, 65, 65);
A1 = false;
}
if(light.equals("scram")){
fill(white);
rect(wa2x, wa2y, 65, 65); //SCRAM Warning
fill(black);
textAlign(CENTER);
text("SCRAM", warnx + 70, warny + 30, 65, 65);
A2 = false;
}
if(light.equals("si")){
fill(white);
rect(wa3x, wa3y, 65, 65); //SI Auto Injection
fill(black);
textAlign(CENTER);
text("SI Auto", warnx + 140, warny + 20, 65, 65);
text("Injection", warnx + 140, warny + 35, 65, 65);
A3 = false;
}
if(light.equals("containment")){
fill(white);
rect(wa4x, wa4y, 65, 65); //Containment Isolation Warning
fill(black);
textAlign(CENTER);
text("Containment", warnx + 205, warny + 10, 75, 65);
text("Isolation", warnx + 210, warny + 25, 65, 65);
text("Warning", warnx + 210, warny + 40, 65, 65);
A4 = false;
}
if(light.equals("reactorh")){
fill(white);
rect(warnx, warny + 70, 65, 65); //Reactor High Temp Warning
fill(black);
textAlign(CENTER);
text("Reactor", warnx, warny + 75, 65, 65);
text("High Temp", warnx, warny + 90, 65, 65);
text("Warning", warnx, warny + 105, 65, 65);
B1 = false;
}
if(light.equals("reactorc")){
fill(white);
rect(warnx + 70, warny + 70, 65, 65); //Reactor Coolant Warning
fill(black);
textAlign(CENTER);
text("Reactor", warnx + 70, warny + 75, 65, 65);
text("Coolant", warnx + 70, warny + 90, 65, 65);
text("Warning", warnx + 70, warny + 105, 65, 65);
B2 = false;
}
if(light.equals("turbine")){
fill(white);
rect(warnx + 140, warny + 70, 65, 65); //Turbine Auto Trip
fill(black);
textAlign(CENTER);
text("Turbine", warnx + 140, warny + 75, 65, 65);
text("Auto Trip", warnx + 140, warny + 90, 65, 65);
B3 = false;
}
if(light.equals("power")){
fill(white);
rect(warnx + 210, warny + 70, 65, 65); //Power Fluctuation Warning
fill(black);
textAlign(CENTER);
text("Power", warnx + 210, warny + 75, 65, 65);
text("Fluctuation", warnx + 210, warny + 90, 65, 65);
text("Warning", warnx + 210, warny + 105, 65, 65);
B4 = false;
}
}
void warnings(String light) {
stroke(0);
int warnx = 490;
int warny = 25;

// Initialize all the warning to off
fill(white);
rect(wa1x, wa1y, 65, 65); //Core-Damage Warning
rect(wa2x, wa2y, 65, 65); //SCRAM Warning
rect(wa3x, wa3y, 65, 65); //SI Auto Injection
rect(wa4x, wa4y, 65, 65); //Containment Isolation Warning
rect(warnx, warny + 70, 65, 65); //Reactor High Temp Warning
rect(warnx + 70, warny + 70, 65, 65); //Reactor Coolant Warning
rect(warnx + 140, warny + 70, 65, 65); //Turbine Auto Trip
rect(warnx + 210, warny + 70, 65, 65); //Power Fluctuation Warning

// Make the warning that was chosen, red.
if(light.equals("none")){}
if(light.equals("core")){
fill(redOn);
rect(wa1x, wa1y, 65, 65); //Core-Damage Warning
}
if(light.equals("scram")){
fill(redOn);
rect(wa2x, wa2y, 65, 65); //SCRAM Warning
//rect(warnx + 140, warny + 70, 65, 65); //Turbine Auto Trip
//because these always happen together.
}
if(light.equals("si")){
fill(redOn);
rect(wa3x, wa3y, 65, 65); //SI Auto Injection
}
if(light.equals("containment")){
fill(redOn);
rect(wa4x, wa4y, 65, 65); //Containment Isolation Warning
}
if(light.equals("reactorh")){
fill(redOn);
rect(warnx, warny + 70, 65, 65); //Reactor High Temp Warning
}
if(light.equals("reactorc")){
fill(redOn);
rect(warnx + 70, warny + 70, 65, 65); //Reactor Coolant Warning
}
if(light.equals("turbine")){
fill(redOn);
rect(warnx + 140, warny + 70, 65, 65); //Turbine Auto Trip
}
if(light.equals("power")){
fill(redOn);
rect(warnx + 210, warny + 70, 65, 65); //Power Fluctuation Warning
}


//Write the labels of each warning and the "coordinate system"
fill(black);
textAlign(CENTER);
text("Core", warnx, warny + 10, 65, 65);
text("Damage", warnx, warny + 20, 65, 65);
text("Warning", warnx, warny + 30, 65, 65);

text("SCRAM", warnx + 70, warny + 30, 65, 65);

text("SI Auto", warnx + 140, warny + 20, 65, 65);
text("Injection", warnx + 140, warny + 35, 65, 65);

text("Containment", warnx + 205, warny + 10, 75, 65);
text("Isolation", warnx + 210, warny + 25, 65, 65);
text("Warning", warnx + 210, warny + 40, 65, 65);

text("Reactor", warnx, warny + 75, 65, 65);
text("High Temp", warnx, warny + 90, 65, 65);
text("Warning", warnx, warny + 105, 65, 65);

text("Reactor", warnx + 70, warny + 75, 65, 65);
text("Coolant", warnx + 70, warny + 90, 65, 65);
text("Warning", warnx + 70, warny + 105, 65, 65);

text("Turbine", warnx + 140, warny + 75, 65, 65);
text("Auto Trip", warnx + 140, warny + 90, 65, 65);

text("Power", warnx + 210, warny + 75, 65, 65);
text("Fluctuation", warnx + 210, warny + 90, 65, 65);
text("Warning", warnx + 210, warny + 105, 65, 65);

text("A", warnx - 20, warny + 30);
text("B", warnx - 20, warny + 100);
text("1", warnx + 30, warny - 5);
text("2", warnx + 100, warny - 5);
text("3", warnx + 180, warny - 5);
text("4", warnx + 240, warny - 5);
}



/*
* **************************CHATBOX***************************************
* **************************CHATBOX***************************************
* **************************CHATBOX***************************************
*/

void chatbox() {
//ChatBox chat = new ChatBox();
//chat.createAndShowGUI(); ///NOW I JUST NEED TO ADD THIS TO THE NUCLEAR PANEL INSTEAD OF ITS OWN CHATBOX PANEL

//int chatx = 490;
//int chaty = 650;
//fill(180);
//rect(chatx, chaty, 275, 250);

//fill(255);
//rect(chatx + 20, chaty + 30, 235, 150);
}

/*
* void SEND(int theValue) { myTextfield.submit(); }
*/

public void chat(String theText) {
// receiving text from controller texting
textAlign(LEFT);
text("Op: " + theText, 515, 828 - lineCt * 20);
lineCt++;
}

void reactor() {
stroke(0);
fill(255);

ellipse(reactorx, reactory, 150, 150);
ellipse(reactorx, reactory + 200, 150, 150);
stroke(255);
rect(reactorx - 75, reactory, 150, 200);
stroke(0);
line(reactorx - 75, reactory, reactorx - 75, reactory + 200);
line(reactorx + 75, reactory, reactorx + 75, reactory + 200);

rect(reactorx - 50, reactory - 80, 100, 30);
fill(0);
text("REACTOR", reactorx - 30, reactory - 60);

// Lines and pumps to Steam Generators

fill(0);
stroke(0);

// Loop 1
joint1x = sgx1 + 60;
joint1y = reactory + 80;
joint2x = sgx1 + 10;
joint2y = reactory + 100;

line(reactorx - 75, joint1y - 3, joint1x + 3, joint1y - 3);
line(reactorx - 75, joint1y, joint1x, joint1y);
line(joint1x, joint1y, joint1x, sgy1 + 130);
line(joint1x + 3, joint1y - 3, joint1x + 3, sgy1 + 127);
line(joint1x + 3, sgy1 + 127, joint2x, sgy1 + 127);
line(joint1x, sgy1 + 130, joint2x + 3, sgy1 + 130);
line(joint2x, sgy1 + 127, joint2x, joint2y);
line(joint2x + 3, sgy1 + 130, joint2x + 3, joint2y - 3);
line(joint2x, joint2y, reactorx - 75, joint2y);
line(joint2x + 3, joint2y - 3, reactorx - 75, joint2y - 3);

// Loop 2
joint1x = sgx2 - 30;
joint1y = reactory + 80;
joint2x = sgx2 + 10;
joint2y = reactory + 100;

line(reactorx + 75, joint1y + 3, joint1x + 3, joint1y + 3);
line(reactorx + 75, joint1y, joint1x, joint1y);
line(joint1x, joint1y, joint1x, sgy2 + 127);
line(joint1x + 3, joint1y + 3, joint1x + 3, sgy2 + 130);
line(joint1x, sgy2 + 127, joint2x + 3, sgy2 + 127);
line(joint1x + 3, sgy2 + 130, joint2x, sgy2 + 130);
line(joint2x + 3, sgy2 + 127, joint2x + 3, joint2y);
line(joint2x, sgy2 + 130, joint2x, joint2y - 3);
line(joint2x + 3, joint2y, reactorx + 75, joint2y);
line(joint2x, joint2y - 3, reactorx + 75, joint2y - 3);

// Loop 3
joint1x = sgx3 + 40;
joint1y = reactory + 200;
joint2x = sgx3 + 10;
joint2y = reactory + 170;

line(reactorx - 75, joint1y - 3, joint1x, joint1y - 3);
line(reactorx - 75, joint1y, joint1x + 3, joint1y);
line(joint1x, joint1y - 3, joint1x, sgy3 + 167);
line(joint1x + 3, joint1y, joint1x + 3, sgy3 + 170);
line(joint1x + 3, sgy3 + 170, joint2x, sgy3 + 170);
line(joint1x, sgy3 + 167, joint2x + 3, sgy3 + 167);
line(joint2x, sgy3 + 170, joint2x, joint2y - 3);
line(joint2x + 3, sgy3 + 167, joint2x + 3, joint2y);
line(joint2x + 3, joint2y, reactorx - 75, joint2y);
line(joint2x, joint2y - 3, reactorx - 75, joint2y - 3);

// Loop 4
joint1x = sgx4 - 20;
joint1y = reactory + 200;
joint2x = sgx4 + 10;
joint2y = reactory + 170;

line(reactorx + 75, joint1y - 3, joint1x + 3, joint1y - 3);
line(reactorx + 75, joint1y, joint1x, joint1y);
line(joint1x, joint1y, joint1x, sgy4 + 170);
line(joint1x + 3, joint1y - 3, joint1x + 3, sgy4 + 167);
line(joint1x + 3, sgy4 + 167, joint2x, sgy4 + 167);
line(joint1x, sgy4 + 170, joint2x + 3, sgy4 + 170);
line(joint2x, sgy4 + 167, joint2x, joint2y);
line(joint2x + 3, sgy4 + 170, joint2x + 3, joint2y - 3);
line(joint2x, joint2y, reactorx + 75, joint2y);
line(joint2x + 3, joint2y - 3, reactorx + 75, joint2y - 3);

}

// functions to call

void vertlabel(float x, float y, String label) { // x,y are the upper left
// hand corner of the
// first letter, and the
// vertex of rotation
fill(0);
stroke(0);
pushMatrix();
translate(x, y);
rotate(radians(90));
text(label, x, y);
rotate(radians(-90));
popMatrix();
}

void meter(float x, float y, float ipos) {
fill(255);
stroke(0);
rect(x, y, 15, 160);
fill(255, 40, 40);
stroke(255, 40, 40);
rect(x, y, 15, 20);
rect(x, y + 140, 15, 20);
fill(200);
stroke(0);
triangle(x + 15, ipos + 5, x + 15, ipos - 5, x + 10, ipos);
}

/* void steamgen(float x, float y) {
stroke(0);
fill(255);
ellipse(x, y, 40, 40);
ellipse(x + 40, y, 40, 40);
stroke(255);
rect(x, y - 20, 40, 50);
rect(x - 20, y, 80, 100);
stroke(0);
fill(100, 200, 250);
ellipse(x, y + 130, 40, 40);
ellipse(x + 40, y + 130, 40, 40);
stroke(100, 200, 250);
rect(x - 20, y + 100, 80, 30);
rect(x, y + 100, 40, 50);
stroke(0);
line(x - 20, y, x - 20, y + 130);
line(x + 60, y, x + 60, y + 130);
line(x, y - 20, x + 40, y - 20);
line(x, y + 150, x + 40, y + 150);
}*/
void steamgen(float x, float y, double z) {
stroke(0);
fill(255);
ellipse(x, y, 40, 40); //top left pie
ellipse(x + 40, y, 40, 40); //top right pie
stroke(255);
rect(x, y - 20, 40, 50); //top middle rect
rect(x - 20, y, 80, 100); // area considered the filled coolant tank
stroke(0);
fill(100, 200, 250); //coolant level
ellipse(x, y + 130, 40, 40); //bot left pie
ellipse(x + 40, y + 130, 40, 40); //bot right pie

stroke(100, 200, 250); // two vert lines inside
//rect(x - 20, y + 100, 80, 30); //middle block = level of coolant!

rect(x, y + 100+30, 40, 20); // bottom middle rect
stroke(0); //vert and horiz lines that make container
line(x - 20, y, x - 20, y + 130);
line(x + 60, y, x + 60, y + 130);
line(x, y - 20, x + 40, y - 20);
line(x, y + 150, x + 40, y + 150);


//add level of coolant
fill(100, 200, 250); //stroke(100, 200, 250);
rect(x - 20, (y+130)-(float)(1.3*z), 80-x+x, (float)(1.3*z)); //draw rect of coolant level
stroke(100, 200, 250);
rect(x-20+1, (y+130)-(float)(1.3*z), 80-2, (float)(1.3*z)); //draw outline

fill(white);
stroke(white);
rect(x-20+1, y, 80-2, (130)-(float)(1.3*z)); //draw empty white space
}



// Identifies whether the mouse is over each of the buttons' shapes
// Done by button TYPE, not individual button

boolean overRect(int x, int y, int width, int height) // Rectangular button
{
if (mouseX >= x && mouseX <= x + width && mouseY >= y
&& mouseY <= y + height) {
return true;
} else {
return false;
}
}

boolean overCircle(int x, int y, int diameter) // Circular button
{
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < diameter / 2) {
return true;
} else {
return false;
}
}

boolean overPumpR(int x, int y)// Right facing pump button
{ // coordinates x,y are at center of circle
if (overCircle(x, y, 16) || overRect(x - 3, y - 9, 18, 8)) {
return true;
} else {
return false;
}
}

boolean overPumpL(int x, int y) // Left facing pump button
{ // coordinates x,y are at center of circle
if (overCircle(x, y, 16) || overRect(x - 3, y - 9, 18, 10)) {
return true;
} else {
return false;
}
}

// //////////////////////FALSIFY//////////////////////////////Make all
// booleans false/////////////////////////

void falsify() {
rodUpOver = rodDownOver = rodAutoOver = rod10Over = rod5Over = rod1Over = false;
wa1Over = wa2Over = wa3Over = wa4Over = wb1Over = wb2Over = wb3Over = wb4Over = false;
prb1Over = prb2Over = prb3Over = prb4Over = prb7Over = plb7Over = prb5Over = vil1Over = vil2Over = vil3Over = vil4Over = prb6Over = plb1Over = plb2Over = plb3Over = plb4Over = plb5Over = plb6Over = vhb1Over = vhb2Over = vhb3Over = vhb4Over = vvb1Over = vvb2Over = vvb3Over = vvb4Over = false;
siaOver = sibOver = tc1Over = tc2Over = tc3Over = tc4Over = false;

}

// ///////////////////////////////////////HOW TO DRAW A RIGHT FACING
// PUMP////////////////////////////////////////////
void pumpR(int x, int y) {
rect(x - 3, y - 9, 18, 8);
ellipse(x, y, 16, 16);
}

// ///////////////////////////////////////HOW TO DRAW A LEFT FACING
// PUMP////////////////////////////////////////////
void pumpL(int x, int y) {
rect(x - 3, y - 9, 18, 8);
ellipse(x + 12, y, 16, 16);
}

// ///////////////////////////////////////HOW TO DRAW A VERTICAL
// VALVE////////////////////////////////////////////
void vvalve(int x, int y) {
triangle(x, y, x + 11, y, x + 6, y + 9);
triangle(x + 6, y + 9, x, y + 18, x + 11, y + 18);
}

// ///////////////////////////////////////HOW TO DRAW A HORIZONTAL
// VALVE////////////////////////////////////////////
void hvalve(int x, int y) {
triangle(x, y, x, y + 10, x + 8, y + 5);
triangle(x + 8, y + 5, x + 16, y, x + 16, y + 10);
}

}

0 Replies