1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005, 2006 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.fantasia; |
24 |
|
25 |
import java.util.prefs.Preferences; |
26 |
|
27 |
|
28 |
/** |
29 |
* |
30 |
* @author Grigor Iliev |
31 |
*/ |
32 |
public class FantasiaPrefs { |
33 |
private final static String prefNode = "org.jsampler.view.fantasia"; |
34 |
private final static Preferences userPrefs = Preferences.userRoot().node(prefNode); |
35 |
|
36 |
private final static String WINDOW_LOCATION = "Mainframe.sizeAndLocation"; |
37 |
private final static String DEF_WINDOW_LOCATION = null; |
38 |
|
39 |
private final static String ALWAYS_ON_TOP = "AlwaysOnTop"; |
40 |
private final static boolean DEF_ALWAYS_ON_TOP = false; |
41 |
|
42 |
|
43 |
|
44 |
/** Forbits instantiation of <code>FantasiaPrefs</code>. */ |
45 |
private FantasiaPrefs() { |
46 |
} |
47 |
|
48 |
public static Preferences |
49 |
user() { return userPrefs; } |
50 |
|
51 |
/** |
52 |
* Gets a string representation of the main window's location. |
53 |
* The string representation is a comma-separated list |
54 |
* of x and y coordinates. |
55 |
* @return A string representation of the main window's location, |
56 |
* or <code>null</code> if the value is not set. |
57 |
*/ |
58 |
public static String |
59 |
getWindowLocation() { |
60 |
return user().get(WINDOW_LOCATION, DEF_WINDOW_LOCATION); |
61 |
} |
62 |
|
63 |
/** |
64 |
* Sets the main window's ocation. |
65 |
* Use <code>null</code> to remove the current value. |
66 |
* @param s A string representation of the main window'socation. |
67 |
* @see #getWindowLocation |
68 |
*/ |
69 |
public static void |
70 |
setWindowLocation(String s) { |
71 |
if(s == null) { |
72 |
user().remove(WINDOW_LOCATION); |
73 |
return; |
74 |
} |
75 |
|
76 |
user().put(WINDOW_LOCATION, s); |
77 |
} |
78 |
|
79 |
/** |
80 |
* Determines whether the main window should be always-on-top window. |
81 |
* @return <code>true</code> if the main window should be always-on-top window, |
82 |
* <code>false</code> otherwise. |
83 |
*/ |
84 |
public static boolean |
85 |
isAlwaysOnTop() { |
86 |
return user().getBoolean(ALWAYS_ON_TOP, DEF_ALWAYS_ON_TOP); |
87 |
} |
88 |
|
89 |
/** |
90 |
* Sets whether the main window should be always-on-top window. |
91 |
* @param b If <code>true</code> the main window should be always-on-top window. |
92 |
*/ |
93 |
public static void |
94 |
setAlwaysOnTop(boolean b) { |
95 |
if(b == isAlwaysOnTop()) return; |
96 |
user().putBoolean(ALWAYS_ON_TOP, b); |
97 |
} |
98 |
|
99 |
|
100 |
} |