svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / gui / styling / SimpleText.java @ 46158
History | View | Annotate | Download (6.72 KB)
1 | 40560 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40560 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40560 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (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 | 40560 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40435 | jjdelcerro | *
|
21 | 40560 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.app.gui.styling; |
||
25 | |||
26 | import java.awt.FlowLayout; |
||
27 | import java.awt.GridLayout; |
||
28 | import java.util.ArrayList; |
||
29 | |||
30 | import javax.swing.JLabel; |
||
31 | import javax.swing.JPanel; |
||
32 | import javax.swing.JToggleButton; |
||
33 | |||
34 | import org.gvsig.andami.PluginServices; |
||
35 | import org.gvsig.app.gui.panels.ColorChooserPanel; |
||
36 | import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
||
37 | import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
||
38 | import org.gvsig.gui.beans.swing.JComboBoxFontSizes; |
||
39 | import org.gvsig.gui.beans.swing.JComboBoxFonts; |
||
40 | 42026 | jjdelcerro | import org.gvsig.gui.beans.swing.JNumberSpinner; |
41 | 40435 | jjdelcerro | import org.gvsig.i18n.Messages; |
42 | import org.gvsig.symbology.SymbologyLocator; |
||
43 | import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.ISimpleTextSymbol; |
||
44 | |||
45 | |||
46 | /**
|
||
47 | * SimpleText allows the user to store and modify the main properties that define a <b>simple text</b>.<p>
|
||
48 | * <p>
|
||
49 | * This functionality is carried out thanks to three tabs (text, formatted, advanced)
|
||
50 | * and a Mask which are included in the panel to edit the properities of a symbol
|
||
51 | * (SymbolEditor)how is explained in AbstractTypeSymbolEditor.<p>
|
||
52 | * <p>
|
||
53 | * The first tab (text)allows the user to change the font (<b>cmbFonts</b>),
|
||
54 | * the size(<b>cmbFontSize</b>), the style (which can be underlined
|
||
55 | * -<b>btnUnderlined</b>-, italic -<b>btnItalic</b>- or bold -<b>btnBold</b>-),the
|
||
56 | * color (<b>jcc</b>)and the offset of the the text(<b>txtXOffset</b> and <b>txtYOffset</b>).<p>
|
||
57 | * <p>
|
||
58 | * The rest of tabs that are not mask are not yet implemented.
|
||
59 | *
|
||
60 | *
|
||
61 | *@see Mask
|
||
62 | *@see AbstractTypeSymbolEditor
|
||
63 | *@author jaume dominguez faus - jaume.dominguez@iver.es
|
||
64 | */
|
||
65 | public class SimpleText extends AbstractTypeSymbolEditor { |
||
66 | |||
67 | private ArrayList tabs = new ArrayList(); |
||
68 | //TODO: Comentarizado hasta que mask est? acabado
|
||
69 | // private Mask mask;
|
||
70 | private JComboBoxFonts cmbFonts;
|
||
71 | private JToggleButton btnUnderlined; |
||
72 | private JToggleButton btnItalic; |
||
73 | private JToggleButton btnBold; |
||
74 | private JComboBoxFontSizes cmbFontSize;
|
||
75 | private ColorChooserPanel jcc;
|
||
76 | 42026 | jjdelcerro | private JNumberSpinner txtXOffset;
|
77 | private JNumberSpinner txtYOffset;
|
||
78 | 40435 | jjdelcerro | |
79 | public SimpleText(SymbolEditor owner) {
|
||
80 | super(owner);
|
||
81 | initialize(); |
||
82 | } |
||
83 | |||
84 | |||
85 | /**
|
||
86 | * Initializes the parameters that define a simpletext.To do it, four tabs
|
||
87 | * are created (one of them is a mask)inside the SymbolEditor panel with
|
||
88 | * default values for the different attributes of the simple text.For the
|
||
89 | * moment only the text tab has been created and it allows the user to modify
|
||
90 | * the font,color, offset and style of the text.
|
||
91 | *
|
||
92 | */
|
||
93 | |||
94 | private void initialize() { |
||
95 | JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
||
96 | JPanel aux = new JPanel(new GridLayout(1,2,15,0)); |
||
97 | myTab.setName(Messages.getText("text"));
|
||
98 | |||
99 | ////------------ Tab Text
|
||
100 | GridBagLayoutPanel leftColumn = new GridBagLayoutPanel();
|
||
101 | leftColumn.addComponent(Messages.getText("font")+": ", cmbFonts = new JComboBoxFonts()); |
||
102 | |||
103 | JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEADING,0,1)); |
||
104 | aux2.add(getBtnBold()); |
||
105 | aux2.add(getBtnItalic()); |
||
106 | aux2.add(getBtnUnderlined()); |
||
107 | leftColumn.addComponent( |
||
108 | Messages.getText("style")+":", aux2); |
||
109 | |||
110 | jcc = new ColorChooserPanel();
|
||
111 | jcc.setAlpha(255);
|
||
112 | leftColumn.addComponent(Messages.getText("color")+":", jcc); |
||
113 | // vertical alignment stuff
|
||
114 | leftColumn.addComponent(new JLabel(" ")); |
||
115 | // \vertical alignment stuff
|
||
116 | leftColumn.addComponent(Messages.getText("x_offset")+":", |
||
117 | 42026 | jjdelcerro | txtXOffset = new JNumberSpinner(0, 3)); |
118 | 40435 | jjdelcerro | leftColumn.addComponent(Messages.getText("x_offset")+":", |
119 | 42026 | jjdelcerro | txtYOffset = new JNumberSpinner(0, 3)); |
120 | 40435 | jjdelcerro | |
121 | |||
122 | GridBagLayoutPanel rightColumn = new GridBagLayoutPanel();
|
||
123 | aux2 = new JPanel(new FlowLayout(0, 0, FlowLayout.LEFT)); |
||
124 | cmbFontSize = new JComboBoxFontSizes();
|
||
125 | aux2.add(cmbFontSize); |
||
126 | rightColumn.addComponent(Messages.getText("size")+":", aux2); |
||
127 | // vertical alignment stuff
|
||
128 | rightColumn.addComponent(new JLabel(" ")); |
||
129 | rightColumn.addComponent(new JLabel(" ")); |
||
130 | rightColumn.addComponent(new JLabel(" ")); |
||
131 | rightColumn.addComponent(new JLabel(" ")); |
||
132 | rightColumn.addComponent(new JLabel(" ")); |
||
133 | rightColumn.addComponent(new JLabel(" ")); |
||
134 | rightColumn.addComponent(new JLabel(" ")); |
||
135 | // \vertical alignment stuff
|
||
136 | |||
137 | |||
138 | aux.add(leftColumn); |
||
139 | aux.add(rightColumn); |
||
140 | |||
141 | |||
142 | myTab.add(aux); |
||
143 | tabs.add(myTab); |
||
144 | |||
145 | ////------------ Tab FORMATTED
|
||
146 | myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
||
147 | myTab.setName(Messages.getText("formatted"));
|
||
148 | |||
149 | leftColumn = new GridBagLayoutPanel();
|
||
150 | |||
151 | myTab.add(leftColumn); |
||
152 | tabs.add(myTab); |
||
153 | |||
154 | ////------------ Tab ADVANCED
|
||
155 | myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
||
156 | myTab.setName(Messages.getText("advanced"));
|
||
157 | leftColumn = new GridBagLayoutPanel();
|
||
158 | |||
159 | myTab.add(leftColumn); |
||
160 | tabs.add(myTab); |
||
161 | |||
162 | ////------------ Tab MASK
|
||
163 | // mask = new Mask(this);
|
||
164 | // tabs.add(mask);
|
||
165 | } |
||
166 | |||
167 | public ISymbol getLayer() {
|
||
168 | ISimpleTextSymbol sts = SymbologyLocator.getSymbologyManager().createSimpleTextSymbol(); |
||
169 | return sts;
|
||
170 | } |
||
171 | |||
172 | public String getName() { |
||
173 | return Messages.getText("simple_text_symbol"); |
||
174 | } |
||
175 | |||
176 | public JPanel[] getTabs() { |
||
177 | return (JPanel[]) tabs.toArray(new JPanel[tabs.size()]); |
||
178 | } |
||
179 | |||
180 | public void refreshControls(ISymbol layer) { |
||
181 | // TODO Implement it
|
||
182 | // throw new Error("Not yet implemented!");
|
||
183 | |||
184 | } |
||
185 | |||
186 | public EditorTool[] getEditorTools() { |
||
187 | return null; |
||
188 | } |
||
189 | |||
190 | private JToggleButton getBtnUnderlined() { |
||
191 | if (btnUnderlined == null) { |
||
192 | btnUnderlined = new JToggleButton(PluginServices.getIconTheme().get("underline-icon")); |
||
193 | } |
||
194 | return btnUnderlined;
|
||
195 | } |
||
196 | |||
197 | private JToggleButton getBtnItalic() { |
||
198 | if (btnItalic == null) { |
||
199 | btnItalic = new JToggleButton(PluginServices.getIconTheme().get("italic-icon")); |
||
200 | } |
||
201 | return btnItalic;
|
||
202 | } |
||
203 | |||
204 | private JToggleButton getBtnBold() { |
||
205 | if (btnBold == null) { |
||
206 | btnBold = new JToggleButton(PluginServices.getIconTheme().get("bold-icon")); |
||
207 | } |
||
208 | return btnBold;
|
||
209 | } |
||
210 | |||
211 | |||
212 | public boolean canManageSymbol(ISymbol symbol) { |
||
213 | return symbol instanceof ISimpleTextSymbol; |
||
214 | } |
||
215 | } |