com.monica.javacom.virtualdisplay
Class MJCAWTDisplay

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--com.monica.javacom.virtualdisplay.MJCAWTDisplay
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, MJCConfigureable, MJCVirtualDisplay, java.io.Serializable

public class MJCAWTDisplay
extends java.awt.Canvas
implements MJCVirtualDisplay

This class provides the virtualDisplay functionality in the AWT framework. This class acts as a Canvas and can be added to other Containers.

Configureable values:

See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
MJCAWTDisplay(MJCConfiguration configuration)
          Default constructor.
 
Method Summary
 void addC(char c)
          Adds a character to the current cursor position.
 void addCA(char[] c)
          Adds a char array to the current cursor position.
 void addS(java.lang.String s)
          Adds a String to the current cursor position.
 void clear()
          Clears the contents of the screen.
 void deleteChar()
          Deletes a character at the cursor position.
 void deleteChar(int charNum)
          Deletes charNum characters at the cursor position.
 void deleteLine(int lineNum)
          Deletes lineNum rows at the current cursor position.
 void dumpContents()
          Dumps the contents of the screen to the standard output.
 void eraseEOL()
          Erases the contents of the current row from the horizontal cursor position (inclusive) to the last column (inclusive).
 MJCConfiguration getConfiguration()
          Returns the MJCConfiguration with which this object is customized.
 int getCPosX()
          Returns the current column of the cursor.
 int getCPosY()
          Returns the current row of the cursor.
 int getCSizeX()
          Returns the screen width in characters.
 int getCSizeY()
          Returns the screen height in characters.
 java.lang.String getVirtualDisplayName()
          Returns the MJC name of the MJCVirtualDisplay.
 java.lang.String getVirtualDisplayVersion()
          Returns the MJC version of the MJCVirtualDisplay.
 boolean goDown()
          Cursor goes one row down (if possible).
 int goDown(int num)
          Cursor goes num times down.
 boolean goLeft()
          Cursor goes one column to the left.
 int goLeft(int num)
          Cursor goes <>num times to the left.
 boolean goRight()
          Cursor goes one column to the right.
 int goRight(int num)
          Cursor goes num times to the right.
 boolean goUp()
          Cursor goes one row up (if possible).
 int goUp(int num)
          Cursor goes num times up.
 void insertChar()
          Inserts an empty character at the cursor position.
 void insertChar(int charNum)
          Inserts charNum empty characters at the cursor position.
 void insertLine(int lineNum)
          Inserts lineNum rows at the current cursor position.
 void moveCursor(boolean status)
          Should addC/addCA/addS advance the cursor while adding characters.
 void newLine()
          Cursors goes one row down.
 void paint(java.awt.Graphics g)
          Repaints the contents of the Canvas.
 void refresh()
          Refreshes the screen contents for the user.
 void scrollDown()
          Moves all rows int the scrolling region one row up.
 void scrollUp()
          Moves all rows in the scolling region one row down.
 void setConfiguration(MJCConfiguration configuration)
          Sets the MJCConfiguration for this object.
 void setCPos(int x, int y)
          Sets the position of the cursor.
 void setCPosX(int x)
          Sets the column of the cursor.
 void setCPosY(int y)
          Sets the row of the cursors.
 void setCSize(int sizeX, int sizeY)
          Sets the screen size in characters.
 void setCSizeX(int sizeX)
          Sets the screen width in characters.
 void setCSizeY(int sizeY)
          Sets the screen height in characters.
 void setInvert(boolean status)
          Sets the inverting status.
 void setScrollingRegion(int firstLine, int lastLine)
          Sets the scrolling region for the screen.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MJCAWTDisplay

public MJCAWTDisplay(MJCConfiguration configuration)
Default constructor. The MJCConfiguration for customization has to be provided.
Parameters:
MJCConfiguration - configuration: the customization object
Method Detail

setConfiguration

public void setConfiguration(MJCConfiguration configuration)
Sets the MJCConfiguration for this object.
Specified by:
setConfiguration in interface MJCConfigureable
Parameters:
MJCConfiguration - configuration: the MJCConfiguration object for the customization

getConfiguration

public MJCConfiguration getConfiguration()
Returns the MJCConfiguration with which this object is customized.
Specified by:
getConfiguration in interface MJCConfigureable
Returns:
MJCConfiguration: the MJCConfiguration with which this object is customized

getVirtualDisplayName

public java.lang.String getVirtualDisplayName()
Returns the MJC name of the MJCVirtualDisplay.
Specified by:
getVirtualDisplayName in interface MJCVirtualDisplay
Returns:
String: the MJC name of the MJCVirtualDisplay

getVirtualDisplayVersion

