Statistics
| Revision:

root / org.gvsig.legend.aggregate / trunk / org.gvsig.legend.aggregate / org.gvsig.legend.aggregate.swing / org.gvsig.legend.aggregate.swing.impl / src / main / java / org / gvsig / legend / aggregate / swing / impl / DefaultAggregateLegendEditorView.java @ 1846

History | View | Annotate | Download (15 KB)

1
package org.gvsig.legend.aggregate.swing.impl;
2

    
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
6
import java.awt.BorderLayout;
7
import java.awt.Color;
8
import java.awt.ComponentOrientation;
9
import java.awt.Container;
10
import java.awt.Dimension;
11
import java.awt.Font;
12
import javax.swing.Box;
13
import javax.swing.ButtonGroup;
14
import javax.swing.ImageIcon;
15
import javax.swing.JButton;
16
import javax.swing.JCheckBox;
17
import javax.swing.JComboBox;
18
import javax.swing.JFrame;
19
import javax.swing.JLabel;
20
import javax.swing.JPanel;
21
import javax.swing.JRadioButton;
22
import javax.swing.JSlider;
23
import javax.swing.JSpinner;
24
import javax.swing.JTextField;
25

    
26

    
27
public class DefaultAggregateLegendEditorView extends JPanel
28
{
29
   JRadioButton rdbBasic = new JRadioButton();
30
   ButtonGroup buttongroup1 = new ButtonGroup();
31
   JRadioButton rdbStyled = new JRadioButton();
32
   JLabel lblOutlineColor = new JLabel();
33
   JLabel lblFillColor = new JLabel();
34
   JLabel lblTextColor = new JLabel();
35
   JLabel lblTextFont = new JLabel();
36
   JLabel lblShowBounds = new JLabel();
37
   JCheckBox chkShowBounds = new JCheckBox();
38
   JLabel lblSymbolSize = new JLabel();
39
   JTextField txtOutlineColor = new JTextField();
40
   JButton btnOutlineColor = new JButton();
41
   JLabel lblOutlineColorAlpha = new JLabel();
42
   JSlider sldOutlineColorAlpha = new JSlider();
43
   JTextField txtFillColor = new JTextField();
44
   JButton btnFillColor = new JButton();
45
   JLabel lblFillColorAlpha = new JLabel();
46
   JSlider sldFillColorAlpha = new JSlider();
47
   JTextField txtTextColor = new JTextField();
48
   JButton btnTextColor = new JButton();
49
   JLabel lblTextColorAlpha = new JLabel();
50
   JSlider sldTextColorAlpha = new JSlider();
51
   JTextField txtTextFont = new JTextField();
52
   JButton btnTextFont = new JButton();
53
   JSpinner spnSymbolSize = new JSpinner();
54
   JLabel lblStyle = new JLabel();
55
   JTextField txtStyle = new JTextField();
56
   JButton btnStyle = new JButton();
57
   JPanel pnlStylePreview = new JPanel();
58
   JLabel lblOperation = new JLabel();
59
   JComboBox cboOperation = new JComboBox();
60
   JLabel lblOperationAttribute = new JLabel();
61
   JLabel lblOperationValue = new JLabel();
62
   JComboBox cboOperationAttribute = new JComboBox();
63
   JTextField txtOperationValue = new JTextField();
64
   JLabel lblOperationDescription = new JLabel();
65

    
66
   /**
67
    * Default constructor
68
    */
69
   public DefaultAggregateLegendEditorView()
70
   {
71
      initializePanel();
72
   }
73

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

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

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

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

    
114
   }
115

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

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

    
153
   public JPanel createPanel()
154
   {
155
      JPanel jpanel1 = new JPanel();
156
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),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");
157
      CellConstraints cc = new CellConstraints();
158
      jpanel1.setLayout(formlayout1);
159

    
160
      rdbBasic.setActionCommand("Basic");
161
      rdbBasic.setName("rdbBasic");
162
      rdbBasic.setText("_Use_basic_cluster_mark");
163
      buttongroup1.add(rdbBasic);
164
      jpanel1.add(rdbBasic,cc.xywh(2,2,3,1));
165

    
166
      rdbStyled.setActionCommand("Styled");
167
      rdbStyled.setName("rdbStyled");
168
      rdbStyled.setText("_Use_styled_cluster_mark");
169
      buttongroup1.add(rdbStyled);
170
      jpanel1.add(rdbStyled,cc.xywh(2,6,3,1));
171

    
172
      jpanel1.add(createPanel1(),cc.xywh(3,4,2,1));
173
      jpanel1.add(createPanel6(),cc.xywh(3,8,2,1));
174
      jpanel1.add(createPanel7(),cc.xywh(2,10,3,1));
175
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11 });
176
      return jpanel1;
177
   }
178

    
179
   public JPanel createPanel1()
180
   {
181
      JPanel jpanel1 = new JPanel();
182
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)","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");
183
      CellConstraints cc = new CellConstraints();
184
      jpanel1.setLayout(formlayout1);
185

    
186
      lblOutlineColor.setName("lblOutlineColor");
