Source code: org/fluidsynth/api/settings/AbstractNumberSetting.java
1 /*
2 * Copyright (C) 2003 Ken Ellinwood.
3 *
4 * This file is part of FluidGUI.
5 *
6 * FluidGUI is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 package org.fluidsynth.api.settings;
22
23 /** Parent of numeric settings, this class provides properties to handle min/max values. */
24 public abstract class AbstractNumberSetting extends Setting
25 {
26
27 String minValueStr = null;
28 String maxValueStr = null;
29
30 public void merge( Setting other) {
31 if (!(other instanceof AbstractNumberSetting))
32 throw new IllegalArgumentException( "Invalid setting class: " + other.getClass().getName());
33
34 super.merge( other);
35
36 AbstractNumberSetting oans = (AbstractNumberSetting)other;
37
38 if (oans.minValueStr != null) setMinValue( oans.minValueStr);
39 if (oans.maxValueStr != null) setMaxValue( oans.maxValueStr);
40 }
41
42 /** Set the min value as a string. */
43 public void setMinValue( String minValueStr)
44 {
45 minValueSetImpl( minValueStr);
46 this.minValueStr = minValueStr;
47 }
48
49 /** Get the min value as a string. */
50 public String getMinValue()
51 {
52 return minValueStr;
53 }
54
55 /** Set the max value as a string. */
56 public void setMaxValue( String maxValueStr)
57 {
58 maxValueSetImpl( maxValueStr);
59 this.maxValueStr = maxValueStr;
60 }
61
62 /** Get the max value as a string. */
63 public String getMaxValue()
64 {
65 return maxValueStr;
66 }
67
68 /** Subclasses override this to set the min value internally as a number. */
69 protected abstract void minValueSetImpl( String minValueStr);
70
71 /** Subclasses override this to set the max value internally as a number. */
72 protected abstract void maxValueSetImpl( String maxValueStr);
73
74 }
75
76
77