SPONSORED LINKS

display
Class CharDisplay

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--display.CharDisplay

public class CharDisplay
extends java.awt.Panel

A simple character display.

Version:
$Id: CharDisplay.html,v 1.1.1.1 2005/09/25 22:40:20 rswindell Exp $
Author:
Matthias L. Jugel, Marcus Meißner
See Also:
Serialized Form

Field Summary
static int BOLD
          Make character bold.
static int debug
          Enable debug messages.
static int INVERT
          Invert character.
static int NORMAL
          Make character normal.
static int RESIZE_FONT
          Resize the font to the new screensize.
static int RESIZE_NONE
          Do nothing when the container is resized.
static int RESIZE_SCREEN
          Resize the width and height of the characterscreen.
static boolean SCROLL_DOWN
          Scroll down when inserting a line.
static boolean SCROLL_UP
          Scroll up when inserting a line.
static int UNDERLINE
          Underline character.
 java.lang.String version
          If you need the runtime version, just ask this variable.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CharDisplay()
          Create a character display with size 80x24 and Font "Courier", size 12.
CharDisplay(int width, int height)
          Create a character display with specific size, Font is "Courier", size 12.
CharDisplay(int width, int height, java.lang.String fname, int fsize)
          Create a character display with specific size, font and font size.
CharDisplay(java.lang.String fname, int fsize)
          Create a character display with 80x24 and specific font and font size.
 
Method Summary
 void deleteArea(int c, int l, int w, int h)
          Delete a rectangular portion of the screen.
 void deleteChar(int c, int l)
          Delete a character at a given position on the screen.
 void deleteLine(int l)
          Delete a line at a specific position.
 int getAttributes(int c, int l)
          Get the attributes for the specified position.
 int getBottomMargin()
          Get the bottom scroll margin.
 int getBufferSize()
          Retrieve current scrollback buffer size.
 char getChar(int c, int l)
          Get the character at the specified position.
 int getColumns()
          Get amount of columns on the screen.
 java.awt.Dimension getCursorPos()
          Get the current cursor position.
 int getMaxBufferSize()
          Retrieve maximum buffer Size.
 int getRows()
          Get amount of rows on the screen.
 int getTopMargin()
          Get the top scroll margin.
 int getWindowBase()
          Get the current window base.
 boolean handleEvent(java.awt.Event evt)
          Handle mouse events for copy & paste
 void insertChar(int c, int l, char ch, int attributes)
          Insert a character at a specific position on the screen.
 void insertLine(int l)
          Insert a blank line at a specific position.
 void insertLine(int l, boolean scrollDown)
          Insert a blank line at a specific position.
 void insertLine(int l, int n)
          Insert blank lines at a specific position.
 void insertLine(int l, int n, boolean scrollDown)
          Insert blank lines at a specific position.
 java.awt.Insets insets()
          The insets of the character display define the border.
 void markLine(int l, int n)
          Mark lines to be updated with redraw().
 java.awt.Color notbold(java.awt.Color colr)
           
 void paint(java.awt.Graphics g)
          Paint the current screen.
 java.awt.Dimension preferredSize()
          Return the preferred Size of the character display.
 void putChar(int c, int l, char ch)
          Put a character on the screen with normal font and outline.
 void putChar(int c, int l, char ch, int attributes)
          Put a character on the screen with specific font and outline.
 void putString(int c, int l, java.lang.String s)
          Put a String at a specific position.
 void putString(int c, int l, java.lang.String s, int attributes)
          Put a String at a specific position giving all characters the same attributes.
 void redraw()
          Redraw marked lines.
 void reshape(int x, int y, int w, int h)
          Reshape character display according to resize strategy.
 void setBorder(int thickness, boolean raised)
          Set the border thickness and the border type.
 void setBottomMargin(int l)
          Set the bottom scroll margin for the screen.
 void setBufferSize(int amount)
          Set scrollback buffer size.
 void setCursorPos(int c, int l)
          Puts the cursor at the specified position.
 void setResizeStrategy(int strategy)
          Set the strategy when window is resized.
 void setScrollbar(java.lang.String position)
          Set the scrollbar position.
 void setTopMargin(int l)
          Set the top scroll margin for the screen.
 void setWindowBase(int line)
          Set the current window base.
 void setWindowSize(int width, int height)
          Change the size of the screen.
 java.awt.Dimension size()
          Return the real size in points of the character display.
 void update(java.awt.Graphics g)
          Update the display.
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, 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, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

version

public java.lang.String version
If you need the runtime version, just ask this variable.

debug

public static final int debug
Enable debug messages. This is final static to prevent unused code to be compiled.

