com.internationalnetwork.tui
Class JScreenFont

Object
  extended by com.internationalnetwork.tui.JScreenFont

public class JScreenFont
extends Object

The JScreenFont class reads a fixed-size font file that contains a list of pixel co-ordinates that are used to draw each ASCII character.  The font data is returned as a multi-dimensional array of integers that JScreen uses to draw pixel-perfect ASCII characters.


Field Summary
static String VERSION
          Version number of this Package (read-only).
 
Constructor Summary
JScreenFont(java.io.InputStream inputStream)
          Read the specified font file and convert it to a multi-dimensional array and provides an interface that JScreen can use to display characters very easily.
JScreenFont(String filename)
          Read the specified font file and convert it to a multi-dimensional array and provides an interface that JScreen can use to display characters very easily.
 
Method Summary
 void display(JScreenCharacter character, int x, int y, boolean blinkState, java.awt.image.BufferedImage bi)
          Display a JScreenCharacter at the specified screen co-ordinates.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Version number of this Package (read-only).

See Also:
Constant Field Values
Constructor Detail

JScreenFont

public JScreenFont(java.io.InputStream inputStream)
            throws java.io.IOException
Read the specified font file and convert it to a multi-dimensional array and provides an interface that JScreen can use to display characters very easily.

To do:  Major improvement to this documentation
To do:  Data integrity checking while reading (to ensure that all pixels are within the specified size range)
To do:  Throw an exception if extra data is stored in the font file.

      File format:
        First 256 elements contain character data
        Last element contains font size ([256][0] == height; [256][1] == width)
        File format:
          Begins with variable-length line of text (copyright notice)
          Byte 0:  Height of fixed-size font
          Byte 1:  Width of fixed-size font
          256 instances of:
            { Short 0:  Number of short values to follow...
              { y, x, [y, x, [y, x, [...]]] }
            } // Each pair of two 16-bit values makes up one coordinate point
    

Parameters:
inputStream - A pre-opened stream of data that will read the .font file data from its current position, only reading forward and not reading beyond last byte of the font data.
Throws:
java.io.IOException - For the usual reasons that DataInputStream can throw this exception, but also some special internal handling throws this exception (instead of a sepearate java.lang.NullPointerException) when NULL is provided for the inputStream.

JScreenFont

public JScreenFont(String filename)
            throws java.io.IOException
Read the specified font file and convert it to a multi-dimensional array and provides an interface that JScreen can use to display characters very easily.

This is a convenience constructor method for JScreenFont(inputStream).

Parameters:
filename - Name of file, with optional absolute/relative path included
Throws:
java.io.IOException - For the usual reasons that FileInputStream can throw this exception
Method Detail

display

public void display(JScreenCharacter character,
                    int x,
                    int y,
                    boolean blinkState,
                    java.awt.image.BufferedImage bi)
Display a JScreenCharacter at the specified screen co-ordinates.

Parameters:
character - The character to display
x - The column on the text-mode JScreen (column 0 is the first column)
y - The row on the text-mode JScreen (row 0 is the first row)
blinkState - If "true" the character will be invisible (and only the background will appear as long as the JScreenCharacter's "transparent" flag has not been set)
bi - The BufferedImage object to draw on