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 / PictureMarkerView.java @ 45526
History | View | Annotate | Download (14.8 KB)
1 |
package org.gvsig.app.gui.styling; |
---|---|
2 |
|
3 |
import com.jeta.forms.components.separator.TitledSeparator; |
4 |
import com.jeta.open.i18n.I18NUtils; |
5 |
import com.jgoodies.forms.layout.CellConstraints; |
6 |
import com.jgoodies.forms.layout.FormLayout; |
7 |
import java.awt.BorderLayout; |
8 |
import java.awt.ComponentOrientation; |
9 |
import java.awt.Container; |
10 |
import java.awt.Dimension; |
11 |
import javax.swing.Box; |
12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JCheckBox; |
15 |
import javax.swing.JFrame; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JPanel; |
18 |
import javax.swing.JSpinner; |
19 |
import javax.swing.JTextField; |
20 |
import javax.swing.border.EmptyBorder; |
21 |
|
22 |
|
23 |
public class PictureMarkerView extends JPanel |
24 |
{ |
25 |
JLabel lblLabelFileName = new JLabel(); |
26 |
JLabel lblLabelSelFileName = new JLabel(); |
27 |
JLabel lblLabelSize = new JLabel(); |
28 |
JLabel lblLabelX = new JLabel(); |
29 |
JLabel lblLabelY = new JLabel(); |
30 |
JSpinner txtSize = new JSpinner(); |
31 |
JSpinner txtX = new JSpinner(); |
32 |
JSpinner txtY = new JSpinner(); |
33 |
JLabel lblLabelXExpression = new JLabel(); |
34 |
JLabel lblLabelYExpression = new JLabel(); |
35 |
JLabel lblLabelRotationExpression = new JLabel(); |
36 |
JLabel lblColorLineExpression = new JLabel(); |
37 |
JButton btnRotationExpression = new JButton(); |
38 |
JTextField txtXOffset = new JTextField(); |
39 |
JTextField txtYOffset = new JTextField(); |
40 |
JTextField txtRotation = new JTextField(); |
41 |
JButton btnYOffsetExpression = new JButton(); |
42 |
JButton btnXOffsetExpression = new JButton(); |
43 |
JButton btnXOffsetExpressionHistory = new JButton(); |
44 |
JButton btnXOffsetExpressionBookmarks = new JButton(); |
45 |
JButton btnYOffsetExpressionHistory = new JButton(); |
46 |
JButton btnYOffsetExpressionBookmarks = new JButton(); |
47 |
JButton btnRotationExpressionHistory = new JButton(); |
48 |
JButton btnRotationExpressionBookmarks = new JButton(); |
49 |
JTextField txtPictureFile = new JTextField(); |
50 |
JTextField txtSelPictureFile = new JTextField(); |
51 |
JButton btnPictureFile = new JButton(); |
52 |
JButton btnSelPictureFile = new JButton(); |
53 |
JLabel lblColorLine = new JLabel(); |
54 |
JTextField txtColorLine = new JTextField(); |
55 |
JButton btnColorLine = new JButton(); |
56 |
JCheckBox chkDrawLineToOffset = new JCheckBox(); |
57 |
TitledSeparator lblDynamicValues = new TitledSeparator();
|
58 |
JTextField txtColorLineExp = new JTextField(); |
59 |
JButton btnColorLineExpression = new JButton(); |
60 |
JButton btnColorLineExpressionHistory = new JButton(); |
61 |
JButton btnColorLineExpressionBookmarks = new JButton(); |
62 |
|
63 |
/**
|
64 |
* Default constructor
|
65 |
*/
|
66 |
public PictureMarkerView()
|
67 |
{ |
68 |
initializePanel(); |
69 |
} |
70 |
|
71 |
/**
|
72 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
73 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
74 |
* @param cols an array of column indices in the first row where fill components should be added.
|
75 |
* @param rows an array of row indices in the first column where fill components should be added.
|
76 |
*/
|
77 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
78 |
{ |
79 |
Dimension filler = new Dimension(10,10); |
80 |
|
81 |
boolean filled_cell_11 = false; |
82 |
CellConstraints cc = new CellConstraints();
|
83 |
if ( cols.length > 0 && rows.length > 0 ) |
84 |
{ |
85 |
if ( cols[0] == 1 && rows[0] == 1 ) |
86 |
{ |
87 |
/** add a rigid area */
|
88 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
89 |
filled_cell_11 = true;
|
90 |
} |
91 |
} |
92 |
|
93 |
for( int index = 0; index < cols.length; index++ ) |
94 |
{ |
95 |
if ( cols[index] == 1 && filled_cell_11 ) |
96 |
{ |
97 |
continue;
|
98 |
} |
99 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
100 |
} |
101 |
|
102 |
for( int index = 0; index < rows.length; index++ ) |
103 |
{ |
104 |
if ( rows[index] == 1 && filled_cell_11 ) |
105 |
{ |
106 |
continue;
|
107 |
} |
108 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
109 |
} |
110 |
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* Helper method to load an image file from the CLASSPATH
|
115 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
116 |
* @return an ImageIcon instance with the specified image file
|
117 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
118 |
*/
|
119 |
public ImageIcon loadImage( String imageName ) |
120 |
{ |
121 |
try
|
122 |
{ |
123 |
ClassLoader classloader = getClass().getClassLoader();
|
124 |
java.net.URL url = classloader.getResource( imageName ); |
125 |
if ( url != null ) |
126 |
{ |
127 |
ImageIcon icon = new ImageIcon( url ); |
128 |
return icon;
|
129 |
} |
130 |
} |
131 |
catch( Exception e ) |
132 |
{ |
133 |
e.printStackTrace(); |
134 |
} |
135 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
136 |
} |
137 |
|
138 |
/**
|
139 |
* Method for recalculating the component orientation for
|
140 |
* right-to-left Locales.
|
141 |
* @param orientation the component orientation to be applied
|
142 |
*/
|
143 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
144 |
{ |
145 |
// Not yet implemented...
|
146 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
147 |
super.applyComponentOrientation(orientation);
|
148 |
} |
149 |
|
150 |
public JPanel createPanel() |
151 |
{ |
152 |
JPanel jpanel1 = new JPanel(); |
153 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
154 |
CellConstraints cc = new CellConstraints();
|
155 |
jpanel1.setLayout(formlayout1); |
156 |
|
157 |
lblLabelFileName.setName("lblLabelFileName");
|
158 |
lblLabelFileName.setText("picture_file");
|
159 |
jpanel1.add(lblLabelFileName,cc.xy(2,2)); |
160 |
|
161 |
lblLabelSelFileName.setName("lblLabelSelFileName");
|
162 |
lblLabelSelFileName.setText("selection_picture_file");
|
163 |
jpanel1.add(lblLabelSelFileName,cc.xy(2,4)); |
164 |
|
165 |
lblLabelSize.setName("lblLabelSize");
|
166 |
lblLabelSize.setText("width");
|
167 |
jpanel1.add(lblLabelSize,cc.xy(2,6)); |
168 |
|
169 |
lblLabelX.setName("lblLabelX");
|
170 |
lblLabelX.setText("x_offset");
|
171 |
jpanel1.add(lblLabelX,cc.xy(2,8)); |
172 |
|
173 |
lblLabelY.setName("lblLabelY");
|
174 |
lblLabelY.setText("y_offset");
|
175 |
jpanel1.add(lblLabelY,cc.xy(2,10)); |
176 |
|
177 |
txtSize.setName("txtSize");
|
178 |
jpanel1.add(txtSize,cc.xywh(4,6,7,1)); |
179 |
|
180 |
txtX.setName("txtX");
|
181 |
jpanel1.add(txtX,cc.xywh(4,8,7,1)); |
182 |
|
183 |
txtY.setName("txtY");
|
184 |
jpanel1.add(txtY,cc.xywh(4,10,7,1)); |
185 |
|
186 |
lblLabelXExpression.setName("lblLabelXExpression");
|
187 |
lblLabelXExpression.setText("x_offset_expression");
|
188 |
jpanel1.add(lblLabelXExpression,cc.xy(2,18)); |
189 |
|
190 |
lblLabelYExpression.setName("lblLabelYExpression");
|
191 |
lblLabelYExpression.setText("y_offset_expression");
|
192 |
jpanel1.add(lblLabelYExpression,cc.xy(2,20)); |
193 |
|
194 |
lblLabelRotationExpression.setName("lblLabelRotationExpression");
|
195 |
lblLabelRotationExpression.setText("rotation_expression");
|
196 |
jpanel1.add(lblLabelRotationExpression,cc.xy(2,22)); |
197 |
|
198 |
lblColorLineExpression.setName("lblColorLineExpression");
|
199 |
lblColorLineExpression.setText("color_line");
|
200 |
jpanel1.add(lblColorLineExpression,cc.xy(2,24)); |
201 |
|
202 |
btnRotationExpression.setActionCommand("...");
|
203 |
btnRotationExpression.setName("btnRotationExpression");
|
204 |
btnRotationExpression.setOpaque(false);
|
205 |
btnRotationExpression.setText("...");
|
206 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
207 |
btnRotationExpression.setBorder(emptyborder1); |
208 |
jpanel1.add(btnRotationExpression,cc.xy(6,22)); |
209 |
|
210 |
txtXOffset.setName("txtXOffset");
|
211 |
jpanel1.add(txtXOffset,cc.xy(4,18)); |
212 |
|
213 |
txtYOffset.setName("txtYOffset");
|
214 |
jpanel1.add(txtYOffset,cc.xy(4,20)); |
215 |
|
216 |
txtRotation.setName("txtRotation");
|
217 |
jpanel1.add(txtRotation,cc.xy(4,22)); |
218 |
|
219 |
btnYOffsetExpression.setActionCommand("...");
|
220 |
btnYOffsetExpression.setName("btnYOffsetExpression");
|
221 |
btnYOffsetExpression.setOpaque(false);
|
222 |
btnYOffsetExpression.setText("...");
|
223 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
224 |
btnYOffsetExpression.setBorder(emptyborder2); |
225 |
jpanel1.add(btnYOffsetExpression,cc.xy(6,20)); |
226 |
|
227 |
btnXOffsetExpression.setActionCommand("...");
|
228 |
btnXOffsetExpression.setName("btnXOffsetExpression");
|
229 |
btnXOffsetExpression.setOpaque(false);
|
230 |
btnXOffsetExpression.setText("...");
|
231 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
232 |
btnXOffsetExpression.setBorder(emptyborder3); |
233 |
jpanel1.add(btnXOffsetExpression,cc.xy(6,18)); |
234 |
|
235 |
btnXOffsetExpressionHistory.setActionCommand("...");
|
236 |
btnXOffsetExpressionHistory.setName("btnXOffsetExpressionHistory");
|
237 |
btnXOffsetExpressionHistory.setOpaque(false);
|
238 |
btnXOffsetExpressionHistory.setText("...");
|
239 |
EmptyBorder emptyborder4 = new EmptyBorder(2,2,2,2); |
240 |
btnXOffsetExpressionHistory.setBorder(emptyborder4); |
241 |
jpanel1.add(btnXOffsetExpressionHistory,cc.xy(8,18)); |
242 |
|
243 |
btnXOffsetExpressionBookmarks.setActionCommand("...");
|
244 |
btnXOffsetExpressionBookmarks.setName("btnXOffsetExpressionBookmarks");
|
245 |
btnXOffsetExpressionBookmarks.setOpaque(false);
|
246 |
btnXOffsetExpressionBookmarks.setText("...");
|
247 |
EmptyBorder emptyborder5 = new EmptyBorder(2,2,2,2); |
248 |
btnXOffsetExpressionBookmarks.setBorder(emptyborder5); |
249 |
jpanel1.add(btnXOffsetExpressionBookmarks,cc.xy(10,18)); |
250 |
|
251 |
btnYOffsetExpressionHistory.setActionCommand("...");
|
252 |
btnYOffsetExpressionHistory.setName("btnYOffsetExpressionHistory");
|
253 |
btnYOffsetExpressionHistory.setOpaque(false);
|
254 |
btnYOffsetExpressionHistory.setText("...");
|
255 |
EmptyBorder emptyborder6 = new EmptyBorder(2,2,2,2); |
256 |
btnYOffsetExpressionHistory.setBorder(emptyborder6); |
257 |
jpanel1.add(btnYOffsetExpressionHistory,cc.xy(8,20)); |
258 |
|
259 |
btnYOffsetExpressionBookmarks.setActionCommand("...");
|
260 |
btnYOffsetExpressionBookmarks.setName("btnYOffsetExpressionBookmarks");
|
261 |
btnYOffsetExpressionBookmarks.setOpaque(false);
|
262 |
btnYOffsetExpressionBookmarks.setText("...");
|
263 |
EmptyBorder emptyborder7 = new EmptyBorder(2,2,2,2); |
264 |
btnYOffsetExpressionBookmarks.setBorder(emptyborder7); |
265 |
jpanel1.add(btnYOffsetExpressionBookmarks,cc.xy(10,20)); |
266 |
|
267 |
btnRotationExpressionHistory.setActionCommand("...");
|
268 |
btnRotationExpressionHistory.setName("btnRotationExpressionHistory");
|
269 |
btnRotationExpressionHistory.setOpaque(false);
|
270 |
btnRotationExpressionHistory.setText("...");
|
271 |
EmptyBorder emptyborder8 = new EmptyBorder(2,2,2,2); |
272 |
btnRotationExpressionHistory.setBorder(emptyborder8); |
273 |
jpanel1.add(btnRotationExpressionHistory,cc.xy(8,22)); |
274 |
|
275 |
btnRotationExpressionBookmarks.setActionCommand("...");
|
276 |
btnRotationExpressionBookmarks.setName("btnRotationExpressionBookmarks");
|
277 |
btnRotationExpressionBookmarks.setOpaque(false);
|
278 |
btnRotationExpressionBookmarks.setText("...");
|
279 |
EmptyBorder emptyborder9 = new EmptyBorder(2,2,2,2); |
280 |
btnRotationExpressionBookmarks.setBorder(emptyborder9); |
281 |
jpanel1.add(btnRotationExpressionBookmarks,cc.xy(10,22)); |
282 |
|
283 |
txtPictureFile.setName("txtPictureFile");
|
284 |
jpanel1.add(txtPictureFile,cc.xywh(4,2,5,1)); |
285 |
|
286 |
txtSelPictureFile.setName("txtSelPictureFile");
|
287 |
jpanel1.add(txtSelPictureFile,cc.xywh(4,4,5,1)); |
288 |
|
289 |
btnPictureFile.setActionCommand("...");
|
290 |
btnPictureFile.setName("btnPictureFile");
|
291 |
btnPictureFile.setOpaque(false);
|
292 |
btnPictureFile.setText("...");
|
293 |
EmptyBorder emptyborder10 = new EmptyBorder(2,2,2,2); |
294 |
btnPictureFile.setBorder(emptyborder10); |
295 |
jpanel1.add(btnPictureFile,cc.xy(10,2)); |
296 |
|
297 |
btnSelPictureFile.setActionCommand("...");
|
298 |
btnSelPictureFile.setName("btnSelPictureFile");
|
299 |
btnSelPictureFile.setOpaque(false);
|
300 |
btnSelPictureFile.setText("...");
|
301 |
EmptyBorder emptyborder11 = new EmptyBorder(2,2,2,2); |
302 |
btnSelPictureFile.setBorder(emptyborder11); |
303 |
jpanel1.add(btnSelPictureFile,cc.xy(10,4)); |
304 |
|
305 |
lblColorLine.setName("lblColorLine");
|
306 |
lblColorLine.setText("color_line");
|
307 |
jpanel1.add(lblColorLine,cc.xy(2,14)); |
308 |
|
309 |
txtColorLine.setName("txtColorLine");
|
310 |
jpanel1.add(txtColorLine,cc.xywh(4,14,5,1)); |
311 |
|
312 |
btnColorLine.setActionCommand("...");
|
313 |
btnColorLine.setName("btnColorLine");
|
314 |
btnColorLine.setOpaque(false);
|
315 |
btnColorLine.setText("...");
|
316 |
EmptyBorder emptyborder12 = new EmptyBorder(2,2,2,2); |
317 |
btnColorLine.setBorder(emptyborder12); |
318 |
jpanel1.add(btnColorLine,cc.xy(10,14)); |
319 |
|
320 |
chkDrawLineToOffset.setActionCommand("Join_the_insertion_point_and_the_offset_with_a_line");
|
321 |
chkDrawLineToOffset.setName("chkDrawLineToOffset");
|
322 |
chkDrawLineToOffset.setText("Join_the_insertion_point_and_the_offset_with_a_line");
|
323 |
chkDrawLineToOffset.setHorizontalTextPosition(JCheckBox.LEFT);
|
324 |
jpanel1.add(chkDrawLineToOffset,cc.xywh(2,12,9,1)); |
325 |
|
326 |
lblDynamicValues.setName("lblDynamicValues");
|
327 |
lblDynamicValues.setText("Valores dinamicos");
|
328 |
jpanel1.add(lblDynamicValues,cc.xywh(2,16,9,1)); |
329 |
|
330 |
txtColorLineExp.setName("txtColorLineExp");
|
331 |
jpanel1.add(txtColorLineExp,cc.xy(4,24)); |
332 |
|
333 |
btnColorLineExpression.setActionCommand("...");
|
334 |
btnColorLineExpression.setName("btnColorLineExpression");
|
335 |
btnColorLineExpression.setOpaque(false);
|
336 |
btnColorLineExpression.setText("...");
|
337 |
EmptyBorder emptyborder13 = new EmptyBorder(2,2,2,2); |
338 |
btnColorLineExpression.setBorder(emptyborder13); |
339 |
jpanel1.add(btnColorLineExpression,cc.xy(6,24)); |
340 |
|
341 |
btnColorLineExpressionHistory.setActionCommand("...");
|
342 |
btnColorLineExpressionHistory.setName("btnColorLineExpressionHistory");
|
343 |
btnColorLineExpressionHistory.setOpaque(false);
|
344 |
btnColorLineExpressionHistory.setText("...");
|
345 |
EmptyBorder emptyborder14 = new EmptyBorder(2,2,2,2); |
346 |
btnColorLineExpressionHistory.setBorder(emptyborder14); |
347 |
jpanel1.add(btnColorLineExpressionHistory,cc.xy(8,24)); |
348 |
|
349 |
btnColorLineExpressionBookmarks.setActionCommand("...");
|
350 |
btnColorLineExpressionBookmarks.setName("btnColorLineExpressionBookmarks");
|
351 |
btnColorLineExpressionBookmarks.setOpaque(false);
|
352 |
btnColorLineExpressionBookmarks.setText("...");
|
353 |
EmptyBorder emptyborder15 = new EmptyBorder(2,2,2,2); |
354 |
btnColorLineExpressionBookmarks.setBorder(emptyborder15); |
355 |
jpanel1.add(btnColorLineExpressionBookmarks,cc.xy(10,24)); |
356 |
|
357 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 }); |
358 |
return jpanel1;
|
359 |
} |
360 |
|
361 |
/**
|
362 |
* Initializer
|
363 |
*/
|
364 |
protected void initializePanel() |
365 |
{ |
366 |
setLayout(new BorderLayout()); |
367 |
add(createPanel(), BorderLayout.CENTER);
|
368 |
} |
369 |
|
370 |
|
371 |
} |