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

Contents of /jsampler/trunk/src/org/jsampler/view/SamplerTreeModel.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2195 - (show annotations) (download)
Tue Jun 28 22:44:39 2011 UTC (12 years, 10 months ago) by iliev
File size: 23866 byte(s)
* Sampler Browser (work in progress): initial implementation of main pane

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2011 Grigor Iliev <grigor@grigoriliev.com>
5 *
6 * This file is part of JSampler.
7 *
8 * JSampler is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * JSampler is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with JSampler; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22 package org.jsampler.view;
23
24 import java.beans.PropertyChangeSupport;
25 import java.util.ArrayList;
26 import java.util.Enumeration;
27 import java.util.Vector;
28 import javax.swing.SwingConstants;
29 import javax.swing.event.TreeModelEvent;
30 import javax.swing.event.TreeModelListener;
31 import javax.swing.tree.TreeModel;
32 import javax.swing.tree.TreeNode;
33 import javax.swing.tree.TreePath;
34
35 import org.jsampler.AudioDeviceModel;
36 import org.jsampler.CC;
37 import org.jsampler.EffectChain;
38 import org.jsampler.EffectInstance;
39 import org.jsampler.event.AudioDeviceEvent;
40 import org.jsampler.event.AudioDeviceListener;
41 import org.jsampler.event.EffectChainEvent;
42 import org.jsampler.event.EffectChainListener;
43 import org.jsampler.event.EffectInstanceEvent;
44 import org.jsampler.event.EffectInstanceListener;
45 import org.jsampler.event.ListEvent;
46 import org.jsampler.event.ListListener;
47
48 import org.linuxsampler.lscp.Effect;
49 import org.linuxsampler.lscp.EffectParameter;
50
51 import static org.jsampler.JSI18n.i18n;
52
53 /**
54 *
55 * @author Grigor Iliev
56 */
57 public class SamplerTreeModel implements TreeModel {
58 private final SamplerTreeNode root = new SamplerTreeNode(this);
59 private ArrayList<TreeModelListener> listeners = new ArrayList<TreeModelListener>();
60
61 private final AudioDevicesTreeNode audioDevices;
62 private final InternalEffectsTreeNode internalEffects;
63
64 public
65 SamplerTreeModel() {
66 audioDevices = new AudioDevicesTreeNode(this, root);
67 root.addChild(audioDevices);
68
69 for(AudioDeviceModel a : CC.getSamplerModel().getAudioDevices()) {
70 audioDevices.addChild(new AudioDeviceTreeNode(this, audioDevices, a));
71 a.addAudioDeviceListener(getHandler());
72 }
73
74 CC.getSamplerModel().addAudioDeviceListListener(getHandler());
75
76 internalEffects = new InternalEffectsTreeNode(this, root);
77 root.addChild(internalEffects);
78 for(int i = 0; i < CC.getSamplerModel().getEffects().getEffectCount(); i++) {
79 Effect fx = CC.getSamplerModel().getEffects().getEffect(i);
80 internalEffects.addChild(new InternalEffectTreeNode(internalEffects, fx));
81 }
82 }
83
84 // Tree model methods
85 @Override
86 public void
87 addTreeModelListener(TreeModelListener l) {
88 listeners.add(l);
89 }
90
91 @Override
92 public void
93 removeTreeModelListener(TreeModelListener l) {
94 listeners.remove(l);
95 }
96
97 @Override
98 public Object
99 getChild(Object parent, int index) {
100 return ((TreeNode)parent).getChildAt(index);
101 }
102
103 @Override
104 public int
105 getChildCount(Object parent) {
106 return ((TreeNode)parent).getChildCount();
107 }
108
109 @Override
110 public Object
111 getRoot() { return root; }
112
113 @Override
114 public int
115 getIndexOfChild(Object parent, Object child) {
116 if(parent == null || child == null) return -1;
117 return ((TreeNode)parent).getIndex((TreeNode)child);
118 }
119
120 @Override
121 public boolean
122 isLeaf(Object node) { return ((TreeNode)node).isLeaf(); }
123
124 @Override
125 public void
126 valueForPathChanged(TreePath path, Object newValue) {
127
128 }
129 ///////
130
131 protected Object[]
132 getPathToRoot(TreeNode node) {
133 Vector v = new Vector();
134
135 while(node != null) {
136 v.insertElementAt(node, 0);
137 if(node == getRoot()) break;
138 node = node.getParent();
139 }
140
141 return v.toArray(new Object[v.size()]);
142 }
143
144 private void
145 fireNodeInserted(TreeNode node, int index) {
146 Object[] path = getPathToRoot(node.getParent());
147
148 int[] idxs = { index };
149 Object[] objs = { node };
150 TreeModelEvent e = new TreeModelEvent(this, path, idxs, objs);
151 for(TreeModelListener l : listeners) {
152 l.treeNodesInserted(e);
153 }
154 }
155
156 private void
157 fireNodeChanged(TreeNode node, int index) {
158 Object[] path = getPathToRoot(node.getParent());
159 int[] idxs = { index };
160 Object[] objs = { node };
161 TreeModelEvent e = new TreeModelEvent(this, path, idxs, objs);
162 for(TreeModelListener l : listeners) {
163 l.treeNodesChanged(e);
164 }
165 }
166
167 private void
168 fireNodeRemoved(TreeNode parent, TreeNode node, int index) {
169 Object[] path = getPathToRoot(parent);
170 int[] idxs = { index };
171 Object[] objs = { node };
172 TreeModelEvent e = new TreeModelEvent(this, path, idxs, objs);
173 for(int i = listeners.size() - 1; i >=0; i--) {
174 listeners.get(i).treeNodesRemoved(e);
175 }
176 }
177
178 private void
179 fireNodeStructureChanged(TreeNode node) {
180 Object[] path = getPathToRoot(node);
181 Object[] objs = { node };
182 TreeModelEvent e = new TreeModelEvent(this, path);
183 for(TreeModelListener l : listeners) {
184 l.treeStructureChanged(e);
185 }
186 }
187
188
189 private final EventHandler eventHandler = new EventHandler();
190
191 private EventHandler
192 getHandler() { return eventHandler; }
193
194 private class EventHandler implements ListListener<AudioDeviceModel>, AudioDeviceListener {
195
196
197 /** Invoked when a new entry is added to a list. */
198 @Override
199 public void
200 entryAdded(final ListEvent<AudioDeviceModel> e) {
201 e.getEntry().addAudioDeviceListener(getHandler());
202 AudioDeviceTreeNode node =
203 new AudioDeviceTreeNode(SamplerTreeModel.this, audioDevices, e.getEntry());
204 audioDevices.addChild(node);
205 fireNodeInserted(node, audioDevices.getIndex(node));
206
207 root.firePropertyChange("SamplerTreeModel.update", null, null);
208 audioDevices.firePropertyChange("SamplerTreeModel.update", null, null);
209 }
210
211 /** Invoked when an entry is removed from a list. */
212 @Override
213 public void
214 entryRemoved(ListEvent<AudioDeviceModel> e) {
215 TreeNode node = audioDevices.getChildById(e.getEntry().getDeviceId());
216 int i = audioDevices.getIndex(node);
217 if(i == -1) return;
218
219 audioDevices.removeChildAt(i);
220 fireNodeRemoved(audioDevices, node, i);
221
222 e.getEntry().removeAudioDeviceListener(getHandler());
223
224 root.firePropertyChange("SamplerTreeModel.update", null, null);
225 audioDevices.firePropertyChange("SamplerTreeModel.update", null, null);
226 }
227
228 @Override
229 public void
230 settingsChanged(AudioDeviceEvent e) {
231 audioDevices.firePropertyChange("SamplerTreeModel.update", null, null);
232
233 TreeNodeBase node =
234 audioDevices.getChildById(e.getAudioDeviceModel().getDeviceId());
235
236 if(node != null) {
237 node.firePropertyChange("SamplerTreeModel.update", null, null);
238 }
239 }
240
241 /** Invoked when a new send effect chain is added to the audio device. */
242 @Override
243 public void
244 sendEffectChainAdded(AudioDeviceEvent e) {
245 AudioDeviceTreeNode node =
246 audioDevices.getChildById(e.getAudioDeviceModel().getDeviceId());
247
248 if(node == null) {
249 CC.getLogger().warning("Missing audio device node. This is a bug!");
250 return;
251 }
252
253 SendEffectChainsTreeNode chainsNode = node.getSendEffectChainsTreeNode();
254
255 SendEffectChainTreeNode child = new SendEffectChainTreeNode (
256 SamplerTreeModel.this, chainsNode, e.getEffectChain()
257 );
258
259 chainsNode.addChild(child);
260 fireNodeInserted(child, chainsNode.getIndex(child));
261
262 node.firePropertyChange("SamplerTreeModel.update", null, null);
263 chainsNode.firePropertyChange("SamplerTreeModel.update", null, null);
264 }
265
266 /** Invoked when when a send effect chain is removed from the audio device. */
267 @Override
268 public void
269 sendEffectChainRemoved(AudioDeviceEvent e) {
270 AudioDeviceTreeNode node =
271 audioDevices.getChildById(e.getAudioDeviceModel().getDeviceId());
272
273 if(node == null) {
274 CC.getLogger().warning("Missing audio device node. This is a bug!");
275 return;
276 }
277
278 SendEffectChainsTreeNode chainsNode = node.getSendEffectChainsTreeNode();
279
280 SendEffectChainTreeNode child = chainsNode.getChildById(e.getEffectChain().getChainId());
281 if(child == null) {
282 CC.getLogger().warning("Missing send effect chain node. This is a bug!");
283 return;
284 }
285
286 e.getEffectChain().removeEffectChainListener(child);
287 child.uninstallListeners();
288
289 int idx = chainsNode.getIndex(child);
290 chainsNode.removeChildAt(idx);
291 fireNodeRemoved(chainsNode, child, idx);
292
293 node.firePropertyChange("SamplerTreeModel.update", null, null);
294 chainsNode.firePropertyChange("SamplerTreeModel.update", null, null);
295 }
296 }
297
298 public static abstract class TreeNodeBase<T extends TreeNodeBase>
299 extends PropertyChangeSupport implements TreeNode {
300
301 public TreeNodeBase() { super(new Object()); }
302
303 public abstract T getChildAt(int index);
304 public abstract boolean isLeaf();
305
306 /** Gets the number of columns for the corresponding table model. */
307 public int
308 getColumnCount() { return 1; }
309
310 /** Gets the number of rows for the corresponding table model. */
311 public int
312 getRowCount() { return 1; }
313
314 /**
315 * Gets the value for the cell at <code>row</code> and
316 * <code>col</code> for the corresponding table model.
317 */
318 public Object
319 getValueAt(int row, int col) { return "Not implemented yet"; }
320
321 /** Gets the name of the column for the corresponding table model. */
322 public String
323 getColumnName(int col) { return " "; }
324
325 /** Gets the number of items this node contains. */
326 public int
327 getItemCount() { return getRowCount(); }
328
329 public String
330 getItemCountString() { return String.valueOf(getItemCount()); }
331
332 /** Determines the alignment for the cells in the specified column. */
333 public int
334 getHorizontalAlignment(int column) {
335 return column == 0 ? SwingConstants.LEFT : SwingConstants.CENTER;
336 }
337 }
338
339 public static class AbstractTreeNode<T extends TreeNodeBase> extends TreeNodeBase<T> {
340 protected final SamplerTreeModel treeModel;
341 private final TreeNodeBase parent;
342 private final Vector<T> children = new Vector<T>();
343
344 public
345 AbstractTreeNode(SamplerTreeModel treeModel) { this(treeModel, null); }
346
347 public
348 AbstractTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) {
349 this.parent = parent;
350 this.treeModel = treeModel;
351 }
352
353 // Tree node model methods
354 @Override
355 public T
356 getChildAt(int index) { return children.get(index); }
357
358 @Override
359 public int
360 getChildCount() { return children.size(); }
361
362 @Override
363 public TreeNodeBase
364 getParent() { return parent; }
365
366 @Override
367 public int
368 getIndex(TreeNode node) { return children.indexOf(node); }
369
370 @Override
371 public boolean
372 getAllowsChildren() { return true; }
373
374 @Override
375 public boolean
376 isLeaf() { return false; }
377
378 @Override
379 public Enumeration
380 children() { return children.elements(); }
381 ///////
382
383 public void
384 addChild(T child) { children.add(child); }
385
386 public T
387 removeChildAt(int index) { return children.remove(index); }
388
389 public void
390 removeAllChildren() { children.removeAllElements(); }
391 }
392
393 public static class AbstractTreeLeaf<T extends TreeNodeBase> extends TreeNodeBase<T> {
394 private final T parent;
395
396 public
397 AbstractTreeLeaf() { this(null); }
398
399 public
400 AbstractTreeLeaf(T parent) {this.parent = parent; }
401
402 // Tree node model methods
403 @Override
404 public T
405 getChildAt(int index) { return null; }
406
407 @Override
408 public int
409 getChildCount() { return 0; }
410
411 @Override
412 public T
413 getParent() { return parent; }
414
415 @Override
416 public int
417 getIndex(TreeNode node) { return -1; }
418
419 @Override
420 public boolean
421 getAllowsChildren() { return false; }
422
423 @Override
424 public boolean
425 isLeaf() { return true; }
426
427 @Override
428 public Enumeration
429 children() { return null; }
430 ///////
431 }
432
433 public static class StandardTreeNode<T extends TreeNodeBase> extends AbstractTreeNode<T> {
434 public
435 StandardTreeNode(SamplerTreeModel treeModel) { this(treeModel, null); }
436
437 public
438 StandardTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) {
439 super(treeModel, parent);
440 }
441
442 /** Gets the number of columns for the corresponding table model. */
443 @Override
444 public int
445 getColumnCount() { return 3; }
446
447 /** Gets the number of rows for the corresponding table model. */
448 @Override
449 public int
450 getRowCount() { return getChildCount(); }
451
452 /**
453 * Gets the value for the cell at <code>row</code> and
454 * <code>col</code> for the corresponding table model.
455 */
456 @Override
457 public Object
458 getValueAt(int row, int col) {
459 if(col == 0) return getChildAt(row);
460 if(col == 1) return getChildAt(row).getItemCountString();
461 return "";
462 }
463
464 /** Gets the name of the column for the corresponding table model. */
465 @Override
466 public String
467 getColumnName(int col) {
468 if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.name");
469 if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.itemCount");
470 return " ";
471 }
472 }
473
474 public static class SamplerTreeNode extends StandardTreeNode {
475 public
476 SamplerTreeNode(SamplerTreeModel treeModel) {
477 super(treeModel);
478 }
479
480 @Override
481 public String
482 toString() { return i18n.getLabel("SamplerTreeNode.toString"); }
483 }
484
485 public static class AudioDevicesTreeNode extends AbstractTreeNode<AudioDeviceTreeNode> {
486 public
487 AudioDevicesTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) {
488 super(treeModel, parent);
489 }
490
491 public AudioDeviceTreeNode
492 getChildById(int audioDeviceId) {
493 for(int i = 0; i < getChildCount(); i++) {
494 if(getChildAt(i).getAudioDeviceId() == audioDeviceId) return getChildAt(i);
495 }
496
497 return null;
498 }
499
500 /** Gets the number of columns for the corresponding table model. */
501 @Override
502 public int
503 getColumnCount() { return 5; }
504
505 /** Gets the number of rows for the corresponding table model. */
506 @Override
507 public int
508 getRowCount() { return getChildCount(); }
509
510 /**
511 * Gets the value for the cell at <code>row</code> and
512 * <code>col</code> for the corresponding table model.
513 */
514 @Override
515 public Object
516 getValueAt(int row, int col) {
517 AudioDeviceModel m = getChildAt(row).getAudioDevice();
518 if(col == 0) return getChildAt(row);
519 if(col == 1) return m.getDeviceInfo().getDriverName();
520 if(col == 2) return m.getDeviceInfo().getSampleRate();
521 if(col == 3) return m.getDeviceInfo().getChannelCount();
522 return "";
523 }
524
525 /** Gets the name of the column for the corresponding table model. */
526 @Override
527 public String
528 getColumnName(int col) {
529 if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.dev");
530 if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.drv");
531 if(col == 2) return i18n.getLabel("SamplerTreeModel.tableColumn.smplrate");
532 if(col == 3) return i18n.getLabel("SamplerTreeModel.tableColumn.chns");
533 return " ";
534 }
535
536 @Override
537 public String
538 toString() { return i18n.getLabel("AudioDevicesTreeNode.toString"); }
539 }
540
541 public static class AudioDeviceTreeNode extends StandardTreeNode {
542 private final AudioDeviceModel audioDevice;
543 private final SendEffectChainsTreeNode effectChains;
544
545 public
546 AudioDeviceTreeNode (
547 SamplerTreeModel treeModel, TreeNodeBase parent, AudioDeviceModel audioDevice
548 ) {
549 super(treeModel, parent);
550 this.audioDevice = audioDevice;
551
552 effectChains = new SendEffectChainsTreeNode(treeModel, this, audioDevice);
553 addChild(effectChains);
554 }
555
556 public AudioDeviceModel
557 getAudioDevice() { return audioDevice; }
558
559 public int
560 getAudioDeviceId() { return audioDevice.getDeviceId(); }
561
562 public SendEffectChainsTreeNode
563 getSendEffectChainsTreeNode() { return effectChains; }
564
565 @Override
566 public String
567 toString() { return i18n.getLabel("AudioDeviceTreeNode.toString", getAudioDeviceId()); }
568 }
569
570 public static class SendEffectChainsTreeNode extends StandardTreeNode<SendEffectChainTreeNode> {
571 private final AudioDeviceModel audioDevice;
572
573 public
574 SendEffectChainsTreeNode (
575 SamplerTreeModel treeModel, TreeNodeBase parent, AudioDeviceModel audioDevice
576 ) {
577 super(treeModel, parent);
578 this.audioDevice = audioDevice;
579
580 for(int i = 0; i < audioDevice.getSendEffectChainCount(); i++) {
581 EffectChain chain = audioDevice.getSendEffectChain(i);
582 addChild(new SendEffectChainTreeNode(treeModel, this, chain));
583 }
584 }
585
586 public AudioDeviceModel
587 getAudioDevice() { return audioDevice; }
588
589 public int
590 getAudioDeviceId() { return audioDevice.getDeviceId(); }
591
592 public SendEffectChainTreeNode
593 getChildById(int chainId) {
594 for(int i = 0; i < getChildCount(); i++) {
595 if(getChildAt(i).getChainId() == chainId) return getChildAt(i);
596 }
597
598 return null;
599 }
600
601 @Override
602 public String
603 toString() { return i18n.getLabel("SendEffectChainsTreeNode.toString"); }
604 }
605
606 public static class SendEffectChainTreeNode extends AbstractTreeNode<EffectInstanceTreeNode>
607 implements EffectChainListener {
608 private final EffectChain chain;
609
610 public
611 SendEffectChainTreeNode (
612 SamplerTreeModel treeModel, SendEffectChainsTreeNode parent, EffectChain chain
613 ) {
614 super(treeModel, parent);
615 this.chain = chain;
616 chain.addEffectChainListener(this);
617 updateEffectInstanceList();
618 }
619 ///////
620
621 public EffectChain
622 getEffectChain() { return chain; }
623
624 public int
625 getChainId() { return chain.getChainId(); }
626
627 /**
628 * Gets the audio device to which the
629 * send effect chain represented by this tree node belongs.
630 */
631 public AudioDeviceModel
632 getAudioDevice() { return ((SendEffectChainsTreeNode)getParent()).getAudioDevice(); }
633
634 /** Gets the number of columns for the corresponding table model. */
635 @Override
636 public int
637 getColumnCount() { return 5; }
638
639 /** Gets the number of rows for the corresponding table model. */
640 @Override
641 public int
642 getRowCount() { return getChildCount(); }
643
644 /**
645 * Gets the value for the cell at <code>row</code> and
646 * <code>col</code> for the corresponding table model.
647 */
648 @Override
649 public Object
650 getValueAt(int row, int col) {
651 EffectInstance e = getChildAt(row).effectInstance;
652 if(col == 0) return getChildAt(row);
653 if(col == 1) return e.getInfo().getSystem();
654 if(col == 2) return e.getInfo().getModule();
655 if(col == 3) return e.getInfo().getName();
656 return "";
657 }
658
659 /** Gets the name of the column for the corresponding table model. */
660 @Override
661 public String
662 getColumnName(int col) {
663 if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.effect");
664 if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.type");
665 if(col == 2) return i18n.getLabel("SamplerTreeModel.tableColumn.file");
666 if(col == 3) return i18n.getLabel("SamplerTreeModel.tableColumn.id");
667 return " ";
668 }
669
670 @Override
671 public int
672 getHorizontalAlignment(int column) {
673 return column == 1 ? SwingConstants.CENTER : SwingConstants.LEFT;
674 }
675
676 @Override
677 public String
678 toString() { return i18n.getLabel("SendEffectChainTreeNode.toString", chain.getChainId()); }
679
680 @Override
681 public void
682 effectInstanceListChanged(EffectChainEvent e) {
683 updateEffectInstanceList();
684 treeModel.fireNodeStructureChanged(this);
685
686 firePropertyChange("SamplerTreeModel.update", null, null);
687 getParent().firePropertyChange("SamplerTreeModel.update", null, null);
688 }
689
690 private void
691 updateEffectInstanceList() {
692 uninstallListeners();
693
694 removeAllChildren();
695 for(int i = 0; i < chain.getEffectInstanceCount(); i++) {
696 EffectInstance ei = chain.getEffectInstance(i);
697 addChild(new EffectInstanceTreeNode(treeModel, this, ei));
698 }
699
700 installListeners();
701 }
702
703 public void
704 installListeners() {
705 for(int i = 0; i < getChildCount(); i++) {
706 getChildAt(i).effectInstance.addEffectInstanceListener(getChildAt(i));
707 }
708 }
709
710 public void
711 uninstallListeners() {
712 for(int i = 0; i < getChildCount(); i++) {
713 getChildAt(i).effectInstance.removeEffectInstanceListener(getChildAt(i));
714 }
715 }
716 }
717
718 public static class EffectInstanceTreeNode extends AbstractTreeNode implements EffectInstanceListener {
719 private final EffectInstance effectInstance;
720 private EffectParameter[] params;
721
722 public
723 EffectInstanceTreeNode (
724 SamplerTreeModel treeModel, SendEffectChainTreeNode parent, EffectInstance ei
725 ) {
726 super(treeModel, parent);
727 effectInstance = ei;
728 params = ei.getInfo().getParameters();
729 }
730
731 @Override
732 public SendEffectChainTreeNode
733 getParent() { return (SendEffectChainTreeNode)super.getParent(); }
734
735 public int
736 getInstanceId() { return effectInstance.getInstanceId(); }
737
738 /** Gets the number of columns for the corresponding table model. */
739 @Override
740 public int
741 getColumnCount() { return 3; }
742
743 /** Gets the number of rows for the corresponding table model. */
744 @Override
745 public int
746 getRowCount() { return params.length; }
747
748 /**
749 * Gets the value for the cell at <code>row</code> and
750 * <code>col</code> for the corresponding table model.
751 */
752 @Override
753 public Object
754 getValueAt(int row, int col) {
755 if(col == 0) return effectInstance.getInfo().getParameter(row);
756 if(col == 1) return effectInstance.getInfo().getParameter(row).getValue();
757 return "";
758 }
759
760 /** Gets the name of the column for the corresponding table model. */
761 @Override
762 public String
763 getColumnName(int col) {
764 if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.name");
765 if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.value");
766 return " ";
767 }
768
769 @Override
770 public int
771 getHorizontalAlignment(int column) {
772 return column == 1 ? SwingConstants.RIGHT : SwingConstants.LEFT;
773 }
774
775 @Override
776 public void
777 effectInstanceChanged(EffectInstanceEvent e) {
778 firePropertyChange("SamplerTreeModel.update", null, null);
779 }
780
781 @Override
782 public String
783 toString() { return effectInstance.getInfo().getDescription(); }
784 }
785
786 public static class InternalEffectsTreeNode extends AbstractTreeNode<InternalEffectTreeNode> {
787 public
788 InternalEffectsTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) {
789 super(treeModel, parent);
790 }
791
792 /** Gets the number of columns for the corresponding table model. */
793 @Override
794 public int
795 getColumnCount() { return 5; }
796
797 /** Gets the number of rows for the corresponding table model. */
798 @Override
799 public int
800 getRowCount() { return getChildCount(); }
801
802 /**
803 * Gets the value for the cell at <code>row</code> and
804 * <code>col</code> for the corresponding table model.
805 */
806 @Override
807 public Object
808 getValueAt(int row, int col) {
809 Effect e = getChildAt(row).effect;
810 if(col == 0) return getChildAt(row);
811 if(col == 1) return e.getSystem();
812 if(col == 2) return e.getModule();
813 if(col == 3) return e.getName();
814 return "";
815 }
816
817 /** Gets the name of the column for the corresponding table model. */
818 @Override
819 public String
820 getColumnName(int col) {
821 if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.effect");
822 if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.type");
823 if(col == 2) return i18n.getLabel("SamplerTreeModel.tableColumn.file");
824 if(col == 3) return i18n.getLabel("SamplerTreeModel.tableColumn.id");
825 return " ";
826 }
827
828 @Override
829 public int
830 getHorizontalAlignment(int column) {
831 return column == 1 ? SwingConstants.CENTER : SwingConstants.LEFT;
832 }
833
834 @Override
835 public String
836 toString() { return i18n.getLabel("InternalEffectsTreeNode.toString"); }
837 }
838
839 public static class InternalEffectTreeNode extends AbstractTreeLeaf {
840 private final Effect effect;
841
842 public
843 InternalEffectTreeNode(TreeNodeBase parent, Effect effect) {
844 super(parent);
845 this.effect = effect;
846 }
847
848 @Override
849 public String
850 toString() { return effect.getDescription(); }
851 }
852
853 }

  ViewVC Help
Powered by ViewVC