View Javadoc

1   /**
2    * This program is free software: you can redistribute it and/or modify
3    * it under the terms of the GNU General Public License as published by
4    * the Free Software Foundation, version 3.
5    *
6    * This program is distributed in the hope that it will be useful,
7    * but WITHOUT ANY WARRANTY; without even the implied warranty of
8    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9    * GNU General Public License for more details.
10   *
11   * You should have received a copy of the GNU General Public License
12   * along with this program. If not, see <http://www.gnu.org/licenses/>.
13   */
14  
15  package net.curre.prefcount.bean;
16  
17  import java.io.Serializable;
18  
19  import net.curre.prefcount.PrefCountRegistry;
20  import net.curre.prefcount.gui.theme.skin.DefaultSkin;
21  
22  /**
23   * Object of this class represents a bean for storing
24   * application settings (window size, theme, default locale, etc.).
25   * <p/>
26   * Created date: Jun 10, 2007
27   *
28   * @author Yevgeny Nyden
29   */
30  public class Settings implements Serializable {
31  
32    /** Serial version number. */
33    static final long serialVersionUID = 39036452918252735L;
34  
35    /** Default value for the main window frame width. */
36    public static final int DEFAULT_MAIN_FRAME_WIDTH = 525;
37  
38    /** Default value for the main window frame height. */
39    public static final int DEFAULT_MAIN_FRAME_HEIGHT = 545;
40  
41    /** Default value for the dialog window frame width. */
42    public static final int DEFAULT_DIALOG_FRAME_WIDTH = 260;
43  
44    /** Default value for the dialog window frame height. */
45    public static final int DEFAULT_DIALOG_FRAME_HEIGHT = 300;
46  
47    /** Default value for the Look and Feel theme/skin ID. */
48    public static final String DEFAULT_LAF_SKIN_ID = DefaultSkin.NAME_KEY;
49  
50    /** The main window frame width. */
51    private int mainFrameWidth;
52  
53    /** The main window frame height. */
54    private int mainFrameHeight;
55  
56    /** The dialog window frame width. */
57    private int dialogFrameWidth;
58  
59    /** The dialog window frame height. */
60    private int dialogFrameHeight;
61  
62    /** Look and Feel theme/skin ID (resource key). */
63    private String lafSkinId;
64  
65    /** Locale identifier (case insensitive language name). */
66    private String localeId;
67  
68    /**
69     * Default constructor that initializes
70     * all properties to the default values.
71     */
72    public Settings() {
73      initializeToDefaults();
74    }
75  
76    /**
77     * Getter for the main window frame width.
78     *
79     * @return The main window frame width.
80     */
81    public int getMainFrameWidth() {
82      return mainFrameWidth;
83    }
84  
85    /**
86     * Setter for the main window frame width.
87     *
88     * @param mainFrameWidth Main window frame width.
89     */
90    public void setMainFrameWidth(int mainFrameWidth) {
91      this.mainFrameWidth = mainFrameWidth;
92    }
93  
94    /**
95     * Getter for the main window frame height.
96     *
97     * @return The main window frame height.
98     */
99    public int getMainFrameHeight() {
100     return mainFrameHeight;
101   }
102 
103   /**
104    * Setter for the main window frame height.
105    *
106    * @param mainFrameHeight Main window frame height.
107    */
108   public void setMainFrameHeight(int mainFrameHeight) {
109     this.mainFrameHeight = mainFrameHeight;
110   }
111 
112   /**
113    * Getter for the dialog window frame width.
114    *
115    * @return The dialog window frame width.
116    */
117   public int getDialogFrameWidth() {
118     return dialogFrameWidth;
119   }
120 
121   /**
122    * Setter for the dialog window frame width.
123    *
124    * @param dialogFrameWidth Dialog window frame width.
125    */
126   public void setDialogFrameWidth(int dialogFrameWidth) {
127     this.dialogFrameWidth = dialogFrameWidth;
128   }
129 
130   /**
131    * Getter for the dialog window frame height.
132    *
133    * @return The dialog window frame height.
134    */
135   public int getDialogFrameHeight() {
136     return dialogFrameHeight;
137   }
138 
139   /**
140    * Setter for the dialog window frame height.
141    *
142    * @param dialogFrameHeight Dialog window frame height.
143    */
144   public void setDialogFrameHeight(int dialogFrameHeight) {
145     this.dialogFrameHeight = dialogFrameHeight;
146   }
147 
148   /**
149    * Getter for the Look and Feel theme/skin ID (resource key).
150    *
151    * @return The Look and Feel theme/skin ID (resource key).
152    */
153   public String getLafSkinId() {
154     return lafSkinId;
155   }
156 
157   /**
158    * Setter for the Look and Feel theme/skin ID (resource key).
159    *
160    * @param lafSkinId The Look and Feel theme/skin ID (resource key).
161    */
162   public void setLafSkinId(String lafSkinId) {
163     this.lafSkinId = lafSkinId;
164   }
165 
166   /**
167    * Getter for the locale identifier (case
168    * insensitive language name).
169    *
170    * @return The locale identifier (language name).
171    */
172   public String getLocaleId() {
173     return localeId;
174   }
175 
176   /**
177    * Setter for the locale identifier (case
178    * insensitive language name).
179    *
180    * @param localeId Locale identifier (case insensitive language name).
181    */
182   public void setLocaleId(String localeId) {
183     this.localeId = localeId;
184   }
185 
186   /** Method to reset the settings to default values. */
187   public void reset() {
188     initializeToDefaults();
189   }
190 
191   /** Private methods ********************** */
192 
193   /**
194    * Helper method to initialize all settings
195    * properties to default values.
196    */
197   private void initializeToDefaults() {
198     mainFrameWidth = DEFAULT_MAIN_FRAME_WIDTH;
199     mainFrameHeight = DEFAULT_MAIN_FRAME_HEIGHT;
200     dialogFrameWidth = DEFAULT_DIALOG_FRAME_WIDTH;
201     dialogFrameHeight = DEFAULT_DIALOG_FRAME_HEIGHT;
202     lafSkinId = DEFAULT_LAF_SKIN_ID;
203     localeId = PrefCountRegistry.DEFAULT_LOCALE_ID;
204   }
205 
206 }