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
;
22 import com
.googlecode
.lanterna
.TerminalPosition
;
23 import com
.googlecode
.lanterna
.TerminalSize
;
26 * Abstract implementation of {@code Border} interface that has some of the methods filled out. If you want to create
27 * your own {@code Border} implementation, should should probably extend from this.
30 public abstract class AbstractBorder
extends AbstractComposite
<Border
> implements Border
{
32 public void setComponent(Component component
) {
33 super.setComponent(component
);
34 if(component
!= null) {
35 component
.setPosition(TerminalPosition
.TOP_LEFT_CORNER
);
40 public BorderRenderer
getRenderer() {
41 return (BorderRenderer
)super.getRenderer();
45 public Border
setSize(TerminalSize size
) {
47 getComponent().setSize(getWrappedComponentSize(size
));
52 public LayoutData
getLayoutData() {
53 return getComponent().getLayoutData();
57 public Border
setLayoutData(LayoutData ld
) {
58 getComponent().setLayoutData(ld
);
63 public TerminalPosition
toBasePane(TerminalPosition position
) {
64 return super.toBasePane(position
).withRelative(getWrappedComponentTopLeftOffset());
68 public TerminalPosition
toGlobal(TerminalPosition position
) {
69 return super.toGlobal(position
).withRelative(getWrappedComponentTopLeftOffset());
72 private TerminalPosition
getWrappedComponentTopLeftOffset() {
73 return getRenderer().getWrappedComponentTopLeftOffset();
76 private TerminalSize
getWrappedComponentSize(TerminalSize borderSize
) {
77 return getRenderer().getWrappedComponentSize(borderSize
);