1 |
iliev |
845 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2005 Grigor Kirilov Iliev |
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.classic; |
24 |
|
|
|
25 |
|
|
import java.awt.Color; |
26 |
|
|
|
27 |
|
|
import java.util.prefs.Preferences; |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
/** |
31 |
|
|
* This class represents the preferences of the JS Classic package. |
32 |
|
|
* @author Grigor Iliev |
33 |
|
|
*/ |
34 |
|
|
public class ClassicPrefs { |
35 |
|
|
private final static String prefNode = "org.jsampler.view.classic"; |
36 |
|
|
|
37 |
|
|
public final static String SHOW_TOOLBAR = "Toolbar.visible"; |
38 |
|
|
public final static boolean DEF_SHOW_TOOLBAR = true; |
39 |
|
|
|
40 |
|
|
public final static String SHOW_STATUSBAR = "Statusbar.visible"; |
41 |
|
|
public final static boolean DEF_SHOW_STATUSBAR = true; |
42 |
|
|
|
43 |
|
|
public final static String SHOW_LEFT_PANE = "LeftPane.visible"; |
44 |
|
|
public final static boolean DEF_SHOW_LEFT_PANE = true; |
45 |
|
|
|
46 |
|
|
public final static String CHANNEL_BORDER_COLOR = "Channel.borderColor"; |
47 |
|
|
public final static int DEF_CHANNEL_BORDER_COLOR = 0xb8cfe5; |
48 |
|
|
|
49 |
|
|
public final static String CUSTOM_CHANNEL_BORDER_COLOR = "Channel.customBorderColor"; |
50 |
|
|
public final static boolean DEF_CUSTOM_CHANNEL_BORDER_COLOR = false; |
51 |
|
|
|
52 |
|
|
private static Preferences userPrefs = Preferences.userRoot().node(prefNode); |
53 |
|
|
|
54 |
|
|
public static Preferences |
55 |
|
|
user() { return userPrefs; } |
56 |
|
|
|
57 |
|
|
/** |
58 |
|
|
* Determines whether the toolbar should be visible. |
59 |
|
|
* @return <code>true</code> if the toolbar should be visible, |
60 |
|
|
* <code>false</code> otherwise. |
61 |
|
|
*/ |
62 |
|
|
public static boolean |
63 |
|
|
shouldShowToolbar() { return user().getBoolean(SHOW_TOOLBAR, DEF_SHOW_TOOLBAR); } |
64 |
|
|
|
65 |
|
|
/** |
66 |
|
|
* Sets whether the toolbar should be visible. |
67 |
|
|
* @param b If <code>true</code> the toolbar will be visible at startup. |
68 |
|
|
*/ |
69 |
|
|
public static void |
70 |
|
|
setShowToolbar(boolean b) { |
71 |
|
|
if(b == shouldShowToolbar()) return; |
72 |
|
|
user().putBoolean(SHOW_TOOLBAR, b); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
/** |
76 |
|
|
* Determines whether the statusbar should be visible. |
77 |
|
|
* @return <code>true</code> if the statusbar should be visible, |
78 |
|
|
* <code>false</code> otherwise. |
79 |
|
|
*/ |
80 |
|
|
public static boolean |
81 |
|
|
shouldShowStatusbar() { return user().getBoolean(SHOW_STATUSBAR, DEF_SHOW_STATUSBAR); } |
82 |
|
|
|
83 |
|
|
/** |
84 |
|
|
* Sets whether the statusbar should be visible. |
85 |
|
|
* @param b If <code>true</code> the statusbar will be visible at startup. |
86 |
|
|
*/ |
87 |
|
|
public static void |
88 |
|
|
setShowStatusbar(boolean b) { |
89 |
|
|
if(b == shouldShowStatusbar()) return; |
90 |
|
|
user().putBoolean(SHOW_STATUSBAR, b); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
/** |
94 |
|
|
* Determines whether the left pane should be visible. |
95 |
|
|
* @return <code>true</code> if the left pane should be visible, |
96 |
|
|
* <code>false</code> otherwise. |
97 |
|
|
*/ |
98 |
|
|
public static boolean |
99 |
|
|
shouldShowLeftPane() { return user().getBoolean(SHOW_LEFT_PANE, DEF_SHOW_LEFT_PANE); } |
100 |
|
|
|
101 |
|
|
/** |
102 |
|
|
* Sets whether the left pane should be visible. |
103 |
|
|
* @param b If <code>true</code> the left pane will be visible at startup. |
104 |
|
|
*/ |
105 |
|
|
public static void |
106 |
|
|
setShowLeftPane(boolean b) { |
107 |
|
|
if(b == shouldShowLeftPane()) return; |
108 |
|
|
user().putBoolean(SHOW_LEFT_PANE, b); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
/** |
112 |
|
|
* Gets the default border color that is used for the selected channels. |
113 |
|
|
* @return The default border color that is used for the selected channels. |
114 |
|
|
*/ |
115 |
|
|
public static Color |
116 |
|
|
getDefaultChannelBorderColor() { return new Color(DEF_CHANNEL_BORDER_COLOR); } |
117 |
|
|
|
118 |
|
|
/** |
119 |
|
|
* Gets the custom border color to be used for the selected channels. |
120 |
|
|
* @return The custom border color to be used for the selected channels. |
121 |
|
|
*/ |
122 |
|
|
public static Color |
123 |
|
|
getChannelBorderColor() { |
124 |
|
|
int c = user().getInt(CHANNEL_BORDER_COLOR, DEF_CHANNEL_BORDER_COLOR); |
125 |
|
|
return new Color(c); |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
/** |
129 |
|
|
* Sets the border color to be used for the selected channels. |
130 |
|
|
* Use <code>null</code> to remove the current value. |
131 |
|
|
* @param color The border color to be used for the selected channels. |
132 |
|
|
*/ |
133 |
|
|
public static void |
134 |
|
|
setChannelBorderColor(Color c) { |
135 |
|
|
if(c == null) { |
136 |
|
|
user().remove(CHANNEL_BORDER_COLOR); |
137 |
|
|
return; |
138 |
|
|
} |
139 |
|
|
|
140 |
|
|
if(c.getRGB() == getChannelBorderColor().getRGB()) return; |
141 |
|
|
|
142 |
|
|
user().putInt(CHANNEL_BORDER_COLOR, c.getRGB()); |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
/** |
146 |
|
|
* Determines whether to use a custom border color for the selected channels. |
147 |
|
|
* @return <code>true</code> if custom border color must be used |
148 |
|
|
* for the selected channels, <code>false</code> otherwise. |
149 |
|
|
*/ |
150 |
|
|
public static boolean |
151 |
|
|
getCustomChannelBorderColor() { |
152 |
|
|
return user().getBoolean ( |
153 |
|
|
CUSTOM_CHANNEL_BORDER_COLOR, DEF_CUSTOM_CHANNEL_BORDER_COLOR |
154 |
|
|
); |
155 |
|
|
} |
156 |
|
|
|
157 |
|
|
/** |
158 |
|
|
* Sets whether to use a custom border color for the selected channels. |
159 |
|
|
* @param b specify <code>true</code> to use a custom border color |
160 |
|
|
* for the selected channels, <code>false</code> otherwise. |
161 |
|
|
*/ |
162 |
|
|
public static void |
163 |
|
|
setCustomChannelBorderColor(boolean b) { |
164 |
|
|
if(b == getCustomChannelBorderColor()) return; |
165 |
|
|
user().putBoolean(CUSTOM_CHANNEL_BORDER_COLOR, b); |
166 |
|
|
} |
167 |
|
|
} |