Statistics
| Revision:

root / org.gvsig.proj / branches / refactor2018 / org.gvsig.proj / org.gvsig.proj.swing / org.gvsig.proj.swing.impl / src / main / java / org / gvsig / proj / swing / impl / CtSelectorView.java @ 866

History | View | Annotate | Download (12.7 KB)

1
package org.gvsig.proj.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 javax.swing.Box;
12
import javax.swing.ImageIcon;
13
import javax.swing.JButton;
14
import javax.swing.JComboBox;
15
import javax.swing.JFrame;
16
import javax.swing.JLabel;
17
import javax.swing.JPanel;
18
import javax.swing.JScrollPane;
19
import javax.swing.JTabbedPane;
20
import javax.swing.JTextArea;
21
import javax.swing.JTextField;
22
import javax.swing.JTree;
23
import javax.swing.border.EmptyBorder;
24

    
25

    
26
public class CtSelectorView extends JPanel
27
{
28
   JLabel lblCurrentCt = new JLabel();
29
   JTree treeResults = new JTree();
30
   JTabbedPane pnlDetails = new JTabbedPane();
31
   JTextArea txtDescription = new JTextArea();
32
   JTextArea txtCtWkt = new JTextArea();
33
   JLabel lblSelectTransform = new JLabel();
34
   JButton btnSearch = new JButton();
35
   JButton btnSearchRemove = new JButton();
36
   JComboBox cboFilterAlpha = new JComboBox();
37
   JLabel lblFilterAlpha = new JLabel();
38
   JButton btnFavoritesAdd = new JButton();
39
   JButton btnFavoritesRemove = new JButton();
40
   JButton btnCtAdd = new JButton();
41
   JButton btnRecentRemove = new JButton();
42
   JLabel lblSourceCrs = new JLabel();
43
   JLabel lblTargetCrs = new JLabel();
44
   JTextField txtSourceCRS = new JTextField();
45
   JButton btnSelectSoureCRS = new JButton();
46
   JButton btnSelectTargetCRS = new JButton();
47
   JTextField txtTargetCRS = new JTextField();
48

    
49
   /**
50
    * Default constructor
51
    */
52
   public CtSelectorView()
53
   {
54
      initializePanel();
55
   }
56

    
57
   /**
58
    * Adds fill components to empty cells in the first row and first column of the grid.
59
    * This ensures that the grid spacing will be the same as shown in the designer.
60
    * @param cols an array of column indices in the first row where fill components should be added.
61
    * @param rows an array of row indices in the first column where fill components should be added.
62
    */
63
   void addFillComponents( Container panel, int[] cols, int[] rows )
64
   {
65
      Dimension filler = new Dimension(10,10);
66

    
67
      boolean filled_cell_11 = false;
68
      CellConstraints cc = new CellConstraints();
69
      if ( cols.length > 0 && rows.length > 0 )
70
      {
71
         if ( cols[0] == 1 && rows[0] == 1 )
72
         {
73
            /** add a rigid area  */
74
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
75
            filled_cell_11 = true;
76
         }
77
      }
78

    
79
      for( int index = 0; index < cols.length; index++ )
80
      {
81
         if ( cols[index] == 1 && filled_cell_11 )
82
         {
83
            continue;
84
         }
85
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
86
      }
87

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

    
97
   }
98

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

    
124
   /**
125
    * Method for recalculating the component orientation for 
126
    * right-to-left Locales.
127
    * @param orientation the component orientation to be applied
128
    */
129
   public void applyComponentOrientation( ComponentOrientation orientation )
130
   {
131
      // Not yet implemented...
132
      // I18NUtils.applyComponentOrientation(this, orientation);
133
      super.applyComponentOrientation(orientation);
134
   }
135

    
136
   public JPanel createPanel()
137
   {
138
      JPanel jpanel1 = new JPanel();
139
      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:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:MIN(60DLU;DEFAULT):GROW(0.3),CENTER:2DLU:NONE");
140
      CellConstraints cc = new CellConstraints();
141
      jpanel1.setLayout(formlayout1);
142

    
143
      lblCurrentCt.setName("lblCurrentCt");
144
      lblCurrentCt.setText("Current coordinate system:");
145
      jpanel1.add(lblCurrentCt,cc.xy(2,11));
146

    
147
      treeResults.setLargeModel(true);
148
      treeResults.setName("treeResults");
149
      treeResults.setRootVisible(false);
150
      treeResults.setShowsRootHandles(true);
151
      JScrollPane jscrollpane1 = new JScrollPane();
152
      jscrollpane1.setViewportView(treeResults);
153
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
154
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
155
      jpanel1.add(jscrollpane1,cc.xy(2,7));
156

    
157
      pnlDetails.setName("pnlDetails");
158
      pnlDetails.setTabPlacement(JTabbedPane.BOTTOM);
159
      pnlDetails.addTab("Description",null,createPanel1());
160
      pnlDetails.addTab("WKT",null,createPanel2());
161
      jpanel1.add(pnlDetails,cc.xy(2,13));
162

    
163
      lblSelectTransform.setName("lblSelectTransform");
164
      lblSelectTransform.setText("Select transformation");
165
      jpanel1.add(lblSelectTransform,cc.xy(2,4));
166

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

    
174
   public JPanel createPanel1()
175
   {
176
      JPanel jpanel1 = new JPanel();
177
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
178
      CellConstraints cc = new CellConstraints();
179
      jpanel1.setLayout(formlayout1);
180

    
181
      txtDescription.setName("txtDescription");
182
      txtDescription.setRows(4);
183
      txtDescription.setSelectionEnd(88);
184
      txtDescription.setSelectionStart(88);
185
      txtDescription.setText("Aqui vendria la informacion que tiene la descripcion \nde la transformacion del catalogo.");
186
      JScrollPane jscrollpane1 = new JScrollPane();
187
      jscrollpane1.setViewportView(txtDescription);
188
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
189
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
190
      jpanel1.add(jscrollpane1,cc.xy(2,2));
191

    
192
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
193
      return jpanel1;
194
   }
195

    
196
   public JPanel createPanel2()
197
   {
198
      JPanel jpanel1 = new JPanel();
199
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
200
      CellConstraints cc = new CellConstraints();
201
      jpanel1.setLayout(formlayout1);
202

    
203
      txtCtWkt.setLineWrap(true);
204
      txtCtWkt.setName("txtCtWkt");
205
      txtCtWkt.setRows(4);
206
      txtCtWkt.setSelectionEnd(32);
207
      txtCtWkt.setSelectionStart(32);
208
      txtCtWkt.setText("Aqui el WKT de la transformacion");
209
      JScrollPane jscrollpane1 = new JScrollPane();
210
      jscrollpane1.setViewportView(txtCtWkt);
211
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
212
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
213
      jpanel1.add(jscrollpane1,cc.xy(2,2));
214

    
215
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
216
      return jpanel1;
217
   }
218

    
219
   public JPanel createPanel3()
220
   {
221
      JPanel jpanel1 = new JPanel();
222
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","FILL:DEFAULT:NONE");
223
      CellConstraints cc = new CellConstraints();
224
      jpanel1.setLayout(formlayout1);
225

    
226
      btnSearch.setName("btnSearch");
227
      btnSearch.setToolTipText("Search");
228
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
229
      btnSearch.setBorder(emptyborder1);
230
      jpanel1.add(btnSearch,cc.xy(5,1));
231

    
232
      btnSearchRemove.setName("btnSearchRemove");
233
      btnSearchRemove.setToolTipText("Clear search");
234
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
235
      btnSearchRemove.setBorder(emptyborder2);
236
      jpanel1.add(btnSearchRemove,cc.xy(7,1));
237

    
238
      cboFilterAlpha.setEditable(true);
239
      cboFilterAlpha.setName("cboFilterAlpha");
240
      cboFilterAlpha.setRequestFocusEnabled(false);
241
      jpanel1.add(cboFilterAlpha,cc.xy(3,1));
242

    
243
      lblFilterAlpha.setName("lblFilterAlpha");
244
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
245
      lblFilterAlpha.setBorder(emptyborder3);
246
      jpanel1.add(lblFilterAlpha,cc.xy(1,1));
247

    
248
      addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]);
249
      return jpanel1;
250
   }
