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 |
* |
* |
22 |
|
|
23 |
package org.jsampler.view; |
package org.jsampler.view; |
24 |
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
|
import java.beans.PropertyChangeEvent; |
|
|
import java.beans.PropertyChangeListener; |
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
25 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
26 |
import org.linuxsampler.lscp.SamplerChannel; |
import org.linuxsampler.lscp.SamplerChannel; |
27 |
|
|
30 |
* This class defines the skeleton of a sampler channel. |
* This class defines the skeleton of a sampler channel. |
31 |
* @author Grigor Iliev |
* @author Grigor Iliev |
32 |
*/ |
*/ |
33 |
public abstract class JSChannel extends JPanel { |
public interface JSChannel { |
|
private SamplerChannelModel model; |
|
|
|
|
|
/** |
|
|
* Creates a new instance of <code>JSChannel</code> using the specified |
|
|
* non-<code>null</code> channel model. |
|
|
* @param model The model to be used by this channel. |
|
|
* @throws IllegalArgumentException If the model is <code>null</code>. |
|
|
*/ |
|
|
public |
|
|
JSChannel(SamplerChannelModel model) { |
|
|
super(new BorderLayout()); |
|
|
|
|
|
if(model == null) throw new IllegalArgumentException("model must be non null"); |
|
|
this.model = model; |
|
|
|
|
|
addPropertyChangeListener("selectionProbablyChanged", new PropertyChangeListener() { |
|
|
public void |
|
|
propertyChange(PropertyChangeEvent e) { |
|
|
boolean b = Boolean.parseBoolean(e.getNewValue().toString()); |
|
|
if(isSelected() == b) return; |
|
|
|
|
|
setSelected(b); |
|
|
} |
|
|
}); |
|
|
} |
|
|
|
|
34 |
/** |
/** |
35 |
* Gets the model that is currently used by this channel. |
* Gets the model that is currently used by this channel. |
36 |
* @return model The <code>SamplerChannelModel</code> instance |
* @return model The <code>SamplerChannelModel</code> instance |
37 |
* which provides information about this channel. |
* which provides information about this channel. |
38 |
*/ |
*/ |
39 |
public SamplerChannelModel |
public SamplerChannelModel getModel(); |
|
getModel() { return model; } |
|
40 |
|
|
41 |
/** |
/** |
42 |
* Gets the numerical ID of this sampler channel. |
* Gets the numerical ID of this sampler channel. |
43 |
* @return The numerical ID of this sampler channel or -1 if the channel's ID is not set. |
* @return The numerical ID of this sampler channel or -1 if the channel's ID is not set. |
44 |
*/ |
*/ |
45 |
public int |
public int getChannelId(); |
|
getChannelId() { |
|
|
return getChannelInfo() == null ? -1 : getChannelInfo().getChannelId(); |
|
|
} |
|
46 |
|
|
47 |
/** |
/** |
48 |
* Gets the current settings of this sampler channel. |
* Gets the current settings of this sampler channel. |
49 |
* @return <code>SamplerChannel</code> instance containing |
* @return <code>SamplerChannel</code> instance containing |
50 |
* the current settings of this sampler channel. |
* the current settings of this sampler channel. |
51 |
*/ |
*/ |
52 |
public SamplerChannel |
public SamplerChannel getChannelInfo(); |
|
getChannelInfo() { return getModel().getChannelInfo(); } |
|
|
|
|
|
/** |
|
|
* Sets the current settings of this sampler channel. |
|
|
* @param chn A <code>SamplerChannel</code> instance containing |
|
|
* the new settings for this sampler channel. |
|
|
* |
|
|
public void |
|
|
setChannelInfo(SamplerChannel chn) { |
|
|
SamplerChannel oldChn = this.chn; |
|
|
this.chn = chn; |
|
|
|
|
|
firePropertyChange("ChannelInfo", oldChn, this.chn); |
|
|
}*/ |
|
53 |
|
|
54 |
/** |
/** |
55 |
* Determines whether the channel is selected. |
* Determines whether the channel is selected. |
56 |
* @return <code>true</code> if the channel is selected, <code>false</code> otherwise. |
* @return <code>true</code> if the channel is selected, <code>false</code> otherwise. |
57 |
*/ |
*/ |
58 |
public abstract boolean isSelected(); |
public boolean isSelected(); |
59 |
|
|
60 |
/** |
/** |
61 |
* Sets the selection state of this channel. |
* Sets the selection state of this channel. |
63 |
* @param select Specifies the new selection state of this channel; |
* @param select Specifies the new selection state of this channel; |
64 |
* <code>true</code> to select the channel, <code>false</code> otherwise. |
* <code>true</code> to select the channel, <code>false</code> otherwise. |
65 |
*/ |
*/ |
66 |
public abstract void setSelected(boolean select); |
public void setSelected(boolean select); |
67 |
} |
} |