KickJava   Java API By Example, From Geeks To Geeks.

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


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