/[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 1539 by iliev, Mon Nov 19 22:22:22 2007 UTC revision 1540 by iliev, Mon Dec 3 23:22:02 2007 UTC
# Line 23  Line 23 
23  package org.jsampler.view.fantasia;  package org.jsampler.view.fantasia;
24    
25  import java.awt.Container;  import java.awt.Container;
 import java.awt.Cursor;  
26  import java.awt.Dimension;  import java.awt.Dimension;
27  import java.awt.Graphics;  import java.awt.Graphics;
28  import java.awt.Graphics2D;  import java.awt.Graphics2D;
# Line 40  import java.awt.event.MouseEvent; Line 39  import java.awt.event.MouseEvent;
39  import java.beans.PropertyChangeEvent;  import java.beans.PropertyChangeEvent;
40  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
41    
42    import java.text.NumberFormat;
43    
44  import java.util.logging.Level;  import java.util.logging.Level;
45    
46  import javax.swing.Action;  import javax.swing.Action;
# Line 49  import javax.swing.BoxLayout; Line 50  import javax.swing.BoxLayout;
50  import javax.swing.DefaultListCellRenderer;  import javax.swing.DefaultListCellRenderer;
51  import javax.swing.JButton;  import javax.swing.JButton;
52  import javax.swing.JComboBox;  import javax.swing.JComboBox;
53    import javax.swing.JComponent;
54  import javax.swing.JLabel;  import javax.swing.JLabel;
55  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
56  import javax.swing.JPanel;  import javax.swing.JPanel;
# Line 71  import org.jdesktop.swingx.JXCollapsible Line 73  import org.jdesktop.swingx.JXCollapsible
73    
74  import org.jsampler.AudioDeviceModel;  import org.jsampler.AudioDeviceModel;
75  import org.jsampler.CC;  import org.jsampler.CC;
76    import org.jsampler.HF;
77  import org.jsampler.MidiDeviceModel;  import org.jsampler.MidiDeviceModel;
78  import org.jsampler.MidiInstrumentMap;  import org.jsampler.MidiInstrumentMap;
79  import org.jsampler.SamplerChannelModel;  import org.jsampler.SamplerChannelModel;
# Line 94  import org.jsampler.event.SamplerListene Line 97  import org.jsampler.event.SamplerListene
97  import org.jsampler.view.std.JSChannelOutputRoutingDlg;  import org.jsampler.view.std.JSChannelOutputRoutingDlg;
98  import org.jsampler.view.std.JSFxSendsPane;  import org.jsampler.view.std.JSFxSendsPane;
99  import org.jsampler.view.std.JSInstrumentChooser;  import org.jsampler.view.std.JSInstrumentChooser;
100    import org.jsampler.view.std.JSVolumeEditorPopup;
 import org.jvnet.lafwidget.animation.FadeConfigurationManager;  
 import org.jvnet.lafwidget.animation.FadeKind;  
101    
102  import org.jvnet.substance.SubstanceImageCreator;  import org.jvnet.substance.SubstanceImageCreator;
 import org.jvnet.substance.SubstanceLookAndFeel;  
103    
104  import org.linuxsampler.lscp.AudioOutputDevice;  import org.linuxsampler.lscp.AudioOutputDevice;
105  import org.linuxsampler.lscp.MidiInputDevice;  import org.linuxsampler.lscp.MidiInputDevice;
# Line 109  import org.linuxsampler.lscp.SamplerEngi Line 109  import org.linuxsampler.lscp.SamplerEngi
109    
110  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
111  import static org.jsampler.view.fantasia.FantasiaPrefs.*;  import static org.jsampler.view.fantasia.FantasiaPrefs.*;
112    import static org.jsampler.view.fantasia.FantasiaUtils.*;
113    import static org.jsampler.view.std.JSVolumeEditorPopup.VolumeType;
114    
115    
116  /**  /**
# Line 263  public class Channel extends org.jsample Line 265  public class Channel extends org.jsample
265                          }                          }
266                  });                  });
267                                    
268                    String vmud = VOL_MEASUREMENT_UNIT_DECIBEL;
269                    preferences().addPropertyChangeListener(vmud, new PropertyChangeListener() {
270                            public void
271                            propertyChange(PropertyChangeEvent e) {
272                                    boolean b;
273                                    b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
274                                    screen.updateVolumeInfo(dialVolume.getValue());
275                            }
276                    });
277                    
278                  getModel().addSamplerChannelListener(getHandler());                  getModel().addSamplerChannelListener(getHandler());
279                                    
280                  updateChannelInfo();                  updateChannelInfo();
# Line 380  public class Channel extends org.jsample Line 392  public class Channel extends org.jsample
392                                    
393                  if(vol == dialVolume.getValue()) return;                  if(vol == dialVolume.getValue()) return;
394                                    
                   
395                  /*                  /*
396                   * If the model's volume is not equal to the dial knob                   * If the model's volume is not equal to the dial knob
397                   * value we assume that the change is due to user input.                   * value we assume that the change is due to user input.
# Line 404  public class Channel extends org.jsample Line 415  public class Channel extends org.jsample
415                                    
416                  if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn);                  if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn);
417                  else btnSolo.setIcon(Res.gfxSoloOff);                  else btnSolo.setIcon(Res.gfxSoloOff);
                   
418                  dialVolume.setValue((int)(sc.getVolume() * 100));                  dialVolume.setValue((int)(sc.getVolume() * 100));
419                                    
420                  boolean b = sc.getEngine() != null;                  boolean b = sc.getEngine() != null;
# Line 661  class ChannelScreen extends PixmapPane { Line 671  class ChannelScreen extends PixmapPane {
671          private final Channel channel;          private final Channel channel;
672                    
673          private final InstrumentPane instrumentPane;          private final InstrumentPane instrumentPane;
674          private JButton btnInstr = new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr"));          
675            private JButton btnInstr =
676                    createScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr"));
677                    
678          private final JButton btnEditInstr =          private final JButton btnEditInstr =
679                  new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnEditInstr"));                  createScreenButton(i18n.getButtonLabel("ChannelScreen.btnEditInstr"));
680          private final ScreenButtonBg sbbEditInstr = new ScreenButtonBg(btnEditInstr);          private final ScreenButtonBg sbbEditInstr = new ScreenButtonBg(btnEditInstr);
681                    
682          private final JButton btnFxSends =          private final JButton btnFxSends =
683                  new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnFxSends"));                  createScreenButton(i18n.getButtonLabel("ChannelScreen.btnFxSends"));
684                    
685          private final JButton btnEngine          private final JButton btnEngine
686                  = new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnEngine"));                  = createScreenButton(i18n.getButtonLabel("ChannelScreen.btnEngine"));
687                    
688          private final JPopupMenu menuEngines = new JPopupMenu();          private final JPopupMenu menuEngines = new JPopupMenu();
689                    
690          private final JLabel lVolume = new ScreenLabel("");          private final JButton btnVolume = createScreenButton("");
691          private final JLabel lStreams = new ScreenLabel(" --");          private JSVolumeEditorPopup popupVolume;
         private final JLabel lVoices = new ScreenLabel("-- ");  
692                    
693          private InformationDialog fxSendsDlg = null;          private final JLabel lStreams = createScreenLabel(" --");
694            private final JLabel lVoices = createScreenLabel("-- ");
695                    
696          private Dimension dimVolume;          private InformationDialog fxSendsDlg = null;
697                    
698          private Timer timer;          private Timer timer;
699                    
700            private static NumberFormat numberFormat = NumberFormat.getInstance();
701            static {
702                    numberFormat.setMaximumFractionDigits(1);
703            }
704            
705          ChannelScreen(final Channel channel) {          ChannelScreen(final Channel channel) {
706                  super(Res.gfxChannelScreen);                  super(Res.gfxChannelScreen);
707                  setPixmapInsets(new Insets(6, 6, 6, 6));                  setPixmapInsets(new Insets(6, 6, 6, 6));
708                  setBorder(BorderFactory.createEmptyBorder(5, 4, 5, 4));                  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
709                                    
710                  this.channel = channel;                  this.channel = channel;
711                    popupVolume = new JSVolumeEditorPopup(btnVolume, VolumeType.CHANNEL);
712                                    
713                  setOpaque(false);                  setOpaque(false);
714                                    
# Line 706  class ChannelScreen extends PixmapPane { Line 724  class ChannelScreen extends PixmapPane {
724                  JPanel p = new JPanel();                  JPanel p = new JPanel();
725                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
726                  p.setAlignmentX(CENTER_ALIGNMENT);                  p.setAlignmentX(CENTER_ALIGNMENT);
727                  p.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));                  p.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0));
728                                    
729                  btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt"));                  btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt"));
730                  btnFxSends.addActionListener(new ActionListener() {                  btnFxSends.addActionListener(new ActionListener() {
# Line 728  class ChannelScreen extends PixmapPane { Line 746  class ChannelScreen extends PixmapPane {
746                                    
747                  p.add(btnFxSends);                  p.add(btnFxSends);
748                                    
749                  p.add(Box.createRigidArea(new Dimension(6, 0)));                  //p.add(Box.createRigidArea(new Dimension(6, 0)));
750                    p.add(Box.createGlue());
751                                    
752                  btnEngine.setIcon(Res.iconEngine12);                  btnEngine.setIcon(Res.iconEngine12);
753                    btnEngine.setIconTextGap(1);
754                  p.add(btnEngine);                  p.add(btnEngine);
755                  //p.add(new Label("|"));                  //p.add(new Label("|"));
756                                    
# Line 742  class ChannelScreen extends PixmapPane { Line 762  class ChannelScreen extends PixmapPane {
762                                    
763                  lStreams.setFont(Res.fontScreenMono);                  lStreams.setFont(Res.fontScreenMono);
764                  lStreams.setHorizontalAlignment(JLabel.RIGHT);                  lStreams.setHorizontalAlignment(JLabel.RIGHT);
765                    lStreams.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount"));
766                  p.add(lStreams);                  p.add(lStreams);
767                                    
768                  JLabel l = new ScreenLabel("/");                  JLabel l = createScreenLabel("/");
769                  l.setFont(Res.fontScreenMono);                  l.setFont(Res.fontScreenMono);
770                    l.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount"));
771                  p.add(l);                  p.add(l);
772                                    
773                  lVoices.setFont(Res.fontScreenMono);                  lVoices.setFont(Res.fontScreenMono);
774                    lVoices.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount"));
775                  p.add(lVoices);                  p.add(lVoices);
776                                    
777                  lVolume.setIcon(Res.iconVolume14);                  btnVolume.setIcon(Res.iconVolume14);
778                  lVolume.setAlignmentX(RIGHT_ALIGNMENT);                  btnVolume.setIconTextGap(2);
779                    btnVolume.setAlignmentX(RIGHT_ALIGNMENT);
780                    btnVolume.setHorizontalAlignment(btnVolume.LEFT);
781                  updateVolumeInfo(100);                  updateVolumeInfo(100);
782                  dimVolume = lVolume.getPreferredSize();                  Dimension d = btnVolume.getPreferredSize();
783                  p.add(lVolume);                  d.width = 60;
784                  p.setPreferredSize(new Dimension(250, p.getPreferredSize().height));                  btnVolume.setPreferredSize(d);
785                    btnVolume.setMinimumSize(d);
786                    
787                    btnVolume.addActionListener(new ActionListener() {
788                            public void
789                            actionPerformed(ActionEvent e) {
790                                    if(popupVolume.isVisible()) {
791                                            popupVolume.commit();
792                                            popupVolume.hide();
793                                    } else {
794                                            float vol = channel.getModel().getChannelInfo().getVolume();
795                                            popupVolume.setCurrentVolume(vol);
796                                            popupVolume.show();
797                                    }
798                            }
799                    });
800                    
801                    popupVolume.addActionListener(new ActionListener() {
802                            public void
803                            actionPerformed(ActionEvent e) {
804                                    channel.getModel().setBackendVolume(popupVolume.getVolumeFactor());
805                            }
806                    });
807                    
808                    p.add(btnVolume);
809                    p.setPreferredSize(new Dimension(260, p.getPreferredSize().height));
810                  p.setMinimumSize(p.getPreferredSize());                  p.setMinimumSize(p.getPreferredSize());
811                  p.setMaximumSize(p.getPreferredSize());                  p.setMaximumSize(p.getPreferredSize());
812                                    
# Line 779  class ChannelScreen extends PixmapPane { Line 829  class ChannelScreen extends PixmapPane {
829          private void          private void
830          createEngineMenu() {          createEngineMenu() {
831                  for(final SamplerEngine engine : CC.getSamplerModel().getEngines()) {                  for(final SamplerEngine engine : CC.getSamplerModel().getEngines()) {
832                          JMenuItem mi = new JMenuItem(engine.getDescription());                          JMenuItem mi = new JMenuItem(engine.getName() + " engine");
833                            mi.setToolTipText(engine.getDescription());
834                                                    
835                          mi.addActionListener(new ActionListener() {                          mi.addActionListener(new ActionListener() {
836                                  public void                                  public void
# Line 859  class ChannelScreen extends PixmapPane { Line 910  class ChannelScreen extends PixmapPane {
910                  instrumentPane.update();                  instrumentPane.update();
911                    
912                  if(sc.getEngine() != null) {                  if(sc.getEngine() != null) {
913                          String s = sc.getEngine().getDescription();                          String s = sc.getEngine().getName();
914                          if(!s.equals(btnEngine.getText())) btnEngine.setText(s);                          s += " engine";
915                            if(!s.equals(btnEngine.getText())) {
916                                    btnEngine.setText(s);
917                                    btnEngine.setToolTipText(sc.getEngine().getDescription());
918                            }
919                  }                  }
920                                    
921          }          }
922                    
923          protected void          protected void
924          updateVolumeInfo(int volume) {          updateVolumeInfo(int volume) {
925                  lVolume.setText(i18n.getLabel("ChannelScreen.volume", volume));                  if(CC.getViewConfig().isMeasurementUnitDecibel()) {
926                  lVolume.setMinimumSize(dimVolume);                          String s = numberFormat.format(HF.percentsToDecibels(volume));
927                  lVolume.setPreferredSize(dimVolume);                          btnVolume.setText(s + "dB");
928                                    } else {
929                            btnVolume.setText(String.valueOf(volume) + "%");
930                    }
931          }          }
932                    
933          /**          /**
# Line 977  class ChannelScreen extends PixmapPane { Line 1034  class ChannelScreen extends PixmapPane {
1034                  }                  }
1035          }          }
1036                    
         static class ScreenButton extends JButton {  
                 ScreenButton(String s) {  
                         super(s);  
                         setContentAreaFilled(false);  
                         setFocusPainted(false);  
                         setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));  
                         setMargin(new Insets(0, 0, 0, 0));  
                           
                         putClientProperty (  
                                 SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE  
                         );  
                           
                         putClientProperty (  
                                 SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE  
                         );  
                           
                         putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE);  
                           
                         FadeConfigurationManager.getInstance().disallowFades(FadeKind.ROLLOVER, this);  
                           
                         setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  
                         setFont(Res.fontScreen);  
                         setForeground(new java.awt.Color(0xFFA300));  
                 }  
                   
                 protected void  
                 paintComponent(Graphics g) {  
                         Graphics2D g2d = (Graphics2D)g;  
                           
                         g2d.setRenderingHint (  
                                 java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,  
                                 java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON  
                         );  
                           
                         super.paintComponent(g2d);  
                 }  
         }  
           
1037          static class ScreenButtonBg extends PixmapPane {          static class ScreenButtonBg extends PixmapPane {
1038                  ScreenButtonBg(JButton btn) {                  ScreenButtonBg(JButton btn) {
1039                          super(Res.gfxScreenBtnBg);                          super(Res.gfxScreenBtnBg);
# Line 1032  class ChannelScreen extends PixmapPane { Line 1051  class ChannelScreen extends PixmapPane {
1051          }          }
1052                    
1053                    
           
         static class ScreenLabel extends JLabel {  
                 ScreenLabel() { this(""); }  
                   
                 ScreenLabel(String s) {  
                         super(s);  
                         setFont(Res.fontScreen);  
                         setForeground(new java.awt.Color(0xFFA300));  
                 }  
                   
                 protected void  
                 paintComponent(Graphics g) {  
                         Graphics2D g2d = (Graphics2D)g;  
                           
                         g2d.setRenderingHint (  
                                 java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,  
                                 java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON  
                         );  
                           
                         super.paintComponent(g2d);  
                 }  
         }  
           
1054          private final EventHandler eventHandler = new EventHandler();          private final EventHandler eventHandler = new EventHandler();
1055                    
1056          private EventHandler          private EventHandler

Legend:
Removed from v.1539  
changed lines
  Added in v.1540

  ViewVC Help
Powered by ViewVC