251

    
252
   public JPanel createPanel4()
253
   {
254
      JPanel jpanel1 = new JPanel();
255
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
256
      CellConstraints cc = new CellConstraints();
257
      jpanel1.setLayout(formlayout1);
258

    
259
      btnFavoritesAdd.setName("btnFavoritesAdd");
260
      btnFavoritesAdd.setToolTipText("Add selected coordinate transformation to favorites");
261
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
262
      btnFavoritesAdd.setBorder(emptyborder1);
263
      jpanel1.add(btnFavoritesAdd,cc.xy(8,1));
264

    
265
      btnFavoritesRemove.setName("btnFavoritesRemove");
266
      btnFavoritesRemove.setToolTipText("Remove selected coordinate transformation from favorites");
267
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
268
      btnFavoritesRemove.setBorder(emptyborder2);
269
      jpanel1.add(btnFavoritesRemove,cc.xy(6,1));
270

    
271
      btnCtAdd.setName("btnCtAdd");
272
      btnCtAdd.setToolTipText("Create a new coordinate transformation");
273
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
274
      btnCtAdd.setBorder(emptyborder3);
275
      jpanel1.add(btnCtAdd,cc.xy(2,1));
276

    
277
      btnRecentRemove.setName("btnRecentRemove");
278
      btnRecentRemove.setToolTipText("Remove selected coordinate transformation from recents");
279
      EmptyBorder emptyborder4 = new EmptyBorder(2,2,2,2);
280
      btnRecentRemove.setBorder(emptyborder4);
281
      jpanel1.add(btnRecentRemove,cc.xy(4,1));
282

    
283
      addFillComponents(jpanel1,new int[]{ 1,3,5,7 },new int[]{ 1 });
284
      return jpanel1;
285
   }
