/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/MainPane.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/fantasia/MainPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1871 by iliev, Wed Dec 24 17:29:47 2008 UTC revision 1872 by iliev, Mon Mar 23 15:34:50 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 59  import static org.jsampler.view.fantasia Line 59  import static org.jsampler.view.fantasia
59   * @author Grigor Iliev   * @author Grigor Iliev
60   */   */
61  public class MainPane extends FantasiaPanel {  public class MainPane extends FantasiaPanel {
         private final int CHANNELS_PANEL_NUMBER = 4;  
62          private final ChannelsBar channelsBar;          private final ChannelsBar channelsBar;
63          private final ButtonsPanel buttonsPanel;          private final ButtonsPanel buttonsPanel;
64          private final Vector<ChannelsPanel> channelsPanes = new Vector<ChannelsPanel>();          private final Vector<ChannelsPanel> channelsPanes = new Vector<ChannelsPanel>();
# Line 69  public class MainPane extends FantasiaPa Line 68  public class MainPane extends FantasiaPa
68          /** Creates a new instance of <code>MainPane</code> */          /** Creates a new instance of <code>MainPane</code> */
69          public MainPane() {          public MainPane() {
70                  setOpaque(false);                  setOpaque(false);
71                    
72                  for(int i = 0; i < CHANNELS_PANEL_NUMBER; i++) {                  int count = CC.preferences().getIntProperty("channelLanes.count");
73                    for(int i = 0; i < count; i++) {
74                          String s = i18n.getButtonLabel("MainPane.ButtonsPanel.tt", i + 1);                          String s = i18n.getButtonLabel("MainPane.ButtonsPanel.tt", i + 1);
75                          channelsPanes.add(new ChannelsPanel(s));                          channelsPanes.add(new ChannelsPanel(s));
76                  }                  }
77                                    
78                  buttonsPanel = new ButtonsPanel();                  buttonsPanel = new ButtonsPanel(count);
79                    if(count == 1) buttonsPanel.setVisible(false);
80                  channelsBar = new ChannelsBar(buttonsPanel);                  channelsBar = new ChannelsBar(buttonsPanel);
81                  GridBagLayout gridbag = new GridBagLayout();                  GridBagLayout gridbag = new GridBagLayout();
82                  GridBagConstraints c = new GridBagConstraints();                  GridBagConstraints c = new GridBagConstraints();
# Line 131  public class MainPane extends FantasiaPa Line 132  public class MainPane extends FantasiaPa
132                                    
133                  setMaximumSize(new Dimension(420, Short.MAX_VALUE));                  setMaximumSize(new Dimension(420, Short.MAX_VALUE));
134          }          }
135    
136            public JSChannelsPane
137            addChannelsPane() {
138                    String s = i18n.getButtonLabel("MainPane.ButtonsPanel.tt", channelsPanes.size() + 1);
139                    ChannelsPanel cp = new ChannelsPanel(s);
140                    channelsPanes.add(cp);
141                    return cp.getChannelsPane();
142            }
143                    
144          private void          private void
145          onScrollBarVisibilityChanged() {          onScrollBarVisibilityChanged() {
# Line 166  public class MainPane extends FantasiaPa Line 175  public class MainPane extends FantasiaPa
175                    
176          public int          public int
177          getChannelsPaneCount() { return channelsPanes.size(); }          getChannelsPaneCount() { return channelsPanes.size(); }
178    
179            public void
180            removeChannelsPane(int index) { channelsPanes.remove(index); }
181                    
182          public void          public void
183          setSelectedChannelsPane(JSChannelsPane pane) {          setSelectedChannelsPane(JSChannelsPane pane) {
# Line 201  public class MainPane extends FantasiaPa Line 213  public class MainPane extends FantasiaPa
213                                    
214                  return null;                  return null;
215          }          }
216    
217            public ButtonsPanel
218            getButtonsPanel() { return buttonsPanel; }
219                    
220          @Override          @Override
221          protected void          protected void
# Line 259  public class MainPane extends FantasiaPa Line 274  public class MainPane extends FantasiaPa
274                  getChannelsPane() { return channelsPane; }                  getChannelsPane() { return channelsPane; }
275          }          }
276                    
277          private class ButtonsPanel extends FantasiaToggleButtonsPanel implements ActionListener {          public class ButtonsPanel extends FantasiaToggleButtonsPanel implements ActionListener {
278                  ButtonsPanel() {                  public
279                          super(CHANNELS_PANEL_NUMBER, true);                  ButtonsPanel(int count) {
280                          for(int i = 0; i < CHANNELS_PANEL_NUMBER; i++) {                          super(count, true);
281                            setButtonNumber(count);
282                    }
283                    
284                    @Override
285                    public void
286                    setButtonNumber(int number) {
287                            if(number > MainFrame.MAX_CHANNEL_LANE_NUMBER) return;
288                            int j = number == 7 ? 98 : 96;
289                            int k = j / number;
290    
291                            for(int i = 0; i < buttons.size(); i++) {
292                                    buttons.get(i).removeActionListener(this);
293                            }
294    
295                            super.setButtonNumber(number);
296    
297                            for(int i = 0; i < number; i++) {
298                                  JToggleButton btn = buttons.get(i);                                  JToggleButton btn = buttons.get(i);
299                                  btn.setText(String.valueOf(i + 1));                                  btn.setText(String.valueOf(i + 1));
300                                  btn.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));                                  btn.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
301                                  btn.addActionListener(this);                                  btn.addActionListener(this);
302                                                                    btn.setMinimumSize(new Dimension(k, btn.getPreferredSize().height));
303                                    btn.setPreferredSize(btn.getMinimumSize());
304                                    btn.setMaximumSize(btn.getMinimumSize());
305                                  String s = "MainPane.ButtonsPanel.tt";                                  String s = "MainPane.ButtonsPanel.tt";
306                                  btn.setToolTipText(i18n.getButtonLabel(s, i + 1));                                  btn.setToolTipText(i18n.getButtonLabel(s, i + 1));
307                          }                          }

Legend:
Removed from v.1871  
changed lines
  Added in v.1872

  ViewVC Help
Powered by ViewVC