187
      lblOutlineColor.setText("_Outline_color");
188
      jpanel1.add(lblOutlineColor,cc.xy(1,3));
189

    
190
      lblFillColor.setName("lblFillColor");
191
      lblFillColor.setText("_Fill_color");
192
      jpanel1.add(lblFillColor,cc.xy(1,5));
193

    
194
      lblTextColor.setName("lblTextColor");
195
      lblTextColor.setText("_Text_color");
196
      jpanel1.add(lblTextColor,cc.xy(1,7));
197

    
198
      lblTextFont.setName("lblTextFont");
199
      lblTextFont.setText("_Text_font");
200
      jpanel1.add(lblTextFont,cc.xy(1,9));
201

    
202
      lblShowBounds.setName("lblShowBounds");
203
      lblShowBounds.setText("_Show_bounds");
204
      jpanel1.add(lblShowBounds,cc.xy(1,11));
205

    
206
      chkShowBounds.setName("chkShowBounds");
207
      jpanel1.add(chkShowBounds,cc.xy(3,11));
208

    
209
      lblSymbolSize.setName("lblSymbolSize");
210
      lblSymbolSize.setText("_Symbol_size");
211
      jpanel1.add(lblSymbolSize,cc.xy(1,1));
212

    
213
      jpanel1.add(createPanel2(),cc.xy(3,3));
214
      jpanel1.add(createPanel3(),cc.xy(3,5));
215
      jpanel1.add(createPanel4(),cc.xy(3,7));
216
      jpanel1.add(createPanel5(),cc.xy(3,9));
217
      spnSymbolSize.setName("spnSymbolSize");
218
      jpanel1.add(spnSymbolSize,cc.xy(3,1));
219

    
220
      addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,4,6,8,10 });
221
      return jpanel1;
222
   }
223

    
224
   public JPanel createPanel2()
225
   {
226
      JPanel jpanel1 = new JPanel();
227
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
228
      CellConstraints cc = new CellConstraints();
229
      jpanel1.setLayout(formlayout1);
230

    
231
      txtOutlineColor.setBackground(new Color(236,233,216));
232
      txtOutlineColor.setEditable(false);
233
      txtOutlineColor.setFont(new Font("Courier 10 Pitch",Font.PLAIN,11));
234
      txtOutlineColor.setName("txtOutlineColor");
235
      txtOutlineColor.setHorizontalAlignment(JTextField.RIGHT);
236
      jpanel1.add(txtOutlineColor,cc.xy(1,1));
237

    
238
      btnOutlineColor.setActionCommand("...");
239
      btnOutlineColor.setName("btnOutlineColor");
240
      btnOutlineColor.setText("...");
241
      jpanel1.add(btnOutlineColor,cc.xy(3,1));
242

    
243
      lblOutlineColorAlpha.setName("lblOutlineColorAlpha");
244
      lblOutlineColorAlpha.setText("Alpha");
245
      jpanel1.add(lblOutlineColorAlpha,cc.xy(5,1));
246

    
247
      sldOutlineColorAlpha.setMajorTickSpacing(20);
248
      sldOutlineColorAlpha.setName("sldOutlineColorAlpha");
249
      jpanel1.add(sldOutlineColorAlpha,cc.xy(7,1));
250

    
251
      addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]);
252
      return jpanel1;
253
   }
254

    
255
   public JPanel createPanel3()
256
   {
257
      JPanel jpanel1 = new JPanel();
258
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
259
      CellConstraints cc = new CellConstraints();
260
      jpanel1.setLayout(formlayout1);
261

    
262
      txtFillColor.setBackground(new Color(236,233,216));
263
      txtFillColor.setEditable(false);
264
      txtFillColor.setFont(new Font("Courier 10 Pitch",Font.PLAIN,11));
265
      txtFillColor.setName("txtFillColor");
266
      txtFillColor.setScrollOffset(1);
267
      txtFillColor.setHorizontalAlignment(JTextField.RIGHT);
268
      jpanel1.add(txtFillColor,cc.xy(1,1));
269

    
270
      btnFillColor.setActionCommand("...");
271
      btnFillColor.setName("btnFillColor");
272
      btnFillColor.setText("...");
273
      jpanel1.add(btnFillColor,cc.xy(3,1));
274

    
275
      lblFillColorAlpha.setName("lblFillColorAlpha");
276
      lblFillColorAlpha.setText("Alpha");
277
      jpanel1.add(lblFillColorAlpha,cc.xy(5,1));
278

    
279
      sldFillColorAlpha.setMajorTickSpacing(20);
280
      sldFillColorAlpha.setName("sldFillColorAlpha");
281
      jpanel1.add(sldFillColorAlpha,cc.xy(7,1));
282

    
283
      addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]);
284
      return jpanel1;
285
   }
286

    
287
   public JPanel createPanel4()
