25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
26 |
import java.awt.Color; |
import java.awt.Color; |
27 |
import java.awt.Dimension; |
import java.awt.Dimension; |
28 |
|
import java.awt.Font; |
29 |
import java.awt.GridBagConstraints; |
import java.awt.GridBagConstraints; |
30 |
import java.awt.GridBagLayout; |
import java.awt.GridBagLayout; |
31 |
import java.awt.Insets; |
import java.awt.Insets; |
39 |
|
|
40 |
import org.jsampler.CC; |
import org.jsampler.CC; |
41 |
|
|
42 |
|
import org.jsampler.event.SamplerChannelListEvent; |
43 |
|
import org.jsampler.event.SamplerChannelListListener; |
44 |
import org.jsampler.event.SamplerEvent; |
import org.jsampler.event.SamplerEvent; |
45 |
import org.jsampler.event.SamplerListener; |
import org.jsampler.event.SamplerListener; |
46 |
|
|
52 |
* @author Grigor Iliev |
* @author Grigor Iliev |
53 |
*/ |
*/ |
54 |
public class Statusbar extends JPanel { |
public class Statusbar extends JPanel { |
55 |
|
JLabel l1; |
56 |
|
JLabel l2; |
57 |
|
|
58 |
private final JProgressBar pbTotalVoices = new JProgressBar(); |
private final JProgressBar pbTotalVoices = new JProgressBar(); |
59 |
|
|
60 |
/** Creates a new instance of StatusBar */ |
/** Creates a new instance of StatusBar */ |
63 |
GridBagConstraints c = new GridBagConstraints(); |
GridBagConstraints c = new GridBagConstraints(); |
64 |
setLayout(gridbag); |
setLayout(gridbag); |
65 |
|
|
66 |
JLabel l1 = new JLabel(" "); |
l1 = new JLabel(); |
67 |
|
l1.setFont(l1.getFont().deriveFont(Font.PLAIN)); |
68 |
l1.setBorder(BorderFactory.createLoweredBevelBorder()); |
l1.setBorder(BorderFactory.createLoweredBevelBorder()); |
69 |
|
|
70 |
JLabel l2 = new JLabel(" "); |
l2 = new JLabel(" "); |
71 |
l2.setBorder(BorderFactory.createLoweredBevelBorder()); |
l2.setBorder(BorderFactory.createLoweredBevelBorder()); |
72 |
|
l2.setPreferredSize(l1.getPreferredSize()); |
73 |
|
|
74 |
|
setTotalChannelCount(CC.getSamplerModel().getChannelCount()); |
75 |
|
|
76 |
JPanel progressPane = new JPanel(); |
JPanel progressPane = new JPanel(); |
77 |
progressPane.setLayout(new BorderLayout()); |
progressPane.setLayout(new BorderLayout()); |
110 |
getHandler().totalVoiceCountChanged(null); |
getHandler().totalVoiceCountChanged(null); |
111 |
|
|
112 |
CC.getSamplerModel().addSamplerListener(getHandler()); |
CC.getSamplerModel().addSamplerListener(getHandler()); |
113 |
|
CC.getSamplerModel().addSamplerChannelListListener(getHandler()); |
114 |
|
} |
115 |
|
|
116 |
|
private void |
117 |
|
setTotalChannelCount(int count) { |
118 |
|
if(count == 1) l1.setText(" " + i18n.getLabel("Statusbar.totalChannel", count)); |
119 |
|
else l1.setText(" " + i18n.getLabel("Statusbar.totalChannels", count)); |
120 |
|
l2.setPreferredSize(l1.getPreferredSize()); |
121 |
} |
} |
122 |
|
|
123 |
private final Handler handler = new Handler(); |
private final Handler handler = new Handler(); |
125 |
private Handler |
private Handler |
126 |
getHandler() { return handler; } |
getHandler() { return handler; } |
127 |
|
|
128 |
private class Handler implements SamplerListener { |
private class Handler implements SamplerListener, SamplerChannelListListener { |
129 |
/** Invoked when the total number of active voices is changed. */ |
/** Invoked when the total number of active voices is changed. */ |
130 |
public void |
public void |
131 |
totalVoiceCountChanged(SamplerEvent e) { |
totalVoiceCountChanged(SamplerEvent e) { |
135 |
pbTotalVoices.setValue(voices); |
pbTotalVoices.setValue(voices); |
136 |
pbTotalVoices.setString(i18n.getLabel("Statusbar.pbTotalVoices", voices)); |
pbTotalVoices.setString(i18n.getLabel("Statusbar.pbTotalVoices", voices)); |
137 |
} |
} |
138 |
|
|
139 |
|
/** |
140 |
|
* Invoked when a new sampler channel is created. |
141 |
|
* @param e A <code>SamplerChannelListEvent</code> |
142 |
|
* instance providing the event information. |
143 |
|
*/ |
144 |
|
public void |
145 |
|
channelAdded(SamplerChannelListEvent e) { |
146 |
|
setTotalChannelCount(CC.getSamplerModel().getChannelCount()); |
147 |
|
} |
148 |
|
|
149 |
|
/** |
150 |
|
* Invoked when a sampler channel is removed. |
151 |
|
* @param e A <code>SamplerChannelListEvent</code> |
152 |
|
* instance providing the event information. |
153 |
|
*/ |
154 |
|
public void |
155 |
|
channelRemoved(SamplerChannelListEvent e) { |
156 |
|
setTotalChannelCount(CC.getSamplerModel().getChannelCount()); |
157 |
|
} |
158 |
} |
} |
159 |
} |
} |