+ // ------------------------------------------------------------------------
+ // LogicalScreen ----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Reallocate screen buffers.
+ *
+ * @param width new width
+ * @param height new 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++) {
+ logical[col][row] = null;
+ }
+ }
+ logical = null;
+ }
+ logical = new Cell[width][height];
+ if (physical != null) {
+ for (int row = 0; row < this.height; row++) {
+ for (int col = 0; col < this.width; col++) {
+ physical[col][row] = null;
+ }
+ }
+ physical = null;
+ }
+ physical = new Cell[width][height];
+
+ for (int row = 0; row < height; row++) {
+ for (int col = 0; col < width; col++) {
+ physical[col][row] = new Cell();
+ logical[col][row] = new Cell();
+ }
+ }
+
+ this.width = width;
+ this.height = height;
+
+ clipLeft = 0;
+ clipTop = 0;
+ clipRight = width;
+ clipBottom = height;
+
+ reallyCleared = true;
+ }
+
+ /**
+ * Clear the physical screen.
+ */
+ public final void clearPhysical() {
+ for (int row = 0; row < height; row++) {
+ for (int col = 0; col < width; col++) {
+ physical[col][row].unset();
+ }
+ }
+ }
+
+ /**
+ * Unset every image cell on one row of the physical screen, forcing
+ * images on that row to be redrawn.
+ *
+ * @param y row coordinate. 0 is the top-most row.
+ */
+ public final void unsetImageRow(final int y) {
+ if ((y < 0) || (y >= height)) {
+ return;
+ }
+ for (int x = 0; x < width; x++) {
+ if (logical[x][y].isImage()) {
+ physical[x][y].unset();
+ }
+ }
+ }
+
+ /**
+ * Render one fullwidth cell.
+ *
+ * @param x column coordinate. 0 is the left-most column.
+ * @param y row coordinate. 0 is the top-most row.
+ * @param cell the cell to draw
+ */
+ public final void putFullwidthCharXY(final int x, final int y,
+ final Cell cell) {
+
+ int cellWidth = getTextWidth();
+ int cellHeight = getTextHeight();
+
+ if (lastTextHeight != cellHeight) {
+ glyphMaker = GlyphMaker.getInstance(cellHeight);
+ lastTextHeight = cellHeight;
+ }
+ BufferedImage image = glyphMaker.getImage(cell, cellWidth * 2,
+ cellHeight);
+ BufferedImage leftImage = image.getSubimage(0, 0, cellWidth,
+ cellHeight);
+ BufferedImage rightImage = image.getSubimage(cellWidth, 0, cellWidth,
+ cellHeight);
+
+ Cell left = new Cell(cell);
+ left.setImage(leftImage);
+ left.setWidth(Cell.Width.LEFT);
+ putCharXY(x, y, left);
+
+ Cell right = new Cell(cell);
+ right.setImage(rightImage);
+ right.setWidth(Cell.Width.RIGHT);
+ putCharXY(x + 1, y, right);
+ }
+
+ /**
+ * Render one fullwidth character with attributes.
+ *
+ * @param x column coordinate. 0 is the left-most column.
+ * @param y row coordinate. 0 is the top-most row.
+ * @param ch character to draw
+ * @param attr attributes to use (bold, foreColor, backColor)
+ */
+ public final void putFullwidthCharXY(final int x, final int y,
+ final int ch, final CellAttributes attr) {
+
+ Cell cell = new Cell(ch, attr);
+ putFullwidthCharXY(x, y, cell);
+ }
+
+ /**
+ * Render one fullwidth character with attributes.
+ *
+ * @param x column coordinate. 0 is the left-most column.
+ * @param y row coordinate. 0 is the top-most row.
+ * @param ch character to draw
+ */
+ public final void putFullwidthCharXY(final int x, final int y,
+ final int ch) {
+
+ Cell cell = new Cell(ch);
+ cell.setAttr(getAttrXY(x, y));
+ putFullwidthCharXY(x, y, cell);
+ }
+