Statistics
| Revision:

svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.library / org.gvsig.raster.tools / org.gvsig.raster.tools.swing / org.gvsig.raster.tools.swing.impl / src / main / java / org / gvsig / raster / tools / swing / impl / viewclip / ViewClipPanelView.java @ 43803

History | View | Annotate | Download (11.8 KB)

1
package org.gvsig.raster.tools.swing.impl.viewclip;
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.ButtonGroup;
13
import javax.swing.ImageIcon;
14
import javax.swing.JButton;
15
import javax.swing.JComboBox;
16
import javax.swing.JFormattedTextField;
17
import javax.swing.JFrame;
18
import javax.swing.JLabel;
19
import javax.swing.JPanel;
20
import javax.swing.JRadioButton;
21
import javax.swing.border.EmptyBorder;
22

    
23

    
24
public class ViewClipPanelView extends JPanel
25
{
26
   TitledSeparator lblRealCoord = new TitledSeparator();
27
   JRadioButton rdbPixelSelection = new JRadioButton();
28
   ButtonGroup buttongroup1 = new ButtonGroup();
29
   JRadioButton rdbPrintSelection = new JRadioButton();
30
   JLabel lblReal1X = new JLabel();
31
   JLabel lblReal2X = new JLabel();
32
   JFormattedTextField txtReal1X = new JFormattedTextField();
33
   JFormattedTextField txtReal2X = new JFormattedTextField();
34
   JLabel lblReal1Y = new JLabel();
35
   JLabel lblReal2Y = new JLabel();
36
   JFormattedTextField txtReal1Y = new JFormattedTextField();
37
   JFormattedTextField txtReal2Y = new JFormattedTextField();
38
   JLabel lblIconReal1 = new JLabel();
39
   JLabel lblIconReal2 = new JLabel();
40
   JLabel lblResultSize = new JLabel();
41
   JButton btnTool = new JButton();
42
   JFormattedTextField txtResultSize = new JFormattedTextField();
43
   JFormattedTextField txtPrintHeight = new JFormattedTextField();
44
   JComboBox cmbResolution = new JComboBox();
45
   JLabel lblPrintHeight = new JLabel();
46
   JLabel lblResolution = new JLabel();
47
   JFormattedTextField txtPrintWidth = new JFormattedTextField();
48
   JFormattedTextField txtScaleDenominator = new JFormattedTextField();
49
   JLabel lblPrintWidth = new JLabel();
50
   JLabel lblScaleDenominator = new JLabel();
51
   JLabel lblWidth = new JLabel();
52
   JLabel lblPixelSize = new JLabel();
53
   JFormattedTextField txtWidth = new JFormattedTextField();
54
   JFormattedTextField txtPixelSize = new JFormattedTextField();
55
   JLabel lblHeight = new JLabel();
56
   JFormattedTextField txtHeight = new JFormattedTextField();
57

    
58
   /**
59
    * Default constructor
60
    */
61
   public ViewClipPanelView()
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: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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
149
      CellConstraints cc = new CellConstraints();
150
      jpanel1.setLayout(formlayout1);
151

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

    
156
      rdbPixelSelection.setActionCommand("_pixel_selection");
157
      rdbPixelSelection.setName("rdbPixelSelection");
158
      rdbPixelSelection.setSelected(true);
159
      rdbPixelSelection.setText("_pixel_selection");
160
      buttongroup1.add(rdbPixelSelection);
161
      jpanel1.add(rdbPixelSelection,cc.xy(2,6));
162

    
163
      rdbPrintSelection.setActionCommand("_pixel_selection");
164
      rdbPrintSelection.setName("rdbPrintSelection");
165
      rdbPrintSelection.setText("_print_selection");
166
      buttongroup1.add(rdbPrintSelection);
167
      jpanel1.add(rdbPrintSelection,cc.xy(2,10));
168

    
169
      jpanel1.add(createPanel1(),cc.xy(2,4));
170
      jpanel1.add(createPanel2(),cc.xy(2,14));
171
      jpanel1.add(createPanel3(),cc.xy(2,12));
172
      jpanel1.add(createPanel4(),cc.xy(2,8));
173
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 });
174
      return jpanel1;
175
   }
176

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

    
184
      lblReal1X.setName("lblReal1X");
185
      lblReal1X.setText("X:");
186
      jpanel1.add(lblReal1X,cc.xy(3,1));
187

    
188
      lblReal2X.setName("lblReal2X");
189
      lblReal2X.setText("X:");
190
      jpanel1.add(lblReal2X,cc.xy(3,3));
191

    
192
      txtReal1X.setName("txtReal1X");
193
      jpanel1.add(txtReal1X,cc.xy(5,1));
194

    
195
      txtReal2X.setName("txtReal2X");
196
      jpanel1.add(txtReal2X,cc.xy(5,3));
197

    
198
      lblReal1Y.setName("lblReal1Y");
199
      lblReal1Y.setText("Y:");
200
      jpanel1.add(lblReal1Y,cc.xy(7,1));
201

    
202
      lblReal2Y.setName("lblReal2Y");
203
      lblReal2Y.setText("Y:");
204
      jpanel1.add(lblReal2Y,cc.xy(7,3));
205

    
206
      txtReal1Y.setName("txtReal1Y");
