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

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

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

revision 1733 by iliev, Sat May 3 01:40:06 2008 UTC revision 1734 by iliev, Sun May 4 18:40:13 2008 UTC
# Line 31  import java.awt.event.HierarchyEvent; Line 31  import java.awt.event.HierarchyEvent;
31  import java.awt.event.HierarchyListener;  import java.awt.event.HierarchyListener;
32  import java.awt.event.MouseAdapter;  import java.awt.event.MouseAdapter;
33  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
34    import java.awt.event.MouseListener;
35    
36  import java.beans.PropertyChangeEvent;  import java.beans.PropertyChangeEvent;
37  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
38    
39    import java.util.Vector;
40    
41  import javax.swing.Action;  import javax.swing.Action;
42  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
43  import javax.swing.Box;  import javax.swing.Box;
# Line 45  import javax.swing.JLabel; Line 48  import javax.swing.JLabel;
48  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
49  import javax.swing.JPanel;  import javax.swing.JPanel;
50  import javax.swing.JPopupMenu;  import javax.swing.JPopupMenu;
 import javax.swing.Timer;  
51    
52  import javax.swing.event.ChangeEvent;  import javax.swing.event.ChangeEvent;
53  import javax.swing.event.ChangeListener;  import javax.swing.event.ChangeListener;
# Line 70  import static org.jsampler.view.fantasia Line 72  import static org.jsampler.view.fantasia
72   *   *
73   * @author Grigor Iliev   * @author Grigor Iliev
74   */   */
75  public class NormalChannelView extends JPanel implements ChannelView {  public class NormalChannelView extends PixmapPane implements ChannelView {
76          private final Channel channel;          private final Channel channel;
77          private final ChannelOptionsView channelOptionsView;          private final ChannelOptionsView channelOptionsView;
78                    
# Line 82  public class NormalChannelView extends J Line 84  public class NormalChannelView extends J
84          private final SoloButton btnSolo = new SoloButton();          private final SoloButton btnSolo = new SoloButton();
85          private final Channel.OptionsButton btnOptions;          private final Channel.OptionsButton btnOptions;
86                    
87            private final Vector<JComponent> components = new Vector<JComponent>();
88            
89                    
90          /** Creates a new instance of <code>NormalChannelView</code> */          /** Creates a new instance of <code>NormalChannelView</code> */
91          public          public
# Line 92  public class NormalChannelView extends J Line 96  public class NormalChannelView extends J
96          /** Creates a new instance of <code>NormalChannelView</code> */          /** Creates a new instance of <code>NormalChannelView</code> */
97          public          public
98          NormalChannelView(Channel channel, ChannelOptionsView channelOptionsView) {          NormalChannelView(Channel channel, ChannelOptionsView channelOptionsView) {
99                    super(Res.gfxChannel);
100                    setPixmapInsets(new Insets(3, 3, 3, 3));
101                    
102                    components.add(this);
103                    
104                  this.channel = channel;                  this.channel = channel;
105                  this.channelOptionsView = channelOptionsView;                  this.channelOptionsView = channelOptionsView;
106                                    
107                  addMouseListener(channel.getContextMenu());                  addMouseListener(channel.getContextMenu());
108                                    
109                  btnPower = new Channel.PowerButton(channel);                  btnPower = new Channel.PowerButton(channel);
110                    components.add(btnPower);
111                  btnOptions = new Channel.OptionsButton(channel);                  btnOptions = new Channel.OptionsButton(channel);
112                                    components.add(btnOptions);
                 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));  
113                                    
114                  screen = new ChannelScreen(channel);                  screen = new ChannelScreen(channel);
115                  ChannelPane p = new ChannelPane();                  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
                 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));  
                   
                 //p.add(Box.createRigidArea(new Dimension(3, 0)));  
