hades.models.special
Class VT52Canvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byhades.models.special.VT52Canvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class VT52Canvas
extends javax.swing.JPanel

VT52Canvas - an AWT component that displays a "VT-52" type terminal window with cursor.

This class is used by both the serial and the parallel interface HADES terminal models: hades.models.special.VT52, and hades.models.special.Terminal.

Text font and color can be specified via the "Hades.VT52Canvas.FontName", "...FontSize", and "Hades.VT52canvas.Color" properties. Call "setCursor(x,y)" to move the cursor, "clear()" to clear the display, and "setChar(c)" to add a character.

Note: somehow, Swing really wants to use its own default font, requiring lots of g.setFont() calls...

See Also:
Serialized Form

Nested Class Summary
protected  class VT52Canvas.BlinkTimer
           
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  boolean auto_repaint_enable
           
protected  int char_height
           
protected  int char_width
           
protected  int cursor_old_x
           
protected  int cursor_old_y
           
protected  boolean cursor_on
           
protected  int cursor_x
           
protected  int cursor_y
           
static boolean debug
           
protected  java.lang.StringBuffer[] displayBuffer
           
protected  int height
           
protected  int max_ascent
           
protected  int mode
           
static int MODE_ESCAPE_MOVETO
           
static int MODE_ESCAPE_MOVETO2
           
static int MODE_ESCAPE_SINGLE
           
static int MODE_NORMAL
           
protected  int moveto_x
           
protected  int moveto_y
           
static int n_chars
           
static int n_lines
           
protected  int t_repaint
           
protected  java.awt.Color textColor
           
protected  java.awt.Font textFont
           
protected  int width
           
 
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.Container
 
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
VT52Canvas()
           
 
Method Summary
 void addChar(char c)
          add one char to the VT52 emulation and interpret it.
 void addDummyListener()
           
 void addDummyMouseListener()
          since JDK 1.1.6, we won't receive the keyboard focus, unless we ask for it.
 void addNormalChar(char c)
           
 void clear()
           
 void clearRestOfDisplay()
           
 void clearRestOfLine()
           
 int clip(int value, int minValue, int maxValue)
           
 boolean getAutoRepaintEnable()
           
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
 void hideCursor(java.awt.Graphics g)
           
 void identifyTerminal()
           
protected  void initDisplayBuffer()
           
protected  void initFontAndColors()
           
 boolean isOpaque()
           
static void main(java.lang.String[] argv)
          main(): simple selftest of the VT52Canvas
static void message(java.lang.String s)
           
 void moveCursorDown()
           
 void moveCursorHome()
           
 void moveCursorLeft()
           
 void moveCursorRight()
           
 void moveCursorTo(int x, int y)
           
 void moveCursorUp()
           
 void moveCursorUpWithScrolling()
           
 void moveNewline()
           
static void msg(java.lang.String s)
           
 void paint(java.awt.Graphics g)
           
 void paintCharAt(java.awt.Graphics g, int x, int y)
           
 void resetMode()
           
 void scrollUp()
           
 void setAutoRepaintDelay(int millis)
           
 void setAutoRepaintEnable(boolean b)
           
 void setCursor(int x, int y)
           
 void setFont(java.awt.Font f)
           
 void setTextFont(java.awt.Font f)
           
 void showCursor(java.awt.Graphics g)
           
 void startCursorBlinking()
           
 void updateFontMetrics()
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

n_lines

public static final int n_lines
See Also:
Constant Field Values

n_chars

public static final int n_chars
See Also:
Constant Field Values

MODE_NORMAL

public static final int MODE_NORMAL
See Also:
Constant Field Values

MODE_ESCAPE_SINGLE

public static final int MODE_ESCAPE_SINGLE
See Also:
Constant Field Values

MODE_ESCAPE_MOVETO

public static final int MODE_ESCAPE_MOVETO
See Also:
Constant Field Values

MODE_ESCAPE_MOVETO2

public static final int MODE_ESCAPE_MOVETO2
See Also:
Constant Field Values

debug

public static boolean debug

cursor_x

protected int cursor_x

cursor_y

protected int cursor_y

cursor_old_x

protected int cursor_old_x

cursor_old_y

protected int cursor_old_y

cursor_on

protected boolean cursor_on

char_width

protected int char_width

char_height

protected int char_height

max_ascent

protected int max_ascent

width

protected int width

height

protected int height

textFont

protected java.awt.Font textFont

textColor

protected java.awt.Color textColor

t_repaint

protected int t_repaint

auto_repaint_enable

protected boolean auto_repaint_enable

displayBuffer

protected java.lang.StringBuffer[] displayBuffer

mode

protected int mode

moveto_x

protected int moveto_x

moveto_y

protected int moveto_y
Constructor Detail

VT52Canvas

public VT52Canvas()
Method Detail

initFontAndColors

protected void initFontAndColors()

setFont

public void setFont(java.awt.Font f)

setTextFont

public void setTextFont(java.awt.Font f)

updateFontMetrics

public void updateFontMetrics()

addDummyMouseListener

public void addDummyMouseListener()
since JDK 1.1.6, we won't receive the keyboard focus, unless we ask for it. Request the focus on each mouse click.


initDisplayBuffer

protected void initDisplayBuffer()

resetMode

public void resetMode()

setCursor

public void setCursor(int x,
                      int y)

moveNewline

public void moveNewline()

moveCursorUp

public void moveCursorUp()

moveCursorUpWithScrolling

public void moveCursorUpWithScrolling()

moveCursorDown

public void moveCursorDown()

moveCursorRight

public void moveCursorRight()

moveCursorLeft

public void moveCursorLeft()

moveCursorHome

public void moveCursorHome()

moveCursorTo

public void moveCursorTo(int x,
                         int y)

clearRestOfLine

public void clearRestOfLine()

clearRestOfDisplay

public void clearRestOfDisplay()

identifyTerminal

public void identifyTerminal()

addChar

public void addChar(char c)
add one char to the VT52 emulation and interpret it. Currently, this model understands the following command sequences:


addNormalChar

public void addNormalChar(char c)

clear

public void clear()

scrollUp

public void scrollUp()

clip

public int clip(int value,
                int minValue,
                int maxValue)

getMinimumSize

public java.awt.Dimension getMinimumSize()

getPreferredSize

public java.awt.Dimension getPreferredSize()

isOpaque

public boolean isOpaque()

paint

public void paint(java.awt.Graphics g)

paintCharAt

public void paintCharAt(java.awt.Graphics g,
                        int x,
                        int y)

showCursor

public void showCursor(java.awt.Graphics g)

hideCursor

public void hideCursor(java.awt.Graphics g)

getAutoRepaintEnable

public boolean getAutoRepaintEnable()

setAutoRepaintEnable

public void setAutoRepaintEnable(boolean b)

setAutoRepaintDelay

public void setAutoRepaintDelay(int millis)

startCursorBlinking

public void startCursorBlinking()

msg

public static void msg(java.lang.String s)

addDummyListener

public void addDummyListener()

message

public static void message(java.lang.String s)

main

public static void main(java.lang.String[] argv)
main(): simple selftest of the VT52Canvas