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

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/ViewConfig.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1818 - (show annotations) (download)
Wed Dec 24 17:29:47 2008 UTC (15 years, 4 months ago) by iliev
File size: 6249 byte(s)
* Added support for controlling the global sampler-wide limit of
  maximum voices and disk streams
  (choose Edit/Preferences, then click the `General' tab)
* Fantasia: store the view configuration of audio/MIDI devices and sampler
  channels in the LSCP script when exporting sampler configuration
* Fantasia: Implemented multiple sampler channels' selection
* Fantasia: Added option to move sampler channels up and down
  in the channels list
* Fantasia: Added option to move sampler channels
  to another channels panels

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 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
23 package org.jsampler.view.fantasia;
24
25 import javax.swing.Icon;
26 import javax.swing.ImageIcon;
27 import javax.swing.UIManager;
28
29 import org.jsampler.CC;
30 import org.jsampler.JSPrefs;
31
32 import org.jsampler.view.InstrumentsDbTableView;
33 import org.jsampler.view.InstrumentsDbTreeView;
34 import org.jsampler.view.BasicIconSet;
35 import org.jsampler.view.JSMainFrame;
36 import org.jsampler.view.JSViewConfig;
37
38 import org.jvnet.substance.api.SubstanceConstants;
39 import org.jvnet.substance.SubstanceLookAndFeel;
40 import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel;
41
42 /**
43 *
44 * @author Grigor Iliev
45 */
46 public class ViewConfig extends JSViewConfig {
47 private InstrumentsDbTreeView instrumentsDbTreeView = new TreeView();
48 private InstrumentsDbTableView instrumentsDbTableView = new TableView();
49 private BasicIconSet basicIconSet = new IconSet();
50
51 /** Creates a new instance of <code>ViewConfig</code> */
52 public
53 ViewConfig() {
54 try {
55 UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel());
56 UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE);
57
58 UIManager.put (
59 SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
60 SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL
61 );
62
63 if(!preferences().getBoolProperty("TurnOffCustomWindowDecoration")) {
64 javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
65 javax.swing.JDialog.setDefaultLookAndFeelDecorated(true);
66 }
67
68 Res.loadTheme(preferences().getStringProperty("Theme"));
69 } catch(Exception e) {
70 e.printStackTrace();
71 }
72 }
73
74 @Override
75 public JSPrefs
76 preferences() { return FantasiaPrefs.preferences(); }
77
78 /** Exports the view configuration of the current session. */
79 @Override
80 public String
81 exportSessionViewConfig() {
82 StringBuffer sb = new StringBuffer();
83 MainFrame frame = (MainFrame)CC.getMainFrame();
84
85 for(int i = 0; i < frame.getChannelsPaneCount(); i++) {
86 exportSamplerChannels(sb, i);
87 }
88
89 MidiDevicesPane midi = frame.getRightSidePane().getDevicesPane().getMidiDevicesPane();
90
91 for(int i = 0; i < midi.getDevicePaneCount(); i++) {
92 sb.append("#jsampler.fantasia: [MIDI device]\r\n");
93
94 boolean b = midi.getDevicePaneAt(i).isOptionsPaneExpanded();
95 sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
96
97 sb.append("#\r\n");
98 }
99
100 AudioDevicesPane au = frame.getRightSidePane().getDevicesPane().getAudioDevicesPane();
101
102 for(int i = 0; i < au.getDevicePaneCount(); i++) {
103 sb.append("#jsampler.fantasia: [audio device]\r\n");
104
105 boolean b = au.getDevicePaneAt(i).isOptionsPaneExpanded();
106 sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
107
108 sb.append("#\r\n");
109 }
110
111 return sb.toString();
112 }
113
114 private void
115 exportSamplerChannels(StringBuffer sb, int channelsPane) {
116 JSMainFrame frame = CC.getMainFrame();
117
118 for(int i = 0; i < frame.getChannelsPane(channelsPane).getChannelCount(); i++) {
119 Channel c = (Channel)frame.getChannelsPane(channelsPane).getChannel(i);
120
121 sb.append("#jsampler.fantasia: [channel]\r\n");
122
123 sb.append("#jsampler.fantasia: channelsPanel = ");
124 sb.append(channelsPane + 1).append("\r\n");
125
126 switch(c.getViewTracker().getOriginalView().getType()) {
127 case SMALL:
128 sb.append("#jsampler.fantasia: viewType = SMALL\r\n");
129 break;
130
131 case NORMAL:
132 sb.append("#jsampler.fantasia: viewType = NORMAL\r\n");
133 break;
134 }
135
136 boolean b = c.getViewTracker().getOriginalView().isOptionsButtonSelected();
137 sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
138
139 sb.append("#\r\n");
140 }
141 }
142
143 @Override
144 public InstrumentsDbTreeView
145 getInstrumentsDbTreeView() { return instrumentsDbTreeView; }
146
147 @Override
148 public InstrumentsDbTableView
149 getInstrumentsDbTableView() { return instrumentsDbTableView; }
150
151 @Override
152 public BasicIconSet
153 getBasicIconSet() { return basicIconSet; }
154
155 private class TreeView implements InstrumentsDbTreeView {
156 @Override
157 public Icon
158 getRootIcon() { return Res.iconDb16; }
159
160 @Override
161 public Icon
162 getClosedIcon() { return Res.iconFolder16; }
163
164 @Override
165 public Icon
166 getOpenIcon() { return Res.iconFolderOpen16; }
167
168 @Override
169 public Icon
170 getInstrumentIcon() { return Res.iconInstrument16; }
171
172 @Override
173 public Icon
174 getGigInstrumentIcon() { return Res.iconInstrument16; }
175 }
176
177 private static class TableView implements InstrumentsDbTableView {
178 @Override
179 public Icon
180 getFolderIcon() { return Res.iconFolder16; }
181
182 @Override
183 public Icon
184 getInstrumentIcon() { return Res.iconInstrument16; }
185
186 @Override
187 public Icon
188 getGigInstrumentIcon() { return Res.iconInstrument16; }
189 }
190
191 private class IconSet implements BasicIconSet {
192 @Override
193 public ImageIcon
194 getApplicationIcon() { return Res.iconAppIcon; }
195
196 @Override
197 public Icon
198 getBack16Icon() { return Res.iconBack16; }
199
200 @Override
201 public Icon
202 getUp16Icon() { return Res.iconUp16; }
203
204 @Override
205 public Icon
206 getForward16Icon() { return Res.iconNext16; }
207
208 @Override
209 public Icon
210 getReload16Icon() { return Res.iconReload16; }
211
212 @Override
213 public Icon
214 getPreferences16Icon() { return Res.iconPreferences16; }
215
216 @Override
217 public Icon
218 getWarning32Icon() { return Res.iconWarning32; }
219
220 @Override
221 public Icon
222 getQuestion32Icon() { return Res.iconQuestion32; }
223 }
224
225 @Override
226 public boolean
227 getInstrumentsDbSupport() { return true; }
228 }

  ViewVC Help
Powered by ViewVC