gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.algorithm / org.gvsig.geoprocess.algorithm.dispersepoints / src / main / java / org / gvsig / geoprocess / algorithm / dispersepoints / DispersePointsParametersPanelView.java @ 962
History | View | Annotate | Download (5.48 KB)
1 |
package org.gvsig.geoprocess.algorithm.dispersepoints; |
---|---|
2 |
|
3 |
import com.jeta.open.i18n.I18NUtils; |
4 |
import com.jgoodies.forms.layout.CellConstraints; |
5 |
import com.jgoodies.forms.layout.FormLayout; |
6 |
|
7 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
8 |
|
9 |
import java.awt.BorderLayout; |
10 |
import java.awt.ComponentOrientation; |
11 |
import java.awt.Container; |
12 |
import java.awt.Dimension; |
13 |
|
14 |
import javax.swing.Box; |
15 |
import javax.swing.ImageIcon; |
16 |
import javax.swing.JComboBox; |
17 |
import javax.swing.JFormattedTextField; |
18 |
import javax.swing.JFrame; |
19 |
import javax.swing.JLabel; |
20 |
import javax.swing.JPanel; |
21 |
|
22 |
|
23 |
public abstract class DispersePointsParametersPanelView extends GeoAlgorithmParametersPanel |
24 |
{ |
25 |
JLabel lblInputPointLayer = new JLabel(); |
26 |
JComboBox cmbInputLayer = new JComboBox(); |
27 |
JLabel lblScatterRadius = new JLabel(); |
28 |
JFormattedTextField txtScatterRadius = new JFormattedTextField(); |
29 |
JFormattedTextField txtMatchDistance = new JFormattedTextField(); |
30 |
JPanel pnlOutputPanel = new JPanel(); |
31 |
|
32 |
/**
|
33 |
* Default constructor
|
34 |
*/
|
35 |
public DispersePointsParametersPanelView()
|
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:4DLU:NONE,FILL:DEFAULT:NONE,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:GROW(1.0),CENTER:2DLU:NONE"); |
123 |
CellConstraints cc = new CellConstraints();
|
124 |
jpanel1.setLayout(formlayout1); |
125 |
|
126 |
lblInputPointLayer.setName("lblInputPointLayer");
|
127 |
lblInputPointLayer.setText("_input_point_layer");
|
128 |
lblInputPointLayer.setToolTipText("_input_point_layer");
|
129 |
jpanel1.add(lblInputPointLayer,cc.xy(2,2)); |
130 |
|
131 |
cmbInputLayer.setName("cmbInputLayer");
|
132 |
cmbInputLayer.setToolTipText("_input_layer");
|
133 |
jpanel1.add(cmbInputLayer,cc.xy(4,2)); |
134 |
|
135 |
lblScatterRadius.setName("lblScatterRadius");
|
136 |
lblScatterRadius.setText("_scatter_radius");
|
137 |
lblScatterRadius.setToolTipText("scatter_radius");
|
138 |
jpanel1.add(lblScatterRadius,cc.xy(2,6)); |
139 |
|
140 |
txtScatterRadius.setName("txtScatterRadius");
|
141 |
txtScatterRadius.setToolTipText("_scatter_radius");
|
142 |
jpanel1.add(txtScatterRadius,cc.xy(4,6)); |
143 |
|
144 |
JLabel jlabel1 = new JLabel(); |
145 |
jlabel1.setText("_match_distance");
|
146 |
jlabel1.setToolTipText("_match_distance");
|
147 |
jpanel1.add(jlabel1,cc.xy(2,4)); |
148 |
|
149 |
txtMatchDistance.setName("txtMatchDistance");
|
150 |
txtMatchDistance.setToolTipText("_match_distance");
|
151 |
jpanel1.add(txtMatchDistance,cc.xy(4,4)); |
152 |
|
153 |
pnlOutputPanel.setName("pnlOutputPanel");
|
154 |
jpanel1.add(pnlOutputPanel,cc.xywh(2,8,3,1)); |
155 |
|
156 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9 }); |
157 |
return jpanel1;
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* Initializer
|
162 |
*/
|
163 |
protected void initializePanel() |
164 |
{ |
165 |
setLayout(new BorderLayout()); |
166 |
add(createPanel(), BorderLayout.CENTER);
|
167 |
} |
168 |
|
169 |
|
170 |
} |