1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
53 |
* Registers the specified listener for receiving event messages. |
* Registers the specified listener for receiving event messages. |
54 |
* @param l The <code>OrchestraListListener</code> to register. |
* @param l The <code>OrchestraListListener</code> to register. |
55 |
*/ |
*/ |
56 |
|
@Override |
57 |
public void |
public void |
58 |
addOrchestraListListener(ListListener<OrchestraModel> l) { listeners.add(l); } |
addOrchestraListListener(ListListener<OrchestraModel> l) { listeners.add(l); } |
59 |
|
|
61 |
* Removes the specified listener. |
* Removes the specified listener. |
62 |
* @param l The <code>OrchestraListListener</code> to remove. |
* @param l The <code>OrchestraListListener</code> to remove. |
63 |
*/ |
*/ |
64 |
|
@Override |
65 |
public void |
public void |
66 |
removeOrchestraListListener(ListListener<OrchestraModel> l) { listeners.remove(l); } |
removeOrchestraListListener(ListListener<OrchestraModel> l) { listeners.remove(l); } |
67 |
|
|
69 |
* Gets the current number of orchestras in the list. |
* Gets the current number of orchestras in the list. |
70 |
* @return The current number of orchestras in the list. |
* @return The current number of orchestras in the list. |
71 |
*/ |
*/ |
72 |
|
@Override |
73 |
public int |
public int |
74 |
getOrchestraCount() { return orchestras.size(); } |
getOrchestraCount() { return orchestras.size(); } |
75 |
|
|
78 |
* @param idx The index of the orchestra to be returned. |
* @param idx The index of the orchestra to be returned. |
79 |
* @return The orchestra at the specified position. |
* @return The orchestra at the specified position. |
80 |
*/ |
*/ |
81 |
|
@Override |
82 |
public OrchestraModel |
public OrchestraModel |
83 |
getOrchestra(int idx) { return orchestras.get(idx); } |
getOrchestra(int idx) { return orchestras.get(idx); } |
84 |
|
|
87 |
* @param orchestra The model of the orchestra to be added. |
* @param orchestra The model of the orchestra to be added. |
88 |
* @throws IllegalArgumentException If <code>orchestra</code> is <code>null</code>. |
* @throws IllegalArgumentException If <code>orchestra</code> is <code>null</code>. |
89 |
*/ |
*/ |
90 |
|
@Override |
91 |
public void |
public void |
92 |
addOrchestra(OrchestraModel orchestra) { |
addOrchestra(OrchestraModel orchestra) { |
93 |
insertOrchestra(orchestra, getOrchestraCount()); |
insertOrchestra(orchestra, getOrchestraCount()); |
100 |
* @throws IllegalArgumentException If <code>orchestra</code> is <code>null</code>. |
* @throws IllegalArgumentException If <code>orchestra</code> is <code>null</code>. |
101 |
* @throws ArrayIndexOutOfBoundsException If the specified index is invalid. |
* @throws ArrayIndexOutOfBoundsException If the specified index is invalid. |
102 |
*/ |
*/ |
103 |
|
@Override |
104 |
public void |
public void |
105 |
insertOrchestra(OrchestraModel orchestra, int idx) { |
insertOrchestra(OrchestraModel orchestra, int idx) { |
106 |
if(orchestra == null) |
if(orchestra == null) |
114 |
* Removes the specified orchestra from the list. |
* Removes the specified orchestra from the list. |
115 |
* @param idx The index of the orchestra to remove. |
* @param idx The index of the orchestra to remove. |
116 |
*/ |
*/ |
117 |
|
@Override |
118 |
public void |
public void |
119 |
removeOrchestra(int idx) { |
removeOrchestra(int idx) { |
120 |
OrchestraModel orchestraModel = orchestras.get(idx); |
OrchestraModel orchestraModel = orchestras.get(idx); |
128 |
* @return <code>true</code> if the specified orchestra was in the list, |
* @return <code>true</code> if the specified orchestra was in the list, |
129 |
* <code>false</code> otherwise. |
* <code>false</code> otherwise. |
130 |
*/ |
*/ |
131 |
|
@Override |
132 |
public boolean |
public boolean |
133 |
removeOrchestra(OrchestraModel orchestraModel) { |
removeOrchestra(OrchestraModel orchestraModel) { |
134 |
boolean b = orchestras.removeElement(orchestraModel); |
boolean b = orchestras.removeElement(orchestraModel); |
137 |
} |
} |
138 |
|
|
139 |
/** Removes all orchestras from the list. */ |
/** Removes all orchestras from the list. */ |
140 |
|
@Override |
141 |
public void |
public void |
142 |
removeAllOrchestras() { |
removeAllOrchestras() { |
143 |
for(int i = 0; i < getOrchestraCount(); i++) removeOrchestra(i); |
for(int i = 0; i < getOrchestraCount(); i++) removeOrchestra(i); |
150 |
* and -1 if <code>orchestra</code> is <code>null</code> or |
* and -1 if <code>orchestra</code> is <code>null</code> or |
151 |
* the orchestra list does not contain the specified orchestra. |
* the orchestra list does not contain the specified orchestra. |
152 |
*/ |
*/ |
153 |
|
@Override |
154 |
public int |
public int |
155 |
getOrchestraIndex(OrchestraModel orchestra) { |
getOrchestraIndex(OrchestraModel orchestra) { |
156 |
if(orchestra == null) return -1; |
if(orchestra == null) return -1; |
169 |
* or if the orchestra is already on the top. |
* or if the orchestra is already on the top. |
170 |
* @param orchestra The orchestra to move on top. |
* @param orchestra The orchestra to move on top. |
171 |
*/ |
*/ |
172 |
|
@Override |
173 |
public void |
public void |
174 |
moveOrchestraOnTop(OrchestraModel orchestra) { |
moveOrchestraOnTop(OrchestraModel orchestra) { |
175 |
if(orchestra == null) return; |
if(orchestra == null) return; |
188 |
* or if the orchestra is already on the top. |
* or if the orchestra is already on the top. |
189 |
* @param orchestra The orchestra to move up. |
* @param orchestra The orchestra to move up. |
190 |
*/ |
*/ |
191 |
|
@Override |
192 |
public void |
public void |
193 |
moveOrchestraUp(OrchestraModel orchestra) { |
moveOrchestraUp(OrchestraModel orchestra) { |
194 |
if(orchestra == null) return; |
if(orchestra == null) return; |
207 |
* or if the orchestra is already at the bottom. |
* or if the orchestra is already at the bottom. |
208 |
* @param orchestra The orchestra to move down. |
* @param orchestra The orchestra to move down. |
209 |
*/ |
*/ |
210 |
|
@Override |
211 |
public void |
public void |
212 |
moveOrchestraDown(OrchestraModel orchestra) { |
moveOrchestraDown(OrchestraModel orchestra) { |
213 |
if(orchestra == null) return; |
if(orchestra == null) return; |
225 |
* or if the orchestra is already at the bottom. |
* or if the orchestra is already at the bottom. |
226 |
* @param orchestra The orchestra to move at bottom. |
* @param orchestra The orchestra to move at bottom. |
227 |
*/ |
*/ |
228 |
|
@Override |
229 |
public void |
public void |
230 |
moveOrchestraAtBottom(OrchestraModel orchestra) { |
moveOrchestraAtBottom(OrchestraModel orchestra) { |
231 |
if(orchestra == null) return; |
if(orchestra == null) return; |
243 |
* @throws IllegalArgumentException If an error occurs while |
* @throws IllegalArgumentException If an error occurs while |
244 |
* reading the content of this orchestra list. |
* reading the content of this orchestra list. |
245 |
*/ |
*/ |
246 |
|
@Override |
247 |
public void |
public void |
248 |
readObject(Node node) { |
readObject(Node node) { |
249 |
if( |
if( |
272 |
* @param node Specifies the node where the content of this orchestra |
* @param node Specifies the node where the content of this orchestra |
273 |
* list should be written. |
* list should be written. |
274 |
*/ |
*/ |
275 |
|
@Override |
276 |
public void |
public void |
277 |
writeObject(Document doc, Node node) { |
writeObject(Document doc, Node node) { |
278 |
Element el = doc.createElement("orchestras"); |
Element el = doc.createElement("orchestras"); |