40 |
import org.jsampler.event.SamplerChannelListListener; |
import org.jsampler.event.SamplerChannelListListener; |
41 |
|
|
42 |
/** |
/** |
43 |
* |
* Defines the skeleton of a JSampler's main frame. |
44 |
* @author Grigor Iliev |
* @author Grigor Iliev |
45 |
*/ |
*/ |
46 |
public abstract class JSMainFrame extends JFrame { |
public abstract class JSMainFrame extends JFrame { |
47 |
private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>(); |
private final Vector<JSChannelsPane> chnPaneList = new Vector<JSChannelsPane>(); |
48 |
|
|
49 |
|
/** Creates a new instance of <code>JSMainFrame</code>. */ |
50 |
public |
public |
51 |
JSMainFrame() { |
JSMainFrame() { |
52 |
super(JSampler.NAME + ' ' + JSampler.VERSION); |
super(JSampler.NAME + ' ' + JSampler.VERSION); |
60 |
CC.getSamplerModel().addSamplerChannelListListener(new EventHandler()); |
CC.getSamplerModel().addSamplerChannelListListener(new EventHandler()); |
61 |
} |
} |
62 |
|
|
63 |
private void |
/** |
64 |
|
* Invoked when this window is about to close. |
65 |
|
* Don't forget to call <code>super.onWindowClose()</code> at the end, |
66 |
|
* when override this method. |
67 |
|
*/ |
68 |
|
protected void |
69 |
onWindowClose() { |
onWindowClose() { |
|
if(Prefs.getSaveWindowProperties()) { |
|
|
Prefs.setWindowMaximized ( |
|
|
(getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH |
|
|
); |
|
|
|
|
|
setVisible(false); |
|
|
if(Prefs.getWindowMaximized()) { |
|
|
//setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH); |
|
|
CC.cleanExit(); |
|
|
return; |
|
|
} |
|
|
|
|
|
java.awt.Point p = getLocation(); |
|
|
Dimension d = getSize(); |
|
|
StringBuffer sb = new StringBuffer(); |
|
|
sb.append(p.x).append(',').append(p.y).append(','); |
|
|
sb.append(d.width).append(',').append(d.height); |
|
|
Prefs.setWindowSizeAndLocation(sb.toString()); |
|
|
} |
|
|
|
|
70 |
CC.cleanExit(); |
CC.cleanExit(); |
71 |
} |
} |
72 |
|
|
73 |
|
/** |
74 |
|
* Returns a list containing all <code>JSChannelsPane</code>s added to the view. |
75 |
|
* @return A list containing all <code>JSChannelsPane</code>s added to the view. |
76 |
|
* @see #addChannelsPane |
77 |
|
* @see #removeChannelsPane |
78 |
|
*/ |
79 |
public Vector<JSChannelsPane> |
public Vector<JSChannelsPane> |
80 |
getChannelsPaneList() { return chnPaneList; } |
getChannelsPaneList() { return chnPaneList; } |
81 |
|
|
82 |
|
/** |
83 |
|
* Return the <code>JSChannelsPane</code> at the specified position. |
84 |
|
* @param idx The position of the <code>JSChannelsPane</code> to be returned. |
85 |
|
* @return The <code>JSChannelsPane</code> at the specified position. |
86 |
|
*/ |
87 |
public JSChannelsPane |
public JSChannelsPane |
88 |
getChannelsPane(int idx) { return chnPaneList.get(idx); } |
getChannelsPane(int idx) { return chnPaneList.get(idx); } |
89 |
|
|
90 |
|
/** |
91 |
|
* Adds the specified <code>JSChannelsPane</code> to the view. |
92 |
|
* @param chnPane The <code>JSChannelsPane</code> to be added. |
93 |
|
*/ |
94 |
public void |
public void |
95 |
addChannelsPane(JSChannelsPane chnPane) { chnPaneList.add(chnPane); } |
addChannelsPane(JSChannelsPane chnPane) { chnPaneList.add(chnPane); } |
96 |
|
|
97 |
|
/** |
98 |
|
* Removes the specified <code>JSChannelsPane</code> from the view. |
99 |
|
* Override this method to remove <code>chnPane</code> from the view, |
100 |
|
* and don't forget to call <code>super.removeChannelsPane(chnPane);</code>. |
101 |
|
* @param chnPane The <code>JSChannelsPane</code> to be removed. |
102 |
|
* @return <code>true</code> if the specified code>JSChannelsPane</code> |
103 |
|
* is actually removed from the view, <code>false</code> otherwise. |
104 |
|
*/ |
105 |
public boolean |
public boolean |
106 |
removeChannelsPane(JSChannelsPane chnPane) { return chnPaneList.remove(chnPane); } |
removeChannelsPane(JSChannelsPane chnPane) { return chnPaneList.remove(chnPane); } |
107 |
|
|
108 |
|
/** |
109 |
|
* Gets the current number of <code>JSChannelsPane</code>s added to the view. |
110 |
|
* @return The current number of <code>JSChannelsPane</code>s added to the view. |
111 |
|
*/ |
112 |
public int |
public int |
113 |
getChannelsPaneCount() { return chnPaneList.size(); } |
getChannelsPaneCount() { return chnPaneList.size(); } |
114 |
|
|
115 |
|
/** |
116 |
|
* Inserts the specified <code>JSChannelsPane</code> at the specified position |
117 |
|
* in the view and in the code>JSChannelsPane</code> list. |
118 |
|
* Where and how this pane will be shown depends on the view/GUI implementation. |
119 |
|
* Note that some GUI implementation may have only one pane containing sampler channels. |
120 |
|
* @param pane The <code>JSChannelsPane</code> to be inserted. |
121 |
|
* @param idx Specifies the position of the <code>JSChannelsPane</code>. |
122 |
|
* @see #getChannelsPaneList |
123 |
|
*/ |
124 |
public abstract void insertChannelsPane(JSChannelsPane pane, int idx); |
public abstract void insertChannelsPane(JSChannelsPane pane, int idx); |
125 |
|
|
126 |
|
/** |
127 |
|
* Gets the <code>JSChannelsPane</code> that is currently shown, |
128 |
|
* or has the focus if more than one channels' panes are shown. |
129 |
|
* If the GUI implementation has only one pane containing sampler channels, |
130 |
|
* than this method should always return that pane (the <code>JSChannelsPane</code> |
131 |
|
* with index 0). |
132 |
|
* @return The selected <code>JSChannelsPane</code>. |
133 |
|
*/ |
134 |
public abstract JSChannelsPane getSelectedChannelsPane(); |
public abstract JSChannelsPane getSelectedChannelsPane(); |
135 |
|
|
136 |
|
/** |
137 |
|
* Sets the <code>JSChannelsPane</code> to be selected. |
138 |
|
* @param pane The <code>JSChannelsPane</code> to be shown. |
139 |
|
*/ |
140 |
public abstract void setSelectedChannelsPane(JSChannelsPane pane); |
public abstract void setSelectedChannelsPane(JSChannelsPane pane); |
141 |
|
|
142 |
private class EventHandler implements SamplerChannelListListener { |
private class EventHandler implements SamplerChannelListListener { |