com.sshtools.sshterm.emulation
Class TerminalPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.sshtools.sshterm.emulation.TerminalPanel
All Implemented Interfaces:
java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, VDUDisplay

public class TerminalPanel
extends javax.swing.JComponent
implements VDUDisplay, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

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

Version:
$Id: TerminalPanel.java,v 1.2 2002/09/16 20:02:16 martianx Exp $
Author:
Matthias L. Jugel, Marcus Meißner
See Also:
Serialized Form

Nested Class Summary
 
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
static int COLOR_BOLD
          Description of the Field
static int COLOR_INVERT
          Description of the Field
static int RESIZE_FONT
          Description of the Field
static int RESIZE_NONE
          Description of the Field
static int RESIZE_SCREEN
          Description of the Field
 
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
TerminalPanel(VDUBuffer buffer)
          Create a display unit with size 80x24 and Font "Monospaced", size 12.
TerminalPanel(VDUBuffer buffer, java.awt.Font font)
          Create a new video display unit with the passed width and height in characters using a special font and font size.
 
Method Summary
 void addFocusListener(java.awt.event.FocusListener listener)
          Adds a feature to the FocusListener attribute of the SwingTerminal object
 void addKeyListener(java.awt.event.KeyListener listener)
          Add a key listener to the VDU.
 void addMouseListener(java.awt.event.MouseListener listener)
          Add a mouse listener to the VDU.
 void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
          Add a mouse motion listener to the VDU.
 void clearSelection()
          Description of the Method
 java.awt.Color[] getColorSet()
          Get current color set.
 java.awt.Insets getInsets()
          The insets of the character display define the border.
 java.awt.Dimension getPreferredSize()
          Return the preferred Size of the character display.
 java.lang.String getSelection()
          Gets the selection attribute of the SwingTerminal object
 java.awt.Dimension getSize()
          Return the real size in points of the character display.
 VDUBuffer getVDUBuffer()
          Return the currently associated VDUBuffer.
 void keyPressed(java.awt.event.KeyEvent e)
          Description of the Method
 void keyReleased(java.awt.event.KeyEvent e)
          Description of the Method
 void keyTyped(java.awt.event.KeyEvent e)
          Description of the Method
protected  double max(double f1, double f2)
          Description of the Method
protected  double min(double f1, double f2)
          Description of the Method
 void mouseClicked(java.awt.event.MouseEvent evt)
          Description of the Method
 void mouseDragged(java.awt.event.MouseEvent evt)
          Description of the Method
 void mouseEntered(java.awt.event.MouseEvent evt)
          Description of the Method
 void mouseExited(java.awt.event.MouseEvent evt)
          Description of the Method
 java.awt.Point mouseGetPos(java.awt.Point evtpt)
          Convert Mouse Event coordinates into character cell coordinates
 void mouseMoved(java.awt.event.MouseEvent evt)
          Description of the Method
 void mousePressed(java.awt.event.MouseEvent evt)
          Handle mouse pressed events for copy & paste.
 void mouseReleased(java.awt.event.MouseEvent evt)
          Handle mouse released events for copy & paste.
 void paint(java.awt.Graphics g)
          Paint the current screen using the backing store image.
 void print(java.awt.Graphics g)
          Description of the Method
 void processFocusEvent(java.awt.event.FocusEvent evt)
          Description of the Method
 void processKeyEvent(java.awt.event.KeyEvent evt)
          Process key events for this component.
 void processMouseEvent(java.awt.event.MouseEvent evt)
          Process mouse events for this component.
 void processMouseMotionEvent(java.awt.event.MouseEvent evt)
          Process mouse motion events for this component.
 void redraw()
          Redraw marked lines.
protected  void redraw(java.awt.Graphics g)
          Description of the Method
 void removeFocusListener(java.awt.event.FocusListener listener)
          Description of the Method
 void removeKeyListener(java.awt.event.KeyListener listener)
          Remove key listener from the VDU.
 void removeMouseListener(java.awt.event.MouseListener listener)
          Remove a mouse listener to the VDU.
 void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
          Remove a mouse motion listener to the VDU.
 void setBorder(int thickness, boolean raised)
          Set the border thickness and the border type.
 void setBounds(int x, int y, int w, int h)
          Reshape character display according to resize strategy.
 void setColorPrinting(boolean colorPrint)
          Set default for printing black&white or colorized as displayed on screen.
 void setColorSet(java.awt.Color[] colorset)
          Set new color set for the display.
 void setCursorColors(java.awt.Color fg, java.awt.Color bg)
          Set cursor FG and BG colors
 void setFont(java.awt.Font font)
          Set the font to be used for rendering the characters on screen.
 void setResizeStrategy(int strategy)
          Set the strategy when window is resized.
 void setScrollbar(javax.swing.JScrollBar scrollBar)
          Connect a scrollbar to the VDU.
 void setVDUBuffer(VDUBuffer buffer)
          Set a new terminal (VDU) buffer.
 
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, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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, updateUI
 
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, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, 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, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, 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

