svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SimpleText.java @ 24962
History | View | Annotate | Download (6.93 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program 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
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.gui.styling; |
42 |
|
43 |
import java.awt.FlowLayout; |
44 |
import java.awt.GridLayout; |
45 |
import java.util.ArrayList; |
46 |
|
47 |
import javax.swing.JLabel; |
48 |
import javax.swing.JPanel; |
49 |
import javax.swing.JToggleButton; |
50 |
|
51 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
52 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleTextSymbol; |
53 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
54 |
import org.gvsig.gui.beans.swing.JComboBoxFontSizes; |
55 |
import org.gvsig.gui.beans.swing.JComboBoxFonts; |
56 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
57 |
|
58 |
import com.iver.andami.PluginServices; |
59 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
60 |
|
61 |
/**
|
62 |
* SimpleText allows the user to store and modify the main properties that define a <b>simple text</b>.<p>
|
63 |
* <p>
|
64 |
* This functionality is carried out thanks to three tabs (text, formatted, advanced)
|
65 |
* and a Mask which are included in the panel to edit the properities of a symbol
|
66 |
* (SymbolEditor)how is explained in AbstractTypeSymbolEditor.<p>
|
67 |
* <p>
|
68 |
* The first tab (text)allows the user to change the font (<b>cmbFonts</b>),
|
69 |
* the size(<b>cmbFontSize</b>), the style (which can be underlined
|
70 |
* -<b>btnUnderlined</b>-, italic -<b>btnItalic</b>- or bold -<b>btnBold</b>-),the
|
71 |
* color (<b>jcc</b>)and the offset of the the text(<b>txtXOffset</b> and <b>txtYOffset</b>).<p>
|
72 |
* <p>
|
73 |
* The rest of tabs that are not mask are not yet implemented.
|
74 |
*
|
75 |
*
|
76 |
*@see Mask
|
77 |
*@see AbstractTypeSymbolEditor
|
78 |
*@author jaume dominguez faus - jaume.dominguez@iver.es
|
79 |
*/
|
80 |
public class SimpleText extends AbstractTypeSymbolEditor { |
81 |
|
82 |
private ArrayList tabs = new ArrayList(); |
83 |
private Mask mask;
|
84 |
private JComboBoxFonts cmbFonts;
|
85 |
private JToggleButton btnUnderlined; |
86 |
private JToggleButton btnItalic; |
87 |
private JToggleButton btnBold; |
88 |
private JComboBoxFontSizes cmbFontSize;
|
89 |
private ColorChooserPanel jcc;
|
90 |
private JIncrementalNumberField txtXOffset;
|
91 |
private JIncrementalNumberField txtYOffset;
|
92 |
|
93 |
public SimpleText(SymbolEditor owner) {
|
94 |
super(owner);
|
95 |
initialize(); |
96 |
} |
97 |
|
98 |
|
99 |
/**
|
100 |
* Initializes the parameters that define a simpletext.To do it, four tabs
|
101 |
* are created (one of them is a mask)inside the SymbolEditor panel with
|
102 |
* default values for the different attributes of the simple text.For the
|
103 |
* moment only the text tab has been created and it allows the user to modify
|
104 |
* the font,color, offset and style of the text.
|
105 |
*
|
106 |
*/
|
107 |
|
108 |
private void initialize() { |
109 |
JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
110 |
JPanel aux = new JPanel(new GridLayout(1,2,15,0)); |
111 |
myTab.setName(PluginServices.getText(this, "text")); |
112 |
|
113 |
////------------ Tab Text
|
114 |
GridBagLayoutPanel leftColumn = new GridBagLayoutPanel();
|
115 |
leftColumn.addComponent(PluginServices.getText(this, "font")+": ", cmbFonts = new JComboBoxFonts()); |
116 |
|
117 |
JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEADING,0,1)); |
118 |
aux2.add(getBtnBold()); |
119 |
aux2.add(getBtnItalic()); |
120 |
aux2.add(getBtnUnderlined()); |
121 |
leftColumn.addComponent( |
122 |
PluginServices.getText(this, "style")+":", aux2); |
123 |
|
124 |
jcc = new ColorChooserPanel();
|
125 |
jcc.setAlpha(255);
|
126 |
leftColumn.addComponent(PluginServices.getText(this, "color")+":", jcc); |
127 |
// vertical alignment stuff
|
128 |
leftColumn.addComponent(new JLabel(" ")); |
129 |
// \vertical alignment stuff
|
130 |
leftColumn.addComponent(PluginServices.getText(this, "x_offset")+":", |
131 |
txtXOffset = new JIncrementalNumberField("0", 3)); |
132 |
leftColumn.addComponent(PluginServices.getText(this, "x_offset")+":", |
133 |
txtYOffset = new JIncrementalNumberField("0", 3)); |
134 |
|
135 |
|
136 |
GridBagLayoutPanel rightColumn = new GridBagLayoutPanel();
|
137 |
aux2 = new JPanel(new FlowLayout(0, 0, FlowLayout.LEFT)); |
138 |
cmbFontSize = new JComboBoxFontSizes();
|
139 |
aux2.add(cmbFontSize); |
140 |
rightColumn.addComponent(PluginServices.getText(this, "size")+":", aux2); |
141 |
// vertical alignment stuff
|
142 |
rightColumn.addComponent(new JLabel(" ")); |
143 |
rightColumn.addComponent(new JLabel(" ")); |
144 |
rightColumn.addComponent(new JLabel(" ")); |
145 |
rightColumn.addComponent(new JLabel(" ")); |
146 |
rightColumn.addComponent(new JLabel(" ")); |
147 |
rightColumn.addComponent(new JLabel(" ")); |
148 |
rightColumn.addComponent(new JLabel(" ")); |
149 |
// \vertical alignment stuff
|
150 |
|
151 |
|
152 |
aux.add(leftColumn); |
153 |
aux.add(rightColumn); |
154 |
|
155 |
|
156 |
myTab.add(aux); |
157 |
tabs.add(myTab); |
158 |
|
159 |
////------------ Tab FORMATTED
|
160 |
myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
161 |
myTab.setName(PluginServices.getText(this, "formatted")); |
162 |
|
163 |
leftColumn = new GridBagLayoutPanel();
|
164 |
|
165 |
myTab.add(leftColumn); |
166 |
tabs.add(myTab); |
167 |
|
168 |
////------------ Tab ADVANCED
|
169 |
myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
170 |
myTab.setName(PluginServices.getText(this, "advanced")); |
171 |
leftColumn = new GridBagLayoutPanel();
|
172 |
|
173 |
myTab.add(leftColumn); |
174 |
tabs.add(myTab); |
175 |
|
176 |
////------------ Tab MASK
|
177 |
mask = new Mask(this); |
178 |
tabs.add(mask); |
179 |
} |
180 |
|
181 |
public ISymbol getLayer() {
|
182 |
SimpleTextSymbol sts = new SimpleTextSymbol();
|
183 |
return sts;
|
184 |
} |
185 |
|
186 |
public String getName() { |
187 |
return PluginServices.getText(this, "simple_text_symbol"); |
188 |
} |
189 |
|
190 |
public JPanel[] getTabs() { |
191 |
return (JPanel[]) tabs.toArray(new JPanel[tabs.size()]); |
192 |
} |
193 |
|
194 |
public void refreshControls(ISymbol layer) { |
195 |
// TODO Implement it
|
196 |
// throw new Error("Not yet implemented!");
|
197 |
|
198 |
} |
199 |
|
200 |
public Class getSymbolClass() { |
201 |
return SimpleTextSymbol.class;
|
202 |
} |
203 |
|
204 |
public EditorTool[] getEditorTools() { |
205 |
return null; |
206 |
} |
207 |
|
208 |
private JToggleButton getBtnUnderlined() { |
209 |
if (btnUnderlined == null) { |
210 |
btnUnderlined = new JToggleButton(PluginServices.getIconTheme().get("underline-icon")); |
211 |
} |
212 |
return btnUnderlined;
|
213 |
} |
214 |
|
215 |
private JToggleButton getBtnItalic() { |
216 |
if (btnItalic == null) { |
217 |
btnItalic = new JToggleButton(PluginServices.getIconTheme().get("italic-icon")); |
218 |
} |
219 |
return btnItalic;
|
220 |
} |
221 |
|
222 |
private JToggleButton getBtnBold() { |
223 |
if (btnBold == null) { |
224 |
btnBold = new JToggleButton(PluginServices.getIconTheme().get("bold-icon")); |
225 |
} |
226 |
return btnBold;
|
227 |
} |
228 |
} |