KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class ALT_ParallelPosition01Test extends LayoutTestCase {
31
32     public ALT_ParallelPosition01Test(String JavaDoc name) {
33         super(name);
34         try {
35         className = this.getClass().getName();
36         className = className.substring(className.lastIndexOf('.') + 1, className.length());
37             startingFormFile = FileUtil.toFileObject(new File JavaDoc(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
38         } catch (IOException JavaDoc ioe) {
39             fail(ioe.toString());
40         }
41     }
42
43     // Resize first textfield to the right, then second textfield to align at
44
// at the same size with the first one. Both textfields should be made
45
// resizing and the parallel group fixed. Note the parallel group remains
46
// one for all components - which is a bit controversial, but perhaps better
47
// for the user (see the Find dialog case).
48
public void doChanges0() {
49         ld.externalSizeChangeHappened();
50         // > UPDATE CURRENT STATE
51
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
52         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
53         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
54         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
55         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 59, 20));
56         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
57         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
58         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
59         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
60         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
61         compBounds.put("jTextField2", new Rectangle JavaDoc(20, 77, 59, 20));
62         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
63         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
64         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
65         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
66         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
67         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 59, 20));
68         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
69         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
70         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
71         compBounds.put("jTextField2", new Rectangle JavaDoc(20, 77, 59, 20));
72         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
73         ld.updateCurrentState();
74         // < UPDATE CURRENT STATE
75
// > START RESIZING
76
baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
77         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
78         {
79             String JavaDoc[] compIds = new String JavaDoc[] {
80                 "jTextField1"
81                 };
82             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
83                 new Rectangle JavaDoc(20, 31, 59, 20)
84                 };
85             Point JavaDoc hotspot = new Point JavaDoc(80,43);
86             int[] resizeEdges = new int[] {
87                 1,
88                     -1
89                 };
90             boolean inLayout = true;
91             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
92         }
93         // < START RESIZING
94
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
95
// > MOVE
96
{
97             Point JavaDoc p = new Point JavaDoc(121,43);
98             String JavaDoc containerId= "Form";
99             boolean autoPositioning = true;
100             boolean lockDimension = false;
101             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
102                 new Rectangle JavaDoc(20, 31, 100, 20)
103                 };
104             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
105         }
106         // < MOVE
107
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
108
// > MOVE
109
{
110             Point JavaDoc p = new Point JavaDoc(122,43);
111             String JavaDoc containerId= "Form";
112             boolean autoPositioning = true;
113             boolean lockDimension = false;
114             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
115                 new Rectangle JavaDoc(20, 31, 101, 20)
116                 };
117             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
118         }
119         // < MOVE
120
// > END MOVING
121
prefPaddingInParent.put("Form-jLabel1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
122
prefPaddingInParent.put("Form-jLabel2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
123
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
124
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
125
ld.endMoving(true);
126         // < END MOVING
127
ld.externalSizeChangeHappened();
128         // > UPDATE CURRENT STATE
129
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
130         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
131         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
132         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
133         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
134         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
135         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
136         compBounds.put("jTextField2", new Rectangle JavaDoc(20, 77, 59, 20));
137         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
138         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
139         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 101, 20));
140         baselinePosition.put("jTextField1-101-20", new Integer JavaDoc(14));
141         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
142         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
143         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
144         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
145         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
146         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
147         compBounds.put("jTextField2", new Rectangle JavaDoc(20, 77, 59, 20));
148         baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
149         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 101, 20));
150         baselinePosition.put("jTextField1-101-20", new Integer JavaDoc(14));
151         ld.updateCurrentState();
152         // < UPDATE CURRENT STATE
153
// > START RESIZING
154
baselinePosition.put("jTextField2-59-20", new Integer JavaDoc(14));
155         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
156         {
157             String JavaDoc[] compIds = new String JavaDoc[] {
158                 "jTextField2"
159                 };
160             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
161                 new Rectangle JavaDoc(20, 77, 59, 20)
162                 };
163             Point JavaDoc hotspot = new Point JavaDoc(80,87);
164             int[] resizeEdges = new int[] {
165                 1,
166                     -1
167                 };
168             boolean inLayout = true;
169             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
170         }
171         // < START RESIZING
172
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
173
// > MOVE
174
{
175             Point JavaDoc p = new Point JavaDoc(116,88);
176             String JavaDoc containerId= "Form";
177             boolean autoPositioning = true;
178             boolean lockDimension = false;
179             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
180                 new Rectangle JavaDoc(20, 77, 101, 20)
181                 };
182             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
183         }
184         // < MOVE
185
prefPaddingInParent.put("Form-jTextField2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
186
// > MOVE
187
{
188             Point JavaDoc p = new Point JavaDoc(117,88);
189             String JavaDoc containerId= "Form";
190             boolean autoPositioning = true;
191             boolean lockDimension = false;
192             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
193                 new Rectangle JavaDoc(20, 77, 101, 20)
194                 };
195             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
196         }
197         // < MOVE
198
// > END MOVING
199
compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
200         prefPaddingInParent.put("Form-jTextField2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
201
ld.endMoving(true);
202         // < END MOVING
203
ld.externalSizeChangeHappened();
204         // > UPDATE CURRENT STATE
205
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
206         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
207         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
208         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
209         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
210         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
211         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
212         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 101, 20));
213         baselinePosition.put("jTextField1-101-20", new Integer JavaDoc(14));
214         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
215         compBounds.put("jTextField2", new Rectangle JavaDoc(20, 77, 101, 20));
216         baselinePosition.put("jTextField2-101-20", new Integer JavaDoc(14));
217         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
218         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
219         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
220         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
221         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
222         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
223         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 101, 20));
224         baselinePosition.put("jTextField1-101-20", new Integer JavaDoc(14));
225         compBounds.put("jTextField2", new Rectangle JavaDoc(20, 77, 101, 20));
226         baselinePosition.put("jTextField2-101-20", new Integer JavaDoc(14));
227         ld.updateCurrentState();
228         // < UPDATE CURRENT STATE
229
}
230     
231 }
232
Popular Tags