KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > render > RenderModeDescriptor


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * *
5  * This library is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or (at your option) any later version. *
9  * *
10  * This library is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13  * Lesser General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Lesser General Public *
16  * License along with this library; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin St, Fifth Floor, *
19  * Boston, MA 02110-1301 USA *
20  * *
21  * Or get it online : *
22  * http://www.gnu.org/copyleft/lesser.html *
23  * *
24  * *
25  ******************************************************************************/

26
27 package org.nightlabs.editor2d.render;
28
29 import java.awt.image.BufferedImage JavaDoc;
30 import java.util.Locale JavaDoc;
31
32 import org.nightlabs.i18n.I18nText;
33 import org.nightlabs.i18n.I18nTextBuffer;
34
35 /**
36  * A Descriptor for a RenderMode
37  *
38  * @author Daniel.Mazurek [AT] NightLabs [DOT] com
39  *
40  */

41 public class RenderModeDescriptor
42 {
43
44     public RenderModeDescriptor(int renderMode, String JavaDoc localizedText)
45     {
46         this(renderMode, localizedText, null, null);
47     }
48     
49     public RenderModeDescriptor(int renderMode, String JavaDoc localizedText, String JavaDoc localizedDesc)
50     {
51         this(renderMode, localizedText, localizedDesc, null);
52     }
53     
54     public RenderModeDescriptor(int renderMode, String JavaDoc localizedText, String JavaDoc localizedDesc,
55         BufferedImage JavaDoc img)
56     {
57         this.renderMode = renderMode;
58         setLocalizedText(localizedText);
59         setLocalizedDescription(localizedDesc);
60         this.image = img;
61     }
62     
63     public RenderModeDescriptor(int renderMode, I18nText text) {
64         this(renderMode, text, null, null);
65     }
66     
67     public RenderModeDescriptor(int renderMode, I18nText text, I18nText description) {
68         this(renderMode, text, description, null);
69     }
70
71     public RenderModeDescriptor(int renderMode, I18nText text, I18nText description, BufferedImage JavaDoc img) {
72         super();
73         this.renderMode = renderMode;
74         this.text = text;
75         this.image = img;
76     }
77     
78     protected int renderMode = RenderConstants.DEFAULT_MODE;
79     /**
80      *
81      * @return the renderMode
82      */

83     public int getRenderMode() {
84         return renderMode;
85     }
86     
87     protected String JavaDoc getLanguageID() {
88         return Locale.getDefault().getLanguage();
89     }
90     
91     protected I18nText text = null;
92     /**
93      *
94      * @return the I18nText which stores the localized text for the renderMode
95      */

96     public I18nText getText()
97     {
98         if (text == null)
99             text = new I18nTextBuffer();
100         
101         return text;
102     }
103     public void setText(I18nText text) {
104         this.text = text;
105     }
106     
107     /**
108      *
109      * @param text the localized (Locale.getDefault().getLanguage()) Text for
110      * the renderMode
111      */

112     public void setLocalizedText(String JavaDoc text) {
113         getText().setText(getLanguageID(), text);
114     }
115     
116     public String JavaDoc getLocalizedText() {
117         return getText().getText(getLanguageID());
118     }
119     
120     
121     protected I18nText description = null;
122     /**
123      *
124      * @return the I18nText which stores the localized description for the renderMode
125      */

126     public I18nText getDescription()
127     {
128         if (description == null)
129             description = new I18nTextBuffer();
130         
131         return description;
132     }
133     public void setDescription(I18nText description) {
134         this.description = description;
135     }
136     
137     /**
138      *
139      * @param desc the localized (Locale.getDefault().getLanguage())
140      * Descriptor for the renderMode
141      */

142     public void setLocalizedDescription(String JavaDoc desc) {
143         getDescription().setText(getLanguageID(), desc);
144     }
145     
146     public String JavaDoc getLocalizedDescription() {
147         return getDescription().getText(getLanguageID());
148     }
149     
150     protected BufferedImage JavaDoc image;
151     /**
152      *
153      * @return the BufferedImage (Icon) for the renderMode
154      */

155     public BufferedImage JavaDoc getImage() {
156         return image;
157     }
158     /**
159      *
160      * @param image the BufferedImage (Icon) for the renderMode
161      */

162     public void setImage(BufferedImage JavaDoc image) {
163         this.image = image;
164     }
165     
166 }
167
Popular Tags