root / branches / v2_0_0_prep / libraries / org.gvsig.annotation / org.gvsig.annotation.swing / org.gvsig.annotation.swing.impl / src / main / java / org / gvsig / annotation / swing / impl / DefaultJAnnotationPreferencesPanel.java @ 38608
History | View | Annotate | Download (8.92 KB)
1 |
package org.gvsig.annotation.swing.impl; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.GridBagConstraints; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.Insets; |
7 |
import java.util.List; |
8 |
|
9 |
import javax.swing.JComboBox; |
10 |
import javax.swing.JLabel; |
11 |
import javax.swing.JTextField; |
12 |
|
13 |
import org.gvsig.annotation.AnnotationManager; |
14 |
import org.gvsig.annotation.swing.AnnotationSwingLocator; |
15 |
import org.gvsig.annotation.swing.AnnotationSwingManager; |
16 |
import org.gvsig.annotation.swing.JAnnotationPreferencesPanel; |
17 |
import org.gvsig.gui.beans.colorchooser.ColorChooser; |
18 |
|
19 |
/**
|
20 |
*
|
21 |
* @author Cesar Martinez Izquierdo <cesar.martinez@iver.es> 01/11/2008
|
22 |
*
|
23 |
*/
|
24 |
public class DefaultJAnnotationPreferencesPanel extends JAnnotationPreferencesPanel{ |
25 |
private static final long serialVersionUID = 8893693122931478526L; |
26 |
private JLabel jLabel1 = null; |
27 |
private JComboBox cmbTypeFont = null; |
28 |
private JLabel jLabel2 = null; |
29 |
private JComboBox cmbStyleFont = null; |
30 |
private JLabel jLabel3 = null; |
31 |
private JTextField txtHeight = null; |
32 |
private JLabel jLabel4 = null; |
33 |
private ColorChooser colorPanel = null; |
34 |
private JLabel jLabel5 = null; |
35 |
private JTextField txtRotate = null; |
36 |
|
37 |
private AnnotationManager annotationManager = null; |
38 |
private AnnotationSwingManager annotationSwingManager = null; |
39 |
|
40 |
/**
|
41 |
* This is the default constructor
|
42 |
*/
|
43 |
public DefaultJAnnotationPreferencesPanel(AnnotationManager annotationManager) {
|
44 |
super();
|
45 |
this.annotationSwingManager = AnnotationSwingLocator.getSwingManager();
|
46 |
this.annotationManager = annotationManager;
|
47 |
initialize(); |
48 |
} |
49 |
|
50 |
/**
|
51 |
* This method initializes this
|
52 |
*
|
53 |
* @return void
|
54 |
*/
|
55 |
private void initialize() { |
56 |
this.setLayout(new GridBagLayout()); |
57 |
Insets rightInsets = new Insets(4,4,4,0); |
58 |
Insets leftInsets = new Insets(4,0,4,4); |
59 |
GridBagConstraints txtRotationConstraints = new GridBagConstraints(); |
60 |
txtRotationConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
61 |
txtRotationConstraints.gridy = 5;
|
62 |
txtRotationConstraints.weightx = 1.0;
|
63 |
txtRotationConstraints.gridx = 1;
|
64 |
txtRotationConstraints.insets = rightInsets; |
65 |
|
66 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
67 |
gridBagConstraints10.gridx = 0;
|
68 |
gridBagConstraints10.gridy = 5;
|
69 |
gridBagConstraints10.insets = leftInsets; |
70 |
gridBagConstraints10.anchor = GridBagConstraints.WEST;
|
71 |
|
72 |
jLabel5 = new JLabel(); |
73 |
jLabel5.setText(annotationSwingManager.getTranslation("fontrotate"));
|
74 |
|
75 |
GridBagConstraints colorChooserConstraints = new GridBagConstraints(); |
76 |
colorChooserConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
77 |
colorChooserConstraints.anchor = GridBagConstraints.WEST;
|
78 |
colorChooserConstraints.gridy = 4;
|
79 |
colorChooserConstraints.weightx = 1.0;
|
80 |
colorChooserConstraints.gridx = 1;
|
81 |
colorChooserConstraints.insets = rightInsets; |
82 |
|
83 |
GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); |
84 |
gridBagConstraints8.gridx = 0;
|
85 |
gridBagConstraints8.gridy = 4;
|
86 |
gridBagConstraints8.anchor = GridBagConstraints.WEST;
|
87 |
gridBagConstraints8.insets = leftInsets; |
88 |
|
89 |
jLabel4 = new JLabel(); |
90 |
jLabel4.setText(annotationSwingManager.getTranslation("fontcolor"));
|
91 |
|
92 |
GridBagConstraints txtHeightConstraints = new GridBagConstraints(); |
93 |
txtHeightConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
94 |
txtHeightConstraints.gridy = 3;
|
95 |
txtHeightConstraints.weightx = 1.0;
|
96 |
txtHeightConstraints.gridx = 1;
|
97 |
txtHeightConstraints.insets = rightInsets; |
98 |
|
99 |
GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); |
100 |
gridBagConstraints6.gridx = 0;
|
101 |
gridBagConstraints6.gridy = 3;
|
102 |
gridBagConstraints6.anchor = GridBagConstraints.WEST;
|
103 |
gridBagConstraints6.insets = leftInsets; |
104 |
|
105 |
jLabel3 = new JLabel(); |
106 |
jLabel3.setText(annotationSwingManager.getTranslation("fontheight"));
|
107 |
|
108 |
GridBagConstraints fontStyleConstraints = new GridBagConstraints(); |
109 |
fontStyleConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
110 |
fontStyleConstraints.gridy = 2;
|
111 |
fontStyleConstraints.weightx = 1.0;
|
112 |
fontStyleConstraints.gridx = 1;
|
113 |
fontStyleConstraints.insets = rightInsets; |
114 |
|
115 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
116 |
gridBagConstraints4.gridx = 0;
|
117 |
gridBagConstraints4.gridy = 2;
|
118 |
gridBagConstraints4.anchor = GridBagConstraints.WEST;
|
119 |
gridBagConstraints4.insets = leftInsets; |
120 |
|
121 |
|
122 |
jLabel2 = new JLabel(); |
123 |
jLabel2.setText(annotationSwingManager.getTranslation("fontstyle"));
|
124 |
|
125 |
GridBagConstraints fontTypeConstraints = new GridBagConstraints(); |
126 |
fontTypeConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
127 |
fontTypeConstraints.gridy = 1;
|
128 |
fontTypeConstraints.weightx = 1.0;
|
129 |
fontTypeConstraints.gridx = 1;
|
130 |
fontTypeConstraints.insets = rightInsets; |
131 |
|
132 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
133 |
gridBagConstraints2.gridx = 0;
|
134 |
gridBagConstraints2.gridy = 1;
|
135 |
gridBagConstraints2.anchor = GridBagConstraints.WEST;
|
136 |
gridBagConstraints2.insets = leftInsets; |
137 |
|
138 |
jLabel1 = new JLabel(); |
139 |
jLabel1.setText(annotationSwingManager.getTranslation("fonttype"));
|
140 |
jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.TRAILING); |
141 |
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEADING); |
142 |
|
143 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
144 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
145 |
gridBagConstraints1.gridy = 0;
|
146 |
gridBagConstraints1.weightx = 1.0;
|
147 |
gridBagConstraints1.gridx = 1;
|
148 |
gridBagConstraints1.insets = rightInsets; |
149 |
|
150 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
151 |
gridBagConstraints.gridx = 0;
|
152 |
gridBagConstraints.gridy = 0;
|
153 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
154 |
gridBagConstraints.insets = leftInsets; |
155 |
|
156 |
this.add(jLabel1, gridBagConstraints2);
|
157 |
this.add(getCmbFontType(), fontTypeConstraints);
|
158 |
this.add(jLabel2, gridBagConstraints4);
|
159 |
this.add(getCmbFontStyle(), fontStyleConstraints);
|
160 |
this.add(jLabel3, gridBagConstraints6);
|
161 |
this.add(getTxtHeightField(), txtHeightConstraints);
|
162 |
this.add(jLabel4, gridBagConstraints8);
|
163 |
this.add(getColorChooser(), colorChooserConstraints);
|
164 |
this.add(jLabel5, gridBagConstraints10);
|
165 |
this.add(getTxtRotationField(), txtRotationConstraints);
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* This method initializes txtTypeFont
|
170 |
*
|
171 |
* @return javax.swing.JTextField
|
172 |
*/
|
173 |
private JComboBox getCmbFontType() { |
174 |
if (cmbTypeFont == null) { |
175 |
cmbTypeFont = new JComboBox(); |
176 |
List<String> types = annotationManager.getFontTypes(); |
177 |
for (int i=0 ; i<types.size() ; i++){ |
178 |
cmbTypeFont.addItem(types.get(i)); |
179 |
} |
180 |
cmbTypeFont.setSelectedItem(annotationManager.getDefaultFontType()); |
181 |
|
182 |
} |
183 |
return cmbTypeFont;
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* This method initializes txtStyleFont
|
188 |
*
|
189 |
* @return javax.swing.JTextField
|
190 |
*/
|
191 |
private JComboBox getCmbFontStyle() { |
192 |
if (cmbStyleFont == null) { |
193 |
cmbStyleFont = new JComboBox(); |
194 |
List<String> styles = annotationManager.getFontStyles(); |
195 |
for (int i=0 ; i<styles.size() ; i++){ |
196 |
cmbStyleFont.addItem(styles.get(i)); |
197 |
} |
198 |
cmbStyleFont.setSelectedItem(annotationManager.getDefaultFontStyle()); |
199 |
} |
200 |
return cmbStyleFont;
|
201 |
} |
202 |
|
203 |
/**
|
204 |
* This method initializes txtHeight
|
205 |
*
|
206 |
* @return javax.swing.JTextField
|
207 |
*/
|
208 |
private JTextField getTxtHeightField() { |
209 |
if (txtHeight == null) { |
210 |
txtHeight = new JTextField(); |
211 |
txtHeight.setText("10");
|
212 |
} |
213 |
return txtHeight;
|
214 |
} |
215 |
|
216 |
/**
|
217 |
* This method initializes txtColor
|
218 |
*
|
219 |
* @return javax.swing.JTextField
|
220 |
*/
|
221 |
private ColorChooser getColorChooser() {
|
222 |
if (colorPanel == null) { |
223 |
colorPanel = new ColorChooser();
|
224 |
colorPanel.setColor(Color.BLACK);
|
225 |
} |
226 |
return colorPanel;
|
227 |
} |
228 |
|
229 |
/**
|
230 |
* This method initializes txtRotate
|
231 |
*
|
232 |
* @return javax.swing.JTextField
|
233 |
*/
|
234 |
private JTextField getTxtRotationField() { |
235 |
if (txtRotate == null) { |
236 |
txtRotate = new JTextField(); |
237 |
txtRotate.setText("0.0");
|
238 |
} |
239 |
return txtRotate;
|
240 |
} |
241 |
|
242 |
public String getDefaultFontType() { |
243 |
return getCmbFontType().getSelectedItem().toString();
|
244 |
} |
245 |
|
246 |
public void setDefaultFontType(String typeFont) { |
247 |
getCmbFontType().setSelectedItem(typeFont); |
248 |
} |
249 |
|
250 |
/**
|
251 |
* @return {@link java.awt.Font#PLAIN}, {@link java.awt.Font#BOLD}
|
252 |
* or {@link java.awt.Font#ITALIC}
|
253 |
*/
|
254 |
public String getDefaultFontStyle() { |
255 |
return (String)getCmbFontStyle().getSelectedItem(); |
256 |
} |
257 |
|
258 |
/**
|
259 |
* One of {@link java.awt.Font#PLAIN}, {@link java.awt.Font#BOLD}
|
260 |
* or {@link java.awt.Font#ITALIC}
|
261 |
* @param style
|
262 |
*/
|
263 |
public void setDefaultFontStyle(String style) { |
264 |
getCmbFontStyle().setSelectedItem(style); |
265 |
} |
266 |
|
267 |
public double getDefaultFontHeight() { |
268 |
return Double.parseDouble(getTxtHeightField().getText()); |
269 |
} |
270 |
|
271 |
public void setDefaultFontHeight(double height) { |
272 |
getTxtHeightField().setText(new Double(height).toString()); |
273 |
} |
274 |
|
275 |
public int getDefaultFontColor() { |
276 |
return getColorChooser().getColor().getRGB();
|
277 |
} |
278 |
|
279 |
public void setDefaultFontColor(int color) { |
280 |
getColorChooser().setColor(new Color(color)); |
281 |
} |
282 |
|
283 |
public double getDefaultFontRotation() { |
284 |
return Double.parseDouble(getTxtRotationField().getText()); |
285 |
} |
286 |
|
287 |
public void setDefaultFontRotation(double rotation) { |
288 |
getTxtRotationField().setText(new Double(rotation).toString()); |
289 |
} |
290 |
|
291 |
} // @jve:decl-index=0:visual-constraint="10,10"
|