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-2023 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 @NotNull [] 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 
86  public void setComponent(@NotNull final Location location, @NotNull final Component component, final boolean alternativeLocation, final int size) {
87  splitPanes[location.ordinal()].setOptionalComponent(component, alternativeLocation, size);
88  }
89 
96  public void unsetComponent(@NotNull final Location location, final boolean alternativeLocation) {
97  splitPanes[location.ordinal()].setOptionalComponent(null, alternativeLocation, 0);
98  }
99 
100 }
net.sf.gridarta.gui.utils.borderpanel.BorderPanel.setComponent
void setComponent(@NotNull final Location location, @NotNull final Component component, final boolean alternativeLocation, final int size)
Sets the optional Component for a location.
Definition: BorderPanel.java:86
net.sf.gridarta.gui.utils.borderpanel.BorderPanel.unsetComponent
void unsetComponent(@NotNull final Location location, final boolean alternativeLocation)
Unsets the optional Component for a location.
Definition: BorderPanel.java:96
net.sf.gridarta.gui.utils.borderpanel.BorderPanel.BorderPanel
BorderPanel(@NotNull final Component component, @NotNull final BorderPanelListener borderPanelListener)
Creates a new instance.
Definition: BorderPanel.java:53
net.sf.gridarta.gui.utils.borderpanel.BorderSplitPaneListener
Interface for listeners interested in BorderSplitPane related events.
Definition: BorderSplitPaneListener.java:30
net.sf.gridarta.gui.utils.borderpanel.BorderSplitPane
A Component that permanently shows another component and optionally displays a JSplitPane and one or ...
Definition: BorderSplitPane.java:37
net.sf.gridarta.gui.utils.borderpanel.BorderPanelListener
Interface for listeners interested in BorderPanel related events.
Definition: BorderPanelListener.java:29
net.sf.gridarta.gui.utils.borderpanel.BorderSplitPane.setOptionalComponent
void setOptionalComponent(@Nullable final Component optionalComponent, final boolean alternativeLocation, final int size)
Sets the optional Component.
Definition: BorderSplitPane.java:197
net.sf.gridarta.gui.utils.borderpanel.BorderPanel
A Component that permanently displays another Component and optionally displays more components on th...
Definition: BorderPanel.java:34
net.sf.gridarta.gui.utils.borderpanel.Location
A location.
Definition: Location.java:33
net.sf.gridarta.gui.utils.borderpanel.BorderSplitPaneListener.sizeChanged
void sizeChanged(@NotNull Component optionalComponent, int size)
The size of the split pane has changed.
net.sf.gridarta.gui.utils.borderpanel.BorderPanel.splitPanes
final BorderSplitPane[] splitPanes
The BorderSplitPanes showing the optional components.
Definition: BorderPanel.java:46
net.sf.gridarta.gui.utils.borderpanel.BorderPanel.serialVersionUID
static final long serialVersionUID
The serial version UID.
Definition: BorderPanel.java:39