--- jsampler/trunk/src/org/jsampler/view/classic/Statusbar.java 2006/03/04 16:23:53 841
+++ jsampler/trunk/src/org/jsampler/view/classic/Statusbar.java 2006/03/16 18:08:34 842
@@ -25,6 +25,7 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
@@ -38,6 +39,8 @@
import org.jsampler.CC;
+import org.jsampler.event.SamplerChannelListEvent;
+import org.jsampler.event.SamplerChannelListListener;
import org.jsampler.event.SamplerEvent;
import org.jsampler.event.SamplerListener;
@@ -49,6 +52,9 @@
* @author Grigor Iliev
*/
public class Statusbar extends JPanel {
+ JLabel l1;
+ JLabel l2;
+
private final JProgressBar pbTotalVoices = new JProgressBar();
/** Creates a new instance of StatusBar */
@@ -57,11 +63,15 @@
GridBagConstraints c = new GridBagConstraints();
setLayout(gridbag);
- JLabel l1 = new JLabel(" ");
+ l1 = new JLabel();
+ l1.setFont(l1.getFont().deriveFont(Font.PLAIN));
l1.setBorder(BorderFactory.createLoweredBevelBorder());
- JLabel l2 = new JLabel(" ");
+ l2 = new JLabel(" ");
l2.setBorder(BorderFactory.createLoweredBevelBorder());
+ l2.setPreferredSize(l1.getPreferredSize());
+
+ setTotalChannelCount(CC.getSamplerModel().getChannelCount());
JPanel progressPane = new JPanel();
progressPane.setLayout(new BorderLayout());
@@ -100,6 +110,14 @@
getHandler().totalVoiceCountChanged(null);
CC.getSamplerModel().addSamplerListener(getHandler());
+ CC.getSamplerModel().addSamplerChannelListListener(getHandler());
+ }
+
+ private void
+ setTotalChannelCount(int count) {
+ if(count == 1) l1.setText(" " + i18n.getLabel("Statusbar.totalChannel", count));
+ else l1.setText(" " + i18n.getLabel("Statusbar.totalChannels", count));
+ l2.setPreferredSize(l1.getPreferredSize());
}
private final Handler handler = new Handler();
@@ -107,7 +125,7 @@
private Handler
getHandler() { return handler; }
- private class Handler implements SamplerListener {
+ private class Handler implements SamplerListener, SamplerChannelListListener {
/** Invoked when the total number of active voices is changed. */
public void
totalVoiceCountChanged(SamplerEvent e) {
@@ -117,5 +135,25 @@
pbTotalVoices.setValue(voices);
pbTotalVoices.setString(i18n.getLabel("Statusbar.pbTotalVoices", voices));
}
+
+ /**
+ * Invoked when a new sampler channel is created.
+ * @param e A SamplerChannelListEvent
+ * instance providing the event information.
+ */
+ public void
+ channelAdded(SamplerChannelListEvent e) {
+ setTotalChannelCount(CC.getSamplerModel().getChannelCount());
+ }
+
+ /**
+ * Invoked when a sampler channel is removed.
+ * @param e A SamplerChannelListEvent
+ * instance providing the event information.
+ */
+ public void
+ channelRemoved(SamplerChannelListEvent e) {
+ setTotalChannelCount(CC.getSamplerModel().getChannelCount());
+ }
}
}