RESIZE_NONE

public static final int RESIZE_NONE
Description of the Field

See Also:
Constant Field Values

RESIZE_FONT

public static final int RESIZE_FONT
Description of the Field

See Also:
Constant Field Values

RESIZE_SCREEN

public static final int RESIZE_SCREEN
Description of the Field

See Also:
Constant Field Values

COLOR_BOLD

public static final int COLOR_BOLD
Description of the Field

See Also:
Constant Field Values

COLOR_INVERT

public static final int COLOR_INVERT
Description of the Field

See Also:
Constant Field Values
Constructor Detail

TerminalPanel

public TerminalPanel(VDUBuffer buffer,
                     java.awt.Font font)
Create a new video display unit with the passed width and height in characters using a special font and font size. These features can be set independently using the appropriate properties.

Parameters:
buffer - a VDU buffer to be associated with the display
font - the font to be used (usually Monospaced)

TerminalPanel

public TerminalPanel(VDUBuffer buffer)
Create a display unit with size 80x24 and Font "Monospaced", size 12.

Parameters:
buffer - Description of the Parameter
Method Detail

max

protected double max(double f1,
                     double f2)
Description of the Method

Parameters:
f1 - Description of the Parameter
f2 - Description of the Parameter
Returns:
Description of the Return Value

min

protected double min(double f1,
                     double f2)
Description of the Method

Parameters:
f1 - Description of the Parameter
f2 - Description of the Parameter
Returns:
Description of the Return Value

setVDUBuffer

public void setVDUBuffer(VDUBuffer buffer)
Set a new terminal (VDU) buffer.

Specified by:
setVDUBuffer in interface VDUDisplay
Parameters:
buffer - new buffer

getVDUBuffer

public VDUBuffer getVDUBuffer()
Return the currently associated VDUBuffer.

Specified by:
getVDUBuffer in interface VDUDisplay
Returns:
the current buffer

setColorSet

public void setColorSet(java.awt.Color[] colorset)
Set new color set for the display.

Parameters:
colorset - new color set

getColorSet

public java.awt.Color[] getColorSet()
Get current color set.

Returns:
the color set currently associated

setFont

public void setFont(java.awt.Font font)
Set the font to be used for rendering the characters on screen.

Overrides:
setFont in class javax.swing.JComponent
Parameters:
font - the new font to be used.

setResizeStrategy

public void setResizeStrategy(int strategy)
Set the strategy when window is resized. RESIZE_FONT is default.

Parameters:
strategy - the strategy
See Also:
RESIZE_NONE, RESIZE_FONT, RESIZE_SCREEN

setBorder

public void setBorder(int thickness,
                      boolean raised)
Set the border thickness and the border type.

Parameters:
thickness - border thickness in pixels, zero means no border
raised - a boolean indicating a raised or embossed border

setScrollbar

public void setScrollbar(javax.swing.JScrollBar scrollBar)
Connect a scrollbar to the VDU. This should be done differently using a property change listener.

Parameters:
scrollBar - the scroll bar

redraw

public void redraw()
Redraw marked lines.

Specified by:
redraw in interface VDUDisplay

redraw

protected void redraw(java.awt.Graphics g)
Description of the Method

Parameters:
g - Description of the Parameter

paint

public void paint(java.awt.Graphics g)
Paint the current screen using the backing store image.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - Description of the Parameter

setColorPrinting

public void setColorPrinting(boolean colorPrint)
Set default for printing black&white or colorized as displayed on screen.

Parameters:
colorPrint - true = print in full color, default b&w only

print

public void print(java.awt.Graphics g)
Description of the Method

Overrides:
print in class javax.swing.JComponent
Parameters:
g - Description of the Parameter

mouseGetPos

public java.awt.Point mouseGetPos(java.awt.Point evtpt)
Convert Mouse Event coordinates into character cell coordinates

Parameters:
evtpt - the mouse point to be converted
Returns:
Character cell coordinate of passed point

