KickJava   Java API By Example, From Geeks To Geeks.

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


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 subordinate resizing interval (creating fixed parallel group).
31
// Once component indented, added as first. Then resized with no res. effect.
32
public class ALT_ParallelPosition08Test extends LayoutTestCase {
33
34     public ALT_ParallelPosition08Test(String JavaDoc name) {
35         super(name);
36         try {
37         className = this.getClass().getName();
38         className = className.substring(className.lastIndexOf('.') + 1, className.length());
39             startingFormFile = FileUtil.toFileObject(new File JavaDoc(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
40         } catch (IOException JavaDoc ioe) {
41             fail(ioe.toString());
42         }
43     }
44
45     // Add two buttons below the toggle button. First one with left indent,
46
// second one right aligned with the toggle button.
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("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
52         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
53         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(179, 23));
54         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
55         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
56         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
57         ld.updateCurrentState();
58         // < UPDATE CURRENT STATE
59
lc = new LayoutComponent("jButton1", false);
60         // > START ADDING
61
baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
62         {
63             LayoutComponent[] comps = new LayoutComponent[] { lc };
64             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
65                 new Rectangle JavaDoc(0, 0, 75, 23)
66                 };
67             String JavaDoc defaultContId = null;
68             Point JavaDoc hotspot = new Point JavaDoc(33,11);
69             ld.startAdding(comps, bounds, hotspot, defaultContId);
70         }
71         // < START ADDING
72
prefPaddingInParent.put("Form-jButton1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
73
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
74
prefPadding.put("jToggleButton1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
75
prefPadding.put("jButton1-jToggleButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
76
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
77
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
78
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
79
// > MOVE
80
{
81             Point JavaDoc p = new Point JavaDoc(58,55);
82             String JavaDoc containerId= "Form";
83             boolean autoPositioning = true;
84             boolean lockDimension = false;
85             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
86                 new Rectangle JavaDoc(20, 40, 75, 23)
87                 };
88             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
89         }
90         // < MOVE
91
prefPaddingInParent.put("Form-jButton1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
92
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
93
prefPadding.put("jToggleButton1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
94
prefPadding.put("jButton1-jToggleButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
95
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
96
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
97
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
98
// > MOVE
99
{
100             Point JavaDoc p = new Point JavaDoc(58,54);
101             String JavaDoc containerId= "Form";
102             boolean autoPositioning = true;
103             boolean lockDimension = false;
104             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
105                 new Rectangle JavaDoc(20, 40, 75, 23)
106                 };
107             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
108         }
109         // < MOVE
110
// > END MOVING
111
compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
112         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
113         prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
114
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
115
ld.endMoving(true);
116         // < END MOVING
117
ld.externalSizeChangeHappened();
118         // > UPDATE CURRENT STATE
119
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
120         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
121         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
122         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(179, 23));
123         compBounds.put("jButton1", new Rectangle JavaDoc(20, 40, 75, 23));
124         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
125         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
126         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
127         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
128         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
129         compBounds.put("jButton1", new Rectangle JavaDoc(20, 40, 75, 23));
130         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
131         ld.updateCurrentState();
132         // < UPDATE CURRENT STATE
133
lc = new LayoutComponent("jButton2", false);
134         // > START ADDING
135
baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
136         {
137             LayoutComponent[] comps = new LayoutComponent[] { lc };
138             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
139                 new Rectangle JavaDoc(20, 40, 75, 23)
140                 };
141             String JavaDoc defaultContId= "Form";
142             Point JavaDoc hotspot = new Point JavaDoc(53,51);
143             ld.startAdding(comps, bounds, hotspot, defaultContId);
144         }
145         // < START ADDING
146
prefPaddingInParent.put("Form-jButton2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
147
prefPaddingInParent.put("Form-jButton2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
148
prefPadding.put("jToggleButton1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
149
prefPadding.put("jButton2-jToggleButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
150
prefPaddingInParent.put("Form-jButton2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
151
prefPaddingInParent.put("Form-jButton2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
152
prefPadding.put("jButton1-jButton2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
153
prefPadding.put("jButton2-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
154
prefPadding.put("jToggleButton1-jButton2-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
155
// > MOVE
156
{
157             Point JavaDoc p = new Point JavaDoc(145,54);
158             String JavaDoc containerId= "Form";
159             boolean autoPositioning = true;
160             boolean lockDimension = false;
161             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
162                 new Rectangle JavaDoc(114, 40, 75, 23)
163                 };
164             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
165         }
166         // < MOVE
167
prefPaddingInParent.put("Form-jButton2-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
168
prefPaddingInParent.put("Form-jButton2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
169
prefPadding.put("jToggleButton1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
170
prefPadding.put("jButton2-jToggleButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
171
prefPaddingInParent.put("Form-jButton2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
172
prefPaddingInParent.put("Form-jButton2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
173
prefPadding.put("jButton1-jButton2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
174
prefPadding.put("jButton2-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
175
prefPadding.put("jToggleButton1-jButton2-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
176
// > MOVE
177
{
178             Point JavaDoc p = new Point JavaDoc(146,54);
179             String JavaDoc containerId= "Form";
180             boolean autoPositioning = true;
181             boolean lockDimension = false;
182             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
183                 new Rectangle JavaDoc(114, 40, 75, 23)
184                 };
185             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
186         }
187         // < MOVE
188
// > END MOVING
189
compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
190         compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
191         prefPadding.put("jButton1-jButton2-0-0-0", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
192
ld.endMoving(true);
193         // < END MOVING
194
ld.externalSizeChangeHappened();
195         // > UPDATE CURRENT STATE
196
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
197         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
198         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
199         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(179, 23));
200         compBounds.put("jButton1", new Rectangle JavaDoc(20, 40, 75, 23));
201         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
202         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
203         compBounds.put("jButton2", new Rectangle JavaDoc(114, 40, 75, 23));
204         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
205         compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
206         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
207         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
208         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
209         compBounds.put("jButton1", new Rectangle JavaDoc(20, 40, 75, 23));
210         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
211         compBounds.put("jButton2", new Rectangle JavaDoc(114, 40, 75, 23));
212         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
213         ld.updateCurrentState();
214         // < UPDATE CURRENT STATE
215
}
216
217     // Resize the left button to left-align with toggle button.
218
public void doChanges1() {
219         // > START RESIZING
220
baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
221         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
222         {
223             String JavaDoc[] compIds = new String JavaDoc[] {
224                 "jButton1"
225                 };
226             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
227                 new Rectangle JavaDoc(20, 40, 75, 23)
228                 };
229             Point JavaDoc hotspot = new Point JavaDoc(21,50);
230             int[] resizeEdges = new int[] {
231                 0,
232                     -1
233                 };
234             boolean inLayout = true;
235             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
236         }
237         // < START RESIZING
238
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
239
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
240
// > MOVE
241
{
242             Point JavaDoc p = new Point JavaDoc(14,51);
243             String JavaDoc containerId= "Form";
244             boolean autoPositioning = true;
245             boolean lockDimension = false;
246             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
247                 new Rectangle JavaDoc(10, 40, 85, 23)
248                 };
249             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
250         }
251         // < MOVE
252
prefPaddingInParent.put("Form-jButton1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
253
prefPadding.put("jToggleButton1-jButton1-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
254
// > MOVE
255
{
256             Point JavaDoc p = new Point JavaDoc(13,51);
257             String JavaDoc containerId= "Form";
258             boolean autoPositioning = true;
259             boolean lockDimension = false;
260             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
261                 new Rectangle JavaDoc(10, 40, 85, 23)
262                 };
263             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
264         }
265         // < MOVE
266
// > END MOVING
267
prefPadding.put("jButton1-jButton2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
268
ld.endMoving(true);
269         // < END MOVING
270
ld.externalSizeChangeHappened();
271         // > UPDATE CURRENT STATE
272
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
273         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
274         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
275         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(179, 23));
276         compBounds.put("jButton2", new Rectangle JavaDoc(114, 40, 75, 23));
277         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
278         compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
279         compBounds.put("jButton1", new Rectangle JavaDoc(10, 40, 85, 23));
280         baselinePosition.put("jButton1-85-23", new Integer JavaDoc(15));
281         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
282         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
283         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
284         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
285         compBounds.put("jButton2", new Rectangle JavaDoc(114, 40, 75, 23));
286         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
287         compBounds.put("jButton1", new Rectangle JavaDoc(10, 40, 85, 23));
288         baselinePosition.put("jButton1-85-23", new Integer JavaDoc(15));
289         ld.updateCurrentState();
290         // < UPDATE CURRENT STATE
291
}
292     
293 }
294
Popular Tags