/[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 841 by iliev, Mon Oct 10 16:03:12 2005 UTC revision 842 by iliev, Thu Mar 16 18:08:34 2006 UTC
# Line 23  Line 23 
23  package org.jsampler.view.classic;  package org.jsampler.view.classic;
24    
25  import java.awt.Color;  import java.awt.Color;
26    import java.awt.Cursor;
27  import java.awt.Dimension;  import java.awt.Dimension;
28  import java.awt.GridBagConstraints;  import java.awt.GridBagConstraints;
29  import java.awt.GridBagLayout;  import java.awt.GridBagLayout;
# Line 31  import java.awt.Insets; Line 32  import java.awt.Insets;
32  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
33  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
34    
35    import java.beans.PropertyChangeEvent;
36    import java.beans.PropertyChangeListener;
37    
38  import java.net.URL;  import java.net.URL;
39    
40    import java.util.Vector;
41    
42  import java.util.logging.Level;  import java.util.logging.Level;
43    
44  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
# Line 47  import javax.swing.JSeparator; Line 53  import javax.swing.JSeparator;
53  import javax.swing.JSlider;  import javax.swing.JSlider;
54  import javax.swing.JToggleButton;  import javax.swing.JToggleButton;
55    
56    import javax.swing.border.Border;
57    import javax.swing.border.LineBorder;
58    
59  import javax.swing.event.ChangeEvent;  import javax.swing.event.ChangeEvent;
60  import javax.swing.event.ChangeListener;  import javax.swing.event.ChangeListener;
61    
# Line 90  public class Channel extends org.jsample Line 99  public class Channel extends org.jsample
99          private final static ImageIcon iconShowProperties;          private final static ImageIcon iconShowProperties;
100          private final static ImageIcon iconHideProperties;          private final static ImageIcon iconHideProperties;
101                    
102            private static Border borderSelected;
103            private static Border borderDeselected;
104            
105            private static Color borderColor;
106            
107            private final static Vector<PropertyChangeListener> propertyChangeListeners
108                    = new Vector<PropertyChangeListener>();
109            
110          static {          static {
111                  String path = "org/jsampler/view/classic/res/icons/";                  String path = "org/jsampler/view/classic/res/icons/";
112                  URL url = ClassLoader.getSystemClassLoader().getResource(path + "mute_on.png");                  URL url = ClassLoader.getSystemClassLoader().getResource(path + "mute_on.png");
# Line 112  public class Channel extends org.jsample Line 129  public class Channel extends org.jsample
129                                    
130                  url = ClassLoader.getSystemClassLoader().getResource(path + "Down16.gif");                  url = ClassLoader.getSystemClassLoader().getResource(path + "Down16.gif");
131                  iconHideProperties = new ImageIcon(url);                  iconHideProperties = new ImageIcon(url);
132                    
133                    if(ClassicPrefs.getCustomChannelBorderColor())
134                            setBorderColor(ClassicPrefs.getChannelBorderColor());
135                    else setBorderColor(ClassicPrefs.getDefaultChannelBorderColor());
136                    
137                    borderSelected = new LineBorder(getBorderColor(), 2, true);
138                    borderDeselected = BorderFactory.createEmptyBorder(2, 2, 2, 2);
139            }
140            
141            /**
142             * Registers the specified listener for receiving property change events.
143             * @param l The <code>PropertyChangeListener</code> to register.
144             */
145            public void
146            addPropertyChangeListener(PropertyChangeListener l) {
147                    propertyChangeListeners.add(l);
148            }
149            
150            /**
151             * Removes the specified listener.
152             * @param l The <code>PropertyChangeListener</code> to remove.
153             */
154            public void
155            removePropertyChangeListener(PropertyChangeListener l) {
156                    propertyChangeListeners.remove(l);
157            }
158            
159            /**
160             * Gets the border color that is used when the channel is selected.
161             * @return The border color that is used when the channel is selected.
162             */
163            public static Color
164            getBorderColor() { return borderColor; }
165            
166            /**
167             * Sets the border color to be used when the channel is selected.
168             * @param c The border color to be used when the channel is selected.
169             */
170            public static void
171            setBorderColor(Color c) {
172                    if(borderColor != null && borderColor.getRGB() == c.getRGB()) return;
173                    
174                    Color oldColor = borderColor;
175                    borderColor = c;
176                    borderSelected = new LineBorder(getBorderColor(), 2, true);
177                    firePropertyChanged("borderColor", oldColor, borderColor);
178            }
179            
180            private static void
181            firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
182                    PropertyChangeEvent e =
183                            new PropertyChangeEvent(Channel.class, propertyName, oldValue, newValue);
184                    
185                    for(PropertyChangeListener l : propertyChangeListeners) l.propertyChange(e);
186          }          }
187                    
188                    
# Line 220  public class Channel extends org.jsample Line 291  public class Channel extends org.jsample
291                  d = getPreferredSize();                  d = getPreferredSize();
292                  setMaximumSize(new Dimension(getMaximumSize().width, d.height));                  setMaximumSize(new Dimension(getMaximumSize().width, d.height));
293                                    
294                  getModel().addSamplerChannelListener(eventHandler);                  getModel().addSamplerChannelListener(getHandler());
295                                    
296                  btnInstr.addActionListener(new ActionListener() {                  btnInstr.addActionListener(new ActionListener() {
297                          public void                          public void
# Line 246  public class Channel extends org.jsample Line 317  public class Channel extends org.jsample
317                          public void                          public void
318                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
319                                  showProperties(btnProperties.isSelected());                                  showProperties(btnProperties.isSelected());
320                                    
321                                    String s;
322                                    if(btnProperties.isSelected()) {
323                                            s = i18n.getButtonLabel("Channel.ttHideProps");
324                                    } else {
325                                            s = i18n.getButtonLabel("Channel.ttShowProps");
326                                    }
327                                    
328                                    btnProperties.setToolTipText(s);
329                          }                          }
330                  });                  });
331                                    
332                    btnProperties.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
333                    
334                    String s;
335                    if(btnProperties.isSelected()) s = i18n.getButtonLabel("Channel.ttHideProps");
336                    else s = i18n.getButtonLabel("Channel.ttShowProps");
337                    
338                    btnProperties.setToolTipText(s);
339                    
340                    addPropertyChangeListener(getHandler());
341                    
342                  updateChannelInfo();                  updateChannelInfo();
343          }          }
344                    
345          private class EventHandler implements SamplerChannelListener {          private EventHandler
346            getHandler() { return eventHandler; }
347            
348            private class EventHandler implements SamplerChannelListener, PropertyChangeListener {
349                  /**                  /**
350                   * Invoked when changes are made to a sampler channel.                   * Invoked when changes are made to a sampler channel.
351                   * @param e A <code>SamplerChannelEvent</code> instance                   * @param e A <code>SamplerChannelEvent</code> instance
# Line 280  public class Channel extends org.jsample Line 373  public class Channel extends org.jsample
373                  voiceCountChanged(SamplerChannelEvent e) {                  voiceCountChanged(SamplerChannelEvent e) {
374                          updateVoiceCount(getModel().getVoiceCount());                          updateVoiceCount(getModel().getVoiceCount());
375                  }                  }
376                    
377                    public void
378                    propertyChange(PropertyChangeEvent e) {
379                            if(e.getPropertyName() == "borderColor") setSelected(isSelected());
380                    }
381          }          }
382                    
383          /**          /**
# Line 296  public class Channel extends org.jsample Line 394  public class Channel extends org.jsample
394           */           */
395          public void          public void
396          setSelected(boolean select) {          setSelected(boolean select) {
397                  if(select)                  if(select)  mainPane.setBorder(borderSelected);
398                          mainPane.setBorder(BorderFactory.createLineBorder(java.awt.Color.WHITE, 3));                  else mainPane.setBorder(borderDeselected);
                 else mainPane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));  
399                                    
400                  selected = select;                  selected = select;
401          }          }

Legend:
Removed from v.841  
changed lines
  Added in v.842

  ViewVC Help
Powered by ViewVC