207
      jpanel1.add(txtReal1Y,cc.xy(9,1));
208

    
209
      txtReal2Y.setName("txtReal2Y");
210
      jpanel1.add(txtReal2Y,cc.xy(9,3));
211

    
212
      lblIconReal1.setName("lblIconReal1");
213
      jpanel1.add(lblIconReal1,cc.xy(1,1));
214

    
215
      lblIconReal2.setName("lblIconReal2");
216
      jpanel1.add(lblIconReal2,cc.xy(1,3));
217

    
218
      addFillComponents(jpanel1,new int[]{ 2,4,6,8 },new int[]{ 2 });
219
      return jpanel1;
220
   }
221

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

    
229
      lblResultSize.setName("lblResultSize");
230
      lblResultSize.setText("_result_size_raw_XCOLONX");
231
      jpanel1.add(lblResultSize,cc.xy(1,1));
232

    
233
      btnTool.setName("btnTool");
234
      btnTool.setToolTipText("activate_tool");
235
      jpanel1.add(btnTool,cc.xy(5,1));
236

    
237
      txtResultSize.setEditable(false);
238
      txtResultSize.setName("txtResultSize");
239
      EmptyBorder emptyborder1 = new EmptyBorder(0,0,0,0);
240
      txtResultSize.setBorder(emptyborder1);
241
      jpanel1.add(txtResultSize,cc.xy(3,1));
242

    
243
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]);
244
      return jpanel1;
245
   }
246

    
247
   public JPanel createPanel3()
248
   {
249
      JPanel jpanel1 = new JPanel();
250
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,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:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
251
      CellConstraints cc = new CellConstraints();
252
      jpanel1.setLayout(formlayout1);
253

    
254
      txtPrintHeight.setEnabled(false);
255
      txtPrintHeight.setName("txtPrintHeight");
256
      jpanel1.add(txtPrintHeight,cc.xy(9,1));
257

    
258
      cmbResolution.setEnabled(false);
259
      cmbResolution.setName("cmbResolution");
260
      jpanel1.add(cmbResolution,cc.xy(9,3));
261

    
262
      lblPrintHeight.setEnabled(false);
263
      lblPrintHeight.setName("lblPrintHeight");
264
      lblPrintHeight.setText("_height_cm");
265
      jpanel1.add(lblPrintHeight,cc.xy(7,1));
266

    
267
      lblResolution.setEnabled(false);
268
      lblResolution.setName("lblResolution");
269
      lblResolution.setText("_resolution_dpi");
270
      jpanel1.add(lblResolution,cc.xy(7,3));
271

    
272
      txtPrintWidth.setEnabled(false);
273
      txtPrintWidth.setName("txtPrintWidth");
274
      jpanel1.add(txtPrintWidth,cc.xy(5,1));
275

    
276
      txtScaleDenominator.setEnabled(false);
277
      txtScaleDenominator.setName("txtScaleDenominator");
278
      jpanel1.add(txtScaleDenominator,cc.xy(5,3));
279

    
280
      lblPrintWidth.setEnabled(false);
281
      lblPrintWidth.setName("lblPrintWidth");
282
      lblPrintWidth.setText("_width_cm");
283
      jpanel1.add(lblPrintWidth,cc.xy(3,1));
284

    
285
      lblScaleDenominator.setEnabled(false);
286
      lblScaleDenominator.setName("lblScaleDenominator");
287
      lblScaleDenominator.setText("_scale_1_XcolonX");
288
      jpanel1.add(lblScaleDenominator,cc.xy(3,3));
289

    
290
      addFillComponents(jpanel1,new int[]{ 1,2,4,6,8 },new int[]{ 1,2,3 });
291
      return jpanel1;
292
   }
293

    
294
   public JPanel createPanel4()
295
   {
296
      JPanel jpanel1 = new JPanel();
297
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,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:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
298
      CellConstraints cc = new CellConstraints();
299
      jpanel1.setLayout(formlayout1);
300

    
301
      lblWidth.setName("lblWidth");
302
      lblWidth.setText("_width");
303
      jpanel1.add(lblWidth,cc.xy(3,1));
304

    
305
      lblPixelSize.setName("lblPixelSize");
306
      lblPixelSize.setText("_pixel_size");
307
      jpanel1.add(lblPixelSize,cc.xy(3,3));
308

    
309
      txtWidth.setName("txtWidth");
310
      jpanel1.add(txtWidth,cc.xy(5,1));
311

    
312
      txtPixelSize.setName("txtPixelSize");
313
      jpanel1.add(txtPixelSize,cc.xywh(5,3,5,1));
314

    
315
      lblHeight.setName("lblHeight");
316
      lblHeight.setText("_height");
317
      jpanel1.add(lblHeight,cc.xy(7,1));
318

    
319
      txtHeight.setName("txtHeight");
320
      jpanel1.add(txtHeight,cc.xy(9,1));
321

    
322
      addFillComponents(jpanel1,new int[]{ 1,2,4,6,8 },new int[]{ 1,2,3 });
323
      return jpanel1;
324
   }
325

    
326
   /**
327
    * Initializer
328
    */
329
   protected void initializePanel()
330
   {
331
      setLayout(new BorderLayout());
332
      add(createPanel(), BorderLayout.CENTER);
333
   }
334

    
335

    
336
}