KickJava   Java API By Example, From Geeks To Geeks.

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


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 with "next to" gesture.
31
public class ALT_ParallelPosition03Test extends LayoutTestCase {
32
33     public ALT_ParallelPosition03Test(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     // Create the layout - toggle button, text area, button (right-aligned with
45
// togle button).
46
public void doChanges0() {
47         ld.externalSizeChangeHappened();
48         // > UPDATE CURRENT STATE
49
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
50         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
51         ld.updateCurrentState();
52         // < UPDATE CURRENT STATE
53
lc = new LayoutComponent("jToggleButton1", false);
54         // > START ADDING
55
baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
56         {
57             LayoutComponent[] comps = new LayoutComponent[] { lc };
58             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
59                 new Rectangle JavaDoc(0, 0, 105, 23)
60                 };
61             String JavaDoc defaultContId = null;
62             Point JavaDoc hotspot = new Point JavaDoc(48,11);
63             ld.startAdding(comps, bounds, hotspot, defaultContId);
64         }
65         // < START ADDING
66
prefPaddingInParent.put("Form-jToggleButton1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
67
prefPaddingInParent.put("Form-jToggleButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
68
prefPaddingInParent.put("Form-jToggleButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
69
prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
70
// > MOVE
71
{
72             Point JavaDoc p = new Point JavaDoc(61,27);
73             String JavaDoc containerId= "Form";
74             boolean autoPositioning = true;
75             boolean lockDimension = false;
76             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
77                 new Rectangle JavaDoc(10, 11, 105, 23)
78                 };
79             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
80         }
81         // < MOVE
82
prefPaddingInParent.put("Form-jToggleButton1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
83
prefPaddingInParent.put("Form-jToggleButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
84
prefPaddingInParent.put("Form-jToggleButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
85
prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
86
// > MOVE
87
{
88             Point JavaDoc p = new Point JavaDoc(60,27);
89             String JavaDoc containerId= "Form";
90             boolean autoPositioning = true;
91             boolean lockDimension = false;
92             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
93                 new Rectangle JavaDoc(10, 11, 105, 23)
94                 };
95             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
96         }
97         // < MOVE
98
// > END MOVING
99
compPrefSize.put("jToggleButton1", new Dimension JavaDoc(105, 23));
100         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(105, 23));
101         prefPaddingInParent.put("Form-jToggleButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
102
prefPaddingInParent.put("Form-jToggleButton1-1-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
103
ld.endMoving(true);
104         // < END MOVING
105
ld.externalSizeChangeHappened();
106         // > UPDATE CURRENT STATE
107
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
108         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
109         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
110         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(105, 23));
111         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
112         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
113         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
114         ld.updateCurrentState();
115         // < UPDATE CURRENT STATE
116
lc = new LayoutComponent("jScrollPane1", false);
117         // > START ADDING
118
baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
119         {
120             LayoutComponent[] comps = new LayoutComponent[] { lc };
121             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
122                 new Rectangle JavaDoc(0, 0, 104, 64)
123                 };
124             String JavaDoc defaultContId = null;
125             Point JavaDoc hotspot = new Point JavaDoc(48,32);
126             ld.startAdding(comps, bounds, hotspot, defaultContId);
127         }
128         // < START ADDING
129
prefPaddingInParent.put("Form-jScrollPane1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
130
prefPaddingInParent.put("Form-jScrollPane1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
131
prefPaddingInParent.put("Form-jScrollPane1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
132
prefPaddingInParent.put("Form-jScrollPane1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
133
prefPadding.put("jToggleButton1-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
134
prefPadding.put("jScrollPane1-jToggleButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
135
// > MOVE
136
{
137             Point JavaDoc p = new Point JavaDoc(172,47);
138             String JavaDoc containerId= "Form";
139             boolean autoPositioning = true;
140             boolean lockDimension = false;
141             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
142                 new Rectangle JavaDoc(121, 11, 104, 64)
143                 };
144             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
145         }
146         // < MOVE
147
prefPaddingInParent.put("Form-jScrollPane1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
148
prefPaddingInParent.put("Form-jScrollPane1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
149
prefPaddingInParent.put("Form-jScrollPane1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
150
prefPaddingInParent.put("Form-jScrollPane1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
151
prefPadding.put("jToggleButton1-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
152
prefPadding.put("jScrollPane1-jToggleButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
153
// > MOVE
154
{
155             Point JavaDoc p = new Point JavaDoc(172,46);
156             String JavaDoc containerId= "Form";
157             boolean autoPositioning = true;
158             boolean lockDimension = false;
159             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
160                 new Rectangle JavaDoc(121, 11, 104, 64)
161                 };
162             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
163         }
164         // < MOVE
165
// > END MOVING
166
compPrefSize.put("jScrollPane1", new Dimension JavaDoc(104, 64));
167         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(104, 64));
168         prefPaddingInParent.put("Form-jScrollPane1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
169
prefPaddingInParent.put("Form-jScrollPane1-1-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
170
ld.endMoving(true);
171         // < END MOVING
172
ld.externalSizeChangeHappened();
173         // > UPDATE CURRENT STATE
174
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
175         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
176         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
177         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(105, 23));
178         compBounds.put("jScrollPane1", new Rectangle JavaDoc(121, 11, 104, 64));
179         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
180         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(104, 64));
181         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
182         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
183         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
184         compBounds.put("jScrollPane1", new Rectangle JavaDoc(121, 11, 104, 64));
185         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
186         ld.updateCurrentState();
187         // < UPDATE CURRENT STATE
188
lc = new LayoutComponent("jButton1", false);
189         // > START ADDING
190
baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
191         {
192             LayoutComponent[] comps = new LayoutComponent[] { lc };
193             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
194                 new Rectangle JavaDoc(0, 0, 75, 23)
195                 };
196             String JavaDoc defaultContId = null;
197             Point JavaDoc hotspot = new Point JavaDoc(33,11);
198             ld.startAdding(comps, bounds, hotspot, defaultContId);
199         }
200         // < START ADDING
201
prefPaddingInParent.put("Form-jButton1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
202
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
203
prefPadding.put("jToggleButton1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
204
prefPadding.put("jButton1-jToggleButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
205
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
206
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
207
prefPadding.put("jScrollPane1-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
208
prefPadding.put("jButton1-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
209
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
210
// > MOVE
211
{
212             Point JavaDoc p = new Point JavaDoc(70,48);
213             String JavaDoc containerId= "Form";
214             boolean autoPositioning = true;
215             boolean lockDimension = false;
216             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
217                 new Rectangle JavaDoc(40, 40, 75, 23)
218                 };
219             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
220         }
221         // < MOVE
222
prefPaddingInParent.put("Form-jButton1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
223
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
224
prefPadding.put("jToggleButton1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
225
prefPadding.put("jButton1-jToggleButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
226
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
227
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
228
prefPadding.put("jScrollPane1-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
229
prefPadding.put("jButton1-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
230
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
231
// > MOVE
232
{
233             Point JavaDoc p = new Point JavaDoc(71,48);
234             String JavaDoc containerId= "Form";
235             boolean autoPositioning = true;
236             boolean lockDimension = false;
237             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
238                 new Rectangle JavaDoc(40, 40, 75, 23)
239                 };
240             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
241         }
242         // < MOVE
243
// > END MOVING
244
compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
245         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
246         prefPaddingInParent.put("Form-jToggleButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
247
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
248
ld.endMoving(true);
249         // < END MOVING
250
ld.externalSizeChangeHappened();
251         // > UPDATE CURRENT STATE
252
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
253         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
254         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
255         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(105, 23));
256         compBounds.put("jScrollPane1", new Rectangle JavaDoc(121, 11, 104, 64));
257         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
258         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(104, 64));
259         compBounds.put("jButton1", new Rectangle JavaDoc(40, 40, 75, 23));
260         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
261         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
262         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
263         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
264         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
265         compBounds.put("jScrollPane1", new Rectangle JavaDoc(121, 11, 104, 64));
266         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
267         compBounds.put("jButton1", new Rectangle JavaDoc(40, 40, 75, 23));
268         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
269         ld.updateCurrentState();
270         // < UPDATE CURRENT STATE
271
}
272
273     // Resize the button to the left to have same size as the toggle button.
274
// Fixed parallel group with both buttons resizing should be created.
275
public void doChanges1() {
276         // > START RESIZING
277
baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
278         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
279         {
280             String JavaDoc[] compIds = new String JavaDoc[] {
281                 "jButton1"
282                 };
283             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
284                 new Rectangle JavaDoc(40, 40, 75, 23)
285                 };
286             Point JavaDoc hotspot = new Point JavaDoc(36,49);
287             int[] resizeEdges = new int[] {
288                 0,
289                     -1
290                 };
291             boolean inLayout = true;
292             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
293         }
294         // < START RESIZING
295
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
296
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
297
// > MOVE
298
{
299             Point JavaDoc p = new Point JavaDoc(10,49);
300             String JavaDoc containerId= "Form";
301             boolean autoPositioning = true;
302             boolean lockDimension = false;
303             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
304                 new Rectangle JavaDoc(10, 40, 105, 23)
305                 };
306             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
307         }
308         // < MOVE
309
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
310
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
311
// > MOVE
312
{
313             Point JavaDoc p = new Point JavaDoc(9,49);
314             String JavaDoc containerId= "Form";
315             boolean autoPositioning = true;
316             boolean lockDimension = false;
317             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
318                 new Rectangle JavaDoc(10, 40, 105, 23)
319                 };
320             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
321         }
322         // < MOVE
323
// > END MOVING
324
compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
325         ld.endMoving(true);
326         // < END MOVING
327
ld.externalSizeChangeHappened();
328         // > UPDATE CURRENT STATE
329
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
330         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
331         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
332         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(105, 23));
333         compBounds.put("jScrollPane1", new Rectangle JavaDoc(121, 11, 104, 64));
334         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
335         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(104, 64));
336         compBounds.put("jButton1", new Rectangle JavaDoc(10, 40, 105, 23));
337         baselinePosition.put("jButton1-105-23", new Integer JavaDoc(15));
338         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
339         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
340         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 105, 23));
341         baselinePosition.put("jToggleButton1-105-23", new Integer JavaDoc(15));
342         compBounds.put("jScrollPane1", new Rectangle JavaDoc(121, 11, 104, 64));
343         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
344         compBounds.put("jButton1", new Rectangle JavaDoc(10, 40, 105, 23));
345         baselinePosition.put("jButton1-105-23", new Integer JavaDoc(15));
346         ld.updateCurrentState();
347         // < UPDATE CURRENT STATE
348
}
349     
350 }
351
Popular Tags