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

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

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

revision 1767 by iliev, Mon Sep 8 00:19:27 2008 UTC revision 1975 by iliev, Mon Aug 3 14:54:18 2009 UTC
# Line 39  import java.text.NumberFormat; Line 39  import java.text.NumberFormat;
39  import javax.swing.AbstractAction;  import javax.swing.AbstractAction;
40  import javax.swing.Action;  import javax.swing.Action;
41  import javax.swing.BoxLayout;  import javax.swing.BoxLayout;
 import javax.swing.ButtonGroup;  
 import javax.swing.DefaultListCellRenderer;  
42  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
43  import javax.swing.JButton;  import javax.swing.JButton;
44  import javax.swing.JComponent;  import javax.swing.JComponent;
# Line 48  import javax.swing.JLabel; Line 46  import javax.swing.JLabel;
46  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
47  import javax.swing.JPanel;  import javax.swing.JPanel;
48  import javax.swing.JPopupMenu;  import javax.swing.JPopupMenu;
 import javax.swing.JRadioButtonMenuItem;  
49  import javax.swing.JScrollPane;  import javax.swing.JScrollPane;
 import javax.swing.JToggleButton;  
50  import javax.swing.JToolBar;  import javax.swing.JToolBar;
51    
 import net.sf.juife.InformationDialog;  
 import net.sf.juife.TitleBar;  
   
