Gridarta Editor
BorderPanel.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.gui.utils.borderpanel;
21 
22 import java.awt.BorderLayout;
23 import java.awt.Component;
24 import java.awt.Container;
25 import org.jetbrains.annotations.NotNull;
26 
34 public class BorderPanel extends Container {
35 
39  private static final long serialVersionUID = 1L;
40 
45  @NotNull
46  private final BorderSplitPane[] splitPanes = new BorderSplitPane[Location.values().length];
47 
53  public BorderPanel(@NotNull final Component component, @NotNull final BorderPanelListener borderPanelListener) {
54  Component nextComponent = component;
55  for (final Location location : Location.values()) {
56  final BorderSplitPaneListener borderSplitPaneListener = new BorderSplitPaneListener() {
57 
58  @Override
59  public void sizeChanged(@NotNull final Component optionalComponent, final int size) {
60  borderPanelListener.sizeChanged(optionalComponent, size);
61  }
62 
63  @Override
64  public void size2Changed(final int size2) {
65  borderPanelListener.size2Changed(location, size2);
66  }
67 
68  };
69  final BorderSplitPane tmp = new BorderSplitPane(nextComponent, location, borderSplitPaneListener, borderPanelListener.getSize2(location));
70  splitPanes[location.ordinal()] = tmp;
71  nextComponent = tmp;
72  }
73  setLayout(new BorderLayout());
74  add(nextComponent, BorderLayout.CENTER);
75  }
76 
87  public void setComponent(@NotNull final Location location, @NotNull final Component component, final boolean alternativeLocation, final int size) {
88  splitPanes[location.ordinal()].setOptionalComponent(component, alternativeLocation, size);
89  }
90 
98  public void unsetComponent(@NotNull final Location location, final boolean alternativeLocation) {
99  splitPanes[location.ordinal()].setOptionalComponent(null, alternativeLocation, 0);
100  }
101 
102 }
void setComponent(@NotNull final Location location, @NotNull final Component component, final boolean alternativeLocation, final int size)
Sets the optional Component for a location.
A Component that permanently shows another component and optionally displays a JSplitPane and one or ...
Interface for listeners interested in BorderSplitPane related events.
void sizeChanged(@NotNull Component optionalComponent, int size)
The size of the split pane has changed.
A Component that permanently displays another Component and optionally displays more components on th...
Interface for listeners interested in BorderPanel related events.
static final long serialVersionUID
The serial version UID.
void setOptionalComponent(@Nullable final Component optionalComponent, final boolean alternativeLocation, final int size)
Sets the optional Component.
BorderPanel(@NotNull final Component component, @NotNull final BorderPanelListener borderPanelListener)
Creates a new instance.
void unsetComponent(@NotNull final Location location, final boolean alternativeLocation)
Unsets the optional Component for a location.
final BorderSplitPane [] splitPanes
The BorderSplitPanes showing the optional components.