Statistics
| Revision:

root / org.gvsig.legend.urbanhorizontalsignage / trunk / org.gvsig.legend.urbanhorizontalsignage / org.gvsig.legend.urbanhorizontalsignage.swing / org.gvsig.legend.urbanhorizontalsignage.swing.impl / src / main / java / org / gvsig / legend / urbanverticalsignage / swing / impl / DefaultPictureMarkerSymbolTableLegendEditorView.java @ 7109

History | View | Annotate | Download (11.6 KB)

1
package org.gvsig.legend.urbanverticalsignage.swing.impl;
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.JComboBox;
16
import javax.swing.JFrame;
17
import javax.swing.JLabel;
18
import javax.swing.JPanel;
19
import javax.swing.JTextField;
20
import javax.swing.border.EmptyBorder;
21

    
22

    
23
public class DefaultPictureMarkerSymbolTableLegendEditorView extends JPanel
24
{
25
   JLabel lblImageSize = new JLabel();
26
   JLabel lblLineToOffsetColor = new JLabel();
27
   JLabel lblClassifyingFieldName = new JLabel();
28
   JLabel lblOffsetXFieldName = new JLabel();
29
   JLabel lblOffsetYFieldName = new JLabel();
30
   JLabel lblRotationFieldName = new JLabel();
31
   JLabel lblLineToOffsetColorFieldName = new JLabel();
32
   JLabel lblDrawLineToOffset = new JLabel();
33
   JComboBox cboLineToOffsetColorFieldName = new JComboBox();
34
   JComboBox cboRotationFieldName = new JComboBox();
35
   JComboBox cboOffsetYFieldName = new JComboBox();
36
   JComboBox cboOffsetXFieldName = new JComboBox();
37
   JComboBox cboClassifyingFieldName = new JComboBox();
38
   JComboBox cboImagesTableName = new JComboBox();
39
   JLabel lblImagesTableName = new JLabel();
40
   JButton btnLineToOffsetColor = new JButton();
41
   JCheckBox chkDrawLineToOffset = new JCheckBox();
42
   TitledSeparator lblImagesTableFields = new TitledSeparator();
43
   JLabel lblImageFieldName = new JLabel();
44
   JLabel lblImageSelectedFieldName = new JLabel();
45
   JComboBox cboImagesTableClassifyingFieldName = new JComboBox();
46
   JComboBox cboImageFieldName = new JComboBox();
47
   JComboBox cboImageSelectedFieldName = new JComboBox();
48
   JLabel lblImagesTableClassifyingFieldName = new JLabel();
49
   JTextField txtLineToOffsetColor = new JTextField();
50
   JButton btnImagesTableNameRefresh = new JButton();
51
   TitledSeparator lblLegendTableFields = new TitledSeparator();
52
   JTextField txtImageSize = new JTextField();
53
   JLabel lblUnits = new JLabel();
54
   JComboBox cboUnits = new JComboBox();
55
   JLabel lblScale = new JLabel();
56
   JTextField txtScale = new JTextField();
57

    
58
   /**
59
    * Default constructor
60
    */
61
   public DefaultPictureMarkerSymbolTableLegendEditorView()
62
   {
63
      initializePanel();
64
   }
65

    
66
   /**
67
    * Adds fill components to empty cells in the first row and first column of the grid.
68
    * This ensures that the grid spacing will be the same as shown in the designer.
69
    * @param cols an array of column indices in the first row where fill components should be added.
70
    * @param rows an array of row indices in the first column where fill components should be added.
71
    */
72
   void addFillComponents( Container panel, int[] cols, int[] rows )
73
   {
74
      Dimension filler = new Dimension(10,10);
75

    
76
      boolean filled_cell_11 = false;
77
      CellConstraints cc = new CellConstraints();
78
      if ( cols.length > 0 && rows.length > 0 )
79
      {
80
         if ( cols[0] == 1 && rows[0] == 1 )
81
         {
82
            /** add a rigid area  */
83
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
84
            filled_cell_11 = true;
85
         }
86
      }
87

    
88
      for( int index = 0; index < cols.length; index++ )
89
      {
90
         if ( cols[index] == 1 && filled_cell_11 )
91
         {
92
            continue;
93
         }
94
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
95
      }
96

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

    
106
   }
107

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

    
133
   /**
134
    * Method for recalculating the component orientation for 
135
    * right-to-left Locales.
136
    * @param orientation the component orientation to be applied
137
    */
138
   public void applyComponentOrientation( ComponentOrientation orientation )
139
   {
140
      // Not yet implemented...
141
      // I18NUtils.applyComponentOrientation(this, orientation);
142
      super.applyComponentOrientation(orientation);
143
   }
144

    
145
   public JPanel createPanel()
146
   {
147
      JPanel jpanel1 = new JPanel();
148
      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","CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU: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:4DLU: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:4DLU:NONE");
149
      CellConstraints cc = new CellConstraints();
150
      jpanel1.setLayout(formlayout1);
151

    
152
      lblImageSize.setName("lblImageSize");
153
      lblImageSize.setText("_Size");
154
      jpanel1.add(lblImageSize,cc.xy(2,2));
155

    
156
      lblLineToOffsetColor.setName("lblLineToOffsetColor");
157
      lblLineToOffsetColor.setText("_Line_to_offset_color");
158
      jpanel1.add(lblLineToOffsetColor,cc.xy(2,4));
159

    
160
      lblClassifyingFieldName.setName("lblClassifyingFieldName");
161
      lblClassifyingFieldName.setText("_Classifying_field");
162
      jpanel1.add(lblClassifyingFieldName,cc.xy(2,12));
163

    
164
      lblOffsetXFieldName.setName("lblOffsetXFieldName");
165
      lblOffsetXFieldName.setText("_OffsetX_field");
166
      jpanel1.add(lblOffsetXFieldName,cc.xy(2,14));
167

    
168
      lblOffsetYFieldName.setName("lblOffsetYFieldName");
169
      lblOffsetYFieldName.setText("_OffsetY_field");
170
      jpanel1.add(lblOffsetYFieldName,cc.xy(2,16));
171

    
172
      lblRotationFieldName.setName("lblRotationFieldName");
173
      lblRotationFieldName.setText("_Rotation_field");
174
      jpanel1.add(lblRotationFieldName,cc.xy(2,18));
175

    
176
      lblLineToOffsetColorFieldName.setName("lblLineToOffsetColorFieldName");
177
      lblLineToOffsetColorFieldName.setText("_Line_to_offset_color_field");
178
      jpanel1.add(lblLineToOffsetColorFieldName,cc.xy(2,20));
179

    
180
      lblDrawLineToOffset.setName("lblDrawLineToOffset");
181
      lblDrawLineToOffset.setText("_Draw_line_to_offset");
182
      jpanel1.add(lblDrawLineToOffset,cc.xy(2,6));
183

    
184
      cboLineToOffsetColorFieldName.setName("cboLineToOffsetColorFieldName");
185
      jpanel1.add(cboLineToOffsetColorFieldName,cc.xywh(4,20,3,1));
186

    
187
      cboRotationFieldName.setName("cboRotationFieldName");
188
      jpanel1.add(cboRotationFieldName,cc.xywh(4,18,3,1));
189

    
190
      cboOffsetYFieldName.setName("cboOffsetYFieldName");
191
      jpanel1.add(cboOffsetYFieldName,cc.xywh(4,16,3,1));
192

    
193
      cboOffsetXFieldName.setName("cboOffsetXFieldName");
194
      jpanel1.add(cboOffsetXFieldName,cc.xywh(4,14,3,1));
195

    
196
      cboClassifyingFieldName.setName("cboClassifyingFieldName");
197
      jpanel1.add(cboClassifyingFieldName,cc.xywh(4,12,3,1));
198

    
199
      cboImagesTableName.setName("cboImagesTableName");
200
      jpanel1.add(cboImagesTableName,cc.xy(4,24));
201

    
202
      lblImagesTableName.setName("lblImagesTableName");
203
      lblImagesTableName.setText("_Table_name");
204
      jpanel1.add(lblImagesTableName,cc.xy(2,24));
205

    
206
      btnLineToOffsetColor.setActionCommand("...");
207
      btnLineToOffsetColor.setName("btnLineToOffsetColor");
208
      btnLineToOffsetColor.setText("...");
209
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
210
      btnLineToOffsetColor.setBorder(emptyborder1);
211
      jpanel1.add(btnLineToOffsetColor,cc.xy(6,4));
212

    
213
      chkDrawLineToOffset.setName("chkDrawLineToOffset");
214
      jpanel1.add(chkDrawLineToOffset,cc.xy(4,6));
215

    
216
      lblImagesTableFields.setName("lblImagesTableFields");
217
      lblImagesTableFields.setText("_Images_table_fields");
218
      jpanel1.add(lblImagesTableFields,cc.xywh(2,22,5,1));
219

    
220
      lblImageFieldName.setName("lblImageFieldName");
221
      lblImageFieldName.setText("_Image_field");
222
      jpanel1.add(lblImageFieldName,cc.xy(2,28));
223

    
224
      lblImageSelectedFieldName.setName("lblImageSelectedFieldName");
225
      lblImageSelectedFieldName.setText("_Image_selected_field");
226
      jpanel1.add(lblImageSelectedFieldName,cc.xy(2,30));
227

    
228
      cboImagesTableClassifyingFieldName.setName("cboImagesTableClassifyingFieldName");
229
      jpanel1.add(cboImagesTableClassifyingFieldName,cc.xywh(4,26,3,1));
230

    
231
      cboImageFieldName.setName("cboImageFieldName");
232
      jpanel1.add(cboImageFieldName,cc.xywh(4,28,3,1));
233

    
234
      cboImageSelectedFieldName.setName("cboImageSelectedFieldName");
235
      jpanel1.add(cboImageSelectedFieldName,cc.xywh(4,30,3,1));
236

    
237
      lblImagesTableClassifyingFieldName.setName("lblImagesTableClassifyingFieldName");
238
      lblImagesTableClassifyingFieldName.setText("_Classifying_field");
239
      jpanel1.add(lblImagesTableClassifyingFieldName,cc.xy(2,26));
240

    
241
      txtLineToOffsetColor.setName("txtLineToOffsetColor");
242
      jpanel1.add(txtLineToOffsetColor,cc.xy(4,4));
243

    
244
      btnImagesTableNameRefresh.setActionCommand("...");
245
      btnImagesTableNameRefresh.setIcon(loadImage("datos/devel/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/resources/org/gvsig/vcsgis/swing/impl/images/common-refresh.png"));
246
      btnImagesTableNameRefresh.setName("btnImagesTableNameRefresh");
247
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
248
      btnImagesTableNameRefresh.setBorder(emptyborder2);
249
      jpanel1.add(btnImagesTableNameRefresh,cc.xy(6,24));
250

    
251
      lblLegendTableFields.setName("lblLegendTableFields");
252
      lblLegendTableFields.setText("_Legend_table_fields");
253
      jpanel1.add(lblLegendTableFields,cc.xywh(2,10,5,1));
254

    
255
      jpanel1.add(createPanel1(),cc.xy(4,2));
256
      lblScale.setName("lblScale");
257
      lblScale.setText("_Scale");
258
      jpanel1.add(lblScale,cc.xy(2,8));
259

    
260
      txtScale.setName("txtScale");
261
      jpanel1.add(txtScale,cc.xy(4,8));
262

    
263
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },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,30,31 });
264
      return jpanel1;
265
   }
266

    
267
   public JPanel createPanel1()
268
   {
269
      JPanel jpanel1 = new JPanel();
270
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(0.5),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.5)","CENTER:DEFAULT:NONE");
271
      CellConstraints cc = new CellConstraints();
272
      jpanel1.setLayout(formlayout1);
273

    
274
      txtImageSize.setName("txtImageSize");
275
      jpanel1.add(txtImageSize,cc.xy(1,1));
276

    
277
      lblUnits.setName("lblUnits");
278
      lblUnits.setText("_Unit");
279
      jpanel1.add(lblUnits,cc.xy(3,1));
280

    
281
      cboUnits.setName("cboUnits");
282
      jpanel1.add(cboUnits,cc.xy(5,1));
283

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

    
288
   /**
289
    * Initializer
290
    */
291
   protected void initializePanel()
292
   {
293
      setLayout(new BorderLayout());
294
      add(createPanel(), BorderLayout.CENTER);
295
   }
296

    
297

    
298
}