KickJava   Java API By Example, From Geeks To Geeks.

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


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