1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
26 |
import java.awt.Color; |
import java.awt.Color; |
27 |
import java.awt.Dimension; |
import java.awt.Dimension; |
28 |
import java.awt.Graphics; |
import java.awt.Graphics; |
29 |
|
import java.awt.Graphics2D; |
30 |
import java.awt.Insets; |
import java.awt.Insets; |
31 |
|
|
32 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
39 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
40 |
import javax.swing.Box; |
import javax.swing.Box; |
41 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
|
import javax.swing.JButton; |
|
42 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
43 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
44 |
import javax.swing.JScrollPane; |
import javax.swing.JScrollPane; |
65 |
*/ |
*/ |
66 |
public class MidiInstrumentsPane extends JPanel { |
public class MidiInstrumentsPane extends JPanel { |
67 |
private final JPanel taskPaneContainer = new JPanel(); |
private final JPanel taskPaneContainer = new JPanel(); |
68 |
private final TaskPane mapsTaskPane = new TaskPane(); |
private final FantasiaTaskPane mapsTaskPane = new FantasiaTaskPane(); |
69 |
|
|
70 |
private ManageMapsPane manageMapsPane = new ManageMapsPane(); |
private ManageMapsPane manageMapsPane = new ManageMapsPane(); |
71 |
private final InstrumentsPane instrumentsPane = new InstrumentsPane(); |
private final InstrumentsPane instrumentsPane = new InstrumentsPane(); |
80 |
setOpaque(false); |
setOpaque(false); |
81 |
|
|
82 |
mapsTaskPane.setTitle(i18n.getLabel("MidiInstrumentsPane.mapsTaskPane")); |
mapsTaskPane.setTitle(i18n.getLabel("MidiInstrumentsPane.mapsTaskPane")); |
83 |
mapsTaskPane.add(manageMapsPane); |
|
84 |
|
FantasiaSubPanel fsp = new FantasiaSubPanel(false, true, false); |
85 |
|
fsp.add(manageMapsPane); |
86 |
|
mapsTaskPane.add(fsp); |
87 |
boolean b; |
boolean b; |
88 |
mapsTaskPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
mapsTaskPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
89 |
b = preferences().getBoolProperty("MidiInstrumentsPane.mapsTaskPane.expanded"); |
b = preferences().getBoolProperty("MidiInstrumentsPane.mapsTaskPane.expanded"); |
129 |
preferences().setBoolProperty("MidiInstrumentsPane.mapsTaskPane.expanded", b); |
preferences().setBoolProperty("MidiInstrumentsPane.mapsTaskPane.expanded", b); |
130 |
} |
} |
131 |
|
|
|
static class ToolBar extends JToolBar { |
|
|
private static Insets pixmapInsets = new Insets(1, 1, 1, 1); |
|
|
|
|
|
ToolBar() { |
|
|
setFloatable(false); |
|
|
setOpaque(false); |
|
|
setPreferredSize(new Dimension(77, 29)); |
|
|
setMinimumSize(getPreferredSize()); |
|
|
} |
|
|
|
|
|
protected void |
|
|
paintComponent(Graphics g) { |
|
|
super.paintComponent(g); |
|
|
|
|
|
PixmapPane.paintComponent(this, g, Res.gfxCreateChannel, pixmapInsets); |
|
|
} |
|
|
} |
|
|
|
|
132 |
class ManageMapsPane extends JSManageMidiMapsPane { |
class ManageMapsPane extends JSManageMidiMapsPane { |
133 |
ManageMapsPane() { |
ManageMapsPane() { |
134 |
actionAddMap.putValue(Action.SMALL_ICON, Res.iconNew16); |
actionAddMap.putValue(Action.SMALL_ICON, Res.iconNew16); |
137 |
|
|
138 |
removeAll(); |
removeAll(); |
139 |
|
|
140 |
ToolBar toolBar = new ToolBar(); |
JToolBar toolBar = FantasiaUtils.createSubToolBar(); |
141 |
toolBar.add(new ToolbarButton(actionAddMap)); |
toolBar.add(new ToolbarButton(actionAddMap)); |
142 |
toolBar.add(new ToolbarButton(actionEditMap)); |
toolBar.add(new ToolbarButton(actionEditMap)); |
143 |
toolBar.add(new ToolbarButton(actionRemoveMap)); |
toolBar.add(new ToolbarButton(actionRemoveMap)); |
146 |
JScrollPane sp = new JScrollPane(midiMapTable); |
JScrollPane sp = new JScrollPane(midiMapTable); |
147 |
sp.setPreferredSize(new Dimension(120, 130)); |
sp.setPreferredSize(new Dimension(120, 130)); |
148 |
|
|
149 |
PixmapPane p = new PixmapPane(Res.gfxChannelOptions); |
JPanel p = FantasiaUtils.createBottomSubPane(); |
150 |
p.setPixmapInsets(new Insets(1, 1, 1, 1)); |
p.add(sp); |
|
p.setLayout(new BorderLayout()); |
|
|
p.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
|
|
|
|
|
PixmapPane p2 = new PixmapPane(Res.gfxBorder); |
|
|
p2.setPixmapInsets(new Insets(1, 1, 1, 1)); |
|
|
p2.setLayout(new BorderLayout()); |
|
|
p2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
|
|
p2.add(sp); |
|
|
p.add(p2); |
|
|
|
|
151 |
add(p); |
add(p); |
152 |
} |
} |
153 |
|
|
154 |
|
@Override |
155 |
|
protected void |
156 |
|
paintComponent(Graphics g) { |
157 |
|
super.paintComponent(g); |
158 |
|
|
159 |
|
double h = getSize().getHeight(); |
160 |
|
double w = getSize().getWidth(); |
161 |
|
|
162 |
|
FantasiaPainter.paintGradient((Graphics2D)g, 0, 0, w - 1, h - 1); |
163 |
|
|
164 |
|
FantasiaPainter.RoundCorners rc = |
165 |
|
new FantasiaPainter.RoundCorners(true, false, false, true); |
166 |
|
|
167 |
|
FantasiaPainter.paintOuterBorder((Graphics2D)g, 0, 0, w - 1, h - 1, rc); |
168 |
|
} |
169 |
} |
} |
170 |
|
|
171 |
class MapsPane extends JPanel { |
class MapsPane extends JPanel { |
172 |
MapsPane() { |
MapsPane() { |
173 |
setOpaque(false); |
setOpaque(false); |
174 |
setLayout(new BorderLayout()); |
setLayout(new BorderLayout()); |
175 |
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); |
176 |
|
|
177 |
PixmapPane p = new PixmapPane(Res.gfxChannelOptions); |
FantasiaSubPanel p2 = new FantasiaSubPanel(true, false); |
|
p.setPixmapInsets(new Insets(1, 1, 1, 1)); |
|
|
p.setLayout(new BorderLayout()); |
|
|
p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
|
|
|
|
|
PixmapPane p2 = new PixmapPane(Res.gfxRoundBg7); |
|
|
p2.setPixmapInsets(new Insets(3, 3, 3, 3)); |
|
|
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
|
178 |
p2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
p2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
179 |
p2.add(cbMaps); |
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS)); |
180 |
p2.add(Box.createRigidArea(new Dimension(0, 5))); |
|
181 |
p2.add(instrumentsPane); |
JPanel p = new FantasiaPanel(); |
182 |
|
p.setOpaque(false); |
183 |
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
184 |
|
p.add(cbMaps); |
185 |
|
p.setBorder(BorderFactory.createEmptyBorder(3, 1, 5, 1)); |
186 |
|
p2.add(p); |
187 |
|
|
188 |
|
FantasiaSubPanel fsp = new FantasiaSubPanel(false, true, false); |
189 |
|
fsp.add(instrumentsPane); |
190 |
|
|
191 |
|
p2.add(fsp); |
192 |
|
|
193 |
add(p2); |
add(p2); |
194 |
} |
} |
202 |
|
|
203 |
removeAll(); |
removeAll(); |
204 |
|
|
205 |
ToolBar toolBar = new ToolBar(); |
JToolBar toolBar = FantasiaUtils.createSubToolBar(); |
206 |
toolBar.add(new ToolbarButton(actionAddInstrument)); |
toolBar.add(new ToolbarButton(actionAddInstrument)); |
207 |
toolBar.add(new ToolbarButton(actionEditInstrument)); |
toolBar.add(new ToolbarButton(actionEditInstrument)); |
208 |
toolBar.add(new ToolbarButton(actionRemove)); |
toolBar.add(new ToolbarButton(actionRemove)); |
209 |
|
|
|
toolBar.setFloatable(false); |
|
210 |
add(toolBar, java.awt.BorderLayout.NORTH); |
add(toolBar, java.awt.BorderLayout.NORTH); |
211 |
|
|
212 |
JScrollPane sp = new JScrollPane(midiInstrumentTree); |
JScrollPane sp = new JScrollPane(midiInstrumentTree); |
214 |
d = new Dimension(sp.getMinimumSize().width, sp.getPreferredSize().height); |
d = new Dimension(sp.getMinimumSize().width, sp.getPreferredSize().height); |
215 |
sp.setPreferredSize(d); |
sp.setPreferredSize(d); |
216 |
|
|
217 |
PixmapPane p = new PixmapPane(Res.gfxChannelOptions); |
JPanel p = FantasiaUtils.createBottomSubPane(); |
218 |
p.setPixmapInsets(new Insets(1, 1, 1, 1)); |
p.add(sp); |
|
p.setLayout(new BorderLayout()); |
|
|
p.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
|
|
|
|
|
PixmapPane p2 = new PixmapPane(Res.gfxBorder); |
|
|
p2.setPixmapInsets(new Insets(1, 1, 1, 1)); |
|
|
p2.setLayout(new BorderLayout()); |
|
|
p2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
|
|
p2.add(sp); |
|
|
p.add(p2); |
|
219 |
|
|
220 |
add(p); |
add(p); |
221 |
} |
} |
222 |
|
|
223 |
|
@Override |
224 |
public void |
public void |
225 |
addInstrument() { |
addInstrument() { |
226 |
MidiInstrumentMap map = (MidiInstrumentMap)cbMaps.getSelectedItem(); |
MidiInstrumentMap map = (MidiInstrumentMap)cbMaps.getSelectedItem(); |
253 |
|
|
254 |
private class Handler implements ListListener<MidiInstrumentMap> { |
private class Handler implements ListListener<MidiInstrumentMap> { |
255 |
/** Invoked when an orchestra is added to the orchestra list. */ |
/** Invoked when an orchestra is added to the orchestra list. */ |
256 |
|
@Override |
257 |
public void |
public void |
258 |
entryAdded(ListEvent<MidiInstrumentMap> e) { |
entryAdded(ListEvent<MidiInstrumentMap> e) { |
259 |
if(cbMaps.getItemCount() == 0) cbMaps.setEnabled(true); |
if(cbMaps.getItemCount() == 0) cbMaps.setEnabled(true); |
261 |
} |
} |
262 |
|
|
263 |
/** Invoked when an orchestra is removed from the orchestra list. */ |
/** Invoked when an orchestra is removed from the orchestra list. */ |
264 |
|
@Override |
265 |
public void |
public void |
266 |
entryRemoved(ListEvent<MidiInstrumentMap> e) { |
entryRemoved(ListEvent<MidiInstrumentMap> e) { |
267 |
cbMaps.removeItem(e.getEntry()); |
cbMaps.removeItem(e.getEntry()); |