288
   {
289
      JPanel jpanel1 = new JPanel();
290
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
291
      CellConstraints cc = new CellConstraints();
292
      jpanel1.setLayout(formlayout1);
293

    
294
      txtTextColor.setBackground(new Color(236,233,216));
295
      txtTextColor.setEditable(false);
296
      txtTextColor.setFont(new Font("Courier 10 Pitch",Font.PLAIN,11));
297
      txtTextColor.setName("txtTextColor");
298
      txtTextColor.setScrollOffset(1);
299
      txtTextColor.setHorizontalAlignment(JTextField.RIGHT);
300
      jpanel1.add(txtTextColor,cc.xy(1,1));
301

    
302
      btnTextColor.setActionCommand("...");
303
      btnTextColor.setName("btnTextColor");
304
      btnTextColor.setText("...");
305
      jpanel1.add(btnTextColor,cc.xy(3,1));
306

    
307
      lblTextColorAlpha.setName("lblTextColorAlpha");
308
      lblTextColorAlpha.setText("Alpha");
309
      jpanel1.add(lblTextColorAlpha,cc.xy(5,1));
310

    
311
      sldTextColorAlpha.setMajorTickSpacing(20);
312
      sldTextColorAlpha.setName("sldTextColorAlpha");
313
      jpanel1.add(sldTextColorAlpha,cc.xy(7,1));
314

    
315
      addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]);
316
      return jpanel1;
317
   }
318

    
319
   public JPanel createPanel5()
320
   {
321
      JPanel jpanel1 = new JPanel();
322
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
323
      CellConstraints cc = new CellConstraints();
324
      jpanel1.setLayout(formlayout1);
325

    
326
      txtTextFont.setBackground(new Color(236,233,216));
327
      txtTextFont.setEditable(false);
328
      txtTextFont.setName("txtTextFont");
329
      jpanel1.add(txtTextFont,cc.xy(1,1));
330

    
331
      btnTextFont.setActionCommand("...");
332
      btnTextFont.setName("btnTextFont");
333
      btnTextFont.setText("...");
334
      jpanel1.add(btnTextFont,cc.xy(3,1));
335

    
336
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
337
      return jpanel1;
338
   }
339

    
340
   public JPanel createPanel6()
341
   {
342
      JPanel jpanel1 = new JPanel();
343
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
344
      CellConstraints cc = new CellConstraints();
345
      jpanel1.setLayout(formlayout1);
346

    
347
      lblStyle.setName("lblStyle");
348
      lblStyle.setText("_Style");
349
      jpanel1.add(lblStyle,cc.xy(1,1));
350

    
351
      txtStyle.setBackground(new Color(236,233,216));
352
      txtStyle.setEditable(false);
353
      txtStyle.setName("txtStyle");
354
      jpanel1.add(txtStyle,cc.xy(3,1));
355

    
356
      btnStyle.setActionCommand("...");
357
      btnStyle.setName("btnStyle");
358
      btnStyle.setText("...");
359
      jpanel1.add(btnStyle,cc.xy(5,1));
360

    
361
      pnlStylePreview.setName("pnlStylePreview");
362
      jpanel1.add(pnlStylePreview,cc.xy(3,3));
363

    
364
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2,3 });
365
      return jpanel1;
366
   }
367

    
368
   public JPanel createPanel7()
369
   {
370
      JPanel jpanel1 = new JPanel();
371
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
372
      CellConstraints cc = new CellConstraints();
373
      jpanel1.setLayout(formlayout1);
374

    
375
      lblOperation.setName("lblOperation");
376
      lblOperation.setText("_Operation");
377
      jpanel1.add(lblOperation,cc.xy(1,1));
378

    
379
      cboOperation.setName("cboOperation");
380
      cboOperation.addItem("Count");
381
      cboOperation.addItem("Maximum");
382
      cboOperation.addItem("Minimum");
383
      cboOperation.addItem("Average");
384
      jpanel1.add(cboOperation,cc.xywh(3,1,3,1));
385

    
386
      lblOperationAttribute.setName("lblOperationAttribute");
387
      lblOperationAttribute.setText("_Attribute");
388
      jpanel1.add(lblOperationAttribute,cc.xy(3,5));
389

    
390
      lblOperationValue.setName("lblOperationValue");
391
      lblOperationValue.setText("_Aditional_value");
392
      jpanel1.add(lblOperationValue,cc.xy(3,7));
393

    
394
      cboOperationAttribute.setName("cboOperationAttribute");
395
      jpanel1.add(cboOperationAttribute,cc.xy(5,5));
396

    
397
      txtOperationValue.setName("txtOperationValue");
398
      jpanel1.add(txtOperationValue,cc.xy(5,7));
399

    
400
      lblOperationDescription.setName("lblOperationDescription");
401
      jpanel1.add(lblOperationDescription,cc.xywh(3,3,3,1));
402

    
403
      addFillComponents(jpanel1,new int[]{ 2,4,5,6 },new int[]{ 2,3,4,5,6,7 });
404
      return jpanel1;
405
   }
406

    
407
   /**
408
    * Initializer
409
    */
410
   protected void initializePanel()
411
   {
412
      setLayout(new BorderLayout());
413
      add(createPanel(), BorderLayout.CENTER);
414
   }
415

    
416

    
417
}