1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
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 |
|
23 |
package org.jsampler.view; |
24 |
|
25 |
import javax.swing.JPanel; |
26 |
import javax.swing.event.ListSelectionListener; |
27 |
|
28 |
import org.jsampler.SamplerChannelModel; |
29 |
|
30 |
|
31 |
/** |
32 |
* |
33 |
* @author Grigor Iliev |
34 |
*/ |
35 |
public abstract class JSChannelsPane extends JPanel { |
36 |
public final static String TITLE = "ChannelsPaneTitle"; |
37 |
|
38 |
private String title; |
39 |
|
40 |
/** Creates a new instance of ChannelsPane */ |
41 |
public |
42 |
JSChannelsPane(String title) { this.title = title; } |
43 |
|
44 |
public String |
45 |
getTitle() { return title; } |
46 |
|
47 |
public void |
48 |
setTitle(String title) { |
49 |
if(this.title.equals(title)) return; |
50 |
|
51 |
String oldTitle = this.title; |
52 |
this.title = title; |
53 |
firePropertyChange(TITLE, oldTitle, title); |
54 |
} |
55 |
|
56 |
public String |
57 |
toString() { return getTitle(); } |
58 |
|
59 |
/** |
60 |
* Adds new channel to this channels pane. |
61 |
* @param channelModel The sampler channel model to be used by the new channel. |
62 |
*/ |
63 |
public abstract void addChannel(SamplerChannelModel channelModel); |
64 |
|
65 |
/** |
66 |
* Adds the specified channels to this channels pane. |
67 |
* @param chns The channels to be added. |
68 |
*/ |
69 |
public abstract void addChannels(JSChannel[] chns); |
70 |
|
71 |
/** |
72 |
* Removes the specified channel from this channels pane. |
73 |
* This method is invoked when a sampler channel is removed in the back-end. |
74 |
* @param chn The channel to be removed from this channels pane. |
75 |
*/ |
76 |
public abstract void removeChannel(JSChannel chn); |
77 |
|
78 |
/** |
79 |
* Determines whether there is at least one selected channel. |
80 |
* @return <code>true</code> if there is at least one selected channel, |
81 |
* <code>false</code> otherwise. |
82 |
*/ |
83 |
public abstract boolean hasSelectedChannel(); |
84 |
|
85 |
/** |
86 |
* Gets the first channel in this channels pane. |
87 |
* @return The first channel in this channels pane or <code>null</code> if |
88 |
* the channels pane is empty. |
89 |
*/ |
90 |
public abstract JSChannel getFirstChannel(); |
91 |
|
92 |
/** |
93 |
* Gets the last channel in this channels pane. |
94 |
* @return The last channel in this channels pane or <code>null</code> if |
95 |
* the channels pane is empty. |
96 |
*/ |
97 |
public abstract JSChannel getLastChannel(); |
98 |
|
99 |
/** |
100 |
* Gets the channel at the specified index. |
101 |
* @return The channel at the specified index. |
102 |
* @throws ArrayIndexOutOfBoundsException If the index is out of range. |
103 |
*/ |
104 |
public abstract JSChannel getChannel(int idx); |
105 |
|
106 |
/** |
107 |
* Gets an array of all channels in this channels pane. |
108 |
* @return An array of all channels in this channels pane. |
109 |
*/ |
110 |
public abstract JSChannel[] getChannels(); |
111 |
|
112 |
/** |
113 |
* Gets the number of channels in this channels pane. |
114 |
* @return The number of channels in this channels pane. |
115 |
*/ |
116 |
public abstract int getChannelCount(); |
117 |
|
118 |
/** |
119 |
* Gets an array of all selected channels. |
120 |
* The channels are sorted in increasing index order. |
121 |
* @return The selected channels or an empty array if nothing is selected. |
122 |
*/ |
123 |
public abstract JSChannel[] getSelectedChannels(); |
124 |
|
125 |
/** |
126 |
* Gets the number of the selected channels. |
127 |
* @return The number of the selected channels. |
128 |
*/ |
129 |
public abstract int getSelectedChannelCount(); |
130 |
|
131 |
/** |
132 |
* Removes all selected channels in this channels pane. |
133 |
* Notice that this method does not remove any channels in the back-end. |
134 |
* It is invoked after the channels are already removed in the back-end. |
135 |
* @return The number of removed channels. |
136 |
*/ |
137 |
public abstract int removeSelectedChannels(); |
138 |
|
139 |
public abstract void addListSelectionListener(ListSelectionListener listener); |
140 |
public abstract void removeListSelectionListener(ListSelectionListener listener); |
141 |
} |