52  import org.jdesktop.swingx.JXCollapsiblePane;  import org.jdesktop.swingx.JXCollapsiblePane;
53    
54  import org.jsampler.CC;  import org.jsampler.CC;
# Line 70  import org.jsampler.event.SamplerChannel Line 63  import org.jsampler.event.SamplerChannel
63  import org.jsampler.view.JSChannel;  import org.jsampler.view.JSChannel;
64  import org.jsampler.view.JSChannelsPane;  import org.jsampler.view.JSChannelsPane;
65    
66    import org.jsampler.view.fantasia.basic.PixmapToggleButton;
67    
68  import org.jsampler.view.std.JSChannelOutputRoutingDlg;  import org.jsampler.view.std.JSChannelOutputRoutingDlg;
69  import org.jsampler.view.std.JSFxSendsDlg;  import org.jsampler.view.std.JSFxSendsDlg;
70  import org.jsampler.view.std.JSFxSendsPane;  import org.jsampler.view.std.JSFxSendsPane;
# Line 78  import org.jsampler.view.std.JSVolumeEdi Line 73  import org.jsampler.view.std.JSVolumeEdi
73    
74  import org.linuxsampler.lscp.SamplerChannel;  import org.linuxsampler.lscp.SamplerChannel;
75    
76    import static org.jsampler.view.fantasia.A4n.a4n;
77  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
78  import static org.jsampler.view.fantasia.FantasiaPrefs.*;  import static org.jsampler.view.fantasia.FantasiaPrefs.*;
79  import static org.jsampler.view.fantasia.FantasiaUtils.*;  import static org.jsampler.view.fantasia.FantasiaUtils.*;
# Line 123  public class Channel extends JSChannel { Line 119  public class Channel extends JSChannel {
119                    
120          private static void          private static void
121          mouseMoved() {          mouseMoved() {
122                  //TODO: do this for all channels panes                  JSChannelsPane cp = CC.getMainFrame().getSelectedChannelsPane();
                 JSChannelsPane cp = CC.getMainFrame().getChannelsPane(0);  
123                  for(int i = 0; i < cp.getChannelCount(); i++) {                  for(int i = 0; i < cp.getChannelCount(); i++) {
124                          mouseMoved((Channel)cp.getChannel(i));                          mouseMoved((Channel)cp.getChannel(i));
125                  }                  }
# Line 175  public class Channel extends JSChannel { Line 170  public class Channel extends JSChannel {
170           */           */
171          public          public
172          Channel(SamplerChannelModel model, final ActionListener listener) {          Channel(SamplerChannelModel model, final ActionListener listener) {
173                    this (
174                            model, listener,
175                            preferences().getIntProperty(DEFAULT_CHANNEL_VIEW) == 0 ?
176                                    ChannelView.Type.SMALL : ChannelView.Type.NORMAL
177                    );
178            }
179            
180            /**
181             * Creates a new instance of <code>Channel</code> using the specified
182             * non-<code>null</code> channel model.
183             * @param model The model to be used by this channel.
184             * @param listener A listener which is notified when the newly created
185             * channel is fully expanded on the screen.
186             * @param type Specifies the view type to be used.
187             * @throws IllegalArgumentException If the model is <code>null</code>.
188             */
189            public
190            Channel(SamplerChannelModel model, final ActionListener listener, ChannelView.Type type) {
191                  super(model);                  super(model);
192                                    
193                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
# Line 188  public class Channel extends JSChannel { Line 201  public class Channel extends JSChannel {
201                          new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS)                          new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS)
202                  );                  );
203                                    
204                  int viewIdx = preferences().getIntProperty(DEFAULT_CHANNEL_VIEW);                  switch(type) {
205                  if(viewIdx == 0) {                          case SMALL: viewTracker.setView(new SmallChannelView(Channel.this)); break;
206                          viewTracker.setView(new SmallChannelView(Channel.this));                          case NORMAL: viewTracker.setView(new NormalChannelView(Channel.this)); break;
207                  } else if(viewIdx == 1) {                          default: viewTracker.setView(new NormalChannelView(Channel.this));
                         viewTracker.setView(new NormalChannelView(Channel.this));  
                 } else {  
                         viewTracker.setView(new NormalChannelView(Channel.this));  
208                  }                  }
209                                    
210                  setOpaque(false);                  setOpaque(false);
# Line 286  public class Channel extends JSChannel { Line 296  public class Channel extends JSChannel {
296           * Determines whether the channel is selected.           * Determines whether the channel is selected.
297           * @return <code>true</code> if the channel is selected, <code>false</code> otherwise.           * @return <code>true</code> if the channel is selected, <code>false</code> otherwise.
298           */           */
299          public boolean isSelected() { return selected; }          @Override
300            public boolean
301            isSelected() { return selected; }
302                    
303          /**          /**
304           * Sets the selection state of this channel.           * Sets the selection state of this channel.
# Line 294  public class Channel extends JSChannel { Line 306  public class Channel extends JSChannel {
306           * @param select Specifies the new selection state of this channel;           * @param select Specifies the new selection state of this channel;
307           * <code>true</code> to select the channel, <code>false</code> otherwise.           * <code>true</code> to select the channel, <code>false</code> otherwise.
308           */           */
309            @Override
310          public void          public void
311          setSelected(boolean select) {          setSelected(boolean select) {
312                                    if(selected == select) return;
313                  selected = select;                  selected = select;
314                    repaint();
315          }          }
316                    
317          /** Shows the channel properties. */          /** Shows the channel properties. */
# Line 389  public class Channel extends JSChannel { Line 403  public class Channel extends JSChannel {
403                   * @param e A <code>SamplerChannelEvent</code> instance                   * @param e A <code>SamplerChannelEvent</code> instance
404                   * containing event information.                   * containing event information.
405                   */                   */
406                    @Override
407                  public void                  public void
408                  channelChanged(SamplerChannelEvent e) { updateChannelInfo(); }                  channelChanged(SamplerChannelEvent e) { updateChannelInfo(); }
409                    
# Line 397  public class Channel extends JSChannel { Line 412  public class Channel extends JSChannel {
412                   * @param e A <code>SamplerChannelEvent</code> instance                   * @param e A <code>SamplerChannelEvent</code> instance
413                   * containing event information.                   * containing event information.
414                   */                   */
415                    @Override
416                  public void                  public void
417                  streamCountChanged(SamplerChannelEvent e) {                  streamCountChanged(SamplerChannelEvent e) {
418                          viewTracker.getCurrentView().updateStreamCount(getModel().getStreamCount());                          viewTracker.getCurrentView().updateStreamCount(getModel().getStreamCount());
# Line 407  public class Channel extends JSChannel { Line 423  public class Channel extends JSChannel {
423                   * @param e A <code>SamplerChannelEvent</code> instance                   * @param e A <code>SamplerChannelEvent</code> instance
424                   * containing event information.                   * containing event information.
425                   */                   */
426                    @Override
427                  public void                  public void
428                  voiceCountChanged(SamplerChannelEvent e) {                  voiceCountChanged(SamplerChannelEvent e) {
429                          viewTracker.getCurrentView().updateVoiceCount(getModel().getVoiceCount());                          viewTracker.getCurrentView().updateVoiceCount(getModel().getVoiceCount());
# Line 417  public class Channel extends JSChannel { Line 434  public class Channel extends JSChannel {
434                   * @param e A <code>SamplerChannelListEvent</code>                   * @param e A <code>SamplerChannelListEvent</code>
435                   * instance providing the event information.                   * instance providing the event information.
436                   */                   */
437                    @Override
438                  public void                  public void
439                  channelAdded(SamplerChannelListEvent e) { }                  channelAdded(SamplerChannelListEvent e) { }
440                    
# Line 425  public class Channel extends JSChannel { Line 443  public class Channel extends JSChannel {
443                   * @param e A <code>SamplerChannelListEvent</code>                   * @param e A <code>SamplerChannelListEvent</code>
444                   * instance providing the event information.                   * instance providing the event information.
445                   */                   */
446                    @Override
447                  public void                  public void
448                  channelRemoved(SamplerChannelListEvent e) {                  channelRemoved(SamplerChannelListEvent e) {
449                          // Some cleanup when the channel is removed.                          // Some cleanup when the channel is removed.
# Line 433  public class Channel extends JSChannel { Line 452  public class Channel extends JSChannel {
452                          }                          }
453                  }                  }
454                                    
455                    @Override
456                  public void                  public void
457                  propertyChange(PropertyChangeEvent e) {                  propertyChange(PropertyChangeEvent e) {
458                          if(e.getNewValue() == "collapsed") {                          if(e.getNewValue() == "collapsed") {
# Line 661  public class Channel extends JSChannel { Line 681  public class Channel extends JSChannel {
681                          fallbackToOriginalView();                          fallbackToOriginalView();
682                  }                  }
683                                    
684                    @Override
685                  public void                  public void
686                  mouseEntered(MouseEvent e) {                  mouseEntered(MouseEvent e) {
687                          guiListener.actionPerformed(null);                          guiListener.actionPerformed(null);
688                  }                  }
689                                    
690                    @Override
691                  public void                  public void
692                  mouseExited(MouseEvent e) {                  mouseExited(MouseEvent e) {
693                          guiListener.actionPerformed(null);                          guiListener.actionPerformed(null);
694                  }                  }
695                                    
696                    @Override
697                  public void                  public void
698                  mousePressed(MouseEvent e) {                  mousePressed(MouseEvent e) {
699                          mousePressed = true;                          mousePressed = true;
700                  }                  }
701                                    
702                    @Override
703                  public void                  public void
704                  mouseReleased(MouseEvent e) {                  mouseReleased(MouseEvent e) {
705                          mousePressed = false;                          mousePressed = false;
# Line 703  public class Channel extends JSChannel { Line 727  public class Channel extends JSChannel {
727                          preferences().removePropertyChangeListener(s, this);                          preferences().removePropertyChangeListener(s, this);
728                  }                  }
729                                    
730                    @Override
731                  public void                  public void
732                  propertyChange(PropertyChangeEvent e) {                  propertyChange(PropertyChangeEvent e) {
733                          updateMouseOverViewType();                          updateMouseOverViewType();
# Line 716  public class Channel extends JSChannel { Line 741  public class Channel extends JSChannel {
741                          getModel().addSamplerChannelListener(this);                          getModel().addSamplerChannelListener(this);
742                  }                  }
743                                    
744                    @Override
745                  public void                  public void
746                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
747                          CC.getSamplerModel().editBackendInstrument(getChannelId());                          CC.getSamplerModel().editBackendInstrument(getChannelId());
748                  }                  }
749                                    
750                    @Override
751                  public void                  public void
752                  channelChanged(SamplerChannelEvent e) {                  channelChanged(SamplerChannelEvent e) {
753                          boolean b = getChannelInfo().getInstrumentStatus() == 100;                          boolean b = getChannelInfo().getInstrumentStatus() == 100;
754                          setEnabled(b);                          setEnabled(b);
755                  }                  }
756                                    
757                    @Override
758                  public void                  public void
759                  streamCountChanged(SamplerChannelEvent e) { }                  streamCountChanged(SamplerChannelEvent e) { }
760                                    
761                    @Override
762                  public void                  public void
763                  voiceCountChanged(SamplerChannelEvent e) { }                  voiceCountChanged(SamplerChannelEvent e) { }
764          }          }
# Line 739  public class Channel extends JSChannel { Line 768  public class Channel extends JSChannel {
768                          super(i18n.getMenuLabel("channels.fxSends"));                          super(i18n.getMenuLabel("channels.fxSends"));
769                  }                  }
770                                    
771                    @Override
772                  public void                  public void
773                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
774                          showFxSendsDialog();                          showFxSendsDialog();
# Line 752  public class Channel extends JSChannel { Line 782  public class Channel extends JSChannel {
782                          getModel().addSamplerChannelListener(this);                          getModel().addSamplerChannelListener(this);
783                  }                  }
784                                    
785                    @Override
786                  public void                  public void
787                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
788                          SamplerChannel c = getChannelInfo();                          SamplerChannel c = getChannelInfo();
789                          new JSChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true);                          new JSChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true);
790                  }                  }
791                                    
792                    @Override
793                  public void                  public void
794                  channelChanged(SamplerChannelEvent e) {                  channelChanged(SamplerChannelEvent e) {
795                          boolean b = getChannelInfo().getAudioOutputDevice() != -1;                          boolean b = getChannelInfo().getAudioOutputDevice() != -1;
796                          setEnabled(b);                          setEnabled(b);
797                  }                  }
798                                    
799                    @Override
800                  public void                  public void
801                  streamCountChanged(SamplerChannelEvent e) { }                  streamCountChanged(SamplerChannelEvent e) { }
802                                    
803                    @Override
804                  public void                  public void
805                  voiceCountChanged(SamplerChannelEvent e) { }                  voiceCountChanged(SamplerChannelEvent e) { }
806          }          }
807                    
         class SetSmallViewAction extends AbstractAction {  
                 SetSmallViewAction() {  
                         super(i18n.getMenuLabel("channels.smallView"));  
                 }  
                   
                 public void  
                 actionPerformed(ActionEvent e) {  
                         viewTracker.setView(new SmallChannelView(Channel.this));  
                 }  
         }  
           
         class SetNormalViewAction extends AbstractAction {  
                 SetNormalViewAction() {  
                         super(i18n.getMenuLabel("channels.normalView"));  
                 }  
                   
                 public void  
                 actionPerformed(ActionEvent e) {  
                         viewTracker.setView(new NormalChannelView(Channel.this));  
                 }  
         }  
           
