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

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

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

revision 1566 by iliev, Mon Dec 3 23:22:02 2007 UTC revision 1567 by iliev, Thu Dec 6 19:37:41 2007 UTC
# Line 45  import java.beans.PropertyChangeListener Line 45  import java.beans.PropertyChangeListener
45    
46  import java.net.URL;  import java.net.URL;
47    
48  import java.util.Vector;  import java.text.NumberFormat;
49    
50    import java.util.Vector;
51  import java.util.logging.Level;  import java.util.logging.Level;
52    
53  import javax.swing.Action;  import javax.swing.Action;
# Line 145  public class Channel extends org.jsample Line 146  public class Channel extends org.jsample
146          private final static Vector<PropertyChangeListener> propertyChangeListeners          private final static Vector<PropertyChangeListener> propertyChangeListeners
147                  = new Vector<PropertyChangeListener>();                  = new Vector<PropertyChangeListener>();
148                    
149            
150            private static NumberFormat numberFormat = NumberFormat.getInstance();
151            
152          static {          static {
153                    numberFormat.setMaximumFractionDigits(1);
154                    
155                  iconEdit = new ImageIcon(Channel.class.getResource("res/icons/edit.png"));                  iconEdit = new ImageIcon(Channel.class.getResource("res/icons/edit.png"));
156                                    
157                  String path = "org/jsampler/view/classic/res/icons/";                  String path = "org/jsampler/view/classic/res/icons/";
# Line 404  public class Channel extends org.jsample Line 410  public class Channel extends org.jsample
410                  lVolume.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 6));                  lVolume.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 6));
411                  lVolume.setHorizontalAlignment(lVolume.RIGHT);                  lVolume.setHorizontalAlignment(lVolume.RIGHT);
412                                    
413                  // We use this to set the size of the lVolume that will be used in setVolume()                  // We use this to set the size of the lVolume
414                  // to prevent the frequent resizing of lVolume                  // to prevent the frequent resizing of lVolume component
415                  lVolume.setText("100%");                  if(CC.getViewConfig().isMeasurementUnitDecibel()) {
416                            lVolume.setText("-30.0dB");
417                    } else {
418                            lVolume.setText("100%");
419                    }
420                    lVolume.setPreferredSize(lVolume.getPreferredSize());
421                                    
422                  volumePane.add(lVolume);                  volumePane.add(lVolume);
423                                    
# Line 441  public class Channel extends org.jsample Line 452  public class Channel extends org.jsample
452                          }                          }
453                  });                  });
454                                    
455                    String vmud = VOL_MEASUREMENT_UNIT_DECIBEL;
456                    preferences().addPropertyChangeListener(vmud, new PropertyChangeListener() {
457                            public void
458                            propertyChange(PropertyChangeEvent e) {
459                                    boolean b;
460                                    b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
461                                    // We use this to set the size of the lVolume
462                                    // to prevent the frequent resizing of lVolume component
463                                    lVolume.setPreferredSize(null);
464                                    if(b) lVolume.setText("-30.0dB");
465                                    else lVolume.setText("100%");
466                                    lVolume.setPreferredSize(lVolume.getPreferredSize());
467                                    ///////
468                                    updateVolume();
469                            }
470                    });
471                    
472                  getModel().addSamplerChannelListener(getHandler());                  getModel().addSamplerChannelListener(getHandler());
473                                    
474                  actInstr = new AbstractAction() {                  actInstr = new AbstractAction() {
# Line 790  public class Channel extends org.jsample Line 818  public class Channel extends org.jsample
818          private void          private void
819          updateVolume() {          updateVolume() {
820                  int volume = slVolume.getValue();                  int volume = slVolume.getValue();
                 slVolume.setToolTipText(i18n.getLabel("Channel.volume", volume));  
                 lVolImg.setToolTipText(i18n.getLabel("Channel.volume", volume));  
                   
                 setVolumeLabel(volume);  
821                                    
822                                    if(CC.getViewConfig().isMeasurementUnitDecibel()) {
823          }                          String dB = numberFormat.format(HF.percentsToDecibels(volume));
824                                    slVolume.setToolTipText(i18n.getLabel("Channel.volumeDecibels", dB));
825          private void                          lVolImg.setToolTipText(i18n.getLabel("Channel.volumeDecibels", dB));
826          setVolumeLabel(int volume) {                          lVolume.setText(dB + "dB");
827                  Dimension d = lVolume.getPreferredSize();                  } else {
828                  lVolume.setText(String.valueOf(volume) + '%');                          slVolume.setToolTipText(i18n.getLabel("Channel.volume", volume));
829                  d = JuifeUtils.getUnionSize(d, lVolume.getPreferredSize());                          lVolImg.setToolTipText(i18n.getLabel("Channel.volume", volume));
830                  lVolume.setMinimumSize(d);                          lVolume.setText(String.valueOf(volume) + '%');
831                  lVolume.setPreferredSize(d);                  }
                 lVolume.setMaximumSize(d);  
832          }          }
833                    
834          /**          /**

Legend:
Removed from v.1566  
changed lines
  Added in v.1567

  ViewVC Help
Powered by ViewVC