public java.lang.String getVirtualDisplayVersion()
Returns the MJC version of the MJCVirtualDisplay.
Specified by:
getVirtualDisplayVersion in interface MJCVirtualDisplay
Returns:
String: the MJC name of the MJCVirtualDisplay

paint

public void paint(java.awt.Graphics g)
Repaints the contents of the Canvas.
Overrides:
paint in class java.awt.Canvas
Parameters:
Grpahics - g: the Graphics object with which the rapinting works

setCSize

public void setCSize(int sizeX,
                     int sizeY)
Sets the screen size in characters. After resize the screen will be cleared.
Specified by:
setCSize in interface MJCVirtualDisplay
Parameters:
int - sizeX: the width
int - sizeY: the height

setCSizeX

public void setCSizeX(int sizeX)
Sets the screen width in characters. After resize the screen will be cleared.
Specified by:
setCSizeX in interface MJCVirtualDisplay
Parameters:
int - sizeX: the width

setCSizeY

public void setCSizeY(int sizeY)
Sets the screen height in characters. After resize the screen will be cleared.
Specified by:
setCSizeY in interface MJCVirtualDisplay
Parameters:
int - sizeY: the height

getCSizeX

public int getCSizeX()
Returns the screen width in characters.
Specified by:
getCSizeX in interface MJCVirtualDisplay
Returns:
int: the width

getCSizeY

public int getCSizeY()
Returns the screen height in characters.
Specified by:
getCSizeY in interface MJCVirtualDisplay
Returns:
int: the height

clear

public void clear()
Clears the contents of the screen. The position of the cursor will not be changed.
Specified by:
clear in interface MJCVirtualDisplay

setCPos

public void setCPos(int x,
                    int y)
Sets the position of the cursor. Indexing begins with 0.
Specified by:
setCPos in interface MJCVirtualDisplay
Parameters:
int - x: the column
int - y: the row

setCPosX

public void setCPosX(int x)
Sets the column of the cursor. Indexing begins with 0.
Specified by:
setCPosX in interface MJCVirtualDisplay
Parameters:
int - x: the column

setCPosY

public void setCPosY(int y)
Sets the row of the cursors. Indexing begins with 0.
Specified by:
setCPosY in interface MJCVirtualDisplay
Parameters:
int - y: the row

getCPosX

public int getCPosX()
Returns the current column of the cursor. Indexing begins with 0.
Specified by:
getCPosX in interface MJCVirtualDisplay
Returns:
int: the current column

getCPosY

public int getCPosY()
Returns the current row of the cursor. Indexing begins with 0.
Specified by:
getCPosY in interface MJCVirtualDisplay
Returns:
int: the current row

addC

public void addC(char c)
Adds a character to the current cursor position. The cursor will be adwanced once. The cursor can be positioned one characted right off the screen. If there is an add character at that position, the cursor will go one line down and to the beginning of the line, and the character will be added there. If there are no lines to go down, the screen will be scrolled down. The removed line at the top will be lost. The cursor cannot leave the scrolling region with this method. Characters will be added with the current inverting status.
Specified by:
addC in interface MJCVirtualDisplay
Parameters:
char - c: the characted to be added

scrollDown

public void scrollDown()
Moves all rows int the scrolling region one row up. The last row in the scrolling region will get empty. Cursor position will not be altered.
Specified by:
scrollDown in interface MJCVirtualDisplay

scrollUp

public void scrollUp()
Moves all rows in the scolling region one row down. The first row in the scrolling region will get empty. Cursor position will not be altered.
Specified by:
scrollUp in interface MJCVirtualDisplay

newLine

public void newLine()
Cursors goes one row down. If the current cursor position is at the bottom of the screen, the screen will be scrolled down. The row scrolled out will be lost. Horizontal position of the cursor will not be altered.
Specified by:
newLine in interface MJCVirtualDisplay

addS

public void addS(java.lang.String s)
Adds a String to the current cursor position. This method should do s.length() times the functionality of addC(s.charAt(i)).
Specified by:
addS in interface MJCVirtualDisplay
Parameters:
String - s: the String to be added

addCA

public void addCA(char[] c)
Adds a char array to the current cursor position. This method should do ca.length times the functionality of addC(ca[i]).
Specified by:
addCA in interface MJCVirtualDisplay
Parameters:
char[] - ca: the char array to be added

refresh

public void refresh()
Refreshes the screen contents for the user.
Specified by:
refresh in interface MJCVirtualDisplay

goLeft

public boolean goLeft()
Cursor goes one column to the left. If the current cursor position is the first column then the cursor will go up one row (if possible) and to the last column. There won't be any scrolling. The cursor cannot leave the scrolling region with this method.
Specified by:
goLeft in interface MJCVirtualDisplay

goLeft

public int goLeft(int num)
Cursor goes <>num times to the left. This method should do num times the functionality of goLeft().
Specified by:
goLeft in interface MJCVirtualDisplay
Parameters:
int - num: the number of times to go left

