KickJava   Java API By Example, From Geeks To Geeks.

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


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 adjusting current space of group when outermost component is removed.
31
public class ALT_Move01Test extends LayoutTestCase {
32
33     public ALT_Move01Test(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 second textfield slightly to the right - right of the first
45
// textfield, but still the left edge within bounds of the original
46
// parallel group. Keep baseline with label.
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(10, 14, 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(48, 11, 59, 20));
55         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
56         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
57         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
58         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
59         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
60         compBounds.put("jTextField2", new Rectangle JavaDoc(70, 37, 59, 20));
61         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
62         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
63         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
64         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
65         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
66         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
67         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
68         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
69         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
70         compBounds.put("jTextField2", new Rectangle JavaDoc(70, 37, 59, 20));
71         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
72         ld.updateCurrentState();
73         // < UPDATE CURRENT STATE
74
// > START MOVING
75
baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
76         {
77             String JavaDoc[] compIds = new String JavaDoc[] {
78                 "jTextField2"
79                 };
80             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
81                 new Rectangle JavaDoc(70, 37, 59, 20)
82                 };
83             Point JavaDoc hotspot = new Point JavaDoc(100,44);
84             ld.startMoving(compIds, bounds, hotspot);
85         }
86         // < START MOVING
87
prefPaddingInParent.put("Form-jTextField2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
88
prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
89
prefPaddingInParent.put("Form-jTextField2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
90
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
91
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
92
prefPadding.put("jLabel1-jTextField2-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
93
prefPadding.put("jTextField1-jTextField2-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
94
// > MOVE
95
{
96             Point JavaDoc p = new Point JavaDoc(138,40);
97             String JavaDoc containerId= "Form";
98             boolean autoPositioning = true;
99             boolean lockDimension = false;
100             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
101                 new Rectangle JavaDoc(108, 37, 59, 20)
102                 };
103             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
104         }
105         // < MOVE
106
prefPaddingInParent.put("Form-jTextField2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
107
prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
108
prefPaddingInParent.put("Form-jTextField2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
109
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
110
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
111
prefPadding.put("jLabel1-jTextField2-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
112
prefPadding.put("jTextField1-jTextField2-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
113
// > MOVE
114
{
115             Point JavaDoc p = new Point JavaDoc(139,40);
116             String JavaDoc containerId= "Form";
117             boolean autoPositioning = true;
118             boolean lockDimension = false;
119             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
120                 new Rectangle JavaDoc(109, 37, 59, 20)
121                 };
122             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
123         }
124         // < MOVE
125
// > END MOVING
126
prefPadding.put("jTextField1-jTextField2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
127
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
128
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
129
ld.endMoving(true);
130         // < END MOVING
131
ld.externalSizeChangeHappened();
132         // > UPDATE CURRENT STATE
133
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
134         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
135         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
136         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
137         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
138         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
139         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
140         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
141         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
142         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
143         compBounds.put("jTextField2", new Rectangle JavaDoc(109, 37, 59, 20));
144         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
145         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
146         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
147         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
148         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
149         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
150         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
151         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
152         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
153         compBounds.put("jTextField2", new Rectangle JavaDoc(109, 37, 59, 20));
154         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
155         ld.updateCurrentState();
156         // < UPDATE CURRENT STATE
157
}
158
159     // Move the second textfield right of its right edge, but still with fixed
160
// gap.
161
public void doChanges1() {
162         // > START MOVING
163
baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
164         {
165             String JavaDoc[] compIds = new String JavaDoc[] {
166                 "jTextField2"
167                 };
168             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
169                 new Rectangle JavaDoc(109, 37, 59, 20)
170                 };
171             Point JavaDoc hotspot = new Point JavaDoc(138,46);
172             ld.startMoving(compIds, bounds, hotspot);
173         }
174         // < START MOVING
175
prefPaddingInParent.put("Form-jTextField2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
176
prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
177
prefPaddingInParent.put("Form-jTextField2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
178
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
179
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
180
// > MOVE
181
{
182             Point JavaDoc p = new Point JavaDoc(224,47);
183             String JavaDoc containerId= "Form";
184             boolean autoPositioning = true;
185             boolean lockDimension = false;
186             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
187                 new Rectangle JavaDoc(195, 37, 59, 20)
188                 };
189             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
190         }
191         // < MOVE
192
prefPaddingInParent.put("Form-jTextField2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
193
prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
194
prefPaddingInParent.put("Form-jTextField2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
195
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
196
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
197
// > MOVE
198
{
199             Point JavaDoc p = new Point JavaDoc(225,47);
200             String JavaDoc containerId= "Form";
201             boolean autoPositioning = true;
202             boolean lockDimension = false;
203             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
204                 new Rectangle JavaDoc(196, 37, 59, 20)
205                 };
206             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
207         }
208         // < MOVE
209
// > END MOVING
210
prefPadding.put("jTextField1-jTextField2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
211
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
212
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
213
ld.endMoving(true);
214         // < END MOVING
215
ld.externalSizeChangeHappened();
216         // > UPDATE CURRENT STATE
217
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
218         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
219         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
220         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
221         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
222         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
223         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
224         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
225         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
226         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
227         compBounds.put("jTextField2", new Rectangle JavaDoc(196, 37, 59, 20));
228         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
229         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
230         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
231         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
232         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
233         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
234         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
235         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
236         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
237         compBounds.put("jTextField2", new Rectangle JavaDoc(196, 37, 59, 20));
238         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
239         ld.updateCurrentState();
240         // < UPDATE CURRENT STATE
241
}
242
243     // Move the textfield to the right - almost to the right border, but don't
244
// snap.
245
public void doChanges2() {
246         // > START MOVING
247
baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
248         {
249             String JavaDoc[] compIds = new String JavaDoc[] {
250                 "jTextField2"
251                 };
252             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
253                 new Rectangle JavaDoc(196, 37, 59, 20)
254                 };
255             Point JavaDoc hotspot = new Point JavaDoc(214,49);
256             ld.startMoving(compIds, bounds, hotspot);
257         }
258         // < START MOVING
259
prefPaddingInParent.put("Form-jTextField2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
260
prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
261
prefPaddingInParent.put("Form-jTextField2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
262
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
263
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
264
// > MOVE
265
{
266             Point JavaDoc p = new Point JavaDoc(340,50);
267             String JavaDoc containerId= "Form";
268             boolean autoPositioning = true;
269             boolean lockDimension = false;
270             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
271                 new Rectangle JavaDoc(322, 37, 59, 20)
272                 };
273             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
274         }
275         // < MOVE
276
prefPaddingInParent.put("Form-jTextField2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
277
prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
278
prefPaddingInParent.put("Form-jTextField2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
279
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
280
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
281
// > MOVE
282
{
283             Point JavaDoc p = new Point JavaDoc(339,50);
284             String JavaDoc containerId= "Form";
285             boolean autoPositioning = true;
286             boolean lockDimension = false;
287             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
288                 new Rectangle JavaDoc(321, 37, 59, 20)
289                 };
290             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
291         }
292         // < MOVE
293
// > END MOVING
294
prefPadding.put("jTextField1-jTextField2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
295
prefPadding.put("jLabel2-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
296
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
297
ld.endMoving(true);
298         // < END MOVING
299
ld.externalSizeChangeHappened();
300         // > UPDATE CURRENT STATE
301
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
302         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
303         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
304         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
305         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
306         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
307         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
308         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
309         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
310         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
311         compBounds.put("jTextField2", new Rectangle JavaDoc(321, 37, 59, 20));
312         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
313         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
314         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
315         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
316         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
317         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
318         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
319         compBounds.put("jLabel2", new Rectangle JavaDoc(32, 40, 34, 14));
320         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
321         compBounds.put("jTextField2", new Rectangle JavaDoc(321, 37, 59, 20));
322         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
323         ld.updateCurrentState();
324         // < UPDATE CURRENT STATE
325
}
326     
327 }
328
Popular Tags