org.gicentre.utils.gui
Class HelpScreen

java.lang.Object
  extended by org.gicentre.utils.gui.HelpScreen

public class HelpScreen
extends java.lang.Object

Class to produce a 'help screen' with the keys and instructions aligned on their separating colons. Calculates the size required to contain all the instructions (regardless of sketch size), then centres this.

Version:
3.3, 1st August, 2011.
Author:
Aidan Slingsby and Jo Wood, giCentre, City University London.

Constructor Summary
HelpScreen(processing.core.PApplet applet, processing.core.PFont font)
          Creates a help screen object with default text size.
HelpScreen(processing.core.PApplet applet, processing.core.PFont font, int textSize)
          Creates a help screen object.
 
Method Summary
 void addSpacer()
          Adds a vertical space (of the current font height) to the help screen entries.
 void draw()
          Draws the help screen centred on the sketch.
 boolean getIsActive()
          Reports whether or not the help window is currently active.
 void putEntry(java.lang.String action, java.lang.String instruction)
          Adds a help entry to the help screen.
 void setBackgroundColour(int bgColour)
          Sets the background colour of the help window.
 void setFooter(java.lang.String text, int verticalSpace, int textSize)
          Provides the optional text to appear at the foot of the help screen.
 void setFooterTextColour(int colour)
          Sets footer text colour.
 void setForegroundColour(int fgColour)
          Sets the foreground colour of the help window.
 void setHeader(java.lang.String text, int verticalSpace, int textSize)
          Provides the optional text to appear at the top of the help screen.
 void setHeaderTextColour(int colour)
          Sets header text colour.
 void setIsActive(boolean isActive)
          Determines whether or not the help screen should be currently active.
 void setTextColour(int colour)
          Sets main text colour.
 void setTextSize(float textSize)
          Sets the current text size in pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HelpScreen

public HelpScreen(processing.core.PApplet applet,
                  processing.core.PFont font)
Creates a help screen object with default text size.

Parameters:
applet - Parent sketch to which this help screen is to be attached.
font - Font used for text in help screen.

HelpScreen

public HelpScreen(processing.core.PApplet applet,
                  processing.core.PFont font,
                  int textSize)
Creates a help screen object.

Parameters:
applet - Parent sketch to which this help screen is to be attached.
font - Font used for text in help screen.
textSize - Size of text to use in help screen (pixels).
Method Detail

putEntry

public void putEntry(java.lang.String action,
                     java.lang.String instruction)
Adds a help entry to the help screen. Items will be displayed in order of addition. Can also be used to modify an entry (e.g. if a mode has changed - keyed to the "action"). Can use \n in either (no automatic wrapping) to indicate new line.

Parameters:
action - The user interaction (e.g. key press) to be documented.
instruction - Description of the action.

addSpacer

public void addSpacer()
Adds a vertical space (of the current font height) to the help screen entries.


setHeader

public void setHeader(java.lang.String text,
                      int verticalSpace,
                      int textSize)
Provides the optional text to appear at the top of the help screen. Could be title or other introductory text. Wraps at top of help screen, centred horizontally. Text size should be set explicitly.

Parameters:
text - The text to appear in the header.
verticalSpace - The space between the header and the text in the help window.
textSize - Size of text in pixels.

setFooter

public void setFooter(java.lang.String text,
                      int verticalSpace,
                      int textSize)
Provides the optional text to appear at the foot of the help screen. Could be version, author etc Wraps at bottom of help screen, right-aligned. Text size should be set explicitly.

Parameters:
text - The text to appear in the footer.
verticalSpace - The space between the footer and the text in the help window.
textSize - Size of text in pixels.

getIsActive

public boolean getIsActive()
Reports whether or not the help window is currently active. This has no direct effect on drawing, which has to be called explicitly, but provides a useful way of storing the state of the window visibility.

Returns:
True if the help window is active.

setIsActive

public void setIsActive(boolean isActive)
Determines whether or not the help screen should be currently active. This has no direct effect on drawing, which has to be called explicitly, but provides a useful way of storing the state of the window visibility.

Parameters:
isActive - If true, the help window is made active.

setTextSize

public void setTextSize(float textSize)
Sets the current text size in pixels.

Parameters:
textSize - New text size in pixels.

setHeaderTextColour

public void setHeaderTextColour(int colour)
Sets header text colour.

Parameters:
colour - Colour of header text, expressed as a Processing integer colour.

setFooterTextColour

public void setFooterTextColour(int colour)
Sets footer text colour.

Parameters:
colour - Colour of footer text, expressed as a Processing integer colour.

setTextColour

public void setTextColour(int colour)
Sets main text colour.

Parameters:
colour - Main text colour expressed as a Processing integer colour.

setBackgroundColour

public void setBackgroundColour(int bgColour)
Sets the background colour of the help window.

Parameters:
bgColour - Background colour expressed as a Processing integer colour.

setForegroundColour

public void setForegroundColour(int fgColour)
Sets the foreground colour of the help window. This is the colour of the text displayed and the border around the window.

Parameters:
fgColour - Foreground colour expressed as a Processing integer colour.

draw

public void draw()
Draws the help screen centred on the sketch. The parent sketch is responsible for calling this method so its visibility can be controlled, possibly by using getIsActive() / setIsActive().



giCentre Utilities V.3.3, API documentation generated 6th April, 2013