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 / VectorLayer3DPanel.java @ 708

History | View | Annotate | Download (5.1 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 VectorLayer3DPanel extends JPanel
19
{
20
   JLabel _elevationModeLabel = new JLabel();
21
   JLabel _defaultColorLabel = new JLabel();
22
   JComboBox _elevationModeCombo = new JComboBox();
23
   JLabel _constantHeightLabel = new JLabel();
24
   JTextField _constantHeightTextField = new JTextField();
25
   JPanel _defaultColorButtonPanel = new JPanel();
26

    
27
   /**
28
    * Default constructor
29
    */
30
   public VectorLayer3DPanel()
31
   {
32
      initializePanel();
33
   }
34

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

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

    
57
      for( int index = 0; index < cols.length; index++ )
58
      {
59
         if ( cols[index] == 1 && filled_cell_11 )
60
         {
61
            continue;
62
         }
63
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
64
      }
65

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

    
75
   }
76

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

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

    
114
   public JPanel createPanel()
115
   {
116
      JPanel jpanel1 = new JPanel();
117
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(0.3),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:GROW(1.0),CENTER:DEFAULT:NONE");
118
      CellConstraints cc = new CellConstraints();
119
      jpanel1.setLayout(formlayout1);
120

    
121
      _elevationModeLabel.setName("elevationModeLabel");
122
      _elevationModeLabel.setText("Elevation Mode");
123
      jpanel1.add(_elevationModeLabel,cc.xywh(2,2,2,1));
124

    
125
      _defaultColorLabel.setName("defaultColorLabel");
126
      _defaultColorLabel.setText("Default Color");
127
      jpanel1.add(_defaultColorLabel,cc.xywh(2,4,2,1));
128

    
129
      _elevationModeCombo.setName("elevationModeCombo");
130
      jpanel1.add(_elevationModeCombo,cc.xywh(5,2,3,1));
131

    
132
      _constantHeightLabel.setName("constantHeightLabel");
133
      _constantHeightLabel.setText("Constant Height");
134
      jpanel1.add(_constantHeightLabel,cc.xywh(2,6,2,1));
135

    
136
      _constantHeightTextField.setName("constantHeightTextField");
137
      jpanel1.add(_constantHeightTextField,cc.xywh(5,6,3,1));
138

    
139
      _defaultColorButtonPanel.setName("defaultColorButtonPanel");
140
      jpanel1.add(_defaultColorButtonPanel,cc.xy(5,4));
141

    
142
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9 });
143
      return jpanel1;
144
   }
145

    
146
   /**
147
    * Initializer
148
    */
149
   protected void initializePanel()
150
   {
151
      setLayout(new BorderLayout());
152
      add(createPanel(), BorderLayout.CENTER);
153
   }
154

    
155

    
156
}