|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jcurzez.AbstractWindow
AbstractWindow
is the base class of Area
and Screen
.
An AbstractWindow
is defined by:
rectangle
: it contains the bounds
of this windowcursor
: it contains the current
position of the cursor in the windowpens
: one for drawing characters
that are printed
, the other one for printing
cells created when deleting
,
inserting
characters and lines.unique id
Every AbstractWindow
has a buffer
that is
used for all operations. One has to invoke refresh()
to sync the content of the window with the buffer.
AbstractWindow
is the biggest piece of Jcurzez.
Bugs for sure are here.
Rectangle
,
Cursor
,
Pen
,
Screen
,
Area
Field Summary | |
protected Cell[][] |
buffer
The buffer we use to perform all operations. |
private java.lang.Object |
bufferLock
The lock on the buffer. |
static org.apache.log4j.Category |
cat
log4j category. |
protected Cursor |
cursor
Cursor attached to this window (the one for drawing new characters). |
protected long |
id
Number of this window. |
protected boolean |
linewrap
Indicates if lines are wrapped. |
private static long |
nextId
Counter for next available window number. |
protected AbstractWindow |
parent
Parent window. |
protected boolean |
scroll
Would the window automatically scroll if needed ? |
private static int |
tabSize
Tabulation size: defaults to 8. |
Constructor Summary | |
protected |
AbstractWindow(AbstractWindow parent,
Cursor cursor,
boolean linewrap,
boolean scroll)
Constructs a new window with specified parent, rectangle and cursor. |
Method Summary | |
private void |
_clear()
Clears the current window. |
private void |
_clearToEndOfLine()
Clears the content of the line, starting from current position, using the filling pen for new cells. |
private void |
_deleteChar()
Deletes char at current position. |
private void |
_deleteLine()
Deletes the current line. |
private void |
_insertChar(int c)
Inserts a character at current cursor position, with the filling pen. |
private void |
_insertLine()
Inserts a blank line at current position, with default pen. |
private void |
_printChar(int c)
Prints specified character c at current position,
using the drawing pen. |
private void |
backspace()
What to do when a '\b' is printChar(int) 'ed or
insertChar(int) 'ed. |
abstract void |
beep()
Emits a beep. |
private void |
checkAllCoordinates(int x,
int y,
int width,
int height)
Checks coordinates for both copyCellsAt(int, int, int, int) and
getCellsAt(int, int, int, int) . |
void |
clear()
Clears the current window. |
void |
clearToBottom()
Clears the content of the window, from current position to the end of the screen, using the filling pen for filling new cells. |
void |
clearToEndOfLine()
Clears the content of the line, starting from current position, using the filling pen for new cells. |
protected Cell[][] |
copyCellsAt(int x,
int y,
int width,
int height)
Retrieves the rectangle of cells starting at ( x ,y ). |
void |
deleteChar()
Deletes char at current position. |
void |
deleteLine()
Deletes the current line. |
boolean |
equals(java.lang.Object o)
Tests equality of this with o . |
protected Cell[][] |
getCellsAt(int x,
int y,
int width,
int height)
Retrieves the rectangle of cells starting at ( x ,y ). |
Cursor |
getCursor()
Returns the cursor attached to this . |
long |
getId()
Returns the id of this window. |
AbstractWindow |
getParent()
Returns the parent window of this . |
Rectangle |
getRectangle()
Returns the rectangle contained within this . |
static int |
getTabulationSize()
Returns the size of the tabulation. |
protected abstract void |
gotoXY(int x,
int y)
Moves the cursor on the physical screen to position (x, y) . |
int |
hashCode()
Returns the hash code of this . |
boolean |
hasLinesWrapped()
Returns true if lines are wrapped. |
private void |
increaseX()
Moves the cursor one character right. |
private boolean |
increaseY()
Moves the cursor one character down. |
void |
insertChar(int c)
Inserts a character at current cursor position, with the filling pen. |
void |
insertLine()
Inserts a blank line at current position, with default pen. |
void |
insertString(java.lang.String text)
Inserts specified text text at current position,
using the filling pen. |
private void |
internalPutChar(int c,
ForegroundColor fg,
BackgroundColor bg,
Attribute attr)
Puts c with given decoration at current
position in buffer . |
protected abstract void |
printCell(int x,
int y,
Cell cell)
Prints a cell on the physical screen at absolute position (x, y) . |
void |
printChar(int c)
Prints specified character c at current position,
using the drawing pen. |
void |
printString(java.lang.String text)
Prints specified String text at current position,
using the drawing pen. |
void |
refresh()
Redraws the window. |
protected java.lang.String |
removeExtraChars(java.lang.String text)
Remove extra chars from text . |
java.lang.String |
toString()
Returns a string representation of this . |
protected void |
touch()
Marks all characters as changed so that the next call to refresh() will have the whole window redisplayed. |
protected abstract void |
update()
Updates the physical screen. |
boolean |
wouldScroll()
Returns true if the window would scroll if needed. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private static long nextId
private static final int tabSize
protected final long id
protected final AbstractWindow parent
protected Cursor cursor
protected final boolean linewrap
protected final boolean scroll
protected final Cell[][] buffer
refresh()
to sync the content of the
window with this buffer.
private java.lang.Object bufferLock
public static org.apache.log4j.Category cat
Constructor Detail |
protected AbstractWindow(AbstractWindow parent, Cursor cursor, boolean linewrap, boolean scroll)
parent
- the parent window.cursor
- the cursor attached to this window.linewrap
- if lines will be wrapped.scroll
- if the window should scroll.tabSize
- size of the tabulation.InconsistentCoordinateException
- if the window
being created is not contained in its parent.Method Detail |
public AbstractWindow getParent()
this
.
null
is the parent of the screen
.
this
.public Rectangle getRectangle()
this
.
this
.public Cursor getCursor()
this
.
this
.public static int getTabulationSize()
tabSize
.public long getId()
id
.public boolean hasLinesWrapped()
true
if lines are wrapped.
true
if lines are wrapped.public boolean wouldScroll()
true
if the window would scroll if needed.
true
if the window has the automatic scrolling
feature.public void insertChar(int c)
c
- the character to insert.private void _insertChar(int c)
c
- the character to insert.private void backspace()
'\b'
is printChar(int)
'ed or
insertChar(int)
'ed.
public void deleteChar()
private void _deleteChar()
public void insertLine()
private void _insertLine()
public void deleteLine()
private void _deleteLine()
public void clear()
private void _clear()
public abstract void beep()
ScreenPeer
.
ScreenPeer.beep()
protected abstract void printCell(int x, int y, Cell cell)
(x, y)
.
This method will be provided by an implementation
of ScreenPeer
.
x
- the x coordinate where to print the cell.y
- the y coordinate where to print the cell.cell
- the cell to print.ScreenPeer.printCell(int, int, jcurzez.Cell)
protected abstract void gotoXY(int x, int y)
(x, y)
.
This method will be provided by an implementation
of ScreenPeer
.
x
- the x coordinate where to move the cursor.y
- the y coordinate where to move the cursor.ScreenPeer.gotoXY(int, int)
protected abstract void update()
ScreenPeer
.
ScreenPeer.update()
public void clearToBottom()
public void clearToEndOfLine()
private void _clearToEndOfLine()
public void insertString(java.lang.String text)
text
at current position,
using the filling pen.
text
- the text to insert.private final void internalPutChar(int c, ForegroundColor fg, BackgroundColor bg, Attribute attr)
c
with given decoration at current
position in buffer
.
c
- the nwe character for the cell.fg
- the new foreground color for the cell.bg
- the new background color for the cell.attr
- the new attrivute for the cell.public void printChar(int c)
c
at current position,
using the drawing pen.
c
- the character to print.private void _printChar(int c)
c
at current position,
using the drawing pen. This is the unsynchronized version.
c
- the character to print.public void printString(java.lang.String text)
text
at current position,
using the drawing pen.
text
- the text to print.public void refresh()
protected java.lang.String removeExtraChars(java.lang.String text)
text
. When linewrap
is set to false
, some chars won't appear, so they are
removed.
text
- the text to modify.text
.private boolean increaseY()
scroll
is true
, then we insert a new line.
Otherwise, the cursor will remain at the same position, and we return
false
.
true
if the y position could be changed.private void increaseX()
public boolean equals(java.lang.Object o)
this
with o
.
Two AbstractWindow
are said to be equal
if they have the same id
.
equals
in class java.lang.Object
o
- the object we want to test for equality with
this
.true
if o
have the same id
.public int hashCode()
this
. It is computed
using its id
.
hashCode
in class java.lang.Object
this
.public java.lang.String toString()
this
. It has the form
[ x,y p1 p2 ] where p1 is the string representation of the drawing pen
and p2 the string representation of the filling pen.
toString
in class java.lang.Object
this
.protected void touch()
refresh()
will have the whole window redisplayed.
private void checkAllCoordinates(int x, int y, int width, int height)
copyCellsAt(int, int, int, int)
and
getCellsAt(int, int, int, int)
.
protected Cell[][] copyCellsAt(int x, int y, int width, int height)
x
,y
). The retrieved array has a
width of width
and a height of height
.
The cells are copied. The first subscript of the returned
array is the y coordinate.
x
- the x coordinate from where to retrieve cells.y
- the y coordinate from where to retrieve cells.width
- the width of the array to get.height
- the height of the array to get.InconsistentCoordinateException
- if either x
or y
is not consistent.java.lang.ArrayIndexOutOfBoundsException
- if width
or
height
is not consistent.protected Cell[][] getCellsAt(int x, int y, int width, int height)
x
,y
). The retrieved array has a
width of width
and a height of height
.
The cells are referenced. The first subscript of the returned array
is the y coordinate.
x
- the x coordinate from where to retrieve cells.y
- the y coordinate from where to retrieve cells.width
- the width of the array to get.height
- the height of the array to get.InconsistentCoordinateException
- if either x
or y
is not consistent.java.lang.ArrayIndexOutOfBoundsException
- if width
or
height
is not consistent.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |