Statistics
| Revision:

gvsig-3d / 2.1 / branches / org.gvsig.view3d_vector_and_extrusion_2.3 / org.gvsig.view3d / org.gvsig.view3d / org.gvsig.view3d.swing / org.gvsig.view3d.swing.impl / src / main / java / org / gvsig / view3d / swing / impl / properties / layer / ExtrudedVectorLayer3DPanel.java @ 708

History | View | Annotate | Download (6.27 KB)

1
package org.gvsig.view3d.swing.impl.properties.layer;
2

    
3
import com.jgoodies.forms.layout.CellConstraints;
4
import com.jgoodies.forms.layout.FormLayout;
5
import java.awt.BorderLayout;
6
import java.awt.ComponentOrientation;
7
import java.awt.Container;
8
import java.awt.Dimension;
9
import javax.swing.Box;
10
import javax.swing.ImageIcon;
11
import javax.swing.JComboBox;
12
import javax.swing.JFrame;
13
import javax.swing.JLabel;
14
import javax.swing.JPanel;
15
import javax.swing.JTextField;
16

    
17

    
18
public class ExtrudedVectorLayer3DPanel extends JPanel
19
{
20
   JLabel _elevationModeLabel = new JLabel();
21
   JLabel _defaultColorLabel = new JLabel();
22
   JComboBox _elevationModeCombo = new JComboBox();
23
   JLabel _extrusionTitleLabel = new JLabel();
24
   JLabel _heightFieldLabel = new JLabel();
25
   JComboBox _heightFieldCombo = new JComboBox();
26
   JLabel _constantHeightLabel = new JLabel();
27
   JTextField _constantHeightTextField = new JTextField();
28
   JLabel _verticalExagerationLabel = new JLabel();
29
   JTextField _verticalExagerationTextField = new JTextField();
30
   JPanel _defaultColorButtonPanel = new JPanel();
31

    
32
   /**
33
    * Default constructor
34
    */
35
   public ExtrudedVectorLayer3DPanel()
36
   {
37
      initializePanel();
38
   }
39

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

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

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

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

    
80
   }
81

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

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

    
119
   public JPanel createPanel()
120
   {
121
      JPanel jpanel1 = new JPanel();
122
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(0.4),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE");
123
      CellConstraints cc = new CellConstraints();
124
      jpanel1.setLayout(formlayout1);
125

    
126
      _elevationModeLabel.setName("elevationModeLabel");
127
      _elevationModeLabel.setText("Elevation Mode");
128
      jpanel1.add(_elevationModeLabel,cc.xywh(2,2,2,1));
129

    
130
      _defaultColorLabel.setName("defaultColorLabel");
131
      _defaultColorLabel.setText("Default Color");
132
      jpanel1.add(_defaultColorLabel,cc.xywh(2,4,2,1));
133

    
134
      _elevationModeCombo.setName("elevationModeCombo");
135
      jpanel1.add(_elevationModeCombo,cc.xywh(5,2,3,1));
136

    
137
      _extrusionTitleLabel.setName("extrusionTitleLabel");
138
      _extrusionTitleLabel.setText("Extrusion");
139
      jpanel1.add(_extrusionTitleLabel,cc.xywh(2,8,2,1));
140

    
141
      _heightFieldLabel.setName("heightFieldLabel");
142
      _heightFieldLabel.setText("Height Field");
143
      jpanel1.add(_heightFieldLabel,cc.xy(3,10));
144

    
145
      _heightFieldCombo.setName("heightFieldCombo");
146
      jpanel1.add(_heightFieldCombo,cc.xywh(5,10,3,1));
147

    
148
      _constantHeightLabel.setName("constantHeightLabel");
149
      _constantHeightLabel.setText("Constant Height");
150
      jpanel1.add(_constantHeightLabel,cc.xy(3,12));
151

    
152
      _constantHeightTextField.setName("constantHeightTextField");
153
      jpanel1.add(_constantHeightTextField,cc.xywh(5,12,3,1));
154

    
155
      _verticalExagerationLabel.setName("verticalExagerationLabel");
156
      _verticalExagerationLabel.setText("Vertical Exageration");
157
      jpanel1.add(_verticalExagerationLabel,cc.xy(3,14));
158

    
159
      _verticalExagerationTextField.setName("verticalExagerationTextField");
160
      jpanel1.add(_verticalExagerationTextField,cc.xywh(5,14,3,1));
161

    
162
      _defaultColorButtonPanel.setName("defaultColorButtonPanel");
163
      jpanel1.add(_defaultColorButtonPanel,cc.xy(5,4));
164

    
165
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 });
166
      return jpanel1;
167
   }
168

    
169
   /**
170
    * Initializer
171
    */
172
   protected void initializePanel()
173
   {
174
      setLayout(new BorderLayout());
175
      add(createPanel(), BorderLayout.CENTER);
176
   }
177

    
178

    
179
}