Add switch panel.
[sonitus.git] / src / main / java / net / pterodactylus / sonitus / gui / ControlledPane.java
1 /*
2  * Sonitus - ControlledTab.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU 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.
8  *
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 General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sonitus.gui;
19
20 import javax.swing.Box;
21 import javax.swing.BoxLayout;
22 import javax.swing.JPanel;
23
24 import net.pterodactylus.sonitus.data.Controlled;
25 import net.pterodactylus.sonitus.data.Controller;
26 import net.pterodactylus.sonitus.data.controller.Fader;
27 import net.pterodactylus.sonitus.data.controller.Switch;
28
29 /**
30  * Panel that displays all {@link Controller}s of a {@link Controlled}
31  * component.
32  *
33  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
34  */
35 public class ControlledPane extends JPanel {
36
37         /**
38          * Creates a new controlled pane.
39          *
40          * @param controlled
41          *              The controlled whose controllers to display
42          */
43         public ControlledPane(Controlled controlled) {
44                 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
45                 for (Controller controller : controlled.controllers()) {
46                         if (controller instanceof Fader) {
47                                 add(new FaderPanel((Fader) controller));
48                         } else if (controller instanceof Switch) {
49                                 add(new SwitchPanel((Switch) controller));
50                         }
51                 }
52                 add(Box.createGlue());
53         }
54
55 }