286

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

    
294
      lblSourceCrs.setName("lblSourceCrs");
295
      lblSourceCrs.setText("Source CRS");
296
      jpanel1.add(lblSourceCrs,cc.xy(1,1));
297

    
298
      lblTargetCrs.setName("lblTargetCrs");
299
      lblTargetCrs.setText("Target CRS");
300
      jpanel1.add(lblTargetCrs,cc.xy(1,3));
301

    
302
      txtSourceCRS.setBackground(new Color(236,233,216));
303
      txtSourceCRS.setEditable(false);
304
      txtSourceCRS.setName("txtSourceCRS");
305
      jpanel1.add(txtSourceCRS,cc.xy(3,1));
306

    
307
      btnSelectSoureCRS.setName("btnSelectSoureCRS");
308
      btnSelectSoureCRS.setToolTipText("Show selector to choose source CRS");
309
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
310
      btnSelectSoureCRS.setBorder(emptyborder1);
311
      jpanel1.add(btnSelectSoureCRS,cc.xy(5,1));
312

    
313
      btnSelectTargetCRS.setName("btnSelectTargetCRS");
314
      btnSelectTargetCRS.setToolTipText("Show selector to choose target CRS");
315
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
316
      btnSelectTargetCRS.setBorder(emptyborder2);
317
      jpanel1.add(btnSelectTargetCRS,cc.xy(5,3));
318

    
319
      txtTargetCRS.setBackground(new Color(236,233,216));
320
      txtTargetCRS.setEditable(false);
321
      txtTargetCRS.setName("txtTargetCRS");
322
      jpanel1.add(txtTargetCRS,cc.xy(3,3));
323

    
324
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2 });
325
      return jpanel1;
326
   }
327

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

    
337

    
338
}