Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / searchpanel / SelectGeometryPanelView.java @ 47564

History | View | Annotate | Download (7.67 KB)

1
package org.gvsig.fmap.dal.swing.impl.searchpanel;
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.ComponentOrientation;
8
import java.awt.Container;
9
import java.awt.Dimension;
10
import javax.swing.Box;
11
import javax.swing.ButtonGroup;
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.JRadioButton;
19
import javax.swing.JScrollPane;
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 SelectGeometryPanelView extends JPanel
27
{
28
   JRadioButton rdbUseGeomsFromClipbard = new JRadioButton();
29
   ButtonGroup buttongroup1 = new ButtonGroup();
30
   JRadioButton rdbUseGeomsFromLayerSelection = new JRadioButton();
31
   JRadioButton rdbConstantGeometry = new JRadioButton();
32
   JTree treeStores = new JTree();
33
   JTextArea txtGeometry = new JTextArea();
34
   JTextField txtProjection = new JTextField();
35
   JButton btnProjection = new JButton();
36
   JLabel lblProjection = new JLabel();
37
   JCheckBox chkUseTheGeometryBoundingBox = new JCheckBox();
38

    
39
   /**
40
    * Default constructor
41
    */
42
   public SelectGeometryPanelView()
43
   {
44
      initializePanel();
45
   }
46

    
47
   /**
48
    * Adds fill components to empty cells in the first row and first column of the grid.
49
    * This ensures that the grid spacing will be the same as shown in the designer.
50
    * @param cols an array of column indices in the first row where fill components should be added.
51
    * @param rows an array of row indices in the first column where fill components should be added.
52
    */
53
   void addFillComponents( Container panel, int[] cols, int[] rows )
54
   {
55
      Dimension filler = new Dimension(10,10);
56

    
57
      boolean filled_cell_11 = false;
58
      CellConstraints cc = new CellConstraints();
59
      if ( cols.length > 0 && rows.length > 0 )
60
      {
61
         if ( cols[0] == 1 && rows[0] == 1 )
62
         {
63
            /** add a rigid area  */
64
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
65
            filled_cell_11 = true;
66
         }
67
      }
68

    
69
      for( int index = 0; index < cols.length; index++ )
70
      {
71
         if ( cols[index] == 1 && filled_cell_11 )
72
         {
73
            continue;
74
         }
75
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
76
      }
77

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

    
87
   }
88

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

    
114
   /**
115
    * Method for recalculating the component orientation for 
116
    * right-to-left Locales.
117
    * @param orientation the component orientation to be applied
118
    */
119
   public void applyComponentOrientation( ComponentOrientation orientation )
120
   {
121
      // Not yet implemented...
122
      // I18NUtils.applyComponentOrientation(this, orientation);
123
      super.applyComponentOrientation(orientation);
124
   }
125

    
126
   public JPanel createPanel()
127
   {
128
      JPanel jpanel1 = new JPanel();
129
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU: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,FILL:DEFAULT:GROW(0.9),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(0.1),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
130
      CellConstraints cc = new CellConstraints();
131
      jpanel1.setLayout(formlayout1);
132

    
133
      rdbUseGeomsFromClipbard.setActionCommand("_Use_geometries_from_clipboard");
134
      rdbUseGeomsFromClipbard.setName("rdbUseGeomsFromClipbard");
135
      rdbUseGeomsFromClipbard.setText("_Use_geometries_from_clipboard");
136
      buttongroup1.add(rdbUseGeomsFromClipbard);
137
      jpanel1.add(rdbUseGeomsFromClipbard,cc.xywh(2,2,2,1));
138

    
139
      rdbUseGeomsFromLayerSelection.setActionCommand("_Use_geometries_from_layer_selection");
140
      rdbUseGeomsFromLayerSelection.setName("rdbUseGeomsFromLayerSelection");
141
      rdbUseGeomsFromLayerSelection.setText("_Use_geometries_from_layer_selection");
142
      buttongroup1.add(rdbUseGeomsFromLayerSelection);
143
      jpanel1.add(rdbUseGeomsFromLayerSelection,cc.xywh(2,4,2,1));
144

    
145
      rdbConstantGeometry.setActionCommand("_Use_next_geometry");
146
      rdbConstantGeometry.setName("rdbConstantGeometry");
147
      rdbConstantGeometry.setText("_Use_the_following_geometry");
148
      buttongroup1.add(rdbConstantGeometry);
149
      jpanel1.add(rdbConstantGeometry,cc.xywh(2,10,2,1));
150

    
151
      treeStores.setName("treeStores");
152
      JScrollPane jscrollpane1 = new JScrollPane();
153
      jscrollpane1.setViewportView(treeStores);
154
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
155
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
156
      jpanel1.add(jscrollpane1,cc.xy(3,8));
157

    
158
      txtGeometry.setName("txtGeometry");
159
      JScrollPane jscrollpane2 = new JScrollPane();
160
      jscrollpane2.setViewportView(txtGeometry);
161
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
162
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
163
      jpanel1.add(jscrollpane2,cc.xy(3,12));
164

    
165
      jpanel1.add(createPanel1(),cc.xy(3,14));
166
      chkUseTheGeometryBoundingBox.setActionCommand("_Use_the_geometry_bounding_box");
167
      chkUseTheGeometryBoundingBox.setName("chkUseTheGeometryBoundingBox");
168
      chkUseTheGeometryBoundingBox.setText("_Use_the_geometry_bounding_box");
169
      jpanel1.add(chkUseTheGeometryBoundingBox,cc.xy(3,6));
170

    
171
      addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 });
172
      return jpanel1;
173
   }
174

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

    
182
      txtProjection.setName("txtProjection");
183
      jpanel1.add(txtProjection,cc.xy(3,1));
184

    
185
      btnProjection.setActionCommand("...");
186
      btnProjection.setName("btnProjection");
187
      btnProjection.setText("...");
188
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
189
      btnProjection.setBorder(emptyborder1);
190
      jpanel1.add(btnProjection,cc.xy(5,1));
191

    
192
      lblProjection.setName("lblProjection");
193
      lblProjection.setText("_Projection");
194
      jpanel1.add(lblProjection,cc.xy(1,1));
195

    
196
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]);
197
      return jpanel1;
198
   }
199

    
200
   /**
201
    * Initializer
202
    */
203
   protected void initializePanel()
204
   {
205
      setLayout(new BorderLayout());
206
      add(createPanel(), BorderLayout.CENTER);
207
   }
208

    
209

    
210
}