116                                    
117                  btnPower.setAlignmentY(JPanel.TOP_ALIGNMENT);                  btnPower.setAlignmentY(JPanel.TOP_ALIGNMENT);
118                                    
119                  JPanel tb = new JPanel();                  JPanel tb = new JPanel();
120                    components.add(tb);
121                  tb.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 4));                  tb.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 4));
122                  tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));                  tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
123                  tb.setOpaque(false);                  tb.setOpaque(false);
# Line 119  public class NormalChannelView extends J Line 126  public class NormalChannelView extends J
126                  tb.setPreferredSize(new Dimension(tb.getPreferredSize().width, 58));                  tb.setPreferredSize(new Dimension(tb.getPreferredSize().width, 58));
127                  tb.setMinimumSize(tb.getPreferredSize());                  tb.setMinimumSize(tb.getPreferredSize());
128                  tb.setMaximumSize(tb.getPreferredSize());                  tb.setMaximumSize(tb.getPreferredSize());
129                  p.add(tb);                  add(tb);
130                                    
131                  //p.add(Box.createRigidArea(new Dimension(4, 0)));                  //p.add(Box.createRigidArea(new Dimension(4, 0)));
132                                    
133                  p.add(createVSeparator());                  add(createVSeparator());
134                                    
135                  //p.add(Box.createRigidArea(new Dimension(3, 0)));                  //p.add(Box.createRigidArea(new Dimension(3, 0)));
136                                    
137                  JPanel p2 = new JPanel();                  JPanel p2 = new JPanel();
138                    components.add(p2);
139                  p2.setOpaque(false);                  p2.setOpaque(false);
140                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
141                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
142                  p2.setBorder(BorderFactory.createEmptyBorder(5, 3, 0, 2));                  p2.setBorder(BorderFactory.createEmptyBorder(5, 3, 0, 2));
143                  p2.add(screen);                  p2.add(screen);
144                  p.add(p2);                  add(p2);
145                                    
146                  p.add(createVSeparator());                  add(createVSeparator());
147                                    
148                  p2 = new JPanel();                  p2 = new JPanel();
149                    components.add(p2);
150                  p2.setOpaque(false);                  p2.setOpaque(false);
151                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
152                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
153                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
154                  p2.add(new JLabel(Res.gfxMuteTitle));                  
155                    JLabel l = new JLabel(Res.gfxMuteTitle);
156                    components.add(l);
157                    p2.add(l);
158                    components.add(btnMute);
159                  p2.add(btnMute);                  p2.add(btnMute);
160                  p2.add(new JLabel(Res.gfxSoloTitle));                  
161                    l = new JLabel(Res.gfxSoloTitle);
162                    components.add(l);
163                    p2.add(l);
164                    
165                    components.add(btnSolo);
166                  p2.add(btnSolo);                  p2.add(btnSolo);
167                                    
168                  p.add(p2);                  add(p2);
169                                    
170                  p.add(createVSeparator());                  add(createVSeparator());
171                                    
172                  p2 = new JPanel();                  p2 = new JPanel();
173                    components.add(p2);
174                  p2.setOpaque(false);                  p2.setOpaque(false);
175                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
176                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
177                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
178                  JLabel l = new JLabel(Res.gfxVolumeTitle);                  l = new JLabel(Res.gfxVolumeTitle);
179                    components.add(l);
180                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);
181                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
182                  p2.add(l);                  p2.add(l);
183                    
184                    components.add(dialVolume);
185                  dialVolume.setDialPixmap(Res.gfxVolumeDial, 30, 330);                  dialVolume.setDialPixmap(Res.gfxVolumeDial, 30, 330);
186                  dialVolume.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  dialVolume.setAlignmentX(JPanel.CENTER_ALIGNMENT);
187                  p2.add(dialVolume);                  p2.add(dialVolume);
188                  p.add(p2);                  add(p2);
189                                    
190                  p.add(createVSeparator());                  add(createVSeparator());
191                                    
192                  p2 = new JPanel();                  p2 = new JPanel();
193                    components.add(p2);
194                  p2.setOpaque(false);                  p2.setOpaque(false);
195                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
196                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
197                  p2.setBorder(BorderFactory.createEmptyBorder(27, 0, 0, 0));                  p2.setBorder(BorderFactory.createEmptyBorder(27, 0, 0, 0));
198                  l = new JLabel(Res.gfxOptionsTitle);                  l = new JLabel(Res.gfxOptionsTitle);
199                    components.add(l);
200                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);
201                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
202                  p2.add(l);                  p2.add(l);
# Line 181  public class NormalChannelView extends J Line 205  public class NormalChannelView extends J
205                                    
206                  btnOptions.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  btnOptions.setAlignmentX(JPanel.CENTER_ALIGNMENT);
207                  p2.add(btnOptions);                  p2.add(btnOptions);
208                  p.add(p2);                  add(p2);
209                                    
210                                    
211                  p.setPreferredSize(new Dimension(420, 60));                  setPreferredSize(new Dimension(420, 60));
212                  p.setMinimumSize(p.getPreferredSize());                  setMinimumSize(getPreferredSize());
213                  p.setMaximumSize(p.getPreferredSize());                  setMaximumSize(getPreferredSize());
214                  //p.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));                  //p.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
215    
216                  p.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  setAlignmentX(JPanel.CENTER_ALIGNMENT);
                   
                 add(p);  
