Change build scripts
[jvcard.git] / src / com / googlecode / lanterna / graphics / NullTextGraphics.java
1 /*
2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
3 *
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.
8 *
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.
13 *
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/>.
16 *
17 * Copyright (C) 2010-2015 Martin
18 */
19 package com.googlecode.lanterna.graphics;
20
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;
26
27 /**
28 * TextGraphics implementation that does nothing, but has a pre-defined size
29 * @author martin
30 */
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;
37
38 /**
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
42 */
43 public NullTextGraphics(TerminalSize size) {
44 this.size = 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);
49 }
50
51 @Override
52 public TerminalSize getSize() {
53 return size;
54 }
55
56 @Override
57 public TextGraphics newTextGraphics(TerminalPosition topLeftCorner, TerminalSize size) throws IllegalArgumentException {
58 return this;
59 }
60
61 @Override
62 public TextColor getBackgroundColor() {
63 return backgroundColor;
64 }
65
66 @Override
67 public TextGraphics setBackgroundColor(TextColor backgroundColor) {
68 this.backgroundColor = backgroundColor;
69 return this;
70 }
71
72 @Override
73 public TextColor getForegroundColor() {
74 return foregroundColor;
75 }
76
77 @Override
78 public TextGraphics setForegroundColor(TextColor foregroundColor) {
79 this.foregroundColor = foregroundColor;
80 return this;
81 }
82
83 @Override
84 public TextGraphics enableModifiers(SGR... modifiers) {
85 activeModifiers.addAll(Arrays.asList(modifiers));
86 return this;
87 }
88
89 @Override
90 public TextGraphics disableModifiers(SGR... modifiers) {
91 activeModifiers.removeAll(Arrays.asList(modifiers));
92 return this;
93 }
94
95 @Override
96 public TextGraphics setModifiers(EnumSet<SGR> modifiers) {
97 clearModifiers();
98 activeModifiers.addAll(modifiers);
99 return this;
100 }
101
102 @Override
103 public TextGraphics clearModifiers() {
104 activeModifiers.clear();
105 return this;
106 }
107
108 @Override
109 public EnumSet<SGR> getActiveModifiers() {
110 return EnumSet.copyOf(activeModifiers);
111 }
112
113 @Override
114 public TabBehaviour getTabBehaviour() {
115 return tabBehaviour;
116 }
117
118 @Override
119 public TextGraphics setTabBehaviour(TabBehaviour tabBehaviour) {
120 this.tabBehaviour = tabBehaviour;
121 return this;
122 }
123
124 @Override
125 public TextGraphics fill(char c) {
126 return this;
127 }
128
129 @Override
130 public TextGraphics setCharacter(int column, int row, char character) {
131 return this;
132 }
133
134 @Override
135 public TextGraphics setCharacter(int column, int row, TextCharacter character) {
136 return this;
137 }
138
139 @Override
140 public TextGraphics setCharacter(TerminalPosition position, char character) {
141 return this;
142 }
143
144 @Override
145 public TextGraphics setCharacter(TerminalPosition position, TextCharacter character) {
146 return this;
147 }
148
149 @Override
150 public TextGraphics drawLine(TerminalPosition fromPoint, TerminalPosition toPoint, char character) {
151 return this;
152 }
153
154 @Override
155 public TextGraphics drawLine(TerminalPosition fromPoint, TerminalPosition toPoint, TextCharacter character) {
156 return this;
157 }
158
159 @Override
160 public TextGraphics drawLine(int fromX, int fromY, int toX, int toY, char character) {
161 return this;
162 }
163
164 @Override
165 public TextGraphics drawLine(int fromX, int fromY, int toX, int toY, TextCharacter character) {
166 return this;
167 }
168
169 @Override
170 public TextGraphics drawTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, char character) {
171 return this;
172 }
173
174 @Override
175 public TextGraphics drawTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, TextCharacter character) {
176 return this;
177 }
178
179 @Override
180 public TextGraphics fillTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, char character) {
181 return this;
182 }
183
184 @Override
185 public TextGraphics fillTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, TextCharacter character) {
186 return this;
187 }
188
189 @Override
190 public TextGraphics drawRectangle(TerminalPosition topLeft, TerminalSize size, char character) {
191 return this;
192 }
193
194 @Override
195 public TextGraphics drawRectangle(TerminalPosition topLeft, TerminalSize size, TextCharacter character) {
196 return this;
197 }
198
199 @Override
200 public TextGraphics fillRectangle(TerminalPosition topLeft, TerminalSize size, char character) {
201 return this;
202 }
203
204 @Override
205 public TextGraphics fillRectangle(TerminalPosition topLeft, TerminalSize size, TextCharacter character) {
206 return this;
207 }
208
209 @Override
210 public TextGraphics drawImage(TerminalPosition topLeft, TextImage image) {
211 return this;
212 }
213
214 @Override
215 public TextGraphics drawImage(TerminalPosition topLeft, TextImage image, TerminalPosition sourceImageTopLeft, TerminalSize sourceImageSize) {
216 return this;
217 }
218
219 @Override
220 public TextGraphics putString(int column, int row, String string) {
221 return this;
222 }
223
224 @Override
225 public TextGraphics putString(TerminalPosition position, String string) {
226 return this;
227 }
228
229 @Override
230 public TextGraphics putString(int column, int row, String string, SGR extraModifier, SGR... optionalExtraModifiers) {
231 return this;
232 }
233
234 @Override
235 public TextGraphics putString(TerminalPosition position, String string, SGR extraModifier, SGR... optionalExtraModifiers) {
236 return this;
237 }
238
239 @Override
240 public TextGraphics putString(int column, int row, String string, Collection<SGR> extraModifiers) {
241 return this;
242 }
243
244 @Override
245 public TextCharacter getCharacter(int column, int row) {
246 return null;
247 }
248
249 @Override
250 public TextCharacter getCharacter(TerminalPosition position) {
251 return null;
252 }
253 }