goRight

public boolean goRight()
Cursor goes one column to the right. If the current cursor position is the last column then the cursor will go down one row (if possible) and to the first column. There won't be any scrolling. The cursor cannot leave the scrolling region wit this method.
Specified by:
goRight in interface MJCVirtualDisplay

goRight

public int goRight(int num)
Cursor goes num times to the right. This method should do num times the functionality of goRight().
Specified by:
goRight in interface MJCVirtualDisplay
Parameters:
int - num: the number of times to go right

goUp

public boolean goUp()
Cursor goes one row up (if possible). There won't be any scrolling. Horizontal position of the cursor will not be altered. Cursor cannot leave the scrolling region with this method.
Specified by:
goUp in interface MJCVirtualDisplay

goUp

public int goUp(int num)
Cursor goes num times up. This method should do num times the functionality of goUp().
Specified by:
goUp in interface MJCVirtualDisplay
Parameters:
int - num: the number of times to go up

goDown

public boolean goDown()
Cursor goes one row down (if possible). There won't be any scrolling. Horizontal position of the cursor will not be altered. Cursor cannot leave the scrolling region with this method.
Specified by:
goDown in interface MJCVirtualDisplay

goDown

public int goDown(int num)
Cursor goes num times down. This method should do num times the functionality of goDown().
Specified by:
goDown in interface MJCVirtualDisplay
Parameters:
int - num: the number of times to go down.

setInvert

public void setInvert(boolean status)
Sets the inverting status. True means inverted, false normal.
Specified by:
setInvert in interface MJCVirtualDisplay
Parameters:
boolan - status: the inverting status

dumpContents

public void dumpContents()
Dumps the contents of the screen to the standard output.

eraseEOL

public void eraseEOL()
Erases the contents of the current row from the horizontal cursor position (inclusive) to the last column (inclusive).
Specified by:
eraseEOL in interface MJCVirtualDisplay

moveCursor

public void moveCursor(boolean status)
Should addC/addCA/addS advance the cursor while adding characters. True means yes, false no. If the cursor is positioned outside the visible screen area and an addC/addCA/addS method is called, the cursor will in either case go one row down and to the first column (and a scrolling will be performed if required). By default addC/addCA/addS will advance the cursor.
Specified by:
moveCursor in interface MJCVirtualDisplay
Parameters:
boolean - status: should the addC/addCA/addS methods advance the cursor while adding characters.

setScrollingRegion

public void setScrollingRegion(int firstLine,
                               int lastLine)
Sets the scrolling region for the screen. Scrolling region is given by the first and last line (both includive, indexing begins with 0). If the cursor is inside the scrolling are, it cannot leave it with addC/addCA/addS/goLeft/goRight/goUp/goDown/ newLine/insertLine/insertChar/deleteLine/deleteChar. By default the scrolling region is the whole screen.
Specified by:
setScrollingRegion in interface MJCVirtualDisplay
Parameters:
int - firstLine: the first line of the scrolling region
int - lastLine: the last line of the scrolling region

insertLine

public void insertLine(int lineNum)
Inserts lineNum rows at the current cursor position. The current row and the rows below the cursor will be moved lineNum rows down. The last row in the scrolling region will get lost during the movement. lineNum empty rows will be created beginning with the current row. Cursor will move to the first column of the current row.
Specified by:
insertLine in interface MJCVirtualDisplay
Parameters:
int - lineNum: the number of rows to be inserted

deleteLine

public void deleteLine(int lineNum)
Deletes lineNum rows at the current cursor position. The rows below the deleted rows will be moved upwards. At the bottom of the scrolling region new empty lines will be added. Cursor will move to the first column of the current row.
Specified by:
deleteLine in interface MJCVirtualDisplay
Parameters:
int - lineNum: the number of rows to be deleted

deleteChar

public void deleteChar()
Deletes a character at the cursor position. Characters after the cursor position in the current row will be moved one position to the left. The last character in the current row will be empty.
Specified by:
deleteChar in interface MJCVirtualDisplay

deleteChar

public void deleteChar(int charNum)
Deletes charNum characters at the cursor position. This method should do charNum times the functionality of deleteChar().
Specified by:
deleteChar in interface MJCVirtualDisplay
Parameters:
int - charNum: number of characters to be deleted

insertChar

public void insertChar()
Inserts an empty character at the cursor position. Characters after the cursor position in the current row will be moved one position to the right. The last character in the current row will be lost.
Specified by:
insertChar in interface MJCVirtualDisplay

insertChar

public void insertChar(int charNum)
Inserts charNum empty characters at the cursor position. This method should do charNum times the functionality of insertChar().
Specified by:
insertChar in interface MJCVirtualDisplay
Parameters:
int - charNum: number of characters to be inserted