Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / expressionevaluator / viewcapturepoint / ViewCapturePointPanelView.java @ 44190

History | View | Annotate | Download (8.27 KB)

1
package org.gvsig.app.project.documents.view.expressionevaluator.viewcapturepoint;
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.JFrame;
17
import javax.swing.JLabel;
18
import javax.swing.JPanel;
19
import javax.swing.JRadioButton;
20
import javax.swing.JTextField;
21

    
22

    
23
public class ViewCapturePointPanelView extends JPanel
24
{
25
   JLabel lblConstantPoint = new JLabel();
26
   JLabel lblValue = new JLabel();
27
   JLabel lblDescription = new JLabel();
28
   JLabel lblCaptureAPointFromCurrentView = new JLabel();
29
   JButton btnToggleCapture = new JButton();
30
   JTextField txtGeometry = new JTextField();
31
   JLabel lblUseWktOrWkb = new JLabel();
32
   JLabel lblUseGeometryOrText = new JLabel();
33
   JRadioButton rdoInsertAsWKT = new JRadioButton();
34
   ButtonGroup buttongroup1 = new ButtonGroup();
35
   JRadioButton rdoInsertAsWKB = new JRadioButton();
36
   JRadioButton rdoInsertAsGeometry = new JRadioButton();
37
   ButtonGroup buttongroup2 = new ButtonGroup();
38
   JRadioButton rdoInsertAsString = new JRadioButton();
39

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

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

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

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

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

    
88
   }
89

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

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

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

    
134
      lblConstantPoint.setFont(new Font("Dialog",Font.BOLD,11));
135
      lblConstantPoint.setName("lblConstantPoint");
136
      lblConstantPoint.setText("_Constant_Point");
137
      jpanel1.add(lblConstantPoint,cc.xywh(2,2,3,1));
138

    
139
      lblValue.setFont(new Font("Dialog",Font.BOLD,11));
140
      lblValue.setName("lblValue");
141
      lblValue.setText("_Value");
142
      jpanel1.add(lblValue,cc.xy(2,4));
143

    
144
      lblDescription.setFont(new Font("Dialog",Font.BOLD,11));
145
      lblDescription.setName("lblDescription");
146
      lblDescription.setText("_Description");
147
      jpanel1.add(lblDescription,cc.xy(2,10));
148

    
149
      lblCaptureAPointFromCurrentView.setName("lblCaptureAPointFromCurrentView");
150
      lblCaptureAPointFromCurrentView.setText("_Capture_a_point_from_current_view");
151
      jpanel1.add(lblCaptureAPointFromCurrentView,cc.xywh(2,11,3,1));
152

    
153
      btnToggleCapture.setActionCommand("Toggle point capture");
154
      btnToggleCapture.setName("btnToggleCapture");
155
      btnToggleCapture.setText("_Start_capture");
156
      jpanel1.add(btnToggleCapture,new CellConstraints(4,8,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
157

    
158
      txtGeometry.setBackground(new Color(236,233,216));
159
      txtGeometry.setEditable(false);
160
      txtGeometry.setName("txtGeometry");
161
      jpanel1.add(txtGeometry,cc.xywh(2,6,3,1));
162

    
163
      jpanel1.add(createPanel1(),cc.xywh(2,13,3,1));
164
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14 });
165
      return jpanel1;
166
   }
167

    
168
   public JPanel createPanel1()
169
   {
170
      JPanel jpanel1 = new JPanel();
171
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:DEFAULT: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");
172
      CellConstraints cc = new CellConstraints();
173
      jpanel1.setLayout(formlayout1);
174

    
175
      lblUseWktOrWkb.setName("lblUseWktOrWkb");
176
      lblUseWktOrWkb.setText("_Use_WKT_or_WKB");
177
      jpanel1.add(lblUseWktOrWkb,cc.xywh(2,1,2,1));
178

    
179
      lblUseGeometryOrText.setName("lblUseGeometryOrText");
180
      lblUseGeometryOrText.setText("_Use_Geometry_or_Text");
181
      jpanel1.add(lblUseGeometryOrText,cc.xywh(2,6,2,1));
182

    
183
      rdoInsertAsWKT.setActionCommand("Insert as WKT");
184
      rdoInsertAsWKT.setName("rdoInsertAsWKT");
185
      rdoInsertAsWKT.setOpaque(false);
186
      rdoInsertAsWKT.setText("_Insert_as_WKT");
187
      buttongroup1.add(rdoInsertAsWKT);
188
      jpanel1.add(rdoInsertAsWKT,cc.xy(3,2));
189

    
190
      rdoInsertAsWKB.setActionCommand("Insert as WKB");
191
      rdoInsertAsWKB.setName("rdoInsertAsWKB");
192
      rdoInsertAsWKB.setOpaque(false);
193
      rdoInsertAsWKB.setSelected(true);
194
      rdoInsertAsWKB.setText("_Insert_as_WKB");
195
      buttongroup1.add(rdoInsertAsWKB);
196
      jpanel1.add(rdoInsertAsWKB,cc.xy(3,4));
197

    
198
      rdoInsertAsGeometry.setActionCommand("Insert as geometry");
199
      rdoInsertAsGeometry.setName("rdoInsertAsGeometry");
200
      rdoInsertAsGeometry.setOpaque(false);
201
      rdoInsertAsGeometry.setSelected(true);
202
      rdoInsertAsGeometry.setText("_Insert_as_Geometry");
203
      buttongroup2.add(rdoInsertAsGeometry);
204
      jpanel1.add(rdoInsertAsGeometry,cc.xy(3,8));
205

    
206
      rdoInsertAsString.setActionCommand("Insert as String");
207
      rdoInsertAsString.setName("rdoInsertAsString");
208
      rdoInsertAsString.setOpaque(false);
209
      rdoInsertAsString.setText("_Insert_as_Text");
210
      buttongroup2.add(rdoInsertAsString);
211
      jpanel1.add(rdoInsertAsString,cc.xy(3,10));
212

    
213
      addFillComponents(jpanel1,new int[]{ 1,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10 });
214
      return jpanel1;
215
   }
216

    
217
   /**
218
    * Initializer
219
    */
220
   protected void initializePanel()
221
   {
222
      setLayout(new BorderLayout());
223
      add(createPanel(), BorderLayout.CENTER);
224
   }
225

    
226

    
227
}