KickJava   Java API By Example, From Geeks To Geeks.

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


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