SCROLL_UP

public static final boolean SCROLL_UP
Scroll up when inserting a line.

SCROLL_DOWN

public static final boolean SCROLL_DOWN
Scroll down when inserting a line.

RESIZE_NONE

public static final int RESIZE_NONE
Do nothing when the container is resized.

RESIZE_SCREEN

public static final int RESIZE_SCREEN
Resize the width and height of the characterscreen.

RESIZE_FONT

public static final int RESIZE_FONT
Resize the font to the new screensize.

NORMAL

public static final int NORMAL
Make character normal.

BOLD

public static final int BOLD
Make character bold.

UNDERLINE

public static final int UNDERLINE
Underline character.

INVERT

public static final int INVERT
Invert character.
Constructor Detail

CharDisplay

public CharDisplay()
Create a character display with size 80x24 and Font "Courier", size 12.

CharDisplay

public CharDisplay(int width,
                   int height)
Create a character display with specific size, Font is "Courier", size 12.

CharDisplay

public CharDisplay(java.lang.String fname,
                   int fsize)
Create a character display with 80x24 and specific font and font size.

CharDisplay

public CharDisplay(int width,
                   int height,
                   java.lang.String fname,
                   int fsize)
Create a character display with specific size, font and font size.
Method Detail

notbold

public java.awt.Color notbold(java.awt.Color colr)

putChar

public void putChar(int c,
                    int l,
                    char ch)
Put a character on the screen with normal font and outline. The character previously on that position will be overwritten. You need to call redraw() to update the screen.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
ch - the character to show on the screen
See Also:
insertChar(int, int, char, int), deleteChar(int, int), redraw()

putChar

public void putChar(int c,
                    int l,
                    char ch,
                    int attributes)
Put a character on the screen with specific font and outline. The character previously on that position will be overwritten. You need to call redraw() to update the screen.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
ch - the character to show on the screen
attributes - the character attributes
See Also:
BOLD, UNDERLINE, INVERT, NORMAL, insertChar(int, int, char, int), deleteChar(int, int), redraw()

getChar

public char getChar(int c,
                    int l)
Get the character at the specified position.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
See Also:
putChar(int, int, char)

getAttributes

public int getAttributes(int c,
                         int l)
Get the attributes for the specified position.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
See Also:
putChar(int, int, char)

insertChar

public void insertChar(int c,
                       int l,
                       char ch,
                       int attributes)
Insert a character at a specific position on the screen. All character right to from this position will be moved one to the right. You need to call redraw() to update the screen.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
ch - the character to insert
attributes - the character attributes
See Also:
BOLD, UNDERLINE, INVERT, NORMAL, putChar(int, int, char), deleteChar(int, int), redraw()

deleteChar

public void deleteChar(int c,
                       int l)
Delete a character at a given position on the screen. All characters right to the position will be moved one to the left. You need to call redraw() to update the screen.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
See Also:
putChar(int, int, char), insertChar(int, int, char, int), redraw()

putString

public void putString(int c,
                      int l,
                      java.lang.String s)
Put a String at a specific position. Any characters previously on that position will be overwritten. You need to call redraw() for screen update.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
s - the string to be shown on the screen
See Also:
BOLD, UNDERLINE, INVERT, NORMAL, putChar(int, int, char), insertLine(int), deleteLine(int), redraw()

putString

public void putString(int c,
                      int l,
                      java.lang.String s,
                      int attributes)
Put a String at a specific position giving all characters the same attributes. Any characters previously on that position will be overwritten. You need to call redraw() to update the screen.
Parameters:
c - x-coordinate (column)
l - y-coordinate (line)
s - the string to be shown on the screen
attributes - character attributes
See Also:
BOLD, UNDERLINE, INVERT, NORMAL, putChar(int, int, char), insertLine(int), deleteLine(int), redraw()

insertLine

public void insertLine(int l)
Insert a blank line at a specific position. The current line and all previous lines are scrolled one line up. The top line is lost. You need to call redraw() to update the screen.
Parameters:
l - the y-coordinate to insert the line
See Also:
deleteLine(int), redraw()

insertLine

public void insertLine(int l,
                       int n)
Insert blank lines at a specific position. You need to call redraw() to update the screen
Parameters:
l - the y-coordinate to insert the line
n - amount of lines to be inserted
See Also:
deleteLine(int), redraw()

insertLine

public void insertLine(int l,
                       boolean scrollDown)
Insert a blank line at a specific position. Scroll text according to the argument. You need to call redraw() to update the screen
Parameters:
l - the y-coordinate to insert the line
scrollDown - scroll down
See Also:
deleteLine(int), SCROLL_UP, SCROLL_DOWN, redraw()