setCursorColors

public void setCursorColors(java.awt.Color fg,
                            java.awt.Color bg)
Set cursor FG and BG colors

Parameters:
fg - foreground color or null
bg - background color or null

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Reshape character display according to resize strategy.

Overrides:
setBounds in class java.awt.Component
Parameters:
x - The new bounds value
y - The new bounds value
w - The new bounds value
h - The new bounds value
See Also:
setResizeStrategy(int)

getSize

public java.awt.Dimension getSize()
Return the real size in points of the character display.

Overrides:
getSize in class java.awt.Component
Returns:
Dimension the dimension of the display
See Also:
Dimension

getPreferredSize

public java.awt.Dimension getPreferredSize()
Return the preferred Size of the character display. This turns out to be the actual size.

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
Dimension dimension of the display
See Also:
Component.size()

getInsets

public java.awt.Insets getInsets()
The insets of the character display define the border.

Overrides:
getInsets in class javax.swing.JComponent
Returns:
Insets border thickness in pixels

clearSelection

public void clearSelection()
Description of the Method


getSelection

public java.lang.String getSelection()
Gets the selection attribute of the SwingTerminal object

Returns:
The selection value

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Description of the Method

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
evt - Description of the Parameter

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Description of the Method

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
evt - Description of the Parameter

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Description of the Method

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
evt - Description of the Parameter

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Description of the Method

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
evt - Description of the Parameter

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Description of the Method

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
evt - Description of the Parameter

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Handle mouse pressed events for copy & paste.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
evt - the event that occured
See Also:
MouseEvent

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Handle mouse released events for copy & paste.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
evt - the mouse event

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Description of the Method

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
e - Description of the Parameter

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Description of the Method

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
e - Description of the Parameter

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Description of the Method

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
e - Description of the Parameter

addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)
Add a mouse listener to the VDU. This is the implementation for the lightweight event handling.

Overrides:
addMouseListener in class java.awt.Component
Parameters:
listener - the new mouse listener

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener listener)
Remove a mouse listener to the VDU. This is the implementation for the lightweight event handling.

Overrides:
removeMouseListener in class java.awt.Component
Parameters:
listener - the mouse listener to remove

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
Add a mouse motion listener to the VDU. This is the implementation for the lightweight event handling.

Overrides:
addMouseMotionListener in class java.awt.Component
Parameters:
listener - the mouse motion listener

removeMouseMotionListener

public void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
Remove a mouse motion listener to the VDU. This is the implementation for the lightweight event handling.

Overrides:
removeMouseMotionListener in class java.awt.Component
Parameters:
listener - the mouse motion listener to remove

processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent evt)
Process mouse events for this component. It will call the methods (mouseClicked() etc) in the added mouse listeners.

Overrides:
processMouseEvent in class java.awt.Component
Parameters:
evt - the dispatched mouse event

processMouseMotionEvent

public void processMouseMotionEvent(java.awt.event.MouseEvent evt)
Process mouse motion events for this component. It will call the methods (mouseDragged() etc) in the added mouse motion listeners.

Overrides:
processMouseMotionEvent in class javax.swing.JComponent
Parameters:
evt - the dispatched mouse event

addKeyListener

public void addKeyListener(java.awt.event.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.

Overrides:
addKeyListener in class java.awt.Component
Parameters:
listener - the key listener

removeKeyListener

public void removeKeyListener(java.awt.event.KeyListener listener)
Remove key listener from the VDU. It is a prerequisite for a lightweigh component.

Overrides:
removeKeyListener in class java.awt.Component
Parameters:
listener - the key listener to remove

processKeyEvent

public void processKeyEvent(java.awt.event.KeyEvent evt)
Process key events for this component.

Overrides:
processKeyEvent in class javax.swing.JComponent
Parameters:
evt - the dispatched key event

addFocusListener

public void addFocusListener(java.awt.event.FocusListener listener)
Adds a feature to the FocusListener attribute of the SwingTerminal object

Overrides:
addFocusListener in class java.awt.Component
Parameters:
listener - The feature to be added to the FocusListener attribute

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener listener)
Description of the Method

Overrides:
removeFocusListener in class java.awt.Component
Parameters:
listener - Description of the Parameter

processFocusEvent

public void processFocusEvent(java.awt.event.FocusEvent evt)
Description of the Method

Overrides:
processFocusEvent in class java.awt.Component
Parameters:
evt - Description of the Parameter


Copyright © 2002 Sshtools.com. All Rights Reserved.