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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2146 - (hide annotations) (download)
Mon Oct 11 09:31:27 2010 UTC (13 years, 6 months ago) by iliev
File size: 7881 byte(s)
* Fantasia: Migrated to substance 6.1
* Fantasia: Some minor GUI enhancements

1 iliev 1286 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4 iliev 2146 * Copyright (C) 2005-2010 Grigor Iliev <grigor@grigoriliev.com>
5 iliev 1286 *
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 iliev 1864 import java.util.HashMap;
26     import java.util.Map;
27    
28 iliev 1286 import javax.swing.Icon;
29 iliev 1786 import javax.swing.ImageIcon;
30 iliev 1286 import javax.swing.UIManager;
31    
32 iliev 1752 import org.jsampler.CC;
33 iliev 1286 import org.jsampler.JSPrefs;
34    
35     import org.jsampler.view.InstrumentsDbTableView;
36     import org.jsampler.view.InstrumentsDbTreeView;
37 iliev 1752 import org.jsampler.view.BasicIconSet;
38 iliev 1818 import org.jsampler.view.JSMainFrame;
39 iliev 1286 import org.jsampler.view.JSViewConfig;
40    
41 iliev 2146 import org.pushingpixels.substance.api.SubstanceConstants;
42     import org.pushingpixels.substance.api.SubstanceLookAndFeel;
43 iliev 1286
44     /**
45     *
46     * @author Grigor Iliev
47     */
48     public class ViewConfig extends JSViewConfig {
49     private InstrumentsDbTreeView instrumentsDbTreeView = new TreeView();
50     private InstrumentsDbTableView instrumentsDbTableView = new TableView();
51 iliev 1752 private BasicIconSet basicIconSet = new IconSet();
52 iliev 1864
53     private Map nativeMenuPropsMap = null;
54     private Map menuPropsMap = null;
55 iliev 1286
56     /** Creates a new instance of <code>ViewConfig</code> */
57     public
58     ViewConfig() {
59     try {
60 iliev 1865 if(isUsingScreenMenuBar()) {
61 iliev 1864 // fix for setting the menu bar on top of the screen
62     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
63     nativeMenuPropsMap = getMenuProperties();
64     }
65 iliev 2146 UIManager.setLookAndFeel(new SubstanceFantasiaLookAndFeel());
66 iliev 1743 UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE);
67 iliev 1496
68 iliev 1729 UIManager.put (
69     SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
70     SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL
71     );
72 iliev 1864
73 iliev 1865 if(isUsingScreenMenuBar()) {
74 iliev 1864 // fix for setting the menu bar on top of the screen
75     menuPropsMap = getMenuProperties();
76     setNativeMenuProperties();
77     }
78 iliev 1729
79 iliev 1496 if(!preferences().getBoolProperty("TurnOffCustomWindowDecoration")) {
80     javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
81     javax.swing.JDialog.setDefaultLookAndFeelDecorated(true);
82     }
83    
84     Res.loadTheme(preferences().getStringProperty("Theme"));
85 iliev 1286 } catch(Exception e) {
86     e.printStackTrace();
87     }
88     }
89 iliev 1864
90     /**
91     * If running on Mac OS and third party LaF is used
92     * certain properties from the system LaF should be set
93     * to be able to move the menu bar on top of the screen.
94     */
95     public void
96     setNativeMenuProperties() {
97     setMenuProperties(nativeMenuPropsMap);
98     }
99    
100     /**
101     * If running on Mac OS and third party LaF is used
102     * certain properties from the system LaF should be set
103     * to be able to move the menu bar on top of the screen.
104     * This method is used to reverse them back to the LaF to be used.
105     */
106     public void
107     restoreMenuProperties() {
108     setMenuProperties(menuPropsMap);
109     }
110    
111     private void
112     setMenuProperties(Map props) {
113     if(props == null) return;
114     for(Object o : props.keySet()) UIManager.put(o, props.get(o));
115     }
116    
117     public Map
118     getMenuProperties() {
119     Map props = new HashMap();
120     props.put("MenuBarUI", UIManager.get("MenuBarUI"));
121     props.put("MenuUI", UIManager.get("MenuUI"));
122     props.put("MenuItemUI", UIManager.get("MenuItemUI"));
123     props.put("CheckBoxMenuItemUI", UIManager.get("CheckBoxMenuItemUI"));
124     props.put("RadioButtonMenuItemUI", UIManager.get("RadioButtonMenuItemUI"));
125     props.put("PopupMenuUI", UIManager.get("PopupMenuUI"));
126     return props;
127     }
128 iliev 1286
129 iliev 1786 @Override
130 iliev 1286 public JSPrefs
131     preferences() { return FantasiaPrefs.preferences(); }
132    
133 iliev 1767 /** Exports the view configuration of the current session. */
134 iliev 1786 @Override
135 iliev 1767 public String
136     exportSessionViewConfig() {
137     StringBuffer sb = new StringBuffer();
138     MainFrame frame = (MainFrame)CC.getMainFrame();
139    
140 iliev 1818 for(int i = 0; i < frame.getChannelsPaneCount(); i++) {
141     exportSamplerChannels(sb, i);
142     }
143    
144     MidiDevicesPane midi = frame.getRightSidePane().getDevicesPane().getMidiDevicesPane();
145    
146     for(int i = 0; i < midi.getDevicePaneCount(); i++) {
147     sb.append("#jsampler.fantasia: [MIDI device]\r\n");
148 iliev 1767
149 iliev 1818 boolean b = midi.getDevicePaneAt(i).isOptionsPaneExpanded();
150     sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
151    
152     sb.append("#\r\n");
153     }
154    
155     AudioDevicesPane au = frame.getRightSidePane().getDevicesPane().getAudioDevicesPane();
156    
157     for(int i = 0; i < au.getDevicePaneCount(); i++) {
158     sb.append("#jsampler.fantasia: [audio device]\r\n");
159    
160     boolean b = au.getDevicePaneAt(i).isOptionsPaneExpanded();
161     sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
162    
163     sb.append("#\r\n");
164     }
165    
166     return sb.toString();
167     }
168    
169     private void
170     exportSamplerChannels(StringBuffer sb, int channelsPane) {
171     JSMainFrame frame = CC.getMainFrame();
172    
173     for(int i = 0; i < frame.getChannelsPane(channelsPane).getChannelCount(); i++) {
174     Channel c = (Channel)frame.getChannelsPane(channelsPane).getChannel(i);
175    
176 iliev 1767 sb.append("#jsampler.fantasia: [channel]\r\n");
177    
178 iliev 1867 sb.append("#jsampler.fantasia: channelLane = ");
179 iliev 1818 sb.append(channelsPane + 1).append("\r\n");
180    
181 iliev 1767 switch(c.getViewTracker().getOriginalView().getType()) {
182     case SMALL:
183     sb.append("#jsampler.fantasia: viewType = SMALL\r\n");
184     break;
185    
186     case NORMAL:
187     sb.append("#jsampler.fantasia: viewType = NORMAL\r\n");
188     break;
189     }
190    
191 iliev 1818 boolean b = c.getViewTracker().getOriginalView().isOptionsButtonSelected();
192     sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n");
193 iliev 1767
194 iliev 1818 sb.append("#\r\n");
195 iliev 1767 }
196     }
197    
198 iliev 1786 @Override
199 iliev 1286 public InstrumentsDbTreeView
200     getInstrumentsDbTreeView() { return instrumentsDbTreeView; }
201    
202 iliev 1786 @Override
203 iliev 1286 public InstrumentsDbTableView
204     getInstrumentsDbTableView() { return instrumentsDbTableView; }
205    
206 iliev 1786 @Override
207 iliev 1752 public BasicIconSet
208     getBasicIconSet() { return basicIconSet; }
209    
210 iliev 1286 private class TreeView implements InstrumentsDbTreeView {
211 iliev 1786 @Override
212 iliev 1286 public Icon
213     getRootIcon() { return Res.iconDb16; }
214    
215 iliev 1786 @Override
216 iliev 1286 public Icon
217     getClosedIcon() { return Res.iconFolder16; }
218    
219 iliev 1786 @Override
220 iliev 1286 public Icon
221     getOpenIcon() { return Res.iconFolderOpen16; }
222    
223 iliev 1786 @Override
224 iliev 1286 public Icon
225     getInstrumentIcon() { return Res.iconInstrument16; }
226    
227 iliev 1786 @Override
228 iliev 1286 public Icon
229     getGigInstrumentIcon() { return Res.iconInstrument16; }
230     }
231    
232     private static class TableView implements InstrumentsDbTableView {
233 iliev 1786 @Override
234 iliev 1286 public Icon
235     getFolderIcon() { return Res.iconFolder16; }
236    
237 iliev 1786 @Override
238 iliev 1286 public Icon
239     getInstrumentIcon() { return Res.iconInstrument16; }
240    
241 iliev 1786 @Override
242 iliev 1286 public Icon
243     getGigInstrumentIcon() { return Res.iconInstrument16; }
244     }
245    
246 iliev 1752 private class IconSet implements BasicIconSet {
247 iliev 1786 @Override
248     public ImageIcon
249     getApplicationIcon() { return Res.iconAppIcon; }
250    
251     @Override
252 iliev 1752 public Icon
253     getBack16Icon() { return Res.iconBack16; }
254    
255 iliev 1786 @Override
256 iliev 1752 public Icon
257     getUp16Icon() { return Res.iconUp16; }
258    
259 iliev 1786 @Override
260 iliev 1752 public Icon
261     getForward16Icon() { return Res.iconNext16; }
262    
263 iliev 1786 @Override
264 iliev 1752 public Icon
265     getReload16Icon() { return Res.iconReload16; }
266    
267 iliev 1786 @Override
268 iliev 1752 public Icon
269     getPreferences16Icon() { return Res.iconPreferences16; }
270 iliev 1767
271 iliev 1786 @Override
272 iliev 1767 public Icon
273     getWarning32Icon() { return Res.iconWarning32; }
274    
275 iliev 1786 @Override
276 iliev 1767 public Icon
277     getQuestion32Icon() { return Res.iconQuestion32; }
278 iliev 1752 }
279    
280 iliev 1786 @Override
281 iliev 1286 public boolean
282     getInstrumentsDbSupport() { return true; }
283     }

  ViewVC Help
Powered by ViewVC