Change build scripts
[jvcard.git] / src / com / googlecode / lanterna / gui2 / TextGUIGraphics.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.gui2;
20
21 import com.googlecode.lanterna.*;
22 import com.googlecode.lanterna.graphics.*;
23 import com.googlecode.lanterna.screen.TabBehaviour;
24
25 import java.util.Collection;
26 import java.util.EnumSet;
27
28 /**
29 * TextGraphics implementation used by TextGUI when doing any drawing operation.
30 * @author Martin
31 */
32 public final class TextGUIGraphics implements ThemedTextGraphics, TextGraphics {
33 private final TextGUI textGUI;
34 private final ImmutableThemedTextGraphics backend;
35
36 TextGUIGraphics(TextGUI textGUI, TextGraphics backend, Theme theme) {
37 this.backend = new ImmutableThemedTextGraphics(backend, theme);
38 this.textGUI = textGUI;
39 }
40
41 @Override
42 public Theme getTheme() {
43 return backend.getTheme();
44 }
45
46 /**
47 * Returns a new {@code TextGUIGraphics} object that has another theme attached to it
48 * @param theme Theme to be used with the new {@code TextGUIGraphics}
49 * @return New {@code TextGUIGraphics} that has the specified theme
50 */
51 public TextGUIGraphics withTheme(Theme theme) {
52 return new TextGUIGraphics(textGUI, backend.getUnderlyingTextGraphics(), theme);
53 }
54
55 /**
56 * Returns the {@code TextGUI} this {@code TextGUIGraphics} belongs to
57 * @return {@code TextGUI} this {@code TextGUIGraphics} belongs to
58 */
59 public TextGUI getTextGUI() {
60 return textGUI;
61 }
62
63 @Override
64 public TextGUIGraphics newTextGraphics(TerminalPosition topLeftCorner, TerminalSize size) throws IllegalArgumentException {
65 return new TextGUIGraphics(textGUI, backend.getUnderlyingTextGraphics().newTextGraphics(topLeftCorner, size), backend.getTheme());
66 }
67
68 @Override
69 public TextGUIGraphics applyThemeStyle(ThemeStyle themeStyle) {
70 backend.applyThemeStyle(themeStyle);
71 return this;
72 }
73
74 @Override
75 public ThemeDefinition getThemeDefinition(Class<?> clazz) {
76 return backend.getThemeDefinition(clazz);
77 }
78
79 @Override
80 public TerminalSize getSize() {
81 return backend.getSize();
82 }
83
84 @Override
85 public TextColor getBackgroundColor() {
86 return backend.getBackgroundColor();
87 }
88
89 @Override
90 public TextGUIGraphics setBackgroundColor(TextColor backgroundColor) {
91 backend.setBackgroundColor(backgroundColor);
92 return this;
93 }
94
95 @Override
96 public TextColor getForegroundColor() {
97 return backend.getForegroundColor();
98 }
99
100 @Override
101 public TextGUIGraphics setForegroundColor(TextColor foregroundColor) {
102 backend.setForegroundColor(foregroundColor);
103 return this;
104 }
105
106 @Override
107 public TextGUIGraphics enableModifiers(SGR... modifiers) {
108 backend.enableModifiers(modifiers);
109 return this;
110 }
111
112 @Override
113 public TextGUIGraphics disableModifiers(SGR... modifiers) {
114 backend.disableModifiers(modifiers);
115 return this;
116 }
117
118 @Override
119 public TextGUIGraphics setModifiers(EnumSet<SGR> modifiers) {
120 backend.setModifiers(modifiers);
121 return this;
122 }
123
124 @Override
125 public TextGUIGraphics clearModifiers() {
126 backend.clearModifiers();
127 return this;
128 }
129
130 @Override
131 public EnumSet<SGR> getActiveModifiers() {
132 return backend.getActiveModifiers();
133 }
134
135 @Override
136 public TabBehaviour getTabBehaviour() {
137 return backend.getTabBehaviour();
138 }
139
140 @Override
141 public TextGUIGraphics setTabBehaviour(TabBehaviour tabBehaviour) {
142 backend.setTabBehaviour(tabBehaviour);
143 return this;
144 }
145
146 @Override
147 public TextGUIGraphics fill(char c) {
148 backend.fill(c);
149 return this;
150 }
151
152 @Override
153 public TextGraphics fillRectangle(TerminalPosition topLeft, TerminalSize size, char character) {
154 backend.fillRectangle(topLeft, size, character);
155 return this;
156 }
157
158 @Override
159 public TextGraphics fillRectangle(TerminalPosition topLeft, TerminalSize size, TextCharacter character) {
160 backend.fillRectangle(topLeft, size, character);
161 return this;
162 }
163
164 @Override
165 public TextGraphics drawRectangle(TerminalPosition topLeft, TerminalSize size, char character) {
166 backend.drawRectangle(topLeft, size, character);
167 return this;
168 }
169
170 @Override
171 public TextGraphics drawRectangle(TerminalPosition topLeft, TerminalSize size, TextCharacter character) {
172 backend.drawRectangle(topLeft, size, character);
173 return this;
174 }
175
176 @Override
177 public TextGraphics fillTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, char character) {
178 backend.fillTriangle(p1, p2, p3, character);
179 return this;
180 }
181
182 @Override
183 public TextGraphics fillTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, TextCharacter character) {
184 backend.fillTriangle(p1, p2, p3, character);
185 return this;
186 }
187
188 @Override
189 public TextGraphics drawTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, char character) {
190 backend.drawTriangle(p1, p2, p3, character);
191 return this;
192 }
193
194 @Override
195 public TextGraphics drawTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, TextCharacter character) {
196 backend.drawTriangle(p1, p2, p3, character);
197 return this;
198 }
199
200 @Override
201 public TextGraphics drawLine(TerminalPosition fromPoint, TerminalPosition toPoint, char character) {
202 backend.drawLine(fromPoint, toPoint, character);
203 return this;
204 }
205
206 @Override
207 public TextGraphics drawLine(TerminalPosition fromPoint, TerminalPosition toPoint, TextCharacter character) {
208 backend.drawLine(fromPoint, toPoint, character);
209 return this;
210 }
211
212 @Override
213 public TextGraphics drawLine(int fromX, int fromY, int toX, int toY, char character) {
214 backend.drawLine(fromX, fromY, toX, toY, character);
215 return this;
216 }
217
218 @Override
219 public TextGraphics drawLine(int fromX, int fromY, int toX, int toY, TextCharacter character) {
220 backend.drawLine(fromX, fromY, toX, toY, character);
221 return this;
222 }
223
224 @Override
225 public TextGraphics drawImage(TerminalPosition topLeft, TextImage image) {
226 backend.drawImage(topLeft, image);
227 return this;
228 }
229
230 @Override
231 public TextGraphics drawImage(TerminalPosition topLeft, TextImage image, TerminalPosition sourceImageTopLeft, TerminalSize sourceImageSize) {
232 backend.drawImage(topLeft, image, sourceImageTopLeft, sourceImageSize);
233 return this;
234 }
235
236 @Override
237 public TextGraphics setCharacter(TerminalPosition position, char character) {
238 backend.setCharacter(position, character);
239 return this;
240 }
241
242 @Override
243 public TextGraphics setCharacter(TerminalPosition position, TextCharacter character) {
244 backend.setCharacter(position, character);
245 return this;
246 }
247
248 @Override
249 public TextGraphics setCharacter(int column, int row, char character) {
250 backend.setCharacter(column, row, character);
251 return this;
252 }
253
254 @Override
255 public TextGraphics setCharacter(int column, int row, TextCharacter character) {
256 backend.setCharacter(column, row, character);
257 return this;
258 }
259
260 @Override
261 public TextGUIGraphics putString(int column, int row, String string) {
262 backend.putString(column, row, string);
263 return this;
264 }
265
266 @Override
267 public TextGUIGraphics putString(TerminalPosition position, String string) {
268 backend.putString(position, string);
269 return this;
270 }
271
272 @Override
273 public TextGUIGraphics putString(int column, int row, String string, SGR extraModifier, SGR... optionalExtraModifiers) {
274 backend.putString(column, row, string, extraModifier, optionalExtraModifiers);
275 return this;
276 }
277
278 @Override
279 public TextGUIGraphics putString(TerminalPosition position, String string, SGR extraModifier, SGR... optionalExtraModifiers) {
280 backend.putString(position, string, extraModifier, optionalExtraModifiers);
281 return this;
282 }
283
284 @Override
285 public TextGraphics putString(int column, int row, String string, Collection<SGR> extraModifiers) {
286 backend.putString(column, row, string, extraModifiers);
287 return this;
288 }
289
290 @Override
291 public TextCharacter getCharacter(int column, int row) {
292 return backend.getCharacter(column, row);
293 }
294
295 @Override
296 public TextCharacter getCharacter(TerminalPosition position) {
297 return backend.getCharacter(position);
298 }
299 }