2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
4 * lanterna is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 2010-2015 Martin
19 package com
.googlecode
.lanterna
.graphics
;
21 import com
.googlecode
.lanterna
.TextCharacter
;
22 import com
.googlecode
.lanterna
.TerminalSize
;
25 * This TextGraphics implementation wraps another TextGraphics and forwards all operations to it, but with a few
26 * differences. First of all, each individual character being printed is printed twice. Secondly, if you call
27 * {@code getSize()}, it will return a size that has half the width of the underlying TextGraphics. This presents the
28 * writable view as somewhat squared, since normally terminal characters are twice as tall as wide. You can see some
29 * examples of how this looks by running the Triangle test in {@code com.googlecode.lanterna.screen.ScreenTriangleTest}
30 * and compare it when running with the --square parameter and without.
32 public class DoublePrintingTextGraphics
extends AbstractTextGraphics
{
33 private final TextGraphics underlyingTextGraphics
;
36 * Creates a new {@code DoublePrintingTextGraphics} on top of a supplied {@code TextGraphics}
37 * @param underlyingTextGraphics backend {@code TextGraphics} to forward all the calls to
39 public DoublePrintingTextGraphics(TextGraphics underlyingTextGraphics
) {
40 this.underlyingTextGraphics
= underlyingTextGraphics
;
44 public TextGraphics
setCharacter(int columnIndex
, int rowIndex
, TextCharacter textCharacter
) {
45 columnIndex
= columnIndex
* 2;
46 underlyingTextGraphics
.setCharacter(columnIndex
, rowIndex
, textCharacter
);
47 underlyingTextGraphics
.setCharacter(columnIndex
+ 1, rowIndex
, textCharacter
);
52 public TextCharacter
getCharacter(int columnIndex
, int rowIndex
) {
53 columnIndex
= columnIndex
* 2;
54 return underlyingTextGraphics
.getCharacter(columnIndex
, rowIndex
);
59 public TerminalSize
getSize() {
60 TerminalSize size
= underlyingTextGraphics
.getSize();
61 return size
.withColumns(size
.getColumns() / 2);