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
.gui2
;
21 import com
.googlecode
.lanterna
.TerminalSize
;
22 import com
.googlecode
.lanterna
.TextColor
;
25 * Simple component which draws a solid color over its area. The size this component will request is specified through
30 public class EmptySpace
extends AbstractComponent
<EmptySpace
> {
31 private final TerminalSize size
;
32 private TextColor color
;
35 * Creates an EmptySpace with size 1x1 and a default color chosen from the theme
38 this(null, TerminalSize
.ONE
);
42 * Creates an EmptySpace with a specified color and preferred size of 1x1
43 * @param color Color to use (null will make it use the theme)
45 public EmptySpace(TextColor color
) {
46 this(color
, TerminalSize
.ONE
);
50 * Creates an EmptySpace with a specified preferred size (color will be chosen from the theme)
51 * @param size Preferred size
53 public EmptySpace(TerminalSize size
) {
58 * Creates an EmptySpace with a specified color (null will make it use a color from the theme) and preferred size
59 * @param color Color to use (null will make it use the theme)
60 * @param size Preferred size
62 public EmptySpace(TextColor color
, TerminalSize size
) {
68 * Changes the color this component will use when drawn
69 * @param color New color to draw the component with, if {@code null} then the component will use the theme's
72 public void setColor(TextColor color
) {
77 * Returns the color this component is drawn with, or {@code null} if this component uses whatever the default color
78 * the theme is set to use
79 * @return Color used when drawing or {@code null} if it's using the theme
81 public TextColor
getColor() {
86 protected ComponentRenderer
<EmptySpace
> createDefaultRenderer() {
87 return new ComponentRenderer
<EmptySpace
>() {
90 public TerminalSize
getPreferredSize(EmptySpace component
) {
95 public void drawComponent(TextGUIGraphics graphics
, EmptySpace component
) {
96 graphics
.applyThemeStyle(graphics
.getThemeDefinition(EmptySpace
.class).getNormal());
98 graphics
.setBackgroundColor(color
);