217                                    
218                  installView();                  installView();
219          }          }
# Line 200  public class NormalChannelView extends J Line 222  public class NormalChannelView extends J
222          // Implementation of the ChannelView interface          // Implementation of the ChannelView interface
223          //////////////////////////////////////////////          //////////////////////////////////////////////
224                    
225            public Type
226            getType() { return Type.NORMAL; }
227            
228          public JComponent          public JComponent
229          getComponent() { return this; }          getComponent() { return this; }
230                    
# Line 214  public class NormalChannelView extends J Line 239  public class NormalChannelView extends J
239                                  screen.updateVolumeInfo(dialVolume.getValue());                                  screen.updateVolumeInfo(dialVolume.getValue());
240                          }                          }
241                  });                  });
242                    
243                    screen.installListeners();
244          }          }
245                    
246          public void          public void
# Line 255  public class NormalChannelView extends J Line 282  public class NormalChannelView extends J
282                  btnOptions.doClick();                  btnOptions.doClick();
283          }          }
284                    
285            public boolean
286            isOptionsButtonSelected() { return btnOptions.isSelected(); }
287            
288            public void
289            setOptionsButtonSelected(boolean b) {
290                    btnOptions.setSelected(b);
291            }
292            
293            public void
294            addEnhancedMouseListener(MouseListener l) {
295                    removeEnhancedMouseListener(l);
296                    
297                    for(JComponent c : components) c.addMouseListener(l);
298                    screen.addEnhancedMouseListener(l);
299            }
300            
301            public void
302            removeEnhancedMouseListener(MouseListener l) {
303                    for(JComponent c : components) c.removeMouseListener(l);
304                    screen.removeEnhancedMouseListener(l);
305            }
306            
307          //////////////////////////////////////////////          //////////////////////////////////////////////
308                    
309                    
# Line 413  public class NormalChannelView extends J Line 462  public class NormalChannelView extends J
462  }  }
463    
464    
   
 class ChannelPane extends PixmapPane {  
         ChannelPane() {  
                 super(Res.gfxChannel);  
                 setPixmapInsets(new Insets(3, 3, 3, 3));  
         }  
 }  
   
