/**
* Drawing offset for x.
*/
- public int offsetX;
+ private int offsetX;
+
+ /**
+ * Set drawing offset for x.
+ *
+ * @param offsetX new drawing offset
+ */
+ public final void setOffsetX(final int offsetX) {
+ this.offsetX = offsetX;
+ }
/**
* Drawing offset for y.
*/
- public int offsetY;
+ private int offsetY;
+
+ /**
+ * Set drawing offset for y.
+ *
+ * @param offsetY new drawing offset
+ */
+ public final void setOffsetY(final int offsetY) {
+ this.offsetY = offsetY;
+ }
/**
* Ignore anything drawn right of clipRight.
*/
- public int clipRight;
+ private int clipRight;
+
+ /**
+ * Get right drawing clipping boundary.
+ *
+ * @return drawing boundary
+ */
+ public final int getClipRight() {
+ return clipRight;
+ }
+
+ /**
+ * Set right drawing clipping boundary.
+ *
+ * @param clipRight new boundary
+ */
+ public final void setClipRight(final int clipRight) {
+ this.clipRight = clipRight;
+ }
/**
* Ignore anything drawn below clipBottom.
*/
- public int clipBottom;
+ private int clipBottom;
+
+ /**
+ * Get bottom drawing clipping boundary.
+ *
+ * @return drawing boundary
+ */
+ public final int getClipBottom() {
+ return clipBottom;
+ }
+
+ /**
+ * Set bottom drawing clipping boundary.
+ *
+ * @param clipBottom new boundary
+ */
+ public final void setClipBottom(final int clipBottom) {
+ this.clipBottom = clipBottom;
+ }
/**
* Ignore anything drawn left of clipLeft.
*/
- public int clipLeft;
+ private int clipLeft;
+
+ /**
+ * Get left drawing clipping boundary.
+ *
+ * @return drawing boundary
+ */
+ public final int getClipLeft() {
+ return clipLeft;
+ }
+
+ /**
+ * Set left drawing clipping boundary.
+ *
+ * @param clipLeft new boundary
+ */
+ public final void setClipLeft(final int clipLeft) {
+ this.clipLeft = clipLeft;
+ }
/**
* Ignore anything drawn above clipTop.
*/
- public int clipTop;
+ private int clipTop;
+
+ /**
+ * Get top drawing clipping boundary.
+ *
+ * @return drawing boundary
+ */
+ public final int getClipTop() {
+ return clipTop;
+ }
+
+ /**
+ * Set top drawing clipping boundary.
+ *
+ * @param clipTop new boundary
+ */
+ public final void setClipTop(final int clipTop) {
+ this.clipTop = clipTop;
+ }
/**
* The physical screen last sent out on flush().
/**
* When true, logical != physical.
*/
- public boolean dirty;
+ protected boolean dirty;
+
+ /**
+ * Get dirty flag.
+ *
+ * @return if true, the logical screen is not in sync with the physical
+ * screen
+ */
+ public final boolean isDirty() {
+ return dirty;
+ }
/**
* Set if the user explicitly wants to redraw everything starting with a
* @param y row coordinate. 0 is the top-most row.
* @return attributes at (x, y)
*/
- public CellAttributes getAttrXY(final int x, final int y) {
+ public final CellAttributes getAttrXY(final int x, final int y) {
+
CellAttributes attr = new CellAttributes();
- attr.setTo(logical[x][y]);
+ if ((x >= 0) && (x < width) && (y >= 0) && (y < height)) {
+ attr.setTo(logical[x][y]);
+ }
return attr;
}
* @param y row coordinate. 0 is the top-most row.
* @param attr attributes to use (bold, foreColor, backColor)
*/
- public void putAttrXY(final int x, final int y, final CellAttributes attr) {
+ public final void putAttrXY(final int x, final int y,
+ final CellAttributes attr) {
+
putAttrXY(x, y, attr, true);
}
* @param attr attributes to use (bold, foreColor, backColor)
* @param clip if true, honor clipping/offset
*/
- public void putAttrXY(final int x, final int y, final CellAttributes attr,
- final boolean clip) {
+ public final void putAttrXY(final int x, final int y
+ , final CellAttributes attr, final boolean clip) {
int X = x;
int Y = y;
* @param ch character to draw
* @param attr attributes to use (bold, foreColor, backColor)
*/
- public void putAll(final char ch, final CellAttributes attr) {
+ public final void putAll(final char ch, final CellAttributes attr) {
+
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
putCharXY(x, y, ch, attr);
* @param y row coordinate. 0 is the top-most row.
* @param ch character + attributes to draw
*/
- public void putCharXY(final int x, final int y, final Cell ch) {
+ public final void putCharXY(final int x, final int y, final Cell ch) {
putCharXY(x, y, ch.getChar(), ch);
}
* @param ch character to draw
* @param attr attributes to use (bold, foreColor, backColor)
*/
- public void putCharXY(final int x, final int y, final char ch,
+ public final void putCharXY(final int x, final int y, final char ch,
final CellAttributes attr) {
if ((x < clipLeft)
* @param y row coordinate. 0 is the top-most row.
* @param ch character to draw
*/
- public void putCharXY(final int x, final int y, final char ch) {
+ public final void putCharXY(final int x, final int y, final char ch) {
+
if ((x < clipLeft)
|| (x >= clipRight)
|| (y < clipTop)
* @param str string to draw
* @param attr attributes to use (bold, foreColor, backColor)
*/
- public void putStrXY(final int x, final int y, final String str,
+ public final void putStrXY(final int x, final int y, final String str,
final CellAttributes attr) {
int i = x;
* @param y row coordinate. 0 is the top-most row.
* @param str string to draw
*/
- public void putStrXY(final int x, final int y, final String str) {
+ public final void putStrXY(final int x, final int y, final String str) {
+
int i = x;
for (int j = 0; j < str.length(); j++) {
char ch = str.charAt(j);
* @param ch character to draw
* @param attr attributes to use (bold, foreColor, backColor)
*/
- public void vLineXY(final int x, final int y, final int n, final char ch,
- final CellAttributes attr) {
+ public final void vLineXY(final int x, final int y, final int n,
+ final char ch, final CellAttributes attr) {
for (int i = y; i < y + n; i++) {
putCharXY(x, i, ch, attr);
* @param ch character to draw
* @param attr attributes to use (bold, foreColor, backColor)
*/
- public void hLineXY(final int x, final int y, final int n, final char ch,
- final CellAttributes attr) {
+ public final void hLineXY(final int x, final int y, final int n,
+ final char ch, final CellAttributes attr) {
for (int i = x; i < x + n; i++) {
putCharXY(i, y, ch, attr);
* @param width new width
* @param height new height
*/
- private void reallocate(final int width, final int height) {
+ private synchronized void reallocate(final int width, final int height) {
if (logical != null) {
for (int row = 0; row < this.height; row++) {
for (int col = 0; col < this.width; col++) {
*
* @param width new screen width
*/
- public void setWidth(final int width) {
+ public final synchronized void setWidth(final int width) {
reallocate(width, this.height);
}
*
* @param height new screen height
*/
- public void setHeight(final int height) {
+ public final synchronized void setHeight(final int height) {
reallocate(this.width, height);
}
* @param width new screen width
* @param height new screen height
*/
- public void setDimensions(final int width, final int height) {
+ public final void setDimensions(final int width, final int height) {
reallocate(width, height);
}
*
* @return current screen height
*/
- public int getHeight() {
+ public final synchronized int getHeight() {
return this.height;
}
*
* @return current screen width
*/
- public int getWidth() {
+ public final synchronized int getWidth() {
return this.width;
}
/**
* Public constructor. Sets everything to not-bold, white-on-black.
*/
- public Screen() {
+ protected Screen() {
offsetX = 0;
offsetY = 0;
width = 80;
* Reset screen to not-bold, white-on-black. Also flushes the offset and
* clip variables.
*/
- public void reset() {
+ public final synchronized void reset() {
dirty = true;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
/**
* Flush the offset and clip variables.
*/
- public void resetClipping() {
+ public final void resetClipping() {
offsetX = 0;
offsetY = 0;
clipLeft = 0;
/**
* Force the screen to be fully cleared and redrawn on the next flush().
*/
- public void clear() {
+ public final void clear() {
reset();
}
* @param border attributes to use for the border
* @param background attributes to use for the background
*/
- public void drawBox(final int left, final int top,
+ public final void drawBox(final int left, final int top,
final int right, final int bottom,
final CellAttributes border, final CellAttributes background) {
* single-line left/right edges (like Qmodem)
* @param shadow if true, draw a "shadow" on the box
*/
- public void drawBox(final int left, final int top,
+ public final void drawBox(final int left, final int top,
final int right, final int bottom,
final CellAttributes border, final CellAttributes background,
final int borderType, final boolean shadow) {
}
/**
- * Draw a box shadow
+ * Draw a box shadow.
*
* @param left left column of box. 0 is the left-most row.
* @param top top row of the box. 0 is the top-most row.
* @param right right column of box
* @param bottom bottom row of the box
*/
- public void drawBoxShadow(final int left, final int top,
+ public final void drawBoxShadow(final int left, final int top,
final int right, final int bottom) {
int boxTop = top;
* Subclasses must provide an implementation to push the logical screen
* to the physical device.
*/
- abstract public void flushPhysical();
+ public abstract void flushPhysical();
/**
* Put the cursor at (x,y).
* @param y row coordinate to put the cursor on
*/
public void putCursor(final boolean visible, final int x, final int y) {
+
cursorVisible = visible;
cursorX = x;
cursorY = y;
}
/**
- * Hide the cursor
+ * Hide the cursor.
*/
- public void hideCursor() {
+ public final void hideCursor() {
cursorVisible = false;
}
}