KickJava   Java API By Example, From Geeks To Geeks.

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


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 creation of parallel group with suppressed resizing - should not
31
// revert alignment of the interval the added one aligns with. Plus the resizing
32
// should be enabled again when the interval which caused it is moved away.
33
public class ALT_ParallelPosition21Test extends LayoutTestCase {
34
35     public ALT_ParallelPosition21Test(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     // Add textarea snapped at the left border, bottom-aligned with list.
47
// This creates resizing gap pushing the textarea to the trailing edge, but
48
// list's alignment should remain leading.
49
public void doChanges0() {
50         ld.externalSizeChangeHappened();
51         // > UPDATE CURRENT STATE
52
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
53         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
54         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
55         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
56         compBounds.put("jScrollPane1", new Rectangle JavaDoc(157, 11, 37, 132));
57         baselinePosition.put("jScrollPane1-37-132", new Integer JavaDoc(0));
58         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(37, 132));
59         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
60         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
61         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
62         compBounds.put("jScrollPane1", new Rectangle JavaDoc(157, 11, 37, 132));
63         baselinePosition.put("jScrollPane1-37-132", new Integer JavaDoc(0));
64         ld.updateCurrentState();
65         // < UPDATE CURRENT STATE
66
lc = new LayoutComponent("jScrollPane2", false);
67         // > START ADDING
68
baselinePosition.put("jScrollPane2-104-64", new Integer JavaDoc(0));
69         {
70             LayoutComponent[] comps = new LayoutComponent[] { lc };
71             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
72                 new Rectangle JavaDoc(0, 0, 104, 64)
73                 };
74             String JavaDoc defaultContId = null;
75             Point JavaDoc hotspot = new Point JavaDoc(48,32);
76             ld.startAdding(comps, bounds, hotspot, defaultContId);
77         }
78         // < START ADDING
79
prefPaddingInParent.put("Form-jScrollPane2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
80
prefPaddingInParent.put("Form-jScrollPane2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
81
prefPadding.put("jLabel1-jScrollPane2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
82
prefPadding.put("jScrollPane2-jLabel1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
83
prefPaddingInParent.put("Form-jScrollPane2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
84
prefPaddingInParent.put("Form-jScrollPane2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
85
prefPadding.put("jScrollPane1-jScrollPane2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
86
prefPadding.put("jScrollPane2-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
87
// > MOVE
88
{
89             Point JavaDoc p = new Point JavaDoc(63,114);
90             String JavaDoc containerId= "Form";
91             boolean autoPositioning = true;
92             boolean lockDimension = false;
93             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
94                 new Rectangle JavaDoc(10, 79, 104, 64)
95                 };
96             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
97         }
98         // < MOVE
99
prefPaddingInParent.put("Form-jScrollPane2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
100
prefPaddingInParent.put("Form-jScrollPane2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
101
prefPadding.put("jLabel1-jScrollPane2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
102
prefPadding.put("jScrollPane2-jLabel1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
103
prefPaddingInParent.put("Form-jScrollPane2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
104
prefPaddingInParent.put("Form-jScrollPane2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
105
prefPadding.put("jScrollPane1-jScrollPane2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
106
prefPadding.put("jScrollPane2-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
107
// > MOVE
108
{
109             Point JavaDoc p = new Point JavaDoc(63,115);
110             String JavaDoc containerId= "Form";
111             boolean autoPositioning = true;
112             boolean lockDimension = false;
113             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
114                 new Rectangle JavaDoc(10, 79, 104, 64)
115                 };
116             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
117         }
118         // < MOVE
119
// > END MOVING
120
compPrefSize.put("jScrollPane2", new Dimension JavaDoc(104, 64));
121         compPrefSize.put("jScrollPane2", new Dimension JavaDoc(104, 64));
122         prefPadding.put("jScrollPane2-jScrollPane1-0-0-0", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
123
prefPadding.put("jLabel1-jScrollPane2-1-0-0", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
124
ld.endMoving(true);
125         // < END MOVING
126
ld.externalSizeChangeHappened();
127         // > UPDATE CURRENT STATE
128
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
129         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
130         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
131         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
132         compBounds.put("jScrollPane1", new Rectangle JavaDoc(157, 11, 37, 132));
133         baselinePosition.put("jScrollPane1-37-132", new Integer JavaDoc(0));
134         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(37, 132));
135         compBounds.put("jScrollPane2", new Rectangle JavaDoc(10, 79, 104, 64));
136         baselinePosition.put("jScrollPane2-104-64", new Integer JavaDoc(0));
137         compPrefSize.put("jScrollPane2", new Dimension JavaDoc(104, 64));
138         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
139         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
140         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
141         compBounds.put("jScrollPane1", new Rectangle JavaDoc(157, 11, 37, 132));
142         baselinePosition.put("jScrollPane1-37-132", new Integer JavaDoc(0));
143         compBounds.put("jScrollPane2", new Rectangle JavaDoc(10, 79, 104, 64));
144         baselinePosition.put("jScrollPane2-104-64", new Integer JavaDoc(0));
145         ld.updateCurrentState();
146         // < UPDATE CURRENT STATE
147
}
148
149     // Move textarea slightly downwards - so it's upper edge is still above
150
// the list's lower edge. The suppressed resizing on created parallel group
151
// from previous step should be enabled again.
152
public void doChanges1() {
153         // > START MOVING
154
baselinePosition.put("jScrollPane2-104-64", new Integer JavaDoc(0));
155         {
156             String JavaDoc[] compIds = new String JavaDoc[] {
157                 "jScrollPane2"
158                 };
159             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
160                 new Rectangle JavaDoc(10, 79, 104, 64)
161                 };
162             Point JavaDoc hotspot = new Point JavaDoc(59,115);
163             ld.startMoving(compIds, bounds, hotspot);
164         }
165         // < START MOVING
166
prefPaddingInParent.put("Form-jScrollPane2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
167
prefPaddingInParent.put("Form-jScrollPane2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
168
prefPadding.put("jLabel1-jScrollPane2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
169
prefPaddingInParent.put("Form-jScrollPane2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
170
prefPaddingInParent.put("Form-jScrollPane2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
171
prefPadding.put("jScrollPane1-jScrollPane2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
172
prefPadding.put("jScrollPane2-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
173
// > MOVE
174
{
175             Point JavaDoc p = new Point JavaDoc(58,146);
176             String JavaDoc containerId= "Form";
177             boolean autoPositioning = true;
178             boolean lockDimension = false;
179             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
180                 new Rectangle JavaDoc(10, 110, 104, 64)
181                 };
182             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
183         }
184         // < MOVE
185
prefPaddingInParent.put("Form-jScrollPane2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
186
prefPaddingInParent.put("Form-jScrollPane2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
187
prefPadding.put("jLabel1-jScrollPane2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
188
prefPaddingInParent.put("Form-jScrollPane2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
189
prefPaddingInParent.put("Form-jScrollPane2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
190
prefPadding.put("jScrollPane1-jScrollPane2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
191
prefPadding.put("jScrollPane2-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
192
// > MOVE
193
{
194             Point JavaDoc p = new Point JavaDoc(58,147);
195             String JavaDoc containerId= "Form";
196             boolean autoPositioning = true;
197             boolean lockDimension = false;
198             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
199                 new Rectangle JavaDoc(10, 111, 104, 64)
200                 };
201             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
202         }
203         // < MOVE
204
// > END MOVING
205
prefPadding.put("jLabel1-jScrollPane2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
206
prefPaddingInParent.put("Form-jScrollPane1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
207
prefPaddingInParent.put("Form-jScrollPane2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
208
prefPadding.put("jScrollPane2-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
209
ld.endMoving(true);
210         // < END MOVING
211
ld.externalSizeChangeHappened();
212         // > UPDATE CURRENT STATE
213
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
214         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
215         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
216         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
217         compBounds.put("jScrollPane1", new Rectangle JavaDoc(157, 11, 37, 132));
218         baselinePosition.put("jScrollPane1-37-132", new Integer JavaDoc(0));
219         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(37, 132));
220         compBounds.put("jScrollPane2", new Rectangle JavaDoc(10, 111, 104, 64));
221         baselinePosition.put("jScrollPane2-104-64", new Integer JavaDoc(0));
222         compPrefSize.put("jScrollPane2", new Dimension JavaDoc(104, 64));
223         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
224         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
225         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
226         compBounds.put("jScrollPane1", new Rectangle JavaDoc(157, 11, 37, 132));
227         baselinePosition.put("jScrollPane1-37-132", new Integer JavaDoc(0));
228         compBounds.put("jScrollPane2", new Rectangle JavaDoc(10, 111, 104, 64));
229         baselinePosition.put("jScrollPane2-104-64", new Integer JavaDoc(0));
230         ld.updateCurrentState();
231         // < UPDATE CURRENT STATE
232
}
233     
234 }
235
Popular Tags