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
.*;
22 import com
.googlecode
.lanterna
.screen
.TabBehaviour
;
23 import java
.util
.Arrays
;
24 import java
.util
.Collection
;
25 import java
.util
.EnumSet
;
28 * TextGraphics implementation that does nothing, but has a pre-defined size
31 class NullTextGraphics
implements TextGraphics
{
32 private final TerminalSize size
;
33 private TextColor foregroundColor
;
34 private TextColor backgroundColor
;
35 private TabBehaviour tabBehaviour
;
36 private final EnumSet
<SGR
> activeModifiers
;
39 * Creates a new {@code NullTextGraphics} that will return the specified size value if asked how big it is but other
40 * than that ignore all other calls.
41 * @param size The size to report
43 public NullTextGraphics(TerminalSize size
) {
45 this.foregroundColor
= TextColor
.ANSI
.DEFAULT
;
46 this.backgroundColor
= TextColor
.ANSI
.DEFAULT
;
47 this.tabBehaviour
= TabBehaviour
.ALIGN_TO_COLUMN_4
;
48 this.activeModifiers
= EnumSet
.noneOf(SGR
.class);
52 public TerminalSize
getSize() {
57 public TextGraphics
newTextGraphics(TerminalPosition topLeftCorner
, TerminalSize size
) throws IllegalArgumentException
{
62 public TextColor
getBackgroundColor() {
63 return backgroundColor
;
67 public TextGraphics
setBackgroundColor(TextColor backgroundColor
) {
68 this.backgroundColor
= backgroundColor
;
73 public TextColor
getForegroundColor() {
74 return foregroundColor
;
78 public TextGraphics
setForegroundColor(TextColor foregroundColor
) {
79 this.foregroundColor
= foregroundColor
;
84 public TextGraphics
enableModifiers(SGR
... modifiers
) {
85 activeModifiers
.addAll(Arrays
.asList(modifiers
));
90 public TextGraphics
disableModifiers(SGR
... modifiers
) {
91 activeModifiers
.removeAll(Arrays
.asList(modifiers
));
96 public TextGraphics
setModifiers(EnumSet
<SGR
> modifiers
) {
98 activeModifiers
.addAll(modifiers
);
103 public TextGraphics
clearModifiers() {
104 activeModifiers
.clear();
109 public EnumSet
<SGR
> getActiveModifiers() {
110 return EnumSet
.copyOf(activeModifiers
);
114 public TabBehaviour
getTabBehaviour() {
119 public TextGraphics
setTabBehaviour(TabBehaviour tabBehaviour
) {
120 this.tabBehaviour
= tabBehaviour
;
125 public TextGraphics
fill(char c
) {
130 public TextGraphics
setCharacter(int column
, int row
, char character
) {
135 public TextGraphics
setCharacter(int column
, int row
, TextCharacter character
) {
140 public TextGraphics
setCharacter(TerminalPosition position
, char character
) {
145 public TextGraphics
setCharacter(TerminalPosition position
, TextCharacter character
) {
150 public TextGraphics
drawLine(TerminalPosition fromPoint
, TerminalPosition toPoint
, char character
) {
155 public TextGraphics
drawLine(TerminalPosition fromPoint
, TerminalPosition toPoint
, TextCharacter character
) {
160 public TextGraphics
drawLine(int fromX
, int fromY
, int toX
, int toY
, char character
) {
165 public TextGraphics
drawLine(int fromX
, int fromY
, int toX
, int toY
, TextCharacter character
) {
170 public TextGraphics
drawTriangle(TerminalPosition p1
, TerminalPosition p2
, TerminalPosition p3
, char character
) {
175 public TextGraphics
drawTriangle(TerminalPosition p1
, TerminalPosition p2
, TerminalPosition p3
, TextCharacter character
) {
180 public TextGraphics
fillTriangle(TerminalPosition p1
, TerminalPosition p2
, TerminalPosition p3
, char character
) {
185 public TextGraphics
fillTriangle(TerminalPosition p1
, TerminalPosition p2
, TerminalPosition p3
, TextCharacter character
) {
190 public TextGraphics
drawRectangle(TerminalPosition topLeft
, TerminalSize size
, char character
) {
195 public TextGraphics
drawRectangle(TerminalPosition topLeft
, TerminalSize size
, TextCharacter character
) {
200 public TextGraphics
fillRectangle(TerminalPosition topLeft
, TerminalSize size
, char character
) {
205 public TextGraphics
fillRectangle(TerminalPosition topLeft
, TerminalSize size
, TextCharacter character
) {
210 public TextGraphics
drawImage(TerminalPosition topLeft
, TextImage image
) {
215 public TextGraphics
drawImage(TerminalPosition topLeft
, TextImage image
, TerminalPosition sourceImageTopLeft
, TerminalSize sourceImageSize
) {
220 public TextGraphics
putString(int column
, int row
, String string
) {
225 public TextGraphics
putString(TerminalPosition position
, String string
) {
230 public TextGraphics
putString(int column
, int row
, String string
, SGR extraModifier
, SGR
... optionalExtraModifiers
) {
235 public TextGraphics
putString(TerminalPosition position
, String string
, SGR extraModifier
, SGR
... optionalExtraModifiers
) {
240 public TextGraphics
putString(int column
, int row
, String string
, Collection
<SGR
> extraModifiers
) {
245 public TextCharacter
getCharacter(int column
, int row
) {
250 public TextCharacter
getCharacter(TerminalPosition position
) {