gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.vector / org.gvsig.view3d.vector.swing / org.gvsig.view3d.vector.swing.impl / src / main / java / org / gvsig / view3d / vector / swing / impl / JVectorExtrusionLoaderParametersView.java @ 760
History | View | Annotate | Download (5.64 KB)
1 |
package org.gvsig.view3d.vector.swing.impl; |
---|---|
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 JVectorExtrusionLoaderParametersView extends JPanel |
19 |
{ |
20 |
JLabel elevationModeText = new JLabel(); |
21 |
JLabel defaultColorText = new JLabel(); |
22 |
JLabel heightFieldText = new JLabel(); |
23 |
JLabel constantHeightText = new JLabel(); |
24 |
JLabel verticalExaggerationText = new JLabel(); |
25 |
JComboBox heightField = new JComboBox(); |
26 |
JTextField constantHeight = new JTextField(); |
27 |
JTextField verticalExaggeration = new JTextField(); |
28 |
JComboBox elevationMode = new JComboBox(); |
29 |
JPanel defaultColorPanel = new JPanel(); |
30 |
|
31 |
/**
|
32 |
* Default constructor
|
33 |
*/
|
34 |
public JVectorExtrusionLoaderParametersView()
|
35 |
{ |
36 |
initializePanel(); |
37 |
} |
38 |
|
39 |
/**
|
40 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
41 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
42 |
* @param cols an array of column indices in the first row where fill components should be added.
|
43 |
* @param rows an array of row indices in the first column where fill components should be added.
|
44 |
*/
|
45 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
46 |
{ |
47 |
Dimension filler = new Dimension(10,10); |
48 |
|
49 |
boolean filled_cell_11 = false; |
50 |
CellConstraints cc = new CellConstraints();
|
51 |
if ( cols.length > 0 && rows.length > 0 ) |
52 |
{ |
53 |
if ( cols[0] == 1 && rows[0] == 1 ) |
54 |
{ |
55 |
/** add a rigid area */
|
56 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
57 |
filled_cell_11 = true;
|
58 |
} |
59 |
} |
60 |
|
61 |
for( int index = 0; index < cols.length; index++ ) |
62 |
{ |
63 |
if ( cols[index] == 1 && filled_cell_11 ) |
64 |
{ |
65 |
continue;
|
66 |
} |
67 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
68 |
} |
69 |
|
70 |
for( int index = 0; index < rows.length; index++ ) |
71 |
{ |
72 |
if ( rows[index] == 1 && filled_cell_11 ) |
73 |
{ |
74 |
continue;
|
75 |
} |
76 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
77 |
} |
78 |
|
79 |
} |
80 |
|
81 |
/**
|
82 |
* Helper method to load an image file from the CLASSPATH
|
83 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
84 |
* @return an ImageIcon instance with the specified image file
|
85 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
86 |
*/
|
87 |
public ImageIcon loadImage( String imageName ) |
88 |
{ |
89 |
try
|
90 |
{ |
91 |
ClassLoader classloader = getClass().getClassLoader();
|
92 |
java.net.URL url = classloader.getResource( imageName ); |
93 |
if ( url != null ) |
94 |
{ |
95 |
ImageIcon icon = new ImageIcon( url ); |
96 |
return icon;
|
97 |
} |
98 |
} |
99 |
catch( Exception e ) |
100 |
{ |
101 |
e.printStackTrace(); |
102 |
} |
103 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
104 |
} |
105 |
|
106 |
/**
|
107 |
* Method for recalculating the component orientation for
|
108 |
* right-to-left Locales.
|
109 |
* @param orientation the component orientation to be applied
|
110 |
*/
|
111 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
112 |
{ |
113 |
// Not yet implemented...
|
114 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
115 |
super.applyComponentOrientation(orientation);
|
116 |
} |
117 |
|
118 |
public JPanel createPanel() |
119 |
{ |
120 |
JPanel jpanel1 = new JPanel(); |
121 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE"); |
122 |
CellConstraints cc = new CellConstraints();
|
123 |
jpanel1.setLayout(formlayout1); |
124 |
|
125 |
elevationModeText.setName("elevationModeText");
|
126 |
elevationModeText.setText("elevation_mode");
|
127 |
jpanel1.add(elevationModeText,cc.xy(1,2)); |
128 |
|
129 |
defaultColorText.setName("defaultColorText");
|
130 |
defaultColorText.setText("default_color");
|
131 |
jpanel1.add(defaultColorText,cc.xy(1,4)); |
132 |
|
133 |
heightFieldText.setName("heightFieldText");
|
134 |
heightFieldText.setText("height_field");
|
135 |
jpanel1.add(heightFieldText,cc.xy(1,6)); |
136 |
|
137 |
constantHeightText.setName("constantHeightText");
|
138 |
constantHeightText.setText("constant_height");
|
139 |
jpanel1.add(constantHeightText,cc.xy(1,8)); |
140 |
|
141 |
verticalExaggerationText.setName("verticalExaggerationText");
|
142 |
verticalExaggerationText.setText("vertical_exaggeration");
|
143 |
jpanel1.add(verticalExaggerationText,cc.xy(1,10)); |
144 |
|
145 |
heightField.setName("heightField");
|
146 |
jpanel1.add(heightField,cc.xywh(3,6,2,1)); |
147 |
|
148 |
constantHeight.setName("constantHeight");
|
149 |
jpanel1.add(constantHeight,cc.xywh(3,8,2,1)); |
150 |
|
151 |
verticalExaggeration.setName("verticalExaggeration");
|
152 |
jpanel1.add(verticalExaggeration,cc.xywh(3,10,2,1)); |
153 |
|
154 |
elevationMode.setName("elevationMode");
|
155 |
jpanel1.add(elevationMode,cc.xywh(3,2,2,1)); |
156 |
|
157 |
defaultColorPanel.setName("defaultColorPanel");
|
158 |
jpanel1.add(defaultColorPanel,cc.xy(3,4)); |
159 |
|
160 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,3,5,7,9,11 }); |
161 |
return jpanel1;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* Initializer
|
166 |
*/
|
167 |
protected void initializePanel() |
168 |
{ |
169 |
setLayout(new BorderLayout()); |
170 |
add(createPanel(), BorderLayout.CENTER);
|
171 |
} |
172 |
|
173 |
|
174 |
} |