465  class ChannelScreen extends PixmapPane {  class ChannelScreen extends PixmapPane {
466          private final Channel channel;          private final Channel channel;
467                    
# Line 445  class ChannelScreen extends PixmapPane { Line 486  class ChannelScreen extends PixmapPane {
486                    
487          private final JPopupMenu menuEngines = new JPopupMenu();          private final JPopupMenu menuEngines = new JPopupMenu();
488                    
489          private Timer timer;          private final ActionListener guiListener;
490            
491            private final Vector<JComponent> components = new Vector<JComponent>();
492                    
493          ChannelScreen(final Channel channel) {          ChannelScreen(final Channel channel) {
494                  super(Res.gfxChannelScreen);                  super(Res.gfxChannelScreen);
495                  setPixmapInsets(new Insets(6, 6, 6, 6));                  setPixmapInsets(new Insets(6, 6, 6, 6));
496                  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));                  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
497                                    
498                    components.add(this);
499                    
500                  this.channel = channel;                  this.channel = channel;
501                  addMouseListener(channel.getContextMenu());                  addMouseListener(channel.getContextMenu());
502                    
503                  streamVoiceCountPane = new Channel.StreamVoiceCountPane(channel);                  streamVoiceCountPane = new Channel.StreamVoiceCountPane(channel);
504                    components.add(streamVoiceCountPane);
505                    
506                  volumePane = new Channel.VolumePane(channel);                  volumePane = new Channel.VolumePane(channel);
507                    components.add(volumePane);
508                                    
509                  setOpaque(false);                  setOpaque(false);
510                                    
# Line 465  class ChannelScreen extends PixmapPane { Line 514  class ChannelScreen extends PixmapPane {
514                  btnInstr.setRolloverEnabled(false);                  btnInstr.setRolloverEnabled(false);
515                  btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));                  btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
516                  btnInstr.addMouseListener(channel.getContextMenu());                  btnInstr.addMouseListener(channel.getContextMenu());
517                    components.add(btnInstr);
518                                    
519                  instrumentPane = new InstrumentPane();                  instrumentPane = new InstrumentPane();
520                    components.add(instrumentPane);
521                  add(instrumentPane);                  add(instrumentPane);
522                                    
523                  JPanel p = new JPanel();                  JPanel p = new JPanel();
524                    components.add(p);
525                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
526                  p.setAlignmentX(CENTER_ALIGNMENT);                  p.setAlignmentX(CENTER_ALIGNMENT);
527                  p.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0));                  p.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0));
528                                    
529                    components.add(btnFxSends);
530                  btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt"));                  btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt"));
531                  btnFxSends.addActionListener(new ActionListener() {                  btnFxSends.addActionListener(new ActionListener() {
532                          public void                          public void
# Line 489  class ChannelScreen extends PixmapPane { Line 542  class ChannelScreen extends PixmapPane {
542                  //p.add(Box.createRigidArea(new Dimension(6, 0)));                  //p.add(Box.createRigidArea(new Dimension(6, 0)));
543                  p.add(Box.createGlue());                  p.add(Box.createGlue());
544                                    
545                    components.add(btnEngine);
546                  btnEngine.setIcon(Res.iconEngine12);                  btnEngine.setIcon(Res.iconEngine12);
547                  btnEngine.setIconTextGap(1);                  btnEngine.setIconTextGap(1);
548                  btnEngine.addMouseListener(channel.getContextMenu());                  btnEngine.addMouseListener(channel.getContextMenu());
# Line 518  class ChannelScreen extends PixmapPane { Line 572  class ChannelScreen extends PixmapPane {
572                  setMaximumSize(getPreferredSize());                  setMaximumSize(getPreferredSize());
573                                    
574                  createEngineMenu();                  createEngineMenu();
575                  installListeners();                  
576                    guiListener = new ActionListener() {
577                            public void
578                            actionPerformed(ActionEvent e) {
579                                    if(getMousePosition(true) != null) {
580                                            getHandler().mouseEntered(null);
581                                    } else {
582                                            getHandler().mouseExited(null);
583                                    }
584                            }
585                    };
586            }
587            
588            public void
589            addEnhancedMouseListener(MouseListener l) {
590                    removeEnhancedMouseListener(l);
591                    for(JComponent c : components) c.addMouseListener(l);
592            }
593            
594            public void
595            removeEnhancedMouseListener(MouseListener l) {
596                    for(JComponent c : components) c.removeMouseListener(l);
597          }          }
598                    
599          protected void          protected void
600          onDestroy() { timer.stop(); }          onDestroy() { uninstallListeners(); }
601                    
602          private void          private void
603          createEngineMenu() {          createEngineMenu() {
# Line 541  class ChannelScreen extends PixmapPane { Line 616  class ChannelScreen extends PixmapPane {
616                  }                  }
617          }          }
618                    
619          private void          protected void
620          installListeners() {          installListeners() {
621                  btnInstr.addActionListener(new ActionListener() {                  btnInstr.addActionListener(new ActionListener() {
622                          public void                          public void
# Line 566  class ChannelScreen extends PixmapPane { Line 641  class ChannelScreen extends PixmapPane {
641                  addMouseListener(getHandler());                  addMouseListener(getHandler());
642                  addHierarchyListener(getHandler());                  addHierarchyListener(getHandler());
643                                    
644                  ActionListener l = new ActionListener() {                  ((MainFrame)CC.getMainFrame()).getGuiTimer().addActionListener(guiListener);
645                          public void          }
646                          actionPerformed(ActionEvent e) {          
647                                  if(getMousePosition(true) != null) {          private void
648                                          getHandler().mouseEntered(null);          uninstallListeners() {
649                                  } else {                  ((MainFrame)CC.getMainFrame()).getGuiTimer().removeActionListener(guiListener);
                                         getHandler().mouseExited(null);  
                                 }  
                         }  
                 };  
                 timer = new Timer(1000, l);  
                 timer.start();  
650          }          }
651                    
652          protected void          protected void

Legend:
Removed from v.1733  
changed lines
  Added in v.1734

  ViewVC Help
Powered by ViewVC