public class InfoDisplay { float x, y, mWidth, mHeight; int bTextHeight = 12; Button runButton; Button setupButton; Button stepButton; Button addPiecesButton; Button movementButton; Button helpButton; public InfoDisplay(float _x, float _y, float _width, float _height) { x = _x; y = _y; mWidth = _width; mHeight = _height; font = loadFont("Courier-Bold-24.vlw"); setupButtons(); } void setupButtons() { Button b; Action a; float bH = bTextHeight + 6; int buttonCol = (int)(x + mWidth - 120); b = new OnceButton(font, bTextHeight); a = new Action() { public void doActiveAction() { reset(); } }; b.setup(buttonCol,(int) (y+bH/2),"Setup", a, 3); b.active.status = false; setupButton = b; b = new Button(font, bTextHeight); a = new Action(); b.setup(buttonCol,(int) (y+bH*4/2-bH/4),"Run", a, 3); b.active.status = false; runButton = b; b = new OnceButton(font, bTextHeight); a = new Action() { public void doActiveAction() { stepit = true; } }; b.setup(buttonCol+50,(int) (y+bH*4/2-bH/4),"Step", a, 3); b.active.status = false; stepButton = b; b = new Button(font, bTextHeight); a = new Action(); b.setup(buttonCol,(int) (y+bH*6/2 - bH/8),"Add Pieces", a, 3); b.active.status = false; addPiecesButton = b; b = new Button(font, bTextHeight); a = new Action() { public void doActiveAction() { moore = true; board.resetFloodBoard(); } public void doInactiveAction() { moore = false; board.resetFloodBoard(); } }; b.setup(buttonCol,(int) (y+bH*8/2),"Moore", a, 3); b.active.status = false; movementButton = b; b = new OnceButton(font, bTextHeight); a = new Action() { public void doActiveAction() { showhelp = true; } }; b.setup(buttonCol+65,(int) (y+bH*8/2),"help", a, 3); b.active.status = false; helpButton = b; } void checkButtons() { checkButton(runButton); checkButton(stepButton); checkButton(setupButton); checkButton(addPiecesButton); checkButton(movementButton); checkButton(helpButton); } void checkButton(Button b) { if (b.inButtonBound(mouseX,mouseY)) b.pressed(); } public void drawButtons() { stepButton.display(); setupButton.display(); runButton.display(); addPiecesButton.display(); movementButton.display(); helpButton.display(); } public void draw() { int xMargin = 20; int yMargin = 10; textFont(font, textHeight); fill(255,255,0); stroke(255,255,0); text("Ticks: " + ticks, x+xMargin, y+textHeight+yMargin); text("Pennies On Board: " + board.pieces.size(), x+xMargin, y+2*textHeight+yMargin); text("Pennies Exited: " + penniesExited, x+xMargin, y+3*textHeight+yMargin); drawButtons(); } } class InfoPanel { ArrayList lines; color backgroundColor = color(0,0,100); color textColor = color(255,255,255); int textHeight = 16; int ymargin = 15; int xmargin = 15; float x, y, panelwidth, panelheight; PFont font; public InfoPanel(String fname) { super(); font = loadFont("Courier-Bold-24.vlw"); String [] input = loadStrings(fname); lines = new ArrayList(); for (int i=0; iheight) ? height : (panelheight>nheight) ? panelheight: nheight; float nwidth = 0; float twidth; for (int i=0; iwidth) ? width : (panelwidth>nwidth) ? panelwidth : nwidth; } } void showInfo() { translate(width/2,height/2); textFont(font,textHeight); calcGeometry(); background(0); fill(backgroundColor); stroke(textColor); rect(x,y,panelwidth,panelheight); fill(textColor); for (int i =0; i