Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SimpleText.java @ 14821

History | View | Annotate | Download (6.96 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.ImageIcon;
48
import javax.swing.JLabel;
49
import javax.swing.JPanel;
50
import javax.swing.JToggleButton;
51

    
52
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
53
import org.gvsig.gui.beans.swing.JComboBoxFontSizes;
54
import org.gvsig.gui.beans.swing.JComboBoxFonts;
55
import org.gvsig.gui.beans.swing.JIncrementalNumberField;
56

    
57
import com.iver.andami.PluginServices;
58
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
59
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol;
60
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
61

    
62
/**
63
 * SimpleText allows the user to store and modify the main properties that define a <b>simple text</b>.<p>
64
 * <p>
65
 * This functionality is carried out thanks to three tabs (text, formatted, advanced)
66
 * and a Mask which are included in the panel to edit the properities of a symbol
67
 * (SymbolEditor)how is explained in AbstractTypeSymbolEditor.<p>
68
 * <p>
69
 * The first tab (text)allows the user to change the font (<b>cmbFonts</b>),
70
 * the size(<b>cmbFontSize</b>), the style (which can be underlined
71
 * -<b>btnUnderlined</b>-, italic -<b>btnItalic</b>- or bold -<b>btnBold</b>-),the
72
 * color (<b>jcc</b>)and the offset of the the text(<b>txtXOffset</b> and <b>txtYOffset</b>).<p>
73
 * <p>
74
 * The rest of tabs that are not mask are not yet implemented.
75
 *
76
 *
77
 *@see Mask
78
 *@see AbstractTypeSymbolEditor
79
 *@author jaume dominguez faus - jaume.dominguez@iver.es
80
 */
81
public class SimpleText extends AbstractTypeSymbolEditor {
82

    
83
        private ArrayList tabs = new ArrayList();
84
        private Mask mask;
85
        private JComboBoxFonts cmbFonts;
86
        private JToggleButton btnUnderlined;
87
        private JToggleButton btnItalic;
88
        private JToggleButton btnBold;
89
        private JComboBoxFontSizes cmbFontSize;
90
        private ColorChooserPanel jcc;
91
        private JIncrementalNumberField txtXOffset;
92
        private JIncrementalNumberField txtYOffset;
93

    
94
        public SimpleText(SymbolEditor owner) {
95
                super(owner);
96
                initialize();
97
        }
98

    
99

    
100
        /**
101
         * Initializes the parameters that define a simpletext.To do it, four tabs
102
         * are created (one of them is a mask)inside the SymbolEditor panel with
103
         * default values for the different attributes of the simple text.For the
104
         * moment only the text tab has been created and it allows the user to modify
105
         * the font,color, offset and style of the text.
106
         *
107
         */
108

    
109
        private void initialize() {
110
                JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5));
111
                JPanel aux = new JPanel(new GridLayout(1,2,15,0));
112
                myTab.setName(PluginServices.getText(this, "text"));
113

    
114
                ////------------ Tab Text
115
                GridBagLayoutPanel leftColumn = new GridBagLayoutPanel();
116
                leftColumn.addComponent(PluginServices.getText(this, "font")+": ", cmbFonts = new JComboBoxFonts());
117

    
118
                JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEADING,0,1));
119
                aux2.add(getBtnBold());
120
                aux2.add(getBtnItalic());
121
                aux2.add(getBtnUnderlined());
122
                leftColumn.addComponent(
123
                                PluginServices.getText(this, "style")+":", aux2);
124

    
125
                jcc = new ColorChooserPanel();
126
                jcc.setAlpha(255);
127
                leftColumn.addComponent(PluginServices.getText(this, "color")+":", jcc);
128
                // vertical alignment stuff
129
                leftColumn.addComponent(new JLabel(" "));
130
                // \vertical alignment stuff
131
                leftColumn.addComponent(PluginServices.getText(this, "x_offset")+":",
132
                                txtXOffset = new JIncrementalNumberField("0", 3));
133
                leftColumn.addComponent(PluginServices.getText(this, "x_offset")+":",
134
                                txtYOffset = new JIncrementalNumberField("0", 3));
135

    
136

    
137
                GridBagLayoutPanel rightColumn = new GridBagLayoutPanel();
138
                aux2 = new JPanel(new FlowLayout(0, 0, FlowLayout.LEFT));
139
                cmbFontSize = new JComboBoxFontSizes();
140
                aux2.add(cmbFontSize);
141
                rightColumn.addComponent(PluginServices.getText(this, "size")+":", aux2);
142
                // vertical alignment stuff
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
                rightColumn.addComponent(new JLabel(" "));
150
                // \vertical alignment stuff
151

    
152

    
153
                aux.add(leftColumn);
154
                aux.add(rightColumn);
155

    
156

    
157
                myTab.add(aux);
158
                tabs.add(myTab);
159

    
160
                ////------------ Tab FORMATTED
161
                myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5));
162
                myTab.setName(PluginServices.getText(this, "formatted"));
163

    
164
                leftColumn = new GridBagLayoutPanel();
165

    
166
                myTab.add(leftColumn);
167
                tabs.add(myTab);
168

    
169
                ////------------ Tab ADVANCED
170
                myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5));
171
                myTab.setName(PluginServices.getText(this, "advanced"));
172
                leftColumn = new GridBagLayoutPanel();
173

    
174
                myTab.add(leftColumn);
175
                tabs.add(myTab);
176

    
177
                ////------------ Tab MASK
178
                mask = new Mask(this);
179
                tabs.add(mask);
180
        }
181

    
182
        public ISymbol getLayer() {
183
                SimpleTextSymbol sts = new SimpleTextSymbol();
184
                return sts;
185
        }
186

    
187
        public String getName() {
188
                return PluginServices.getText(this, "simple_text_symbol");
189
        }
190

    
191
        public JPanel[] getTabs() {
192
                return (JPanel[]) tabs.toArray(new JPanel[tabs.size()]);
193
        }
194

    
195
        public void refreshControls(ISymbol layer) {
196
                // TODO Implement it
197
//                throw new Error("Not yet implemented!");
198

    
199
        }
200

    
201
        public Class getSymbolClass() {
202
                return SimpleTextSymbol.class;
203
        }
204

    
205
        public EditorTool[] getEditorTools() {
206
                return null;
207
        }
208

    
209
        private JToggleButton getBtnUnderlined() {
210
                if (btnUnderlined == null) {
211
                        btnUnderlined = new JToggleButton(PluginServices.getIconTheme().get("underline-icon"));
212
                }
213
                return btnUnderlined;
214
        }
215

    
216
        private JToggleButton getBtnItalic() {
217
                if (btnItalic == null) {
218
                        btnItalic = new JToggleButton(PluginServices.getIconTheme().get("italic-icon"));
219
                }
220
                return btnItalic;
221
        }
222

    
223
        private JToggleButton getBtnBold() {
224
                if (btnBold == null) {
225
                        btnBold = new JToggleButton(PluginServices.getIconTheme().get("bold-icon"));
226
                }
227
                return btnBold;
228
        }
229
}