/*
 * This file is part of lanterna (http://code.google.com/p/lanterna/).
 *
 * lanterna is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright (C) 2010-2020 Martin Berglund
 */
package com.googlecode.lanterna.gui2;

import com.googlecode.lanterna.*;
import com.googlecode.lanterna.graphics.*;
import com.googlecode.lanterna.screen.TabBehaviour;

import java.util.Collection;
import java.util.EnumSet;

TextGraphics implementation used by TextGUI when doing any drawing operation.
Author:Martin
/** * TextGraphics implementation used by TextGUI when doing any drawing operation. * @author Martin */
public class TextGUIGraphics implements ThemedTextGraphics, TextGraphics { private final TextGUI textGUI; private final TextGraphics backend; @Deprecated TextGUIGraphics(TextGUI textGUI, TextGraphics backend, Theme theme) { this(textGUI, backend); } TextGUIGraphics(TextGUI textGUI, TextGraphics backend) { this.backend = backend; this.textGUI = textGUI; } @Override @Deprecated public Theme getTheme() { return textGUI.getTheme(); }
Returns a new TextGUIGraphics object that has another theme attached to it
Params:
  • theme – Theme to be used with the new TextGUIGraphics
Returns:New TextGUIGraphics that has the specified theme
Deprecated:Now this method does nothing
/** * Returns a new {@code TextGUIGraphics} object that has another theme attached to it * @param theme Theme to be used with the new {@code TextGUIGraphics} * @return New {@code TextGUIGraphics} that has the specified theme * @deprecated Now this method does nothing */
@Deprecated public TextGUIGraphics withTheme(Theme theme) { return this; }
Returns the TextGUI this TextGUIGraphics belongs to
Returns:TextGUI this TextGUIGraphics belongs to
/** * Returns the {@code TextGUI} this {@code TextGUIGraphics} belongs to * @return {@code TextGUI} this {@code TextGUIGraphics} belongs to */
public TextGUI getTextGUI() { return textGUI; } @Override public TextGUIGraphics newTextGraphics(TerminalPosition topLeftCorner, TerminalSize size) throws IllegalArgumentException { return new TextGUIGraphics(textGUI, backend.newTextGraphics(topLeftCorner, size)); } @Override public TextGUIGraphics applyThemeStyle(ThemeStyle themeStyle) { setForegroundColor(themeStyle.getForeground()); setBackgroundColor(themeStyle.getBackground()); setModifiers(themeStyle.getSGRs()); return this; } @Deprecated @Override public ThemeDefinition getThemeDefinition(Class<?> clazz) { return getTheme().getDefinition(clazz); } @Override public TerminalSize getSize() { return backend.getSize(); } @Override public TextColor getBackgroundColor() { return backend.getBackgroundColor(); } @Override public TextGUIGraphics setBackgroundColor(TextColor backgroundColor) { backend.setBackgroundColor(backgroundColor); return this; } @Override public TextColor getForegroundColor() { return backend.getForegroundColor(); } @Override public TextGUIGraphics setForegroundColor(TextColor foregroundColor) { backend.setForegroundColor(foregroundColor); return this; } @Override public TextGUIGraphics enableModifiers(SGR... modifiers) { backend.enableModifiers(modifiers); return this; } @Override public TextGUIGraphics disableModifiers(SGR... modifiers) { backend.disableModifiers(modifiers); return this; } @Override public TextGUIGraphics setModifiers(EnumSet<SGR> modifiers) { backend.setModifiers(modifiers); return this; } @Override public TextGUIGraphics clearModifiers() { backend.clearModifiers(); return this; } @Override public EnumSet<SGR> getActiveModifiers() { return backend.getActiveModifiers(); } @Override public TabBehaviour getTabBehaviour() { return backend.getTabBehaviour(); } @Override public TextGUIGraphics setTabBehaviour(TabBehaviour tabBehaviour) { backend.setTabBehaviour(tabBehaviour); return this; } @Override public TextGUIGraphics fill(char c) { backend.fill(c); return this; } @Override public TextGraphics fillRectangle(TerminalPosition topLeft, TerminalSize size, char character) { backend.fillRectangle(topLeft, size, character); return this; } @Override public TextGraphics fillRectangle(TerminalPosition topLeft, TerminalSize size, TextCharacter character) { backend.fillRectangle(topLeft, size, character); return this; } @Override public TextGraphics drawRectangle(TerminalPosition topLeft, TerminalSize size, char character) { backend.drawRectangle(topLeft, size, character); return this; } @Override public TextGraphics drawRectangle(TerminalPosition topLeft, TerminalSize size, TextCharacter character) { backend.drawRectangle(topLeft, size, character); return this; } @Override public TextGraphics fillTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, char character) { backend.fillTriangle(p1, p2, p3, character); return this; } @Override public TextGraphics fillTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, TextCharacter character) { backend.fillTriangle(p1, p2, p3, character); return this; } @Override public TextGraphics drawTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, char character) { backend.drawTriangle(p1, p2, p3, character); return this; } @Override public TextGraphics drawTriangle(TerminalPosition p1, TerminalPosition p2, TerminalPosition p3, TextCharacter character) { backend.drawTriangle(p1, p2, p3, character); return this; } @Override public TextGraphics drawLine(TerminalPosition fromPoint, TerminalPosition toPoint, char character) { backend.drawLine(fromPoint, toPoint, character); return this; } @Override public TextGraphics drawLine(TerminalPosition fromPoint, TerminalPosition toPoint, TextCharacter character) { backend.drawLine(fromPoint, toPoint, character); return this; } @Override public TextGraphics drawLine(int fromX, int fromY, int toX, int toY, char character) { backend.drawLine(fromX, fromY, toX, toY, character); return this; } @Override public TextGraphics drawLine(int fromX, int fromY, int toX, int toY, TextCharacter character) { backend.drawLine(fromX, fromY, toX, toY, character); return this; } @Override public TextGraphics drawImage(TerminalPosition topLeft, TextImage image) { backend.drawImage(topLeft, image); return this; } @Override public TextGraphics drawImage(TerminalPosition topLeft, TextImage image, TerminalPosition sourceImageTopLeft, TerminalSize sourceImageSize) { backend.drawImage(topLeft, image, sourceImageTopLeft, sourceImageSize); return this; } @Override public TextGraphics setCharacter(TerminalPosition position, char character) { backend.setCharacter(position, character); return this; } @Override public TextGraphics setCharacter(TerminalPosition position, TextCharacter character) { backend.setCharacter(position, character); return this; } @Override public TextGraphics setCharacter(int column, int row, char character) { backend.setCharacter(column, row, character); return this; } @Override public TextGraphics setCharacter(int column, int row, TextCharacter character) { backend.setCharacter(column, row, character); return this; } @Override public TextGUIGraphics putString(int column, int row, String string) { backend.putString(column, row, string); return this; } @Override public TextGUIGraphics putString(TerminalPosition position, String string) { backend.putString(position, string); return this; } @Override public TextGUIGraphics putString(int column, int row, String string, SGR extraModifier, SGR... optionalExtraModifiers) { backend.putString(column, row, string, extraModifier, optionalExtraModifiers); return this; } @Override public TextGUIGraphics putString(TerminalPosition position, String string, SGR extraModifier, SGR... optionalExtraModifiers) { backend.putString(position, string, extraModifier, optionalExtraModifiers); return this; } @Override public TextGraphics putString(int column, int row, String string, Collection<SGR> extraModifiers) { backend.putString(column, row, string, extraModifiers); return this; } @Override public TextGraphics putCSIStyledString(int column, int row, String string) { backend.putCSIStyledString(column, row, string); return this; } @Override public TextGraphics putCSIStyledString(TerminalPosition position, String string) { backend.putCSIStyledString(position, string); return this; } @Override public TextCharacter getCharacter(int column, int row) { return backend.getCharacter(column, row); } @Override public TextCharacter getCharacter(TerminalPosition position) { return backend.getCharacter(position); } @Override public TextGraphics setStyleFrom(StyleSet<?> source) { setBackgroundColor(source.getBackgroundColor()); setForegroundColor(source.getForegroundColor()); setModifiers(source.getActiveModifiers()); return this; } }