/[svn]/jsampler/trunk/src/org/jsampler/view/classic/Statusbar.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/classic/Statusbar.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 787 - (show annotations) (download)
Mon Oct 10 16:03:12 2005 UTC (18 years, 6 months ago) by iliev
File size: 3482 byte(s)
* The first alpha-release of JSampler

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005 Grigor Kirilov Iliev
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.classic;
24
25 import java.awt.BorderLayout;
26 import java.awt.Color;
27 import java.awt.Dimension;
28 import java.awt.GridBagConstraints;
29 import java.awt.GridBagLayout;
30 import java.awt.Insets;
31
32 import javax.swing.BorderFactory;
33 import javax.swing.Box;
34 import javax.swing.BoxLayout;
35 import javax.swing.JLabel;
36 import javax.swing.JPanel;
37 import javax.swing.JProgressBar;
38
39 import org.jsampler.CC;
40
41 import org.jsampler.event.SamplerEvent;
42 import org.jsampler.event.SamplerListener;
43
44 import static org.jsampler.view.classic.ClassicI18n.i18n;
45
46
47 /**
48 *
49 * @author Grigor Iliev
50 */
51 public class Statusbar extends JPanel {
52 private final JProgressBar pbTotalVoices = new JProgressBar();
53
54 /** Creates a new instance of StatusBar */
55 public Statusbar() {
56 GridBagLayout gridbag = new GridBagLayout();
57 GridBagConstraints c = new GridBagConstraints();
58 setLayout(gridbag);
59
60 JLabel l1 = new JLabel(" ");
61 l1.setBorder(BorderFactory.createLoweredBevelBorder());
62
63 JLabel l2 = new JLabel(" ");
64 l2.setBorder(BorderFactory.createLoweredBevelBorder());
65
66 JPanel progressPane = new JPanel();
67 progressPane.setLayout(new BorderLayout());
68 progressPane.add(pbTotalVoices, BorderLayout.CENTER);
69 progressPane.setBorder(BorderFactory.createLoweredBevelBorder());
70
71 pbTotalVoices.setBorderPainted(false);
72 pbTotalVoices.setStringPainted(true);
73 float fsize = pbTotalVoices.getFont().getSize2D();
74 fsize = fsize > 10 ? fsize - 3 : 8;
75 pbTotalVoices.setFont(pbTotalVoices.getFont().deriveFont(fsize));
76
77 c.gridx = 0;
78 c.gridy = 0;
79 c.insets = new Insets(2, 0, 0, 2);
80 //c.anchor = GridBagConstraints.WEST;
81 c.weightx = 1;
82 c.weighty = 0;
83 c.fill = GridBagConstraints.HORIZONTAL;
84 gridbag.setConstraints(l1, c);
85 add(l1);
86
87 c.gridx = 1;
88 c.gridy = 0;
89 c.weightx = 0.3;
90 gridbag.setConstraints(progressPane, c);
91 add(progressPane);
92
93 c.gridx = 2;
94 c.gridy = 0;
95 c.weightx = 1;
96 c.insets = new Insets(2, 0, 0, 0);
97 gridbag.setConstraints(l2, c);
98 add(l2);
99
100 getHandler().totalVoiceCountChanged(null);
101
102 CC.getSamplerModel().addSamplerListener(getHandler());
103 }
104
105 private final Handler handler = new Handler();
106
107 private Handler
108 getHandler() { return handler; }
109
110 private class Handler implements SamplerListener {
111 /** Invoked when the total number of active voices is changed. */
112 public void
113 totalVoiceCountChanged(SamplerEvent e) {
114 int voices = CC.getSamplerModel().getTotalVoiceCount();
115 int voicesMax = CC.getSamplerModel().getTotalVoiceCountMax();
116 pbTotalVoices.setMaximum(voicesMax);
117 pbTotalVoices.setValue(voices);
118 pbTotalVoices.setString(i18n.getLabel("Statusbar.pbTotalVoices", voices));
119 }
120 }
121 }

  ViewVC Help
Powered by ViewVC