Video Display Unit emulation for Swing/AWT. This class implements all necessary
features of a character display unit, but not the actual terminal emulation.
It can be used as the base for terminal emulations of any kind.
This is a lightweight component. It will render very badly if used
in standard AWT components without overloaded update() method. The
update() method must call paint() immediately without clearing the
components graphics context or parts of the screen will simply
disappear.
Maintainer: Matthias L. Jugel
addFocusListener
public void addFocusListener(FocusListener listener)
addKeyListener
public void addKeyListener(KeyListener listener)
Add a key listener to the VDU. This is necessary to be able to receive
keyboard input from this component. It is a prerequisite for a
lightweigh component.
listener
- the key listener
addMouseListener
public void addMouseListener(MouseListener listener)
Add a mouse listener to the VDU. This is the implementation for
the lightweight event handling.
listener
- the new mouse listener
addMouseMotionListener
public void addMouseMotionListener(MouseMotionListener listener)
Add a mouse motion listener to the VDU. This is the implementation for
the lightweight event handling.
listener
- the mouse motion listener
clearSelection
public void clearSelection()
getColorSet
public Color[] getColorSet()
Get current color set.
- the color set currently associated
getInsets
public Insets getInsets()
The insets of the character display define the border.
- Insets border thickness in pixels
getPreferredSize
public Dimension getPreferredSize()
Return the preferred Size of the character display.
This turns out to be the actual size.
- Dimension dimension of the display
getSelection
public String getSelection()
getSize
public Dimension getSize()
Return the real size in points of the character display.
- Dimension the dimension of the display
keyPressed
public void keyPressed(KeyEvent e)
keyReleased
public void keyReleased(KeyEvent e)
keyTyped
public void keyTyped(KeyEvent e)
max
protected double max(double f1,
double f2)
min
protected double min(double f1,
double f2)
mouseClicked
public void mouseClicked(MouseEvent evt)
mouseDragged
public void mouseDragged(MouseEvent evt)
mouseEntered
public void mouseEntered(MouseEvent evt)
mouseExited
public void mouseExited(MouseEvent evt)
mouseGetPos
public Point mouseGetPos(Point evtpt)
Convert Mouse Event coordinates into character cell coordinates
evtpt
- the mouse point to be converted
- Character cell coordinate of passed point
mouseMoved
public void mouseMoved(MouseEvent evt)
mousePressed
public void mousePressed(MouseEvent evt)
Handle mouse pressed events for copy & paste.
evt
- the event that occured
java.awt.event.MouseEvent
mouseReleased
public void mouseReleased(MouseEvent evt)
Handle mouse released events for copy & paste.
paint
public void paint(Graphics g)
Paint the current screen using the backing store image.
print
public void print(Graphics g)
processFocusEvent
public void processFocusEvent(FocusEvent evt)
processKeyEvent
public void processKeyEvent(KeyEvent evt)
Process key events for this component.
evt
- the dispatched key event
processMouseEvent
public void processMouseEvent(MouseEvent evt)
Process mouse events for this component. It will call the
methods (mouseClicked() etc) in the added mouse listeners.
evt
- the dispatched mouse event
processMouseMotionEvent
public void processMouseMotionEvent(MouseEvent evt)
Process mouse motion events for this component. It will call the
methods (mouseDragged() etc) in the added mouse motion listeners.
evt
- the dispatched mouse event
redraw
protected void redraw(Graphics g)
removeFocusListener
public void removeFocusListener(FocusListener listener)
removeKeyListener
public void removeKeyListener(KeyListener listener)
Remove key listener from the VDU. It is a prerequisite for a
lightweigh component.
listener
- the key listener to remove
removeMouseListener
public void removeMouseListener(MouseListener listener)
Remove a mouse listener to the VDU. This is the implementation for
the lightweight event handling.
listener
- the mouse listener to remove
removeMouseMotionListener
public void removeMouseMotionListener(MouseMotionListener listener)
Remove a mouse motion listener to the VDU. This is the implementation for
the lightweight event handling.
listener
- the mouse motion listener to remove
setBorder
public void setBorder(int thickness,
boolean raised)
Set the border thickness and the border type.
thickness
- border thickness in pixels, zero means no borderraised
- a boolean indicating a raised or embossed border
setBounds
public void setBounds(int x,
int y,
int w,
int h)
Reshape character display according to resize strategy.
setColorPrinting
public void setColorPrinting(boolean colorPrint)
Set default for printing black&white or colorized as displayed on
screen.
colorPrint
- true = print in full color, default b&w only
setColorSet
public void setColorSet(Color[] colorset)
Set new color set for the display.
setCursorColors
public void setCursorColors(Color fg,
Color bg)
Set cursor FG and BG colors
fg
- foreground color or nullbg
- background color or null
setFont
public void setFont(Font font)
Set the font to be used for rendering the characters on screen.
font
- the new font to be used.
setResizeStrategy
public void setResizeStrategy(int strategy)
Set the strategy when window is resized.
RESIZE_FONT is default.
setScrollbar
public void setScrollbar(JScrollBar scrollBar)
Connect a scrollbar to the VDU. This should be done differently
using a property change listener.
scrollBar
- the scroll bar