Statistics
| Revision:

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 @ 47464

History | View | Annotate | Download (16 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 txtRotationExp = 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
   JLabel lblLabelSizeExpression = new JLabel();
63
   JTextField txtSizeExp = new JTextField();
64
   JButton btnSizeExpression = new JButton();
65
   JButton btnSizeExpressionHistory = new JButton();
66
   JButton btnSizeExpressionBookmarks = new JButton();
67
   JLabel lblLabelRotation = new JLabel();
68
   JSpinner txtRotation = new JSpinner();
69

    
70
   /**
71
    * Default constructor
72
    */
73
   public PictureMarkerView()
74
   {
75
      initializePanel();
76
   }
77

    
78
   /**
79
    * Adds fill components to empty cells in the first row and first column of the grid.
80
    * This ensures that the grid spacing will be the same as shown in the designer.
81
    * @param cols an array of column indices in the first row where fill components should be added.
82
    * @param rows an array of row indices in the first column where fill components should be added.
83
    */
84
   void addFillComponents( Container panel, int[] cols, int[] rows )
85
   {
86
      Dimension filler = new Dimension(10,10);
87

    
88
      boolean filled_cell_11 = false;
89
      CellConstraints cc = new CellConstraints();
90
      if ( cols.length > 0 && rows.length > 0 )
91
      {
92
         if ( cols[0] == 1 && rows[0] == 1 )
93
         {
94
            /** add a rigid area  */
95
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
96
            filled_cell_11 = true;
97
         }
98
      }
99

    
100
      for( int index = 0; index < cols.length; index++ )
101
      {
102
         if ( cols[index] == 1 && filled_cell_11 )
103
         {
104
            continue;
105
         }
106
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
107
      }
108

    
109
      for( int index = 0; index < rows.length; index++ )
110
      {
111
         if ( rows[index] == 1 && filled_cell_11 )
112
         {
113
            continue;
114
         }
115
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
116
      }
117

    
118
   }
119

    
120
   /**
121
    * Helper method to load an image file from the CLASSPATH
122
    * @param imageName the package and name of the file to load relative to the CLASSPATH
123
    * @return an ImageIcon instance with the specified image file
124
    * @throws IllegalArgumentException if the image resource cannot be loaded.
125
    */
126
   public ImageIcon loadImage( String imageName )
127
   {
128
      try
129
      {
130
         ClassLoader classloader = getClass().getClassLoader();
131
         java.net.URL url = classloader.getResource( imageName );
132
         if ( url != null )
133
         {
134
            ImageIcon icon = new ImageIcon( url );
135
            return icon;
136
         }
137
      }
138
      catch( Exception e )
139
      {
140
         e.printStackTrace();
141
      }
142
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
143
   }
144

    
145
   /**
146
    * Method for recalculating the component orientation for 
147
    * right-to-left Locales.
148
    * @param orientation the component orientation to be applied
149
    */
150
   public void applyComponentOrientation( ComponentOrientation orientation )
151
   {
152
      // Not yet implemented...
153
      // I18NUtils.applyComponentOrientation(this, orientation);
154
      super.applyComponentOrientation(orientation);
155
   }
156

    
157
   public JPanel createPanel()
158
   {
159
      JPanel jpanel1 = new JPanel();
160
      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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
161
      CellConstraints cc = new CellConstraints();
162
      jpanel1.setLayout(formlayout1);
163

    
164
      lblLabelFileName.setName("lblLabelFileName");
165
      lblLabelFileName.setText("picture_file");
166
      jpanel1.add(lblLabelFileName,cc.xy(2,2));
167

    
168
      lblLabelSelFileName.setName("lblLabelSelFileName");
169
      lblLabelSelFileName.setText("selection_picture_file");
170
      jpanel1.add(lblLabelSelFileName,cc.xy(2,4));
171

    
172
      lblLabelSize.setName("lblLabelSize");
173
      lblLabelSize.setText("width");
174
      jpanel1.add(lblLabelSize,cc.xy(2,6));
175

    
176
      lblLabelX.setName("lblLabelX");
177
      lblLabelX.setText("x_offset");
178
      jpanel1.add(lblLabelX,cc.xy(2,10));
179

    
180
      lblLabelY.setName("lblLabelY");
181
      lblLabelY.setText("y_offset");
182
      jpanel1.add(lblLabelY,cc.xy(2,12));
183

    
184
      txtSize.setName("txtSize");
185
      jpanel1.add(txtSize,cc.xywh(4,6,7,1));
186

    
187
      txtX.setName("txtX");
188
      jpanel1.add(txtX,cc.xywh(4,10,7,1));
189

    
190
      txtY.setName("txtY");
191
      jpanel1.add(txtY,cc.xywh(4,12,7,1));
192

    
193
      lblLabelXExpression.setName("lblLabelXExpression");
194
      lblLabelXExpression.setText("_X_offset_expression");
195
      jpanel1.add(lblLabelXExpression,cc.xy(2,22));
196

    
197
      lblLabelYExpression.setName("lblLabelYExpression");
198
      lblLabelYExpression.setText("_Y_offset_expression");
199
      jpanel1.add(lblLabelYExpression,cc.xy(2,24));
200

    
201
      lblLabelRotationExpression.setName("lblLabelRotationExpression");
202
      lblLabelRotationExpression.setText("_Rotation_expression");
203
      jpanel1.add(lblLabelRotationExpression,cc.xy(2,26));
204

    
205
      lblColorLineExpression.setName("lblColorLineExpression");
206
      lblColorLineExpression.setText("_Line_color_expression");
207
      jpanel1.add(lblColorLineExpression,cc.xy(2,28));
208

    
209
      btnRotationExpression.setActionCommand("...");
210
      btnRotationExpression.setName("btnRotationExpression");
211
      btnRotationExpression.setText("...");
212
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
213
      btnRotationExpression.setBorder(emptyborder1);
214
      jpanel1.add(btnRotationExpression,cc.xy(6,26));
215

    
216
      txtXOffset.setName("txtXOffset");
217
      jpanel1.add(txtXOffset,cc.xy(4,22));
218

    
219
      txtYOffset.setName("txtYOffset");
220
      jpanel1.add(txtYOffset,cc.xy(4,24));
221

    
222
      txtRotationExp.setName("txtRotationExp");
223
      jpanel1.add(txtRotationExp,cc.xy(4,26));
224

    
225
      btnYOffsetExpression.setActionCommand("...");
226
      btnYOffsetExpression.setName("btnYOffsetExpression");
227
      btnYOffsetExpression.setText("...");
228
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
229
      btnYOffsetExpression.setBorder(emptyborder2);
230
      jpanel1.add(btnYOffsetExpression,cc.xy(6,24));
231

    
232
      btnXOffsetExpression.setActionCommand("...");
233
      btnXOffsetExpression.setName("btnXOffsetExpression");
234
      btnXOffsetExpression.setText("...");
235
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
236
      btnXOffsetExpression.setBorder(emptyborder3);
237
      jpanel1.add(btnXOffsetExpression,cc.xy(6,22));
238

    
239
      btnXOffsetExpressionHistory.setActionCommand("...");
240
      btnXOffsetExpressionHistory.setName("btnXOffsetExpressionHistory");
241
      btnXOffsetExpressionHistory.setText("...");
242
      EmptyBorder emptyborder4 = new EmptyBorder(2,2,2,2);
243
      btnXOffsetExpressionHistory.setBorder(emptyborder4);
244
      jpanel1.add(btnXOffsetExpressionHistory,cc.xy(8,22));
245

    
246
      btnXOffsetExpressionBookmarks.setActionCommand("...");
247
      btnXOffsetExpressionBookmarks.setName("btnXOffsetExpressionBookmarks");
248
      btnXOffsetExpressionBookmarks.setText("...");
249
      EmptyBorder emptyborder5 = new EmptyBorder(2,2,2,2);
250
      btnXOffsetExpressionBookmarks.setBorder(emptyborder5);
251
      jpanel1.add(btnXOffsetExpressionBookmarks,cc.xy(10,22));
252

    
253
      btnYOffsetExpressionHistory.setActionCommand("...");
254
      btnYOffsetExpressionHistory.setName("btnYOffsetExpressionHistory");
255
      btnYOffsetExpressionHistory.setText("...");
256
      EmptyBorder emptyborder6 = new EmptyBorder(2,2,2,2);
257
      btnYOffsetExpressionHistory.setBorder(emptyborder6);
258
      jpanel1.add(btnYOffsetExpressionHistory,cc.xy(8,24));
259

    
260
      btnYOffsetExpressionBookmarks.setActionCommand("...");
261
      btnYOffsetExpressionBookmarks.setName("btnYOffsetExpressionBookmarks");
262
      btnYOffsetExpressionBookmarks.setText("...");
263
      EmptyBorder emptyborder7 = new EmptyBorder(2,2,2,2);
264
      btnYOffsetExpressionBookmarks.setBorder(emptyborder7);
265
      jpanel1.add(btnYOffsetExpressionBookmarks,cc.xy(10,24));
266

    
267
      btnRotationExpressionHistory.setActionCommand("...");
268
      btnRotationExpressionHistory.setName("btnRotationExpressionHistory");
269
      btnRotationExpressionHistory.setText("...");
270
      EmptyBorder emptyborder8 = new EmptyBorder(2,2,2,2);
271
      btnRotationExpressionHistory.setBorder(emptyborder8);
272
      jpanel1.add(btnRotationExpressionHistory,cc.xy(8,26));
273

    
274
      btnRotationExpressionBookmarks.setActionCommand("...");
275
      btnRotationExpressionBookmarks.setName("btnRotationExpressionBookmarks");
276
      btnRotationExpressionBookmarks.setText("...");
277
      EmptyBorder emptyborder9 = new EmptyBorder(2,2,2,2);
278
      btnRotationExpressionBookmarks.setBorder(emptyborder9);
279
      jpanel1.add(btnRotationExpressionBookmarks,cc.xy(10,26));
280

    
281
      txtPictureFile.setName("txtPictureFile");
282
      jpanel1.add(txtPictureFile,cc.xywh(4,2,5,1));
283

    
284
      txtSelPictureFile.setName("txtSelPictureFile");
285
      jpanel1.add(txtSelPictureFile,cc.xywh(4,4,5,1));
286

    
287
      btnPictureFile.setActionCommand("...");
288
      btnPictureFile.setName("btnPictureFile");
289
      btnPictureFile.setText("...");
290
      EmptyBorder emptyborder10 = new EmptyBorder(2,2,2,2);
291
      btnPictureFile.setBorder(emptyborder10);
292
      jpanel1.add(btnPictureFile,cc.xy(10,2));
293

    
294
      btnSelPictureFile.setActionCommand("...");
295
      btnSelPictureFile.setName("btnSelPictureFile");
296
      btnSelPictureFile.setText("...");
297
      EmptyBorder emptyborder11 = new EmptyBorder(2,2,2,2);
298
      btnSelPictureFile.setBorder(emptyborder11);
299
      jpanel1.add(btnSelPictureFile,cc.xy(10,4));
300

    
301
      lblColorLine.setName("lblColorLine");
302
      lblColorLine.setText("_Line_color");
303
      jpanel1.add(lblColorLine,cc.xy(2,16));
304

    
305
      txtColorLine.setName("txtColorLine");
306
      jpanel1.add(txtColorLine,cc.xywh(4,16,5,1));
307

    
308
      btnColorLine.setActionCommand("...");
309
      btnColorLine.setName("btnColorLine");
310
      btnColorLine.setText("...");
311
      EmptyBorder emptyborder12 = new EmptyBorder(2,2,2,2);
312
      btnColorLine.setBorder(emptyborder12);
313
      jpanel1.add(btnColorLine,cc.xy(10,16));
314

    
315
      chkDrawLineToOffset.setActionCommand("Join_the_insertion_point_and_the_offset_with_a_line");
316
      chkDrawLineToOffset.setName("chkDrawLineToOffset");
317
      chkDrawLineToOffset.setText("_Join_the_insertion_point_and_the_offset_with_a_line");
318
      chkDrawLineToOffset.setHorizontalTextPosition(JCheckBox.LEFT);
319
      jpanel1.add(chkDrawLineToOffset,cc.xywh(2,14,9,1));
320

    
321
      lblDynamicValues.setName("lblDynamicValues");
322
      lblDynamicValues.setText("Valores dinamicos");
323
      jpanel1.add(lblDynamicValues,cc.xywh(2,18,9,1));
324

    
325
      txtColorLineExp.setName("txtColorLineExp");
326
      jpanel1.add(txtColorLineExp,cc.xy(4,28));
327

    
328
      btnColorLineExpression.setActionCommand("...");
329
      btnColorLineExpression.setName("btnColorLineExpression");
330
      btnColorLineExpression.setText("...");
331
      EmptyBorder emptyborder13 = new EmptyBorder(2,2,2,2);
332
      btnColorLineExpression.setBorder(emptyborder13);
333
      jpanel1.add(btnColorLineExpression,cc.xy(6,28));
334

    
335
      btnColorLineExpressionHistory.setActionCommand("...");
336
      btnColorLineExpressionHistory.setName("btnColorLineExpressionHistory");
337
      btnColorLineExpressionHistory.setText("...");
338
      EmptyBorder emptyborder14 = new EmptyBorder(2,2,2,2);
339
      btnColorLineExpressionHistory.setBorder(emptyborder14);
340
      jpanel1.add(btnColorLineExpressionHistory,cc.xy(8,28));
341

    
342
      btnColorLineExpressionBookmarks.setActionCommand("...");
343
      btnColorLineExpressionBookmarks.setName("btnColorLineExpressionBookmarks");
344
      btnColorLineExpressionBookmarks.setText("...");
345
      EmptyBorder emptyborder15 = new EmptyBorder(2,2,2,2);
346
      btnColorLineExpressionBookmarks.setBorder(emptyborder15);
347
      jpanel1.add(btnColorLineExpressionBookmarks,cc.xy(10,28));
348

    
349
      lblLabelSizeExpression.setName("lblLabelSizeExpression");
350
      lblLabelSizeExpression.setText("_Size_expression");
351
      jpanel1.add(lblLabelSizeExpression,cc.xy(2,20));
352

    
353
      txtSizeExp.setName("txtSizeExp");
354
      jpanel1.add(txtSizeExp,cc.xy(4,20));
355

    
356
      btnSizeExpression.setActionCommand("...");
357
      btnSizeExpression.setName("btnSizeExpression");
358
      btnSizeExpression.setText("...");
359
      EmptyBorder emptyborder16 = new EmptyBorder(2,2,2,2);
360
      btnSizeExpression.setBorder(emptyborder16);
361
      jpanel1.add(btnSizeExpression,cc.xy(6,20));
362

    
363
      btnSizeExpressionHistory.setActionCommand("...");
364
      btnSizeExpressionHistory.setName("btnSizeExpressionHistory");
365
      btnSizeExpressionHistory.setText("...");
366
      EmptyBorder emptyborder17 = new EmptyBorder(2,2,2,2);
367
      btnSizeExpressionHistory.setBorder(emptyborder17);
368
      jpanel1.add(btnSizeExpressionHistory,cc.xy(8,20));
369

    
370
      btnSizeExpressionBookmarks.setActionCommand("...");
371
      btnSizeExpressionBookmarks.setName("btnSizeExpressionBookmarks");
372
      btnSizeExpressionBookmarks.setText("...");
373
      EmptyBorder emptyborder18 = new EmptyBorder(2,2,2,2);
374
      btnSizeExpressionBookmarks.setBorder(emptyborder18);
375
      jpanel1.add(btnSizeExpressionBookmarks,cc.xy(10,20));
376

    
377
      lblLabelRotation.setName("lblLabelRotation");
378
      lblLabelRotation.setText("angle");
379
      jpanel1.add(lblLabelRotation,cc.xy(2,8));
380

    
381
      txtRotation.setName("txtRotation");
382
      jpanel1.add(txtRotation,cc.xywh(4,8,7,1));
383

    
384
      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,26,27,28,29 });
385
      return jpanel1;
386
   }
387

    
388
   /**
389
    * Initializer
390
    */
391
   protected void initializePanel()
392
   {
393
      setLayout(new BorderLayout());
394
      add(createPanel(), BorderLayout.CENTER);
395
   }
396

    
397

    
398
}