KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > layoutdesign > ALT_Bug70904Test


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.form.layoutdesign;
21
22 import java.awt.Dimension JavaDoc;
23 import java.awt.Point JavaDoc;
24 import java.awt.Rectangle JavaDoc;
25 import java.io.File JavaDoc;
26 import java.io.IOException JavaDoc;
27 import java.util.*;
28 import org.openide.filesystems.FileUtil;
29
30 // Tests vertical structure reduced just to one parallel group with baseline
31
// alignment, no gaps around.
32
public class ALT_Bug70904Test extends LayoutTestCase {
33
34     public ALT_Bug70904Test(String JavaDoc name) {
35         super(name);
36         try {
37         className = this.getClass().getName();
38         className = className.substring(className.lastIndexOf('.') + 1, className.length());
39             startingFormFile = FileUtil.toFileObject(new File JavaDoc(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
40         } catch (IOException JavaDoc ioe) {
41             fail(ioe.toString());
42         }
43     }
44
45     // Resize (shrink) whole form both horizontally and vertically so there is
46
// no gap.
47
public void doChanges0() {
48         ld.externalSizeChangeHappened();
49         // > UPDATE CURRENT STATE
50
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
51         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 3, 34, 14));
52         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
53         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
54         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 59, 20));
55         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
56         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
57         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
58         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 3, 34, 14));
59         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
60         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 59, 20));
61         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
62         ld.updateCurrentState();
63         // < UPDATE CURRENT STATE
64
// > START RESIZING
65
baselinePosition.put("Form-400-300", new Integer JavaDoc(-1));
66         prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
67
prefPaddingInParent.put("Form-jLabel1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
68
prefPaddingInParent.put("Form-jTextField1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
69
{
70             String JavaDoc[] compIds = new String JavaDoc[] {
71                 "Form"
72                 };
73             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
74                 new Rectangle JavaDoc(0, 0, 400, 300)
75                 };
76             Point JavaDoc hotspot = new Point JavaDoc(400,301);
77             int[] resizeEdges = new int[] {
78                 1,
79                     1
80                 };
81             boolean inLayout = false;
82             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
83         }
84         // < START RESIZING
85
// > MOVE
86
{
87             Point JavaDoc p = new Point JavaDoc(92,24);
88             String JavaDoc containerId = null;
89             boolean autoPositioning = true;
90             boolean lockDimension = false;
91             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
92                 new Rectangle JavaDoc(0, 0, 97, 20)
93                 };
94             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
95         }
96         // < MOVE
97
// > MOVE
98
{
99             Point JavaDoc p = new Point JavaDoc(92,23);
100             String JavaDoc containerId = null;
101             boolean autoPositioning = true;
102             boolean lockDimension = false;
103             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
104                 new Rectangle JavaDoc(0, 0, 97, 20)
105                 };
106             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
107         }
108         // < MOVE
109
// > END MOVING
110
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 97, 20));
111         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 3, 34, 14));
112         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
113         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
114         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 59, 20));
115         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
116         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
117         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
118         prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
119
compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
120         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
121         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
122         ld.endMoving(true);
123         // < END MOVING
124
ld.externalSizeChangeHappened();
125         // > UPDATE CURRENT STATE
126
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 97, 20));
127         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 3, 34, 14));
128         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
129         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
130         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 59, 20));
131         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
132         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
133         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
134         prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
135
compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
136         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
137         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
138         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 97, 20));
139         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 3, 34, 14));
140         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
141         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 59, 20));
142         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
143         ld.updateCurrentState();
144         // < UPDATE CURRENT STATE
145
}
146
147     // Resize textfield to the right (this creates a gap), then down, then to
148
// the right to snap to border without gap.
149
public void doChanges1() {
150         // > START RESIZING
151
baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
152         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
153         {
154             String JavaDoc[] compIds = new String JavaDoc[] {
155                 "jTextField1"
156                 };
157             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
158                 new Rectangle JavaDoc(38, 0, 59, 20)
159                 };
160             Point JavaDoc hotspot = new Point JavaDoc(99,10);
161             int[] resizeEdges = new int[] {
162                 1,
163                     -1
164                 };
165             boolean inLayout = true;
166             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
167         }
168         // < START RESIZING
169
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
170
// > MOVE
171
{
172             Point JavaDoc p = new Point JavaDoc(128,12);
173             String JavaDoc containerId= "Form";
174             boolean autoPositioning = true;
175             boolean lockDimension = false;
176             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
177                 new Rectangle JavaDoc(38, 0, 88, 20)
178                 };
179             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
180         }
181         // < MOVE
182
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
183
// > MOVE
184
{
185             Point JavaDoc p = new Point JavaDoc(129,12);
186             String JavaDoc containerId= "Form";
187             boolean autoPositioning = true;
188             boolean lockDimension = false;
189             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
190                 new Rectangle JavaDoc(38, 0, 89, 20)
191                 };
192             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
193         }
194         // < MOVE
195
// > END MOVING
196
compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
197         prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
198
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
199
compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
200         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
201         ld.endMoving(true);
202         // < END MOVING
203
ld.externalSizeChangeHappened();
204         // > UPDATE CURRENT STATE
205
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 137, 20));
206         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 3, 34, 14));
207         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
208         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
209         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 89, 20));
210         baselinePosition.put("jTextField1-89-20", new Integer JavaDoc(14));
211         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
212         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
213         prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
214
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
215
compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
216         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
217         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 137, 20));
218         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 3, 34, 14));
219         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
220         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 89, 20));
221         baselinePosition.put("jTextField1-89-20", new Integer JavaDoc(14));
222         ld.updateCurrentState();
223         // < UPDATE CURRENT STATE
224
// > START RESIZING
225
baselinePosition.put("jTextField1-89-20", new Integer JavaDoc(14));
226         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
227         {
228             String JavaDoc[] compIds = new String JavaDoc[] {
229                 "jTextField1"
230                 };
231             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
232                 new Rectangle JavaDoc(38, 0, 89, 20)
233                 };
234             Point JavaDoc hotspot = new Point JavaDoc(80,20);
235             int[] resizeEdges = new int[] {
236                 -1,
237                     1
238                 };
239             boolean inLayout = true;
240             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
241         }
242         // < START RESIZING
243
prefPaddingInParent.put("Form-jTextField1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
244
// > MOVE
245
{
246             Point JavaDoc p = new Point JavaDoc(80,38);
247             String JavaDoc containerId= "Form";
248             boolean autoPositioning = true;
249             boolean lockDimension = false;
250             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
251                 new Rectangle JavaDoc(38, 0, 89, 38)
252                 };
253             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
254         }
255         // < MOVE
256
prefPaddingInParent.put("Form-jTextField1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
257
// > MOVE
258
{
259             Point JavaDoc p = new Point JavaDoc(80,39);
260             String JavaDoc containerId= "Form";
261             boolean autoPositioning = true;
262             boolean lockDimension = false;
263             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
264                 new Rectangle JavaDoc(38, 0, 89, 39)
265                 };
266             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
267         }
268         // < MOVE
269
// > END MOVING
270
compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
271         prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
272
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
273
compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
274         ld.endMoving(true);
275         // < END MOVING
276
ld.externalSizeChangeHappened();
277         // > UPDATE CURRENT STATE
278
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 137, 39));
279         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 12, 34, 14));
280         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
281         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
282         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 89, 39));
283         baselinePosition.put("jTextField1-89-39", new Integer JavaDoc(23));
284         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
285         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
286         prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
287
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
288
compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
289         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 137, 39));
290         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 12, 34, 14));
291         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
292         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 89, 39));
293         baselinePosition.put("jTextField1-89-39", new Integer JavaDoc(23));
294         ld.updateCurrentState();
295         // < UPDATE CURRENT STATE
296
// > START RESIZING
297
baselinePosition.put("jTextField1-89-39", new Integer JavaDoc(23));
298         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
299         {
300             String JavaDoc[] compIds = new String JavaDoc[] {
301                 "jTextField1"
302                 };
303             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
304                 new Rectangle JavaDoc(38, 0, 89, 39)
305                 };
306             Point JavaDoc hotspot = new Point JavaDoc(126,22);
307             int[] resizeEdges = new int[] {
308                 1,
309                     -1
310                 };
311             boolean inLayout = true;
312             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
313         }
314         // < START RESIZING
315
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
316
// > MOVE
317
{
318             Point JavaDoc p = new Point JavaDoc(133,23);
319             String JavaDoc containerId= "Form";
320             boolean autoPositioning = true;
321             boolean lockDimension = false;
322             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
323                 new Rectangle JavaDoc(38, 0, 99, 39)
324                 };
325             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
326         }
327         // < MOVE
328
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
329
// > MOVE
330
{
331             Point JavaDoc p = new Point JavaDoc(134,23);
332             String JavaDoc containerId= "Form";
333             boolean autoPositioning = true;
334             boolean lockDimension = false;
335             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
336                 new Rectangle JavaDoc(38, 0, 99, 39)
337                 };
338             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
339         }
340         // < MOVE
341
// > END MOVING
342
compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
343         ld.endMoving(true);
344         // < END MOVING
345
ld.externalSizeChangeHappened();
346         // > UPDATE CURRENT STATE
347
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 137, 39));
348         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 12, 34, 14));
349         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
350         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
351         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 99, 39));
352         baselinePosition.put("jTextField1-99-39", new Integer JavaDoc(23));
353         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
354         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
355         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 137, 39));
356         compBounds.put("jLabel1", new Rectangle JavaDoc(0, 12, 34, 14));
357         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
358         compBounds.put("jTextField1", new Rectangle JavaDoc(38, 0, 99, 39));
359         baselinePosition.put("jTextField1-99-39", new Integer JavaDoc(23));
360         ld.updateCurrentState();
361         // < UPDATE CURRENT STATE
362
}
363     
364 }
365
Popular Tags