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

Contents of /jsampler/trunk/src/org/jsampler/view/classic/ClassicPrefs.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1204 - (show annotations) (download)
Thu May 24 21:43:45 2007 UTC (16 years, 10 months ago) by iliev
File size: 31377 byte(s)
upgrading to version 0.5a

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2006 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.classic;
24
25 import java.awt.Color;
26
27 import java.util.prefs.Preferences;
28
29 import org.jsampler.CC;
30
31
32 /**
33 * This class represents the preferences of the JS Classic package.
34 * @author Grigor Iliev
35 */
36 public class ClassicPrefs {
37 private final static String prefNode = "org.jsampler.view.classic";
38
39 private final static String WINDOW_SIZE_AND_LOCATION = ".sizeAndLocation";
40 private final static String DEF_WINDOW_SIZE_AND_LOCATION = null;
41
42 private final static String WINDOW_MAXIMIZED = ".maximized";
43 private final static boolean DEF_WINDOW_MAXIMIZED = false;
44
45 private final static String SAVE_WINDOW_PROPERTIES = "Mainframe.saveProperties";
46 private final static boolean DEF_SAVE_WINDOW_PROPERTIES = true;
47
48 private final static String HSPLIT_DIVIDER_LOCATION = "HSplit.dividerLocation";
49 private final static int DEF_HSPLIT_DIVIDER_LOCATION = 180;
50
51 private final static String SAVE_LEFT_PANE_STATE = "LeftPane.saveState";
52 private final static boolean DEF_SAVE_LEFT_PANE_STATE = true;
53
54 private final static String LEFT_PANE_PAGE_IDX = "LeftPane.pageIndex";
55 private final static int DEF_LEFT_PANE_PAGE_IDX = 0;
56
57 private final static String SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = "showLSConsoleWhenRunScript";
58 private final static boolean DEF_SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT = true;
59
60 private final static String SHOW_CHANNELS_BAR = "ChannelsBar.visible";
61 private final static boolean DEF_SHOW_CHANNELS_BAR = true;
62
63 private final static String SHOW_STATUSBAR = "Statusbar.visible";
64 private final static boolean DEF_SHOW_STATUSBAR = true;
65
66 private final static String SHOW_LEFT_PANE = "LeftPane.visible";
67 private final static boolean DEF_SHOW_LEFT_PANE = true;
68
69 private final static String SHOW_STANDARD_BAR = "StandardBar.visible";
70 private final static boolean DEF_SHOW_STANDARD_BAR = true;
71
72 private final static String RECENT_SCRIPTS = "recentScripts";
73 private final static String DEF_RECENT_SCRIPTS = "";
74
75 private final static String RECENT_SCRIPTS_SIZE = "recentScripts.maxNumber";
76 private final static int DEF_RECENT_SCRIPTS_SIZE = 7;
77
78 private final static String SHOW_LS_CONSOLE = "LSConsole.visible";
79 private final static boolean DEF_SHOW_LS_CONSOLE = false;
80
81 private final static String LS_CONSOLE_POPOUT = "LSConsole.popout";
82 private final static boolean DEF_LS_CONSOLE_POPOUT = false;
83
84 private final static String LS_CONSOLE_HISTSIZE = "LSConsole.histsize";
85 private final static int DEF_LS_CONSOLE_HISTSIZE = 1000;
86
87 private final static String LS_CONSOLE_TEXT_COLOR = "LSConsole.textColor";
88 private final static int DEF_LS_CONSOLE_TEXT_COLOR = 0x000000;
89
90 private final static String LS_CONSOLE_BACKGROUND_COLOR = "LSConsole.backgroundColor";
91 private final static int DEF_LS_CONSOLE_BACKGROUND_COLOR = 0xffffff;
92
93 private final static String LS_CONSOLE_NOTIFY_COLOR = "LSConsole.notifyColor";
94 private final static int DEF_LS_CONSOLE_NOTIFY_COLOR = 0xcccccc;
95
96 private final static String LS_CONSOLE_WARNING_COLOR = "LSConsole.warningColor";
97 private final static int DEF_LS_CONSOLE_WARNING_COLOR = 0x6699ff;
98
99 private final static String LS_CONSOLE_ERROR_COLOR = "LSConsole.errorColor";
100 private final static int DEF_LS_CONSOLE_ERROR_COLOR = 0xff0000;
101
102 private final static String SAVE_LS_CONSOLE_HISTORY = "LSConsole.saveCommandHistory";
103 private final static boolean DEF_SAVE_LS_CONSOLE_HISTORY = true;
104
105 private final static String CHANNEL_BORDER_COLOR = "Channel.borderColor";
106 private final static int DEF_CHANNEL_BORDER_COLOR = 0xb8cfe5;
107
108 private final static String CUSTOM_CHANNEL_BORDER_COLOR = "Channel.customBorderColor";
109 private final static boolean DEF_CUSTOM_CHANNEL_BORDER_COLOR = false;
110
111 private final static String CHANNEL_BORDER_HL_COLOR = "Channel.borderMouseOverColor";
112 private final static int DEF_CHANNEL_BORDER_HL_COLOR = 0xb8cfe5;
113
114 private final static String CUSTOM_CHANNEL_BORDER_HL_COLOR = "Channel.customHlColor";
115 private final static boolean DEF_CUSTOM_CHANNEL_BORDER_HL_COLOR = false;
116
117 private final static String SEL_CHANNEL_BG_COLOR = "Channel.sel.BgColor";
118 private final static int DEF_SEL_CHANNEL_BG_COLOR = 0xe0e6eb;
119
120 private final static String CUSTOM_SEL_CHANNEL_BG_COLOR = "Channel.sel.customBgColor";
121 private final static boolean DEF_CUSTOM_SEL_CHANNEL_BG_COLOR = false;
122
123 private final static String HL_CHANNEL_BG_COLOR = "Channel.hl.BgColor";
124 private final static int DEF_HL_CHANNEL_BG_COLOR = -1;
125
126 private final static String CUSTOM_HL_CHANNEL_BG_COLOR = "Channel.hl.customBgColor";
127 private final static boolean DEF_CUSTOM_HL_CHANNEL_BG_COLOR = false;
128
129 private final static String VSPLIT_DIVIDER_LOCATION = "VSplit.dividerLocation";
130 private final static int DEF_VSPLIT_DIVIDER_LOCATION = 200;
131
132 private final static String CURRENT_ORCHESTRA_IDX = "OrchestrasPage.currentOrchestraIndex";
133 private final static int DEF_CURRENT_ORCHESTRA_IDX = 0;
134
135 private final static String LAST_SCRIPT_LOCATION = "lastScriptLocation";
136 private final static String DEF_LAST_SCRIPT_LOCATION = null;
137
138 private final static String NEW_MIDI_INSTR_WIZARD_SKIP1 = "NewMidiInstrumentWizard.skip1";
139 private final static boolean DEF_NEW_MIDI_INSTR_WIZARD_SKIP1 = false;
140
141 private final static String INSTR_LOCATION_METHOD = "InstrLocationMethod";
142 private final static int DEF_INSTR_LOCATION_METHOD = 0;
143
144 private static Preferences userPrefs = Preferences.userRoot().node(prefNode);
145
146 public static Preferences
147 user() { return userPrefs; }
148
149 /**
150 * Gets a string representation of a window's size and location.
151 * The string representation is a comma-separated list
152 * of x and y coordinates, and width and height of the window.
153 * @param window The name of the window whose size and location should be obtained.
154 * @return A string representation of the window's size and location,
155 * or <code>null</code> if the value is not set.
156 */
157 public static String
158 getWindowSizeAndLocation(String window) {
159 return user().get(window + WINDOW_SIZE_AND_LOCATION, DEF_WINDOW_SIZE_AND_LOCATION);
160 }
161
162 /**
163 * Sets the window's size and location.
164 * Use <code>null</code> to remove the current value.
165 * @param window The name of the window whose size and location should be set.
166 * @param s A string representation of the window's size and location.
167 */
168 public static void
169 setWindowSizeAndLocation(String window, String s) {
170 if(s == null) {
171 user().remove(window + WINDOW_SIZE_AND_LOCATION);
172 return;
173 }
174
175 user().put(window + WINDOW_SIZE_AND_LOCATION, s);
176 }
177
178 /**
179 * Determines whether the specified window should be maximized.
180 * @param window The name of the window.
181 * @return <code>true</code> if the specified window should be maximized,
182 * <code>false</code> otherwise.
183 */
184 public static boolean
185 getWindowMaximized(String window) {
186 return user().getBoolean(window + WINDOW_MAXIMIZED, DEF_WINDOW_MAXIMIZED);
187 }
188
189 /**
190 * Sets whether the specified window should be maximized.
191 * @param window The name of the window.
192 * @param b If <code>true</code> the specified window should be maximized.
193 */
194 public static void
195 setWindowMaximized(String window, boolean b) {
196 if(b == getWindowMaximized(window)) return;
197 user().putBoolean(window + WINDOW_MAXIMIZED, b);
198 }
199
200 /**
201 * Gets the divider location of the horizontal split pane.
202 * @return The divider location of the horizontal split pane.
203 */
204 public static int
205 getHSplitDividerLocation() {
206 return user().getInt(HSPLIT_DIVIDER_LOCATION, DEF_HSPLIT_DIVIDER_LOCATION);
207 }
208
209 /**
210 * Sets the divider location of the horizontal split pane.
211 * @param i The new divider location of the horizontal split pane.
212 */
213 public static void
214 setHSplitDividerLocation(int i) {
215 if(i == getHSplitDividerLocation()) return;
216 user().putInt(HSPLIT_DIVIDER_LOCATION, i);
217 }
218
219 /**
220 * Determines whether the window properties (like size and location) should be saved.
221 * @return <code>true</code> if the window properties should be saved,
222 * <code>false</code> otherwise.
223 */
224 public static boolean
225 getSaveWindowProperties() {
226 return user().getBoolean(SAVE_WINDOW_PROPERTIES, DEF_SAVE_WINDOW_PROPERTIES);
227 }
228
229 /**
230 * Sets whether the window properties (like size and location) should be saved.
231 * @param b If <code>true</code> the window properties will be saved.
232 */
233 public static void
234 setSaveWindowProperties(boolean b) {
235 if(b == getSaveWindowProperties()) return;
236 user().putBoolean(SAVE_WINDOW_PROPERTIES, b);
237 }
238
239 /**
240 * Determines whether the Left Pane state should be saved.
241 * @return <code>true</code> if the Left Pane state should be saved,
242 * <code>false</code> otherwise.
243 */
244 public static boolean
245 getSaveLeftPaneState() {
246 return user().getBoolean(SAVE_LEFT_PANE_STATE, DEF_SAVE_LEFT_PANE_STATE);
247 }
248
249 /**
250 * Sets whether the Left Pane state should be saved.
251 * @param b If <code>true</code> the Left Pane state will be saved.
252 */
253 public static void
254 setSaveLeftPaneState(boolean b) {
255 if(b == getSaveLeftPaneState()) return;
256 user().putBoolean(SAVE_LEFT_PANE_STATE, b);
257 }
258
259 /**
260 * Gets the index of the page to be shown in the Left Pane.
261 * @return The index of the page to be shown in the Left Pane.
262 */
263 public static int
264 getLeftPanePageIndex() {
265 return user().getInt(LEFT_PANE_PAGE_IDX, DEF_LEFT_PANE_PAGE_IDX);
266 }
267
268 /**
269 * Sets the maximum number of recent scripts to be kept.
270 * @param i Determines the maximum number of recent scripts to be kept.
271 */
272 public static void
273 setLeftPanePageIndex(int i) {
274 if(i == getLeftPanePageIndex()) return;
275 user().putInt(LEFT_PANE_PAGE_IDX, i);
276 }
277
278 /**
279 * Determines whether to show the LS Console when script is run.
280 * @return <code>true</code> if the LS Console should be shown when script is run,
281 * <code>false</code> otherwise.
282 */
283 public static boolean
284 getShowLSConsoleWhenRunScript() {
285 return user().getBoolean (
286 SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, DEF_SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT
287 );
288 }
289
290 /**
291 * Sets whether to show the LS Console when script is run.
292 * @param b Specify <code>true</code> to show LS Console when script is run,
293 * <code>false</code> otherwise.
294 */
295 public static void
296 setShowLSConsoleWhenRunScript(boolean b) {
297 if(b == getShowLSConsoleWhenRunScript()) return;
298 user().putBoolean(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
299 }
300
301 /**
302 * Determines whether the <b>Channels</b> toolbar should be visible.
303 * @return <code>true</code> if the <b>Channels</b> toolbar should be visible,
304 * <code>false</code> otherwise.
305 */
306 public static boolean
307 shouldShowChannelsBar() {
308 return user().getBoolean(SHOW_CHANNELS_BAR, DEF_SHOW_CHANNELS_BAR);
309 }
310
311 /**
312 * Sets whether the <b>Channels</b> toolbar should be visible.
313 * @param b If <code>true</code> the <b>Channels</b> toolbar will be visible at startup.
314 */
315 public static void
316 setShowChannelsBar(boolean b) {
317 if(b == shouldShowChannelsBar()) return;
318 user().putBoolean(SHOW_CHANNELS_BAR, b);
319 }
320
321 /**
322 * Determines whether the statusbar should be visible.
323 * @return <code>true</code> if the statusbar should be visible,
324 * <code>false</code> otherwise.
325 */
326 public static boolean
327 shouldShowStatusbar() { return user().getBoolean(SHOW_STATUSBAR, DEF_SHOW_STATUSBAR); }
328
329 /**
330 * Sets whether the statusbar should be visible.
331 * @param b If <code>true</code> the statusbar will be visible at startup.
332 */
333 public static void
334 setShowStatusbar(boolean b) {
335 if(b == shouldShowStatusbar()) return;
336 user().putBoolean(SHOW_STATUSBAR, b);
337 }
338
339 /**
340 * Gets the recent script list.
341 * @return The recent script list.
342 */
343 public static String
344 getRecentScripts() {
345 return user().get(RECENT_SCRIPTS, DEF_RECENT_SCRIPTS);
346 }
347
348 /**
349 * Sets the recent script list.
350 * @param s The recent script list.
351 */
352 public static void
353 setRecentScripts(String s) {
354 if(s == null) {
355 user().remove(RECENT_SCRIPTS);
356 return;
357 }
358
359 user().put(RECENT_SCRIPTS, s);
360 }
361
362 /**
363 * Determines the maximum number of recent scripts to be kept.
364 * @return The maximum number of recent scripts to be kept.
365 */
366 public static int
367 getRecentScriptsSize() {
368 return user().getInt(RECENT_SCRIPTS_SIZE, DEF_RECENT_SCRIPTS_SIZE);
369 }
370
371 /**
372 * Sets the maximum number of recent scripts to be kept.
373 * @param i Determines the maximum number of recent scripts to be kept.
374 */
375 public static void
376 setRecentScriptstSize(int i) {
377 if(i == getRecentScriptsSize()) return;
378 user().putInt(RECENT_SCRIPTS_SIZE, i);
379 }
380
381 /**
382 * Determines whether the LS Console should be visible.
383 * @return <code>true</code> if the LS Console should be visible,
384 * <code>false</code> otherwise.
385 */
386 public static boolean
387 shouldShowLSConsole() { return user().getBoolean(SHOW_LS_CONSOLE, DEF_SHOW_LS_CONSOLE); }
388
389 /**
390 * Sets whether the LS Console should be visible.
391 * @param b If <code>true</code> the LS Console will be visible at startup.
392 */
393 public static void
394 setShowLSConsole(boolean b) {
395 if(b == shouldShowLSConsole()) return;
396 user().putBoolean(SHOW_LS_CONSOLE, b);
397 }
398
399 /**
400 * Determines whether the LS Console should be shown in a new window or
401 * docked in the main frame.
402 * @return <code>true</code> if the LS Console should be shown in a new window,
403 * <code>false</code> if the LS Console should be docked in the main frame.
404 */
405 public static boolean
406 isLSConsolePopOut() { return user().getBoolean(LS_CONSOLE_POPOUT, DEF_LS_CONSOLE_POPOUT); }
407
408 /**
409 * Sets whether the LS Console should be shown in a new window or
410 * docked in the main frame.
411 * @param b code>true</code> means that the LS Console will be shown in a new window;
412 * <code>false</code> means that the LS Console will be docked in the main frame.
413 */
414 public static void
415 setLSConsolePopOut(boolean b) {
416 if(b == isLSConsolePopOut()) return;
417 user().putBoolean(LS_CONSOLE_POPOUT, b);
418 }
419
420 /**
421 * Gets the LS Console's command history size.
422 * @return The maximum number of lines to be kept in the command history.
423 */
424 public static int
425 getLSConsoleHistSize() {
426 return user().getInt(LS_CONSOLE_HISTSIZE, DEF_LS_CONSOLE_HISTSIZE);
427 }
428
429 /**
430 * Sets the LS Console's command history size.
431 * @param i The maximum number of lines to be kept in the command history.
432 */
433 public static void
434 setLSConsoleHistSize(int i) {
435 if(i == getLSConsoleHistSize()) return;
436 user().putInt(LS_CONSOLE_HISTSIZE, i);
437 }
438
439 /**
440 * Gets the text color of the LS Console.
441 * @return The text color of the LS Console.
442 */
443 public static Color
444 getLSConsoleTextColor() {
445 int c = user().getInt(LS_CONSOLE_TEXT_COLOR, DEF_LS_CONSOLE_TEXT_COLOR);
446 return new Color(c);
447 }
448
449 /**
450 * Sets the text color of the LS Console.
451 * Use <code>null</code> to remove the current value.
452 * @param color The text color of the LS Console.
453 */
454 public static void
455 setLSConsoleTextColor(Color c) {
456 if(c == null) {
457 user().remove(LS_CONSOLE_TEXT_COLOR);
458 return;
459 }
460
461 if(c.getRGB() == getLSConsoleTextColor().getRGB()) return;
462
463 user().putInt(LS_CONSOLE_TEXT_COLOR, c.getRGB());
464 }
465
466 /**
467 * Gets the background color of the LS Console.
468 * @return The background color of the LS Console.
469 */
470 public static Color
471 getLSConsoleBackgroundColor() {
472 int c = user().getInt(LS_CONSOLE_BACKGROUND_COLOR, DEF_LS_CONSOLE_BACKGROUND_COLOR);
473 return new Color(c);
474 }
475
476 /**
477 * Sets the background color of the LS Console.
478 * Use <code>null</code> to remove the current value.
479 * @param color The background color of the LS Console.
480 */
481 public static void
482 setLSConsoleBackgroundColor(Color c) {
483 if(c == null) {
484 user().remove(LS_CONSOLE_BACKGROUND_COLOR);
485 return;
486 }
487
488 if(c.getRGB() == getLSConsoleBackgroundColor().getRGB()) return;
489
490 user().putInt(LS_CONSOLE_BACKGROUND_COLOR, c.getRGB());
491 }
492
493 /**
494 * Gets the notification messages' color.
495 * @return The notification messages' color.
496 */
497 public static Color
498 getLSConsoleNotifyColor() {
499 int c = user().getInt(LS_CONSOLE_NOTIFY_COLOR, DEF_LS_CONSOLE_NOTIFY_COLOR);
500 return new Color(c);
501 }
502
503 /**
504 * Sets the notification messages' color.
505 * Use <code>null</code> to remove the current value.
506 * @param color The notification messages' color.
507 */
508 public static void
509 setLSConsoleNotifyColor(Color c) {
510 if(c == null) {
511 user().remove(LS_CONSOLE_NOTIFY_COLOR);
512 return;
513 }
514
515 if(c.getRGB() == getLSConsoleNotifyColor().getRGB()) return;
516
517 user().putInt(LS_CONSOLE_NOTIFY_COLOR, c.getRGB());
518 }
519
520 /**
521 * Gets the warning messages' color.
522 * @return The warning messages' color.
523 */
524 public static Color
525 getLSConsoleWarningColor() {
526 int c = user().getInt(LS_CONSOLE_WARNING_COLOR, DEF_LS_CONSOLE_WARNING_COLOR);
527 return new Color(c);
528 }
529
530 /**
531 * Sets the warning messages' color.
532 * Use <code>null</code> to remove the current value.
533 * @param color The warning messages' color.
534 */
535 public static void
536 setLSConsoleWarningColor(Color c) {
537 if(c == null) {
538 user().remove(LS_CONSOLE_WARNING_COLOR);
539 return;
540 }
541
542 if(c.getRGB() == getLSConsoleWarningColor().getRGB()) return;
543
544 user().putInt(LS_CONSOLE_WARNING_COLOR, c.getRGB());
545 }
546
547 /**
548 * Gets the error messages' color.
549 * @return The error messages' color.
550 */
551 public static Color
552 getLSConsoleErrorColor() {
553 int c = user().getInt(LS_CONSOLE_ERROR_COLOR, DEF_LS_CONSOLE_ERROR_COLOR);
554 return new Color(c);
555 }
556
557 /**
558 * Sets the error messages' color.
559 * Use <code>null</code> to remove the current value.
560 * @param color The error messages' color.
561 */
562 public static void
563 setLSConsoleErrorColor(Color c) {
564 if(c == null) {
565 user().remove(LS_CONSOLE_ERROR_COLOR);
566 return;
567 }
568
569 if(c.getRGB() == getLSConsoleErrorColor().getRGB()) return;
570
571 user().putInt(LS_CONSOLE_ERROR_COLOR, c.getRGB());
572 }
573
574 /**
575 * Determines whether the command history should be saved on exit.
576 * @return <code>true</code> if the command history should be saved on exit,
577 * <code>false</code> otherwise.
578 */
579 public static boolean
580 getSaveConsoleHistory() {
581 return user().getBoolean(SAVE_LS_CONSOLE_HISTORY, DEF_SAVE_LS_CONSOLE_HISTORY);
582 }
583
584 /**
585 * Sets whether the command history should be saved on exit.
586 * @param b If <code>true</code> the command history will be saved on exit.
587 */
588 public static void
589 setSaveConsoleHistory(boolean b) {
590 if(b == getSaveConsoleHistory()) return;
591 user().putBoolean(SAVE_LS_CONSOLE_HISTORY, b);
592 }
593
594 /**
595 * Determines whether the left pane should be visible.
596 * @return <code>true</code> if the left pane should be visible,
597 * <code>false</code> otherwise.
598 */
599 public static boolean
600 shouldShowLeftPane() { return user().getBoolean(SHOW_LEFT_PANE, DEF_SHOW_LEFT_PANE); }
601
602 /**
603 * Sets whether the left pane should be visible.
604 * @param b If <code>true</code> the left pane will be visible at startup.
605 */
606 public static void
607 setShowLeftPane(boolean b) {
608 if(b == shouldShowLeftPane()) return;
609 user().putBoolean(SHOW_LEFT_PANE, b);
610 }
611
612 /**
613 * Determines whether the <b>Standard</b> toolbar should be visible.
614 * @return <code>true</code> if the <b>Standard</b> toolbar should be visible,
615 * <code>false</code> otherwise.
616 */
617 public static boolean
618 shouldShowStandardBar() {
619 return user().getBoolean(SHOW_STANDARD_BAR, DEF_SHOW_STANDARD_BAR);
620 }
621
622 /**
623 * Sets whether the <b>Standard</b> toolbar should be visible.
624 * @param b If <code>true</code> the <b>Standard</b> toolbar will be visible at startup.
625 */
626 public static void
627 setShowStandardBar(boolean b) {
628 if(b == shouldShowStandardBar()) return;
629 user().putBoolean(SHOW_STANDARD_BAR, b);
630 }
631
632 /**
633 * Gets the default border color that is used for the selected channels.
634 * @return The default border color that is used for the selected channels.
635 */
636 public static Color
637 getDefaultChannelBorderColor() { return new Color(DEF_CHANNEL_BORDER_COLOR); }
638
639 /**
640 * Gets the custom border color to be used for the selected channels.
641 * @return The custom border color to be used for the selected
642 * channels or <code>null</code> if the color is not specified.
643 */
644 public static Color
645 getChannelBorderColor() {
646 int c = user().getInt(CHANNEL_BORDER_COLOR, DEF_CHANNEL_BORDER_COLOR);
647 return new Color(c);
648 }
649
650 /**
651 * Sets the border color to be used for the selected channels.
652 * Use <code>null</code> to remove the current value.
653 * @param color The border color to be used for the selected channels.
654 */
655 public static void
656 setChannelBorderColor(Color c) {
657 if(c == null) {
658 user().remove(CHANNEL_BORDER_COLOR);
659 return;
660 }
661
662 if(c.getRGB() == getChannelBorderColor().getRGB()) return;
663
664 user().putInt(CHANNEL_BORDER_COLOR, c.getRGB());
665 }
666
667 /**
668 * Determines whether to use a custom border color for the selected channels.
669 * @return <code>true</code> if custom border color must be used
670 * for the selected channels, <code>false</code> otherwise.
671 */
672 public static boolean
673 getCustomChannelBorderColor() {
674 return user().getBoolean (
675 CUSTOM_CHANNEL_BORDER_COLOR, DEF_CUSTOM_CHANNEL_BORDER_COLOR
676 );
677 }
678
679 /**
680 * Sets whether to use a custom border color for the selected channels.
681 * @param b specify <code>true</code> to use a custom border color
682 * for the selected channels, <code>false</code> otherwise.
683 */
684 public static void
685 setCustomChannelBorderColor(boolean b) {
686 if(b == getCustomChannelBorderColor()) return;
687 user().putBoolean(CUSTOM_CHANNEL_BORDER_COLOR, b);
688 }
689
690 /**
691 * Gets the default highlighted border color that
692 * is used when the mouse pointer is over a channel.
693 * @return The default highlighted border color.
694 */
695 public static Color
696 getDefaultChannelBorderHlColor() { return new Color(DEF_CHANNEL_BORDER_HL_COLOR); }
697
698 /**
699 * Gets the custom highlighted border color that
700 * is used when the mouse pointer is over a channel.
701 * @return The custom highlighted border color.
702 */
703 public static Color
704 getChannelBorderHlColor() {
705 int c = user().getInt(CHANNEL_BORDER_HL_COLOR, DEF_CHANNEL_BORDER_HL_COLOR);
706 return new Color(c);
707 }
708
709 /**
710 * Sets the highlighted border color that
711 * is used when the mouse pointer is over a channel.
712 * Use <code>null</code> to remove the current value.
713 * @param color The new highlighted border color.
714 */
715 public static void
716 setChannelBorderHlColor(Color c) {
717 if(c == null) {
718 user().remove(CHANNEL_BORDER_HL_COLOR);
719 return;
720 }
721
722 if(c.getRGB() == getChannelBorderHlColor().getRGB()) return;
723
724 user().putInt(CHANNEL_BORDER_HL_COLOR, c.getRGB());
725 }
726
727 /**
728 * Determines whether to use a custom highlighted border color.
729 * @return <code>true</code> if custom highlighted border color
730 * must be used, <code>false</code> otherwise.
731 */
732 public static boolean
733 getCustomChannelBorderHlColor() {
734 return user().getBoolean (
735 CUSTOM_CHANNEL_BORDER_HL_COLOR, DEF_CUSTOM_CHANNEL_BORDER_HL_COLOR
736 );
737 }
738
739 /**
740 * Sets whether to use a custom highlighted border color.
741 * @param b specify <code>true</code> to use a custom highlighted
742 * border color, <code>false</code> otherwise.
743 */
744 public static void
745 setCustomChannelBorderHlColor(boolean b) {
746 if(b == getCustomChannelBorderHlColor()) return;
747 user().putBoolean(CUSTOM_CHANNEL_BORDER_HL_COLOR, b);
748 }
749
750 /**
751 * Gets the custom background color that
752 * is used when the channel is selected.
753 * @return The custom background color that
754 * is used when the channel is selected.
755 */
756 public static Color
757 getSelectedChannelBgColor() {
758 int c = user().getInt(SEL_CHANNEL_BG_COLOR, DEF_SEL_CHANNEL_BG_COLOR);
759 return c == -1 ? null : new Color(c);
760 }
761
762 /**
763 * Sets the custom background color to
764 * be used when the channel is selected.
765 * Use <code>null</code> to remove the current value.
766 * @param color The new background color to
767 * be used when the channel is selected.
768 */
769 public static void
770 setSelectedChannelBgColor(Color c) {
771 if(c == null) {
772 user().remove(SEL_CHANNEL_BG_COLOR);
773 return;
774 }
775
776 if(getSelectedChannelBgColor() != null) {
777 if(c.getRGB() == getSelectedChannelBgColor().getRGB()) return;
778 }
779
780 user().putInt(SEL_CHANNEL_BG_COLOR, c.getRGB());
781 }
782
783 /**
784 * Determines whether to use a custom background color when a channel is selected.
785 * @return <code>true</code> if custom background color
786 * should be used, <code>false</code> otherwise.
787 */
788 public static boolean
789 getCustomSelectedChannelBgColor() {
790 return user().getBoolean (
791 CUSTOM_SEL_CHANNEL_BG_COLOR, DEF_CUSTOM_SEL_CHANNEL_BG_COLOR
792 );
793 }
794
795 /**
796 * Sets whether to use a custom background color when a channel is selected.
797 * @param b specify <code>true</code> to use a custom
798 * background color, <code>false</code> otherwise.
799 */
800 public static void
801 setCustomSelectedChannelBgColor(boolean b) {
802 if(b == getCustomSelectedChannelBgColor()) return;
803 user().putBoolean(CUSTOM_SEL_CHANNEL_BG_COLOR, b);
804 }
805
806 /**
807 * Gets the custom background color that
808 * is used when the mouse pointer is over a channel.
809 * @return The custom background color that
810 * is used when the mouse pointer is over a channel.
811 */
812 public static Color
813 getHighlightedChannelBgColor() {
814 int c = user().getInt(HL_CHANNEL_BG_COLOR, DEF_HL_CHANNEL_BG_COLOR);
815 return c == -1 ? null : new Color(c);
816 }
817
818 /**
819 * Sets the custom background color to
820 * be used when the mouse pointer is over a channel.
821 * Use <code>null</code> to remove the current value.
822 * @param color The new background color to
823 * be used when the mouse pointer is over a channel.
824 */
825 public static void
826 setHighlightedChannelBgColor(Color c) {
827 if(c == null) {
828 user().remove(HL_CHANNEL_BG_COLOR);
829 return;
830 }
831
832 if(getHighlightedChannelBgColor() != null) {
833 if(c.getRGB() == getHighlightedChannelBgColor().getRGB()) return;
834 }
835
836 user().putInt(HL_CHANNEL_BG_COLOR, c.getRGB());
837 }
838
839 /**
840 * Determines whether to use a custom background
841 * color when the mouse pointer is over a channel.
842 * @return <code>true</code> if custom background color
843 * should be used, <code>false</code> otherwise.
844 */
845 public static boolean
846 getCustomHighlightedChannelBgColor() {
847 return user().getBoolean (
848 CUSTOM_HL_CHANNEL_BG_COLOR, DEF_CUSTOM_HL_CHANNEL_BG_COLOR
849 );
850 }
851
852 /**
853 * Sets whether to use a custom background
854 * color when the mouse pointer is over a channel.
855 * @param b specify <code>true</code> to use a custom
856 * background color, <code>false</code> otherwise.
857 */
858 public static void
859 setCustomHighlightedChannelBgColor(boolean b) {
860 if(b == getCustomHighlightedChannelBgColor()) return;
861 user().putBoolean(CUSTOM_HL_CHANNEL_BG_COLOR, b);
862 }
863
864 /**
865 * Gets the divider location of the vertical split pane.
866 * @return The divider location of the vertical split pane.
867 */
868 public static int
869 getVSplitDividerLocation() {
870 return user().getInt(VSPLIT_DIVIDER_LOCATION, DEF_VSPLIT_DIVIDER_LOCATION);
871 }
872
873 /**
874 * Sets the divider location of the vertical split pane.
875 * @param i The new divider location of the vertical split pane.
876 */
877 public static void
878 setVSplitDividerLocation(int i) {
879 if(i == getVSplitDividerLocation()) return;
880 user().putInt(VSPLIT_DIVIDER_LOCATION, i);
881 }
882
883 /**
884 * Gets the current orchestra index of the last session.
885 * @return The current orchestra index of the last session.
886 */
887 public static int
888 getCurrentOrchestraIndex() {
889 return user().getInt(CURRENT_ORCHESTRA_IDX, DEF_CURRENT_ORCHESTRA_IDX);
890 }
891
892 /**
893 * Sets the current orchestra index.
894 * @param i The orchestra index to be set as current.
895 */
896 public static void
897 setCurrentOrchestraIndex(int i) {
898 if(i == getCurrentOrchestraIndex()) return;
899 user().putInt(CURRENT_ORCHESTRA_IDX, i);
900 }
901
902 /**
903 * Gets the absolute path of the directory containing the last saved script.
904 * @return The absolute path of the directory containing the last saved script or
905 * <code>null</code>.
906 */
907 public static String
908 getLastScriptLocation() {
909 return user().get(LAST_SCRIPT_LOCATION, DEF_LAST_SCRIPT_LOCATION);
910 }
911
912 /**
913 * Sets the absolute path of the directory containing the last saved script.
914 * @param s The absolute path of the directory containing the last saved script.
915 */
916 public static void
917 setLastScriptLocation(String s) {
918 if(s == null) {
919 user().remove(LAST_SCRIPT_LOCATION);
920 return;
921 }
922
923 user().put(LAST_SCRIPT_LOCATION, s);
924 }
925
926 /**
927 * Determines whether the first step in the
928 * <b>New MIDI Instrument Wizard</b> should be skipped.
929 * @return <code>true</code> if the first step should be skipped,
930 * <code>false</code> otherwise.
931 */
932 public static boolean
933 getNewMidiInstrWizardSkip1() {
934 return user().getBoolean (
935 NEW_MIDI_INSTR_WIZARD_SKIP1, DEF_NEW_MIDI_INSTR_WIZARD_SKIP1
936 );
937 }
938
939 /**
940 * Sets whether the first step in the
941 * <b>New MIDI Instrument Wizard</b> should be skipped.
942 * @param b If <code>true</code> the first step will be skipped.
943 */
944 public static void
945 setNewMidiInstrWizardSkip1(boolean b) {
946 if(b == getNewMidiInstrWizardSkip1()) return;
947 user().putBoolean(NEW_MIDI_INSTR_WIZARD_SKIP1, b);
948 }
949
950 /**
951 * Gets the instrument location method (locating an instrument by
952 * choosing from orchestra, etc).
953 * @return The index of the instrument location method.
954 */
955 public static int
956 getInstrLocationMethod() {
957 return user().getInt(INSTR_LOCATION_METHOD, DEF_INSTR_LOCATION_METHOD);
958 }
959
960 /**
961 * Sets the instrument location method.
962 * @param i Determines the instrument location method.
963 */
964 public static void
965 setInstrLocationMethod(int i) {
966 if(i == getInstrLocationMethod()) return;
967 user().putInt(INSTR_LOCATION_METHOD, i);
968 }
969
970
971 /**
972 * Gets an integer property.
973 * @param name The name of the property.
974 * @return The value of the specified property.
975 * If the property is not set, the return value is zero.
976 */
977 public static int
978 getIntProperty(String name) {
979 return user().getInt(name, 0);
980 }
981
982 /**
983 * Sets an integer property.
984 * @param name The name of the property.
985 * @param i The new value for the specified property.
986 */
987 public static void
988 setIntProperty(String name, int i) {
989 if(i == getIntProperty(name)) return;
990 user().putInt(name, i);
991 }
992
993
994 /**
995 * Gets a boolean property.
996 * @param name The name of the property.
997 * @return The value of the specified property.
998 * If the property is not set, the return value is <code>false</code>.
999 */
1000 public static boolean
1001 getBoolProperty(String name) {
1002 return user().getBoolean(name, false);
1003 }
1004
1005 /**
1006 * Sets a boolean property.
1007 * @param name The name of the property.
1008 * @param b The new value for the specified property.
1009 */
1010 public static void
1011 setBoolProperty(String name, boolean b) {
1012 if(b == getBoolProperty(name)) return;
1013 user().putBoolean(name, b);
1014 }
1015 }

  ViewVC Help
Powered by ViewVC