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
.terminal
.swing
;
21 import com
.googlecode
.lanterna
.graphics
.AbstractTextGraphics
;
22 import com
.googlecode
.lanterna
.TextCharacter
;
23 import com
.googlecode
.lanterna
.TerminalPosition
;
24 import com
.googlecode
.lanterna
.TerminalSize
;
25 import com
.googlecode
.lanterna
.graphics
.TextGraphics
;
28 * Implementation of TextGraphics for the SwingTerminal, which is able to access directly into the TextBuffer and set
29 * values in there directly.
32 class VirtualTerminalTextGraphics
extends AbstractTextGraphics
{
33 private final VirtualTerminal virtualTerminal
;
35 VirtualTerminalTextGraphics(VirtualTerminal virtualTerminal
) {
36 this.virtualTerminal
= virtualTerminal
;
40 public TextGraphics
setCharacter(int columnIndex
, int rowIndex
, TextCharacter textCharacter
) {
41 TerminalSize size
= getSize();
42 if(columnIndex
< 0 || columnIndex
>= size
.getColumns() ||
43 rowIndex
< 0 || rowIndex
>= size
.getRows()) {
46 virtualTerminal
.setCursorAndPutCharacter(new TerminalPosition(columnIndex
, rowIndex
), textCharacter
);
51 public TextCharacter
getCharacter(TerminalPosition position
) {
52 return virtualTerminal
.getCharacter(position
);
56 public TextCharacter
getCharacter(int column
, int row
) {
57 return getCharacter(new TerminalPosition(column
, row
));
61 public TerminalSize
getSize() {
62 return virtualTerminal
.getSize();