net.slashie.libjcsi
Interface ConsoleSystemInterface

All Known Implementing Classes:
JCursesConsoleInterface, WSwingConsoleInterface

public interface ConsoleSystemInterface

Allows for easy output to a console screen emulation and keyboard input.

Author:
Santiago Zapata, Eben Howard

Field Summary
static int BLACK
           
static int BLUE
           
static int BROWN
           
static int CYAN
           
static int DARK_BLUE
           
static int DARK_RED
           
static int GRAY
           
static int GREEN
           
static int LEMON
           
static int LIGHT_GRAY
           
static int MAGENTA
           
static int PURPLE
           
static int RED
           
static int TEAL
           
static int WHITE
           
static int YELLOW
           
 
Method Summary
 void cls()
          Clears the screen
 void flash(int color)
          Makes the screen flash with a given color
 void flushColorTable()
          This flushes the internal Hashtable for the colors.
 CharKey inkey()
          Waits until a key is pressed and returns it
 java.lang.String input()
          Reads a string from the keyboard
 java.lang.String input(int length)
          Reads a string from the keyboard with a maximum length
 boolean isInsideBounds(Position e)
          Checks if the position is valid
 void locateCaret(int x, int y)
          Locates the input caret on a given position
 char peekChar(int x, int y)
          Checks what character is at a given position
 int peekColor(int x, int y)
          Checks what color is at a given position
 void print(int x, int y, char what, CSIColor color)
          Prints a character on the console, using a custom color
 void print(int x, int y, char what, int color)
          Prints a character on the console
 void print(int x, int y, java.lang.String what)
          Prints a String on the console with the default color.
 void print(int x, int y, java.lang.String what, CSIColor color)
          Prints a String on the console, using a custom color.
 void print(int x, int y, java.lang.String what, int color)
          Prints a String on the console in the color specified.
 void refresh()
          Refreshes the screen, printing all characters that were buffered Some implementations may instead write directly to the console
 void refresh(java.lang.Thread t)
          Refreshes the screen, printing all characters that were buffered, and interrupts the Thread Some implementations may instead write directly to the console
 void restore()
          Restores the contents of the backup buffer to screen
 void safeprint(int x, int y, char what, int color)
          Same as print but must check for validity of the coordinates
 void saveBuffer()
          Saves the screen contents to a backup buffer
 void setAutoRefresh(boolean value)
          Sets whether or not a buffer will be used
 void waitKey(int keyCode)
          Waits for the user to press a key
 

Field Detail

BLACK

static final int BLACK
See Also:
Constant Field Values

DARK_BLUE

static final int DARK_BLUE
See Also:
Constant Field Values

GREEN

static final int GREEN
See Also:
Constant Field Values

TEAL

static final int TEAL
See Also:
Constant Field Values

DARK_RED

static final int DARK_RED
See Also:
Constant Field Values

PURPLE

static final int PURPLE
See Also:
Constant Field Values

BROWN

static final int BROWN
See Also:
Constant Field Values

LIGHT_GRAY

static final int LIGHT_GRAY
See Also:
Constant Field Values

GRAY

static final int GRAY
See Also:
Constant Field Values

BLUE

static final int BLUE
See Also:
Constant Field Values

LEMON

static final int LEMON
See Also:
Constant Field Values

CYAN

static final int CYAN
See Also:
Constant Field Values

RED

static final int RED
See Also:
Constant Field Values

MAGENTA

static final int MAGENTA
See Also:
Constant Field Values

YELLOW

static final int YELLOW
See Also:
Constant Field Values

WHITE

static final int WHITE
See Also:
Constant Field Values
Method Detail

print

void print(int x,
           int y,
           char what,
           int color)
Prints a character on the console

Parameters:
x - horizontal position
y - vertical position
what - The character to be printed
color - The color, one of the ConsoleSystemInterface constants

safeprint

void safeprint(int x,
               int y,
               char what,
               int color)
Same as print but must check for validity of the coordinates

Parameters:
x - horizontal position
y - vertical position
what - The character to be printed
color - The color, one of the ConsoleSystemInterface constants

print

void print(int x,
           int y,
           java.lang.String what,
           int color)
Prints a String on the console in the color specified. Does not check for running of the edge of the screen, so calling function must do such a check to avoid errors.

Parameters:
x - horizontal starting position
y - vertical position
what - The string to be printed
color - The color, one of the ConsoleSystemInterface constants

print

void print(int x,
           int y,
           java.lang.String what)
Prints a String on the console with the default color. Does not check for running of the edge of the screen, so calling function must do such a check to avoid errors.

Parameters:
x - horizontal starting position
y - vertical starting position
what - The String to be printed

peekChar

char peekChar(int x,
              int y)
Checks what character is at a given position

Parameters:
x - horizontal position
y - vertical position
Returns:
The character at the x,y position

peekColor

int peekColor(int x,
              int y)
Checks what color is at a given position

Parameters:
x - horizontal position
y - vertical position
Returns:
The color at the x,y position

inkey

CharKey inkey()
Waits until a key is pressed and returns it

Returns:
The key that was pressed

locateCaret

void locateCaret(int x,
                 int y)
Locates the input caret on a given position

Parameters:
x - horizontal position
y - vertical position

input

java.lang.String input()
Reads a string from the keyboard

Returns:
The String that was read after pressing enter

input

java.lang.String input(int length)
Reads a string from the keyboard with a maximum length

Returns:
The String that was read after pressing enter, truncated at specified length

isInsideBounds

boolean isInsideBounds(Position e)
Checks if the position is valid

Parameters:
e - position to be tested
Returns:
true if the position is valid

cls

void cls()
Clears the screen


refresh

void refresh()
Refreshes the screen, printing all characters that were buffered Some implementations may instead write directly to the console


refresh

void refresh(java.lang.Thread t)
Refreshes the screen, printing all characters that were buffered, and interrupts the Thread Some implementations may instead write directly to the console


flash

void flash(int color)
Makes the screen flash with a given color

Parameters:
color -

flushColorTable

void flushColorTable()
This flushes the internal Hashtable for the colors. Should be called when changing the map drasticaly, such as during a level change event.


setAutoRefresh

void setAutoRefresh(boolean value)
Sets whether or not a buffer will be used

Parameters:
value - true to activate buffer

waitKey

void waitKey(int keyCode)
Waits for the user to press a key

Parameters:
keyCode - code of specific key to wait for

saveBuffer

void saveBuffer()
Saves the screen contents to a backup buffer


restore

void restore()
Restores the contents of the backup buffer to screen


print

void print(int x,
           int y,
           char what,
           CSIColor color)
Prints a character on the console, using a custom color

Parameters:
x - horizontal position
y - vertical position
what - The character to be printed
color - The color, a rgba instance of CSIColor

print

void print(int x,
           int y,
           java.lang.String what,
           CSIColor color)
Prints a String on the console, using a custom color. Does not check for running of the edge of the screen, so calling function must do such a check to avoid errors.

Parameters:
x - horizontal position
y - vertical position
what - The String to be printed
color - The color, a rgba instance of CSIColor