KickJava   Java API By Example, From Geeks To Geeks.

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


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 vertical resizing of components aligned at baseline.
31
public class ALT_Baseline01Test extends LayoutTestCase {
32
33     public ALT_Baseline01Test(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     // Resize jTextField1 downwards.
45
public void doChanges0() {
46         ld.externalSizeChangeHappened();
47         // > UPDATE CURRENT STATE
48
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
49         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
50         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
51         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
52         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
53         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
54         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
55         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 40, 34, 14));
56         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
57         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
58         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 37, 59, 20));
59         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
60         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
61         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
62         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
63         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
64         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
65         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
66         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 40, 34, 14));
67         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
68         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 37, 59, 20));
69         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
70         ld.updateCurrentState();
71         // < UPDATE CURRENT STATE
72
// > START RESIZING
73
baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
74         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
75         {
76             String JavaDoc[] compIds = new String JavaDoc[] {
77                 "jTextField1"
78                 };
79             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
80                 new Rectangle JavaDoc(48, 11, 59, 20)
81                 };
82             Point JavaDoc hotspot = new Point JavaDoc(77,29);
83             int[] resizeEdges = new int[] {
84                 -1,
85                     1
86                 };
87             boolean inLayout = true;
88             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
89         }
90         // < START RESIZING
91
prefPadding.put("jTextField1-jLabel2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
92
prefPadding.put("jTextField1-jTextField2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
93
// > MOVE
94
{
95             Point JavaDoc p = new Point JavaDoc(78,63);
96             String JavaDoc containerId= "Form";
97             boolean autoPositioning = true;
98             boolean lockDimension = false;
99             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
100                 new Rectangle JavaDoc(48, 11, 59, 54)
101                 };
102             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
103         }
104         // < MOVE
105
prefPadding.put("jTextField1-jLabel2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
106
prefPadding.put("jTextField1-jTextField2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
107
// > MOVE
108
{
109             Point JavaDoc p = new Point JavaDoc(78,64);
110             String JavaDoc containerId= "Form";
111             boolean autoPositioning = true;
112             boolean lockDimension = false;
113             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
114                 new Rectangle JavaDoc(48, 11, 59, 55)
115                 };
116             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
117         }
118         // < MOVE
119
// > END MOVING
120
ld.endMoving(true);
121         // < END MOVING
122
ld.externalSizeChangeHappened();
123         // > UPDATE CURRENT STATE
124
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
125         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 31, 34, 14));
126         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
127         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
128         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 75, 34, 14));
129         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
130         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
131         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 72, 59, 20));
132         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
133         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
134         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 55));
135         baselinePosition.put("jTextField1-59-55", new Integer JavaDoc(31));
136         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
137         prefPaddingInParent.put("Form-jLabel2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
138
prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
139
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
140         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 31, 34, 14));
141         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
142         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 75, 34, 14));
143         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
144         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 72, 59, 20));
145         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
146         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 55));
147         baselinePosition.put("jTextField1-59-55", new Integer JavaDoc(31));
148         ld.updateCurrentState();
149         // < UPDATE CURRENT STATE
150
}
151
152     // Resize jLabel2 downwards.
153
public void doChanges1() {
154         // > START RESIZING
155
baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
156         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
157         {
158             String JavaDoc[] compIds = new String JavaDoc[] {
159                 "jLabel2"
160                 };
161             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
162                 new Rectangle JavaDoc(10, 75, 34, 14)
163                 };
164             Point JavaDoc hotspot = new Point JavaDoc(32,91);
165             int[] resizeEdges = new int[] {
166                 -1,
167                     1
168                 };
169             boolean inLayout = true;
170             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
171         }
172         // < START RESIZING
173
prefPaddingInParent.put("Form-jLabel2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
174
// > MOVE
175
{
176             Point JavaDoc p = new Point JavaDoc(30,130);
177             String JavaDoc containerId= "Form";
178             boolean autoPositioning = true;
179             boolean lockDimension = false;
180             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
181                 new Rectangle JavaDoc(10, 75, 34, 53)
182                 };
183             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
184         }
185         // < MOVE
186
prefPaddingInParent.put("Form-jLabel2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
187
// > MOVE
188
{
189             Point JavaDoc p = new Point JavaDoc(30,131);
190             String JavaDoc containerId= "Form";
191             boolean autoPositioning = true;
192             boolean lockDimension = false;
193             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
194                 new Rectangle JavaDoc(10, 75, 34, 54)
195                 };
196             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
197         }
198         // < MOVE
199
// > END MOVING
200
ld.endMoving(true);
201         // < END MOVING
202
ld.externalSizeChangeHappened();
203         // > UPDATE CURRENT STATE
204
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
205         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 31, 34, 14));
206         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
207         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
208         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 89, 59, 20));
209         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
210         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
211         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 55));
212         baselinePosition.put("jTextField1-59-55", new Integer JavaDoc(31));
213         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
214         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 72, 34, 54));
215         baselinePosition.put("jLabel2-34-54", new Integer JavaDoc(31));
216         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
217         prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
218
prefPaddingInParent.put("Form-jLabel2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
219
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
220         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 31, 34, 14));
221         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
222         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 89, 59, 20));
223         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
224         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 55));
225         baselinePosition.put("jTextField1-59-55", new Integer JavaDoc(31));
226         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 72, 34, 54));
227         baselinePosition.put("jLabel2-34-54", new Integer JavaDoc(31));
228         ld.updateCurrentState();
229         // < UPDATE CURRENT STATE
230
}
231     
232 }
233
Popular Tags