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 / symboltables / functionPanels / perimeter / PerimeterAditionalPanelView.java @ 44129

History | View | Annotate | Download (6.11 KB)

1
package org.gvsig.app.project.symboltables.functionPanels.perimeter;
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.ImageIcon;
14
import javax.swing.JButton;
15
import javax.swing.JComboBox;
16
import javax.swing.JFrame;
17
import javax.swing.JLabel;
18
import javax.swing.JList;
19
import javax.swing.JPanel;
20
import javax.swing.JScrollPane;
21
import javax.swing.JTextField;
22

    
23

    
24
public class PerimeterAditionalPanelView extends JPanel
25
{
26
   JLabel lblTitle = new JLabel();
27
   JLabel lblSelectUnits = new JLabel();
28
   JList lstUnits = new JList();
29
   JLabel lblSelectField = new JLabel();
30
   JComboBox cboFields = new JComboBox();
31
   JButton btnInsertFunction = new JButton();
32
   JTextField txtPreview = new JTextField();
33

    
34
   /**
35
    * Default constructor
36
    */
37
   public PerimeterAditionalPanelView()
38
   {
39
      initializePanel();
40
   }
41

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

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

    
64
      for( int index = 0; index < cols.length; index++ )
65
      {
66
         if ( cols[index] == 1 && filled_cell_11 )
67
         {
68
            continue;
69
         }
70
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
71
      }
72

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

    
82
   }
83

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

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

    
121
   public JPanel createPanel()
122
   {
123
      JPanel jpanel1 = new JPanel();
124
      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,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
125
      CellConstraints cc = new CellConstraints();
126
      jpanel1.setLayout(formlayout1);
127

    
128
      lblTitle.setFont(new Font("Dialog",Font.BOLD,11));
129
      lblTitle.setName("lblTitle");
130
      lblTitle.setText("_Perimeter");
131
      jpanel1.add(lblTitle,cc.xy(2,2));
132

    
133
      lblSelectUnits.setName("lblSelectUnits");
134
      lblSelectUnits.setText("_Select_units");
135
      jpanel1.add(lblSelectUnits,cc.xy(2,8));
136

    
137
      lstUnits.setName("lstUnits");
138
      JScrollPane jscrollpane1 = new JScrollPane();
139
      jscrollpane1.setViewportView(lstUnits);
140
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
141
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
142
      jpanel1.add(jscrollpane1,cc.xy(2,10));
143

    
144
      lblSelectField.setName("lblSelectField");
145
      lblSelectField.setText("_Select_field");
146
      jpanel1.add(lblSelectField,cc.xy(2,4));
147

    
148
      cboFields.setName("cboFields");
149
      jpanel1.add(cboFields,cc.xy(2,6));
150

    
151
      jpanel1.add(createPanel1(),cc.xy(2,14));
152
      txtPreview.setBackground(new Color(236,233,216));
153
      txtPreview.setEditable(false);
154
      txtPreview.setName("txtPreview");
155
      jpanel1.add(txtPreview,cc.xy(2,12));
156

    
157
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 });
158
      return jpanel1;
159
   }
160

    
161
   public JPanel createPanel1()
162
   {
163
      JPanel jpanel1 = new JPanel();
164
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
165
      CellConstraints cc = new CellConstraints();
166
      jpanel1.setLayout(formlayout1);
167

    
168
      btnInsertFunction.setActionCommand("_Insert_function");
169
      btnInsertFunction.setName("btnInsertFunction");
170
      btnInsertFunction.setText("_Insert_function");
171
      jpanel1.add(btnInsertFunction,cc.xy(3,1));
172

    
173
      addFillComponents(jpanel1,new int[]{ 1,2 },new int[]{ 1 });
174
      return jpanel1;
175
   }
176

    
177
   /**
178
    * Initializer
179
    */
180
   protected void initializePanel()
181
   {
182
      setLayout(new BorderLayout());
183
      add(createPanel(), BorderLayout.CENTER);
184
   }
185

    
186

    
187
}