mdh.hephaestus2.gamelib
Class Terminal

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--mdh.hephaestus2.gamelib.DoublePanel
                          |
                          +--mdh.hephaestus2.gamelib.Terminal
All Implemented Interfaces:
Accessible, AdjustmentListener, EventListener, ImageObserver, MenuContainer, MouseListener, MouseMotionListener, Serializable

public class Terminal
extends DoublePanel
implements AdjustmentListener, MouseListener, MouseMotionListener

A "glass TTY" with scrollback, and optional icons next to every line.

Author:
Copyright © 2000 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Field Summary
static int DEFAULT_COLS
           
static int DEFAULT_FONTSIZE
           
static int DEFAULT_LINES
           
 
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
Terminal()
          Creates a default 80 * 25 Terminal, with 10-pixel font.
Terminal(int lines)
          Creates a default 80 * lines Terminal, with 10-pixel font.
Terminal(int cols, int lines)
          Creates a default cols * lines Terminal, with 10-pixel font.
Terminal(int cols, int lines, boolean scroll)
          Creates a Terminal with 10-pixel font.
Terminal(int cols, int lines, int fontsize)
          Creates a Terminal with a scrollbar.
Terminal(int cols, int lines, int fontsize, boolean scroll)
           
 
Method Summary
 void adjustmentValueChanged(AdjustmentEvent ae)
          Messages from the scrollbar
 void cls()
           
 void draw(Graphics2D g)
          Override this to do your drawing on the offscreen buffer; you need do nothing else.
 int getAtomic()
           
 int getColumns()
           
 mdh.hephaestus2.gamelib.TerminalLine getLine(int line)
           
 int getLines()
           
 Dimension getPreferredSize()
           
 int getTopLine()
           
 int getVisibleLines()
           
 boolean isFocusable()
           
 boolean isFocusTraversable()
          This is deprecated in 1.4, but still necessary for 1.3 compatibility.
 void mouseClicked(MouseEvent me)
           
 void mouseDragged(MouseEvent me)
           
 void mouseEntered(MouseEvent me)
           
 void mouseExited(MouseEvent me)
           
 void mouseMoved(MouseEvent me)
           
 void mousePressed(MouseEvent me)
           
 void mouseReleased(MouseEvent me)
           
 void println(Color fore, Color back, String s)
           
 void println(Icon icon, Color fore, Color back, String s)
           
 void println(Icon icon, String s)
           
 void println(String s)
           
 void printlnMarkup(String s)
           
 void printlnReverse(String s)
           
 void setAtomic(boolean a)
           
 void setColumns(int c)
          Use with extreme caution.
 void setFont(Font f)
           
 void setIconWidth(int w)
           
 void setTopLine(int t)
          Sets the topmost visible cell.
 void setVisibleLines(int v)
           
 
Methods inherited from class mdh.hephaestus2.gamelib.DoublePanel
getMinimumSize, isDoubleBuffered, isFixedSize, paint, redraw, repaintNow, setSize, update
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_COLS

public static final int DEFAULT_COLS
See Also:
Constant Field Values

DEFAULT_LINES

public static final int DEFAULT_LINES
See Also:
Constant Field Values

DEFAULT_FONTSIZE

public static final int DEFAULT_FONTSIZE
See Also:
Constant Field Values
Constructor Detail

Terminal

public Terminal()
Creates a default 80 * 25 Terminal, with 10-pixel font.


Terminal

public Terminal(int lines)
Creates a default 80 * lines Terminal, with 10-pixel font.


Terminal

public Terminal(int cols,
                int lines)
Creates a default cols * lines Terminal, with 10-pixel font.


Terminal

public Terminal(int cols,
                int lines,
                boolean scroll)
Creates a Terminal with 10-pixel font.


Terminal

public Terminal(int cols,
                int lines,
                int fontsize)
Creates a Terminal with a scrollbar.


Terminal

public Terminal(int cols,
                int lines,
                int fontsize,
                boolean scroll)
Method Detail

adjustmentValueChanged

public void adjustmentValueChanged(AdjustmentEvent ae)
Messages from the scrollbar

Specified by:
adjustmentValueChanged in interface AdjustmentListener

cls

public void cls()

draw

public void draw(Graphics2D g)
Description copied from class: DoublePanel
Override this to do your drawing on the offscreen buffer; you need do nothing else.

Specified by:
draw in class DoublePanel

getAtomic

public int getAtomic()

getColumns

public int getColumns()

getLine

public mdh.hephaestus2.gamelib.TerminalLine getLine(int line)

getLines

public int getLines()

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class DoublePanel

getTopLine

public int getTopLine()
Returns:
the topmost visible text line.

getVisibleLines

public int getVisibleLines()

isFocusable

public boolean isFocusable()
Overrides:
isFocusable in class DoublePanel

isFocusTraversable

public boolean isFocusTraversable()
Description copied from class: DoublePanel
This is deprecated in 1.4, but still necessary for 1.3 compatibility.

Overrides:
isFocusTraversable in class DoublePanel

mouseClicked

public void mouseClicked(MouseEvent me)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent me)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent me)
Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent me)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent me)
Specified by:
mouseReleased in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent me)
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent me)
Specified by:
mouseMoved in interface MouseMotionListener

println

public void println(String s)

printlnMarkup

public void printlnMarkup(String s)

printlnReverse

public void printlnReverse(String s)

println

public void println(Icon icon,
                    String s)

println

public void println(Color fore,
                    Color back,
                    String s)

println

public void println(Icon icon,
                    Color fore,
                    Color back,
                    String s)

setAtomic

public void setAtomic(boolean a)

setColumns

public void setColumns(int c)
Use with extreme caution. If you resize it below the number of columns set, the rightmost text will be cut off. The alternative is to add another scrollbar (a waste of screen space in most cases), or rewrap the text (which would leave the text screwed up if you resize it wide again). So don't do that.


setFont

public void setFont(Font f)
Overrides:
setFont in class Container

setIconWidth

public void setIconWidth(int w)

setTopLine

public void setTopLine(int t)
Sets the topmost visible cell.


setVisibleLines

public void setVisibleLines(int v)