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

Annotation of /jsampler/trunk/src/org/jsampler/view/JSViewConfig.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2288 - (hide annotations) (download)
Wed Nov 23 21:19:44 2011 UTC (12 years, 4 months ago) by iliev
File size: 5148 byte(s)
* Added option to select a sampler engine in Add/Edit Instrument dialog
* Moved all Swing dependent code outside the JSampler core

1 iliev 1285 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4 iliev 2195 * Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com>
5 iliev 1285 *
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;
24    
25 iliev 1540 import java.beans.PropertyChangeEvent;
26     import java.beans.PropertyChangeListener;
27    
28 iliev 1864 import org.jsampler.CC;
29 iliev 1285 import org.jsampler.JSPrefs;
30 iliev 1767 import org.jsampler.MidiInstrument;
31 iliev 1285
32 iliev 1767 import static org.jsampler.JSPrefs.*;
33 iliev 1540
34 iliev 1285 /**
35     * Provides the view configuration.
36     * @author Grigor Iliev
37     */
38 iliev 2288 public abstract class JSViewConfig<I> {
39 iliev 1540 private boolean measurementUnitDecibel;
40 iliev 1285
41 iliev 1767 private int firstMidiBankNumber;
42     private int firstMidiProgramNumber;
43    
44 iliev 1285 /** Creates a new instance of <code>JSViewConfig</code> */
45     public
46     JSViewConfig() {
47 iliev 1540 measurementUnitDecibel = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
48 iliev 1285
49 iliev 1540 String s = VOL_MEASUREMENT_UNIT_DECIBEL;
50     preferences().addPropertyChangeListener(s, new PropertyChangeListener() {
51     public void
52     propertyChange(PropertyChangeEvent e) {
53     boolean b;
54     b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
55     measurementUnitDecibel = b;
56     }
57     });
58 iliev 1767
59     firstMidiBankNumber = preferences().getIntProperty(FIRST_MIDI_BANK_NUMBER);
60     firstMidiProgramNumber = preferences().getIntProperty(FIRST_MIDI_PROGRAM_NUMBER);
61    
62     MidiInstrument.setFirstProgramNumber(firstMidiProgramNumber);
63    
64     s = FIRST_MIDI_BANK_NUMBER;
65     preferences().addPropertyChangeListener(s, new PropertyChangeListener() {
66     public void
67     propertyChange(PropertyChangeEvent e) {
68     firstMidiBankNumber = preferences().getIntProperty(FIRST_MIDI_BANK_NUMBER);
69     }
70     });
71    
72     s = FIRST_MIDI_PROGRAM_NUMBER;
73     preferences().addPropertyChangeListener(s, new PropertyChangeListener() {
74     public void
75     propertyChange(PropertyChangeEvent e) {
76     firstMidiProgramNumber = preferences().getIntProperty(FIRST_MIDI_PROGRAM_NUMBER);
77     MidiInstrument.setFirstProgramNumber(firstMidiProgramNumber);
78     }
79     });
80 iliev 1285 }
81    
82     /**
83     * Provides UI information for instruments database trees.
84     */
85 iliev 2288 public abstract InstrumentsDbTreeView<I> getInstrumentsDbTreeView();
86 iliev 1285
87     /**
88     * Provides UI information for instruments database tables.
89     */
90 iliev 2288 public abstract InstrumentsDbTableView<I> getInstrumentsDbTableView();
91 iliev 1285
92 iliev 2288 public abstract SamplerBrowserView<I> getSamplerBrowserView();
93 iliev 2195
94 iliev 2288 public abstract BasicIconSet<I> getBasicIconSet();
95 iliev 1752
96 iliev 1285 public abstract JSPrefs preferences();
97    
98     /**
99     * Determines whether this view provides instruments database support.
100     * @return <code>false</code>
101     */
102     public boolean
103     getInstrumentsDbSupport() { return false; }
104 iliev 1540
105 iliev 2288 public abstract void initInstrumentsDbTreeModel();
106     public abstract void resetInstrumentsDbTreeModel();
107    
108 iliev 1540 /**
109     * Determines whether the volume values should be shown in decibels.
110     */
111     public boolean
112     isMeasurementUnitDecibel() { return measurementUnitDecibel; }
113 iliev 1752
114     /** Exports the view configuration of the current session. */
115     public String
116     exportSessionViewConfig() { return ""; }
117 iliev 1767
118 iliev 1818 private SessionViewConfig sessionViewConfig = null;
119    
120     public SessionViewConfig
121     getSessionViewConfig() { return sessionViewConfig; }
122    
123     public void
124     setSessionViewConfig(SessionViewConfig config) { sessionViewConfig = config; }
125    
126 iliev 1767 public int
127     getFirstMidiBankNumber() { return firstMidiBankNumber; }
128    
129     public int
130     getFirstMidiProgramNumber() { return firstMidiProgramNumber; }
131 iliev 1864
132 iliev 2288 public abstract int getDefaultModKey();
133 iliev 1864
134     /**
135     * Determines whether main menu is moved to
136     * the screen menu bar when running on Mac OS
137     */
138     public boolean
139     isUsingScreenMenuBar() {
140     if(!CC.isMacOS()) return false;
141     String s = System.getProperty("apple.laf.useScreenMenuBar");
142     return (s != null && "true".equalsIgnoreCase(s)) ? true : false;
143     }
144 iliev 2288
145     /**
146     * Shows a dialog with the specified error message.
147     * @param msg The error message to be shown.
148     */
149     public abstract void showErrorMessage(String msg);
150    
151     /**
152     * Shows a dialog with error message.
153     * @param e The <code>Exception</code> from which the error message is obtained.
154     */
155     public abstract void showErrorMessage(Exception e);
156    
157     /**
158     * Shows a dialog with error message.
159     * @param e The <code>Exception</code> from which the error message is obtained.
160     * @param prefix The prefix to be added to the error message.
161     */
162     public abstract void showErrorMessage(Exception e, String prefix);
163    
164     /**
165     * Sets the default font to be used in the GUI.
166     * @param fontName The name of the font to be used as default.
167     */
168     public abstract void setUIDefaultFont(String fontName);
169 iliev 1285 }

  ViewVC Help
Powered by ViewVC