1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.fantasia; |
24 |
|
25 |
import java.awt.BorderLayout; |
26 |
import java.awt.Dimension; |
27 |
import java.awt.Graphics; |
28 |
import java.awt.Insets; |
29 |
|
30 |
import java.beans.PropertyChangeEvent; |
31 |
import java.beans.PropertyChangeListener; |
32 |
|
33 |
import javax.swing.JPanel; |
34 |
|
35 |
import org.jvnet.substance.SubstanceLookAndFeel; |
36 |
import org.jvnet.substance.button.ClassicButtonShaper; |
37 |
import org.jvnet.substance.utils.SubstanceConstants.FocusKind; |
38 |
|
39 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
40 |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
41 |
|
42 |
/** |
43 |
* |
44 |
* @author Grigor Iliev |
45 |
*/ |
46 |
public class DevicesPane extends JPanel { |
47 |
private final TaskPaneContainer taskPaneContainer = new EnhancedTaskPaneContainer(); |
48 |
private final TaskPane midiDevicesTaskPane = new TaskPane(); |
49 |
private final TaskPane audioDevicesTaskPane = new TaskPane(); |
50 |
|
51 |
/** Creates a new instance of <code>DevicesPane</code> */ |
52 |
public |
53 |
DevicesPane() { |
54 |
setLayout(new BorderLayout()); |
55 |
midiDevicesTaskPane.setTitle(i18n.getLabel("DevicesPane.midiDevicesTaskPane")); |
56 |
midiDevicesTaskPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
57 |
|
58 |
preferences().addPropertyChangeListener(ANIMATED, new PropertyChangeListener() { |
59 |
public void |
60 |
propertyChange(PropertyChangeEvent e) { |
61 |
boolean b = preferences().getBoolProperty(ANIMATED); |
62 |
midiDevicesTaskPane.setAnimated(b); |
63 |
} |
64 |
}); |
65 |
|
66 |
audioDevicesTaskPane.setTitle(i18n.getLabel("DevicesPane.audioDevicesTaskPane")); |
67 |
audioDevicesTaskPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
68 |
|
69 |
preferences().addPropertyChangeListener(ANIMATED, new PropertyChangeListener() { |
70 |
public void |
71 |
propertyChange(PropertyChangeEvent e) { |
72 |
boolean b = preferences().getBoolProperty(ANIMATED); |
73 |
audioDevicesTaskPane.setAnimated(b); |
74 |
} |
75 |
}); |
76 |
|
77 |
midiDevicesTaskPane.putClientProperty ( |
78 |
SubstanceLookAndFeel.FOCUS_KIND, FocusKind.NONE |
79 |
); |
80 |
|
81 |
taskPaneContainer.putClientProperty ( |
82 |
SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY, new ClassicButtonShaper() |
83 |
); |
84 |
|
85 |
taskPaneContainer.add(midiDevicesTaskPane); |
86 |
taskPaneContainer.add(audioDevicesTaskPane); |
87 |
add(taskPaneContainer); |
88 |
|
89 |
midiDevicesTaskPane.add(new MidiDevicesPane()); |
90 |
audioDevicesTaskPane.add(new AudioDevicesPane()); |
91 |
|
92 |
taskPaneContainer.setOpaque(false); |
93 |
} |
94 |
|
95 |
class EnhancedTaskPaneContainer extends TaskPaneContainer { |
96 |
EnhancedTaskPaneContainer() { |
97 |
|
98 |
} |
99 |
|
100 |
protected void |
101 |
paintComponent(Graphics g) { |
102 |
super.paintComponent(g); |
103 |
PixmapPane.paintComponent(this, g, Res.gfxRoundBg14, new Insets(6, 6, 6, 6)); |
104 |
|
105 |
} |
106 |
} |
107 |
} |