808          public ContextMenu          public ContextMenu
809          getContextMenu() { return contextMenu; }          getContextMenu() { return contextMenu; }
810                    
811          class ContextMenu extends MouseAdapter {          class ContextMenu extends MouseAdapter {
812                  private JPopupMenu menu = null;                  private JPopupMenu menu = null;
813                                    
                 protected JRadioButtonMenuItem rbmiSmallView;  
                 protected JRadioButtonMenuItem rbmiNormalView;  
                   
814                  ContextMenu() {                  ContextMenu() {
815                                                    
816                  }                  }
# Line 812  public class Channel extends JSChannel { Line 821  public class Channel extends JSChannel {
821                          menu.add(new JMenuItem(new EditInstrumentAction()));                          menu.add(new JMenuItem(new EditInstrumentAction()));
822                          menu.addSeparator();                          menu.addSeparator();
823                                                    
824                          rbmiSmallView = new JRadioButtonMenuItem(new SetSmallViewAction());                          MenuManager.ChannelViewGroup group;
825                          rbmiNormalView = new JRadioButtonMenuItem(new SetNormalViewAction());                          group = new MenuManager.ChannelViewGroup(true, true);
826                          if(viewTracker.getOriginalView() instanceof SmallChannelView) {                          MenuManager.getMenuManager().registerChannelViewGroup(group);
                                 rbmiSmallView.setSelected(true);  
                         } else if(viewTracker.getOriginalView() instanceof NormalChannelView) {  
                                 rbmiNormalView.setSelected(true);  
                         }  
827                                                    
828                          ButtonGroup group = new ButtonGroup();                          for(JMenuItem mi : group.getMenuItems()) menu.add(mi);
                         group.add(rbmiSmallView);  
                         group.add(rbmiNormalView);  
829                                                    
830                          menu.add(rbmiSmallView);                          menu.addSeparator();
831                          menu.add(rbmiNormalView);                          
832                            menu.add(new JMenuItem(a4n.moveChannelsOnTop));
833                            menu.add(new JMenuItem(a4n.moveChannelsUp));
834                            menu.add(new JMenuItem(a4n.moveChannelsDown));
835                            menu.add(new JMenuItem(a4n.moveChannelsAtBottom));
836                            
837                            menu.add(new MainFrame.ToPanelMenu());
838                                                    
839                          menu.addSeparator();                          menu.addSeparator();
840                            
841                          menu.add(new JMenuItem(new FxSendsAction()));                          menu.add(new JMenuItem(new FxSendsAction()));
842                          menu.add(new JMenuItem(new ChannelRoutingAction()));                          menu.add(new JMenuItem(new ChannelRoutingAction()));
843                  }                  }
# Line 838  public class Channel extends JSChannel { Line 848  public class Channel extends JSChannel {
848                          return menu;                          return menu;
849                  }                  }
850                                    
851                    @Override
852                  public void                  public void
853                  mousePressed(MouseEvent e) {                  mousePressed(MouseEvent e) {
854                          if(e.isPopupTrigger()) show(e);                          if(e.isPopupTrigger()) show(e);
855                  }                  }
856                    
857                    @Override
858                  public void                  public void
859                  mouseReleased(MouseEvent e) {                  mouseReleased(MouseEvent e) {
860                          if(e.isPopupTrigger()) show(e);                          if(e.isPopupTrigger()) show(e);
# Line 862  public class Channel extends JSChannel { Line 874  public class Channel extends JSChannel {
874                          actionRemoveFxSend.putValue(Action.SMALL_ICON, Res.iconDelete16);                          actionRemoveFxSend.putValue(Action.SMALL_ICON, Res.iconDelete16);
875                  }                  }
876                                    
877                    @Override
878                  protected JToolBar                  protected JToolBar
879                  createToolBar() {                  createToolBar() {
880                          JToolBar tb = new JToolBar();                          JToolBar tb = new JToolBar();
# Line 1009  public class Channel extends JSChannel { Line 1022  public class Channel extends JSChannel {
1022                          setToolTipText(i18n.getButtonLabel("Channel.ttRemoveChannel"));                          setToolTipText(i18n.getButtonLabel("Channel.ttRemoveChannel"));
1023                  }                  }
1024                                    
1025                    @Override
1026                  public void                  public void
1027                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
1028                          boolean b = preferences().getBoolProperty(CONFIRM_CHANNEL_REMOVAL);                          boolean b = preferences().getBoolProperty(CONFIRM_CHANNEL_REMOVAL);
# Line 1022  public class Channel extends JSChannel { Line 1036  public class Channel extends JSChannel {
1036                          channel.remove();                          channel.remove();
1037                  }                  }
1038                                    
1039                    @Override
1040                  public boolean                  public boolean
1041                  contains(int x, int y) { return (x - 11)*(x - 11) + (y - 11)*(y - 11) < 71; }                  contains(int x, int y) { return (x - 11)*(x - 11) + (y - 11)*(y - 11) < 71; }
1042          }          }
# Line 1042  public class Channel extends JSChannel { Line 1057  public class Channel extends JSChannel {
1057                          setToolTipText(i18n.getButtonLabel("Channel.ttShowOptions"));                          setToolTipText(i18n.getButtonLabel("Channel.ttShowOptions"));
1058                  }                  }
1059                                    
1060                    @Override
1061                  public void                  public void
1062                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
1063                          ChannelView view = channel.viewTracker.getCurrentView();                          ChannelView view = channel.viewTracker.getCurrentView();
# Line 1064  public class Channel extends JSChannel { Line 1080  public class Channel extends JSChannel {
1080                          channel.optionsPane.addPropertyChangeListener(s, this);                          channel.optionsPane.addPropertyChangeListener(s, this);
1081                  }                  }
1082                                    
1083                    @Override
1084                  public void                  public void
1085                  propertyChange(PropertyChangeEvent e) {                  propertyChange(PropertyChangeEvent e) {
1086                          if(e.getNewValue() == "collapsed") {                          if(e.getNewValue() == "collapsed") {
# Line 1079  public class Channel extends JSChannel { Line 1096  public class Channel extends JSChannel {
1096                          channel.optionsPane.removePropertyChangeListener(s, this);                          channel.optionsPane.removePropertyChangeListener(s, this);
1097                  }                  }
1098                                    
1099                    @Override
1100                  public boolean                  public boolean
1101                  contains(int x, int y) { return super.contains(x, y) & y < 13; }                  contains(int x, int y) { return super.contains(x, y) & y < 13; }
1102          }          }

Legend:
Removed from v.1767  
changed lines
  Added in v.1975

  ViewVC Help
Powered by ViewVC