insertLine

public void insertLine(int l,
                       int n,
                       boolean scrollDown)
Insert blank lines at a specific position. The current line and all previous lines are scrolled one line up. The top line is lost. You need to call redraw() to update the screen.
Parameters:
l - the y-coordinate to insert the line
n - number of lines to be inserted
scrollDown - scroll down
See Also:
deleteLine(int), SCROLL_UP, SCROLL_DOWN, redraw()

deleteLine

public void deleteLine(int l)
Delete a line at a specific position. Subsequent lines will be scrolled up to fill the space and a blank line is inserted at the end of the screen.
Parameters:
l - the y-coordinate to insert the line
See Also:
deleteLine(int)

deleteArea

public void deleteArea(int c,
                       int l,
                       int w,
                       int h)
Delete a rectangular portion of the screen. You need to call redraw() to update the screen.
Parameters:
c - x-coordinate (column)
l - y-coordinate (row)
w - with of the area in characters
h - height of the area in characters
See Also:
deleteChar(int, int), deleteLine(int), redraw

setCursorPos

public void setCursorPos(int c,
                         int l)
Puts the cursor at the specified position.
Parameters:
c - column
l - line

getCursorPos

public java.awt.Dimension getCursorPos()
Get the current cursor position.
See Also:
Dimension

setTopMargin

public void setTopMargin(int l)
Set the top scroll margin for the screen. If the current bottom margin is smaller it will become the top margin and the line will become the bottom margin.
Parameters:
l - line that is the margin

getTopMargin

public int getTopMargin()
Get the top scroll margin.

setBottomMargin

public void setBottomMargin(int l)
Set the bottom scroll margin for the screen. If the current top margin is bigger it will become the bottom margin and the line will become the top margin.
Parameters:
l - line that is the margin

getBottomMargin

public int getBottomMargin()
Get the bottom scroll margin.

setBufferSize

public void setBufferSize(int amount)
Set scrollback buffer size.
Parameters:
amount - new size of the buffer

getBufferSize

public int getBufferSize()
Retrieve current scrollback buffer size.
See Also:
setBufferSize(int)

getMaxBufferSize

public int getMaxBufferSize()
Retrieve maximum buffer Size.
See Also:
getBufferSize()

setWindowBase

public void setWindowBase(int line)
Set the current window base. This allows to view the scrollback buffer.
Parameters:
line - the line where the screen window starts
See Also:
setBufferSize, getBufferSize

getWindowBase

public int getWindowBase()
Get the current window base.
See Also:
setWindowBase

setWindowSize

public void setWindowSize(int width,
                          int height)
Change the size of the screen. This will include adjustment of the scrollback buffer.
Parameters:
columns - width of the screen
columns - height of the screen

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

getRows

public int getRows()
Get amount of rows on the screen.

getColumns

public int getColumns()
Get amount of columns on the 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(java.lang.String position)
Set the scrollbar position. valid values are "East" or "West".
Parameters:
position - the position of the scrollbar

markLine

public void markLine(int l,
                     int n)
Mark lines to be updated with redraw().
Parameters:
l - starting line
n - amount of lines to be updated
See Also:
redraw()

redraw

public void redraw()
Redraw marked lines.
See Also:
markLine(int, int)

update

public void update(java.awt.Graphics g)
Update the display. to reduce flashing we have overridden this method.
Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Paint the current screen. All painting is done here. Only lines that have changed will be redrawn!
Overrides:
paint in class java.awt.Container

reshape

public void reshape(int x,
                    int y,
                    int w,
                    int h)
Reshape character display according to resize strategy.
Overrides:
reshape in class java.awt.Component
See Also:
setResizeStrategy(int)

size

public java.awt.Dimension size()
Return the real size in points of the character display.
Returns:
Dimension the dimension of the display
Overrides:
size in class java.awt.Component
See Also:
Dimension

preferredSize

public java.awt.Dimension preferredSize()
Return the preferred Size of the character display. This turns out to be the actual size.
Returns:
Dimension dimension of the display
Overrides:
preferredSize in class java.awt.Container
See Also:
size

insets

public java.awt.Insets insets()
The insets of the character display define the border.
Returns:
Insets border thickness in pixels
Overrides:
insets in class java.awt.Container

handleEvent

public boolean handleEvent(java.awt.Event evt)
Handle mouse events for copy & paste
Parameters:
evt - the event that occured
Returns:
boolean true if action was taken
Overrides:
handleEvent in class java.awt.Component
See Also:
Event