com.internationalnetwork.tui
Class JScreen

Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.internationalnetwork.tui.JScreen
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, Runnable, EventListener

public class JScreen
extends javax.swing.JComponent
implements java.awt.event.ActionListener, Runnable

The JScreen class creates a text mode screen that fits within any JFC/Swing GUI like a typical JComponent.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int BACKGROUND
          Next argument specifies the background colour by its ID number, which must be within the range of 0 through 15.  The constant ("static final") RGB values may also be provided, and will be recognized automatically (any other values will cause java.lang.IndexOutOfBoundsException to be thrown.
static int BLACK
          The colour BLACK.  Also colour number 0.
static int BLINK_OFF
          Disables the BLINK attribute.
static int BLINK_ON
          Enables the BLINK attribute.
static int BLUE
          The colour BLUE.  Also colour number 1.
static int BOTTOM
          Moves the cursor to the bottom row.
static int BRIGHT_BLUE
          The colour BRIGHT_BLUE.  Also colour number 9.
static int BRIGHT_CYAN
          The colour BRIGHT_CYAN.  Also colour number 11.
static int BRIGHT_GRAY
          An alias for BRIGHT_GREY.
static int BRIGHT_GREEN
          An alias for LIME.
static int BRIGHT_GREY
          The colour BRIGHT_GREY.  Also colour number 7.
static int BRIGHT_RED
          The colour BRIGHT_RED.  Also colour number 12.
static int BROWN
          The colour BROWN.  Also colour number 6.
static int CENTRE
          Moves the cursor to the centre of the screen.  Where an even number of rows or columns is in effect, the centre is decided by rounding off the result after dividing by two.
static int CLEAR
          Clears the screen and moves the cursor to the top-left corner.
static int COL
          An alias for COL.
static int COLUMN
          An alias for COL.
static int CURSORFLASH_OFF
          Disables the CURSORFLASH attribute.  The cursor disappears when this attribute is disabled.
static int CURSORFLASH_ON
          Enables the CURSORFLASH attribute.  The cursor flashes at a steady rate when this attribute is enabled.
static int CURSORSTATE_OFF
          Turns the current state of the cursor off.  Only useful when flashing mode is turned off.
static int CURSORSTATE_ON
          Turns the current state of the cursor on.  Only useful when flashing mode is turned off.
static int CURSORSTYLE_BLOCK
          Change the cursor style to a block.
static int CURSORSTYLE_LINE
          Change the cursor style to a line.
static int CYAN
          The colour CYAN.  Also colour number 3.
static int DARK_GRAY
          An alias for GRAY.
static int DARK_GREY
          An alias for GREY.
static int DOWN
          Moves the cursor down one line (if it's not already at the bottom).
static int END
          Moves the cursor to the right-most column.
static int FOREGROUND
          Next argument specifies the foreground colour by its ID number, which must be within the range of 0 through 15.  The constant ("static final") RGB values may also be provided, and will be recognized automatically (any other values will cause java.lang.IndexOutOfBoundsException to be thrown.
static int GRAY
          An alias for GREY.
static int GREEN
          The colour GREEN.  Also colour number 2.
static int GREY
          The colour GREY.  Also colour number 8.
static int HOME
          Moves the cursor to the left-most column.
static int LEFT
          Moves the cursor left one space (if it's not already at the left).
static int LIME
          The colour LIME.  Also colour number 10.
static int NEWLINE
          Advances the cursor to the beginning of the next line.
static int NO_REPAINT
          Disables calling the repaint() method for this set of commands.  The repaint() command will be called very soon due to flashing cursor and blinking text updates, and will also be called again on subsequent sets of commands that don't include this NO_REPAINT value.
static int PINK
          The colour PINK.  Also colour number 13.
static int POP
          Loads previously saved output attributes from the internal stack.
static int PURPLE
          The colour PURPLE.  Also colour number 5.
static int PUSH
          Saves all current output attributes, including the cursor position, on the internal stack.
static int PUSH_ATTR
          Saves all current output attributes, except for the cursor position, on the internal stack.
static int RED
          The colour RED.  Also colour number 4.
static int RGB_BACKGROUND
          Next argument specifies the background colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters.
static int RGB_FOREGROUND
          Next argument specifies the foreground colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters.
static int RGBA_BACKGROUND
          Next argument specifies the background colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters, which also includes the alpha channel blending value that specifies the level of transparency.
static int RGBA_FOREGROUND
          Next argument specifies the foreground colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters, which also includes the alpha channel blending value that specifies the level of transparency.
static int RIGHT
          Moves the cursor right one space (if it's not already at the right).
static int ROW
          An alias for ROW.
static int STRIKE_OFF
          Disables the STRIKE attribute.
static int STRIKE_ON
          Enables the STRIKE attribute.
static int TOP
          Moves the cursor to the top row.
static int TRANSACTION
          Next argument specifies a transaction ID number.  This is the point in the queue where the transaction was created.
static int TRANSPARENT_OFF
          Disables the TRANSPARENT attribute.
static int TRANSPARENT_ON
          Enables the TRANSPARENT attribute.
static int UNDERLINE_OFF
          Disables the UNDERLINE attribute.
static int UNDERLINE_ON
          Enables the UNDERLINE attribute.
static int UP
          Moves the cursor up one line (if it's not already at the top).
static String VERSION
          Version number of this Package (read-only).
static int WHITE
          The colour WHITE.  Also colour number 15.
static int X
          Next argument specifies the current X coordinate of the cursor.  The numbering of columns begins with 0 for the first column.
static int XY
          Next two arguments specify the current X and Y coordinates of the cursor, where X comes before Y.  The numbering of columns and rows begin with 0 for both the top-left corner.
static int Y
          Next argument specifies the current Y coordinate of the cursor.  The numbering of rows begins with 0 for the first row.
static int YELLOW
          The colour YELLOW.  Also colour number 14.
static int YX
          Next two arguments specify the current Y and X coordinates of the cursor, where Y comes before X.  The numbering of columns and rows begin with 0 for the top-left corner.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JScreen(int... args)
          Instantiate a new JScreen object, with optional parameters provided in any order (see the "cmd" method for examples).
JScreen(int rows, int cols, String screenName, int... args)
          Instantiate a new JScreen object, with optional parameters provided in any order (see the "cmd" method for examples).
JScreen(String screenName, int... args)
          Instantiate a new JScreen object, with optional parameters provided in any order (see the "cmd" method for examples).
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Used internally to implement blinking text and the flashing cursor.
 JScreenTransaction begin()
          Starts a new transaction, and inserts it into the command queue.  See the documentation for commit(), commitNow(), and rollback() in the JScreenTransaction() class to learn more about the signifigance of a transaction's position in the command queue.
 JScreen cmd(int... args)
          Alters the values of any number of parameters (in any order).  The parameters are added to an internal queue for near-immediate processing, after a successful syntax check.
 java.awt.Dimension getPreferredSize()
          Provides the size (in pixels) of this JScreen object to its JComponent super-class so that any LayoutManagers can fit it correctly into the GUI.
 JScreen gotoX(int x)
          Moves the cursor to new column.  If the coordinates are out of range, it will be adjusted to the nearest respective position.
 JScreen gotoXY(int x, int y)
          Moves the cursor to new coordinates.  If the coordinates are out of range, they will be adjusted to the nearest respective positions.
 JScreen gotoY(int y)
          Moves the cursor to new row.  If the coordinate is out of range, it will be adjusted to the nearest respective position.
 JScreen gotoYX(int y, int x)
          Moves the cursor to new coordinates.  If the coordinates are out of range, they will be adjusted to the nearest respective positions.
 JScreen newLine()
          Advance the cursor to the beginning of the next line.  Scrolls the screen if needed.
 void paintComponent(java.awt.Graphics g)
          Draws the screen.
 JScreen pop()
          Loads the current cursor positions and screen state from an internal stack that were added earlier by the push() method.  If the stack is empty, the attributes remain unchanged.
 JScreen print(String text)
          Display a string of text on the screen, while updating the cursor position.
 JScreen printANSI(String text)
          Display a string of text on the screen, and interprets any ANSI control code sequences (following a control sequence indicator, or more commonly referred to as an ANSI escape sequence because ASCII character 27 is used), while updating the cursor position.
 JScreen printChar(int ascii)
          Display ONLY a single character with the specified ASCII value on the screen, and update the cursor position accordingly.  The screen is scrolled, as needed.
 JScreen printChar(String character)
          Display ONLY a single character on the screen (additional characters will all be ignored; this method is used internally), and update the cursor position accordingly.  The screen is scrolled, as needed.
 JScreen println()
          This is actually just an alias for newLine().
 JScreen println(String text)
          Display a string of text on the screen, while updating the cursor position, then advance to the beginning of the next line (like adding a CR/LF or a NewLine control sequence to the end of the string).
 JScreen push()
          Saves the current cursor positions and screen state in an internal stack for use later by the pop() method.
 JScreen pushAttr()
          Saves the screen state, but not the cursor position, in an internal stack for use later by the pop() method.
 void run()
          For internal use only.  Runs in parallel as a separate thread that sequentially processes commands, to prevent corruption when multiple threads write output to the same JScreen object.
 JScreen waitPoint()
          Waits for the current position in the command queue to be processed before returning.  This is a blocking call.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BACKGROUND

public static final int BACKGROUND
Next argument specifies the background colour by its ID number, which must be within the range of 0 through 15.  The constant ("static final") RGB values may also be provided, and will be recognized automatically (any other values will cause java.lang.IndexOutOfBoundsException to be thrown.

Default:  BLACK

See Also:
Constant Field Values

BLACK

public static final int BLACK
The colour BLACK.  Also colour number 0.

See Also:
Constant Field Values

BLINK_OFF

public static final int BLINK_OFF
Disables the BLINK attribute.

See Also:
Constant Field Values

BLINK_ON

public static final int BLINK_ON
Enables the BLINK attribute.

See Also:
Constant Field Values

BLUE

public static final int BLUE
The colour BLUE.  Also colour number 1.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Moves the cursor to the bottom row.

See Also:
Constant Field Values

BRIGHT_BLUE

public static final int BRIGHT_BLUE
The colour BRIGHT_BLUE.  Also colour number 9.

See Also:
Constant Field Values

BRIGHT_CYAN

public static final int BRIGHT_CYAN
The colour BRIGHT_CYAN.  Also colour number 11.

See Also:
Constant Field Values

BRIGHT_GRAY

public static final int BRIGHT_GRAY
An alias for BRIGHT_GREY.

See Also:
Constant Field Values

BRIGHT_GREEN

public static final int BRIGHT_GREEN
An alias for LIME.

See Also:
Constant Field Values

BRIGHT_GREY

public static final int BRIGHT_GREY
The colour BRIGHT_GREY.  Also colour number 7.

See Also:
Constant Field Values

BRIGHT_RED

public static final int BRIGHT_RED
The colour BRIGHT_RED.  Also colour number 12.

See Also:
Constant Field Values

BROWN

public static final int BROWN
The colour BROWN.  Also colour number 6.

See Also:
Constant Field Values

CENTRE

public static final int CENTRE
Moves the cursor to the centre of the screen.  Where an even number of rows or columns is in effect, the centre is decided by rounding off the result after dividing by two.

See Also:
Constant Field Values

CLEAR

public static final int CLEAR
Clears the screen and moves the cursor to the top-left corner.

See Also:
Constant Field Values

COL

public static final int COL
An alias for COL.

See Also:
Constant Field Values

COLUMN

public static final int COLUMN
An alias for COL.

See Also:
Constant Field Values

CURSORFLASH_OFF

public static final int CURSORFLASH_OFF
Disables the CURSORFLASH attribute.  The cursor disappears when this attribute is disabled.

Default:  Enabled

See Also:
Constant Field Values

CURSORFLASH_ON

public static final int CURSORFLASH_ON
Enables the CURSORFLASH attribute.  The cursor flashes at a steady rate when this attribute is enabled.

Default:  Enabled

See Also:
Constant Field Values

CURSORSTATE_OFF

public static final int CURSORSTATE_OFF
Turns the current state of the cursor off.  Only useful when flashing mode is turned off.

Default:  Not applicable

See Also:
Constant Field Values

CURSORSTATE_ON

public static final int CURSORSTATE_ON
Turns the current state of the cursor on.  Only useful when flashing mode is turned off.

Default:  Not applicable

See Also:
Constant Field Values

CURSORSTYLE_BLOCK

public static final int CURSORSTYLE_BLOCK
Change the cursor style to a block.

Default:  Disabled

See Also:
Constant Field Values

CURSORSTYLE_LINE

public static final int CURSORSTYLE_LINE
Change the cursor style to a line.

Default:  Enabled

See Also:
Constant Field Values

CYAN

public static final int CYAN
The colour CYAN.  Also colour number 3.

See Also:
Constant Field Values

DARK_GRAY

public static final int DARK_GRAY
An alias for GRAY.

See Also:
Constant Field Values

DARK_GREY

public static final int DARK_GREY
An alias for GREY.

See Also:
Constant Field Values

DOWN

public static final int DOWN
Moves the cursor down one line (if it's not already at the bottom).

See Also:
Constant Field Values

END

public static final int END
Moves the cursor to the right-most column.

See Also:
Constant Field Values

FOREGROUND

public static final int FOREGROUND
Next argument specifies the foreground colour by its ID number, which must be within the range of 0 through 15.  The constant ("static final") RGB values may also be provided, and will be recognized automatically (any other values will cause java.lang.IndexOutOfBoundsException to be thrown.

Default:  WHITE (not the same as BRIGHT_WHITE, which is more intense)

See Also:
Constant Field Values

GRAY

public static final int GRAY
An alias for GREY.

See Also:
Constant Field Values

GREEN

public static final int GREEN
The colour GREEN.  Also colour number 2.

See Also:
Constant Field Values

GREY

public static final int GREY
The colour GREY.  Also colour number 8.

See Also:
Constant Field Values

HOME

public static final int HOME
Moves the cursor to the left-most column.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Moves the cursor left one space (if it's not already at the left).

See Also:
Constant Field Values

LIME

public static final int LIME
The colour LIME.  Also colour number 10.

See Also:
Constant Field Values

NEWLINE

public static final int NEWLINE
Advances the cursor to the beginning of the next line.

See Also:
Constant Field Values

NO_REPAINT

public static final int NO_REPAINT
Disables calling the repaint() method for this set of commands.  The repaint() command will be called very soon due to flashing cursor and blinking text updates, and will also be called again on subsequent sets of commands that don't include this NO_REPAINT value.

See Also:
Constant Field Values

PINK

public static final int PINK
The colour PINK.  Also colour number 13.

See Also:
Constant Field Values

POP

public static final int POP
Loads previously saved output attributes from the internal stack.

See Also:
Constant Field Values

PURPLE

public static final int PURPLE
The colour PURPLE.  Also colour number 5.

See Also:
Constant Field Values

PUSH

public static final int PUSH
Saves all current output attributes, including the cursor position, on the internal stack.

See Also:
Constant Field Values

PUSH_ATTR

public static final int PUSH_ATTR
Saves all current output attributes, except for the cursor position, on the internal stack.

See Also:
Constant Field Values

RED

public static final int RED
The colour RED.  Also colour number 4.

See Also:
Constant Field Values

RGB_BACKGROUND

public static final int RGB_BACKGROUND
Next argument specifies the background colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters.

Although you can specify your own colours, the standard 16 basic colours, which are provided as constant ("static final") values, should suffice for most purposes (and also for those who prefer to remain consistent with actual text-mode applications).

See Also:
Constant Field Values

RGB_FOREGROUND

public static final int RGB_FOREGROUND
Next argument specifies the foreground colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters.

Although you can specify your own colours, the standard 16 basic colours, which are provided as constant ("static final") values, should suffice for most purposes (and also for those who prefer to remain consistent with actual text-mode applications).

See Also:
Constant Field Values

RGBA_BACKGROUND

public static final int RGBA_BACKGROUND
Next argument specifies the background colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters, which also includes the alpha channel blending value that specifies the level of transparency.

Although you can specify your own colours, the standard 16 basic colours, which are provided as constant ("static final") values, should suffice for most purposes (and also for those who prefer to remain consistent with actual text-mode applications).

See Also:
Constant Field Values

RGBA_FOREGROUND

public static final int RGBA_FOREGROUND
Next argument specifies the foreground colour.  This is the RGB colour value that will be used to display all succeeding ASCII text characters, which also includes the alpha channel blending value that specifies the level of transparency.

Although you can specify your own colours, the standard 16 basic colours, which are provided as constant ("static final") values, should suffice for most purposes (and also for those who prefer to remain consistent with actual text-mode applications).

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Moves the cursor right one space (if it's not already at the right).

See Also:
Constant Field Values

ROW

public static final int ROW
An alias for ROW.

See Also:
Constant Field Values

STRIKE_OFF

public static final int STRIKE_OFF
Disables the STRIKE attribute.

See Also:
Constant Field Values

STRIKE_ON

public static final int STRIKE_ON
Enables the STRIKE attribute.

See Also:
Constant Field Values

TOP

public static final int TOP
Moves the cursor to the top row.

See Also:
Constant Field Values

TRANSACTION

public static final int TRANSACTION
Next argument specifies a transaction ID number.  This is the point in the queue where the transaction was created.

For internal use only.  Use the begin() method to start a transaction.

See Also:
Constant Field Values

TRANSPARENT_OFF

public static final int TRANSPARENT_OFF
Disables the TRANSPARENT attribute.

See Also:
Constant Field Values

TRANSPARENT_ON

public static final int TRANSPARENT_ON
Enables the TRANSPARENT attribute.

See Also:
Constant Field Values

UNDERLINE_OFF

public static final int UNDERLINE_OFF
Disables the UNDERLINE attribute.

See Also:
Constant Field Values

UNDERLINE_ON

public static final int UNDERLINE_ON
Enables the UNDERLINE attribute.

See Also:
Constant Field Values

UP

public static final int UP
Moves the cursor up one line (if it's not already at the top).

See Also:
Constant Field Values

VERSION

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

See Also:
Constant Field Values

WHITE

public static final int WHITE
The colour WHITE.  Also colour number 15.

See Also:
Constant Field Values

X

public static final int X
Next argument specifies the current X coordinate of the cursor.  The numbering of columns begins with 0 for the first column.

Default:  0

See Also:
Constant Field Values

XY

public static final int XY
Next two arguments specify the current X and Y coordinates of the cursor, where X comes before Y.  The numbering of columns and rows begin with 0 for both the top-left corner.

Default:  0

See Also:
Constant Field Values

Y

public static final int Y
Next argument specifies the current Y coordinate of the cursor.  The numbering of rows begins with 0 for the first row.

Default:  0

See Also:
Constant Field Values

YELLOW

public static final int YELLOW
The colour YELLOW.  Also colour number 14.

See Also:
Constant Field Values

YX

public static final int YX
Next two arguments specify the current Y and X coordinates of the cursor, where Y comes before X.  The numbering of columns and rows begin with 0 for the top-left corner.

Default:  0

See Also:
Constant Field Values
Constructor Detail

JScreen

public JScreen(int... args)
Instantiate a new JScreen object, with optional parameters provided in any order (see the "cmd" method for examples).

See also:  Constants (for a complete list of possible parameters)


JScreen

public JScreen(int rows,
               int cols,
               String screenName,
               int... args)
Instantiate a new JScreen object, with optional parameters provided in any order (see the "cmd" method for examples).

See also:  Constants (for a complete list of possible parameters)

Parameters:
rows - Number of rows (minimum is 3)
cols - Number of columns (minimum is 3)
Throws:
UnsupportedOperationException - If there is any problem with the font file, including file I/O errors (catching this is optional because it is highly unlikely that an error will occur since the font data is included in the .jar file)

JScreen

public JScreen(String screenName,
               int... args)
Instantiate a new JScreen object, with optional parameters provided in any order (see the "cmd" method for examples).

See also:  Constants (for a complete list of possible parameters)

Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Used internally to implement blinking text and the flashing cursor.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

begin

public JScreenTransaction begin()
Starts a new transaction, and inserts it into the command queue.  See the documentation for commit(), commitNow(), and rollback() in the JScreenTransaction() class to learn more about the signifigance of a transaction's position in the command queue.

With a transaction, most of JScreen's methods and commands are available.

Returns:
Reference to the new JScreenTransaction object.

cmd

public JScreen cmd(int... args)
Alters the values of any number of parameters (in any order).  The parameters are added to an internal queue for near-immediate processing, after a successful syntax check.

Parameters:
args - Variable list of parameters followed by any/all associated values
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Provides the size (in pixels) of this JScreen object to its JComponent super-class so that any LayoutManagers can fit it correctly into the GUI.

Overrides:
getPreferredSize in class javax.swing.JComponent

gotoX

public JScreen gotoX(int x)
Moves the cursor to new column.  If the coordinates are out of range, it will be adjusted to the nearest respective position.

Parameters:
x - New column
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

gotoXY

public JScreen gotoXY(int x,
                      int y)
Moves the cursor to new coordinates.  If the coordinates are out of range, they will be adjusted to the nearest respective positions.

Parameters:
x - New column
y - New row
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

gotoY

public JScreen gotoY(int y)
Moves the cursor to new row.  If the coordinate is out of range, it will be adjusted to the nearest respective position.

Parameters:
y - New row
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

gotoYX

public JScreen gotoYX(int y,
                      int x)
Moves the cursor to new coordinates.  If the coordinates are out of range, they will be adjusted to the nearest respective positions.

Parameters:
y - New row
x - New column
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

newLine

public JScreen newLine()
Advance the cursor to the beginning of the next line.  Scrolls the screen if needed.

Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

paintComponent

public void paintComponent(java.awt.Graphics g)
Draws the screen.

Overrides:
paintComponent in class javax.swing.JComponent

pop

public JScreen pop()
Loads the current cursor positions and screen state from an internal stack that were added earlier by the push() method.  If the stack is empty, the attributes remain unchanged.

Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

print

public JScreen print(String text)
Display a string of text on the screen, while updating the cursor position.

Parameters:
text - String of text to display
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

printANSI

public JScreen printANSI(String text)
Display a string of text on the screen, and interprets any ANSI control code sequences (following a control sequence indicator, or more commonly referred to as an ANSI escape sequence because ASCII character 27 is used), while updating the cursor position.

Invalid or unsupported ANSI codes will be displayed as is, which simulates the behaviour of the majority of ANSI implementations.  If row or column positions exceed the maximum height and width, these values will be reduced to the respective maximums as appropriate.

The entire sequence of data will be converted to a series of internal commands and will be processed atomically as a single group commands.  This means that other threads will never be able to cause text or commands to interfere while this sequence of output is being processed.

Parameters:
text - String of text to display
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

printChar

public JScreen printChar(int ascii)
Display ONLY a single character with the specified ASCII value on the screen, and update the cursor position accordingly.  The screen is scrolled, as needed.

Parameters:
ascii - ASCII value of the character (0..255)
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

printChar

public JScreen printChar(String character)
Display ONLY a single character on the screen (additional characters will all be ignored; this method is used internally), and update the cursor position accordingly.  The screen is scrolled, as needed.

Parameters:
character - String containing only one character
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

println

public JScreen println()
This is actually just an alias for newLine().

Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

println

public JScreen println(String text)
Display a string of text on the screen, while updating the cursor position, then advance to the beginning of the next line (like adding a CR/LF or a NewLine control sequence to the end of the string).

Parameters:
text - String of text to display
Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

push

public JScreen push()
Saves the current cursor positions and screen state in an internal stack for use later by the pop() method.

Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

pushAttr

public JScreen pushAttr()
Saves the screen state, but not the cursor position, in an internal stack for use later by the pop() method.

Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.

run

public void run()
For internal use only.  Runs in parallel as a separate thread that sequentially processes commands, to prevent corruption when multiple threads write output to the same JScreen object.

Checks the queue, as a background thread, and processes jobs in the order they were added.  The repaint() method is called after every group of jobs is processed, unless the NO_REPAINT command is encountered anywhere in the particular set of commands being processed.

Specified by:
run in interface Runnable

waitPoint

public JScreen waitPoint()
Waits for the current position in the command queue to be processed before returning.  This is a blocking call.

Usually this call isn't needed at all, but there may be some circumstances where large amounts of data are sent to the screen and you need to wait until after the data has been displayed.  One example might be that you're detecting keystrokes such as CTRL-C (to break {terminate} text output) or CTRL-S (to pause text output) during text output, and you need to know when to stop detecting these keystrokes.

Returns:
Reference to this object so that the programmer can stack this method before other methods, to help make code easier to read.