56 |
protected Hashtable comptable; |
protected Hashtable comptable; |
57 |
protected GridBagLayoutInfo layoutInfo; |
protected GridBagLayoutInfo layoutInfo; |
58 |
protected GridBagConstraints defaultConstraints = new GridBagConstraints(); |
protected GridBagConstraints defaultConstraints = new GridBagConstraints(); |
|
|
|
59 |
|
|
60 |
public double[] columnWeights; |
public double[] columnWeights; |
61 |
public int[] columnWidths; |
public int[] columnWidths; |
82 |
|
|
83 |
public void removeLayoutComponent (Component component) |
public void removeLayoutComponent (Component component) |
84 |
{ |
{ |
85 |
comptable.remove (component); |
// do nothing here |
86 |
} |
} |
87 |
|
|
88 |
public Dimension preferredLayoutSize (Container parent) |
public Dimension preferredLayoutSize (Container parent) |
89 |
{ |
{ |
90 |
if (layoutInfo == null) |
if (parent == null) |
91 |
layoutContainer (parent); |
return new Dimension (0, 0); |
92 |
|
|
93 |
throw new Error ("Not implemented"); |
GridBagLayoutInfo li = getLayoutInfo (parent, PREFERREDSIZE); |
94 |
|
return getMinSize (parent, li); |
95 |
} |
} |
96 |
|
|
97 |
public Dimension minimumLayoutSize (Container parent) |
public Dimension minimumLayoutSize (Container parent) |
98 |
{ |
{ |
99 |
if (layoutInfo == null) |
if (parent == null) |
100 |
layoutContainer (parent); |
return new Dimension (0, 0); |
101 |
|
|
102 |
throw new Error ("Not implemented"); |
GridBagLayoutInfo li = getLayoutInfo (parent, MINSIZE); |
103 |
|
return getMinSize (parent, li); |
104 |
} |
} |
105 |
|
|
106 |
public Dimension maximumLayoutSize (Container target) |
public Dimension maximumLayoutSize (Container target) |
107 |
{ |
{ |
108 |
throw new Error ("Not implemented"); |
return new Dimension (Integer.MAX_VALUE, Integer.MAX_VALUE); |
109 |
} |
} |
110 |
|
|
111 |
public void layoutContainer (Container parent) |
public void layoutContainer (Container parent) |
172 |
|
|
173 |
protected GridBagConstraints lookupConstraints (Component component) |
protected GridBagConstraints lookupConstraints (Component component) |
174 |
{ |
{ |
175 |
return (GridBagConstraints) comptable.get (component); |
GridBagConstraints result = (GridBagConstraints) comptable.get (component); |
176 |
|
|
177 |
|
if (result == null) |
178 |
|
{ |
179 |
|
setConstraints (component, defaultConstraints); |
180 |
|
result = (GridBagConstraints) comptable.get (component); |
181 |
|
} |
182 |
|
|
183 |
|
return result; |
184 |
} |
} |
185 |
|
|
186 |
/** |
/** |
187 |
* @since 1.1 |
* @since 1.1 |
188 |
*/ |
*/ |
189 |
public int[][] getLayoutDimensions () |
public Point getLayoutOrigin () |
190 |
{ |
{ |
191 |
throw new Error ("Not implemented"); |
if (layoutInfo == null) |
192 |
|
return new Point (0, 0); |
193 |
|
|
194 |
|
return new Point (layoutInfo.x, layoutInfo.y); |
195 |
} |
} |
196 |
|
|
197 |
/** |
/** |
198 |
* @since 1.1 |
* @since 1.1 |
199 |
*/ |
*/ |
200 |
public Point getLayoutOrigin () |
public int[][] getLayoutDimensions () |
201 |
{ |
{ |
202 |
throw new Error ("Not implemented"); |
if (layoutInfo == null) |
203 |
|
return new int [2][]; |
204 |
|
|
205 |
|
int[][] result = new int [2][]; |
206 |
|
result [0] = new int [layoutInfo.cols]; |
207 |
|
System.arraycopy (layoutInfo.colWidths, 0, result [0], 0, layoutInfo.cols); |
208 |
|
result [1] = new int [layoutInfo.rows]; |
209 |
|
System.arraycopy (layoutInfo.rowHeights, 0, result [1], 0, layoutInfo.rows); |
210 |
|
return result; |
211 |
} |
} |
212 |
|
|
213 |
public double[][] getLayoutWeights () |
public double[][] getLayoutWeights () |
214 |
{ |
{ |
215 |
throw new Error ("Not implemented"); |
if (layoutInfo == null) |
216 |
|
return new double [2][]; |
217 |
|
|
218 |
|
double[][] result = new double [2][]; |
219 |
|
result [0] = new double [layoutInfo.cols]; |
220 |
|
System.arraycopy (layoutInfo.colWeights, 0, result [0], 0, layoutInfo.cols); |
221 |
|
result [1] = new double [layoutInfo.rows]; |
222 |
|
System.arraycopy (layoutInfo.rowWeights, 0, result [1], 0, layoutInfo.rows); |
223 |
|
return result; |
224 |
} |
} |
225 |
|
|
226 |
/** |
/** |
228 |
*/ |
*/ |
229 |
public Point location (int x, int y) |
public Point location (int x, int y) |
230 |
{ |
{ |
231 |
throw new Error ("Not implemented"); |
if (layoutInfo == null) |
232 |
|
return new Point (0, 0); |
233 |
|
|
234 |
|
int col; |
235 |
|
int row; |
236 |
|
int pixel_x = layoutInfo.x; |
237 |
|
int pixel_y = layoutInfo.y; |
238 |
|
|
239 |
|
for (col = 0; col < layoutInfo.cols; col++) |
240 |
|
{ |
241 |
|
if (pixel_x < x) |
242 |
|
break; |
243 |
|
|
244 |
|
pixel_x += layoutInfo.colWidths [col]; |
245 |
|
} |
246 |
|
|
247 |
|
for (row = 0; row < layoutInfo.rows; row++) |
248 |
|
{ |
249 |
|
if (pixel_y < y) |
250 |
|
break; |
251 |
|
|
252 |
|
pixel_y += layoutInfo.rowHeights [row]; |
253 |
|
} |
254 |
|
|
255 |
|
return new Point (col, row); |
256 |
} |
} |
257 |
|
|
258 |
/** |
/** |
260 |
*/ |
*/ |
261 |
protected GridBagLayoutInfo getLayoutInfo (Container parent, int sizeflag) |
protected GridBagLayoutInfo getLayoutInfo (Container parent, int sizeflag) |
262 |
{ |
{ |
263 |
|
if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE) |
264 |
|
throw new IllegalArgumentException(); |
265 |
|
|
266 |
throw new Error ("Not implemented"); |
throw new Error ("Not implemented"); |
267 |
} |
} |
268 |
|
|
276 |
*/ |
*/ |
277 |
protected Dimension getMinSize (Container parent, GridBagLayoutInfo info) |
protected Dimension getMinSize (Container parent, GridBagLayoutInfo info) |
278 |
{ |
{ |
279 |
throw new Error ("Not implemented"); |
if (parent == null || info == null) |
280 |
|
return new Dimension (0, 0); |
281 |
|
|
282 |
|
int width = 0; |
283 |
|
int height = 0; |
284 |
|
|
285 |
|
for (int i = 0; i < info.cols; i++) |
286 |
|
width += info.colWidths [i]; |
287 |
|
|
288 |
|
for (int i = 0; i < info.rows; i++) |
289 |
|
height += info.rowHeights [i]; |
290 |
|
|
291 |
|
Insets insets = parent.getInsets(); |
292 |
|
width += insets.left + insets.right; |
293 |
|
height += insets.top + insets.bottom; |
294 |
|
|
295 |
|
return new Dimension (width, height); |
296 |
} |
} |
297 |
|
|
298 |
protected Dimension GetMinSize (Container parent, GridBagLayoutInfo info) |
protected Dimension GetMinSize (Container parent, GridBagLayoutInfo info) |
299 |
{ |
{ |
300 |
throw new Error ("Not implemented"); |
return getMinSize (parent, info); |
301 |
} |
} |
302 |
} |
} |