KickJava   Java API By Example, From Geeks To Geeks.

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


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 sequential merging in an edge situation. Original parallel position
31
// needs to be merged with sequential position out of the parallel group.
32
public class ALT_Resizing09Test extends LayoutTestCase {
33
34     public ALT_Resizing09Test(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     // Resize the first textfield to the left to snap next to the label.
46
public void doChanges0() {
47         ld.externalSizeChangeHappened();
48         // > UPDATE CURRENT STATE
49
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
50         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 40, 68, 14));
51         baselinePosition.put("jLabel2-68-14", new Integer JavaDoc(11));
52         compPrefSize.put("jLabel2", new Dimension JavaDoc(68, 14));
53         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
54         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
55         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
56         compBounds.put("jTextField2", new Rectangle JavaDoc(82, 11, 90, 20));
57         baselinePosition.put("jTextField2-90-20", new Integer JavaDoc(14));
58         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
59         compBounds.put("jTextField1", new Rectangle JavaDoc(82, 37, 90, 20));
60         baselinePosition.put("jTextField1-90-20", new Integer JavaDoc(14));
61         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
62         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
63         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 40, 68, 14));
64         baselinePosition.put("jLabel2-68-14", new Integer JavaDoc(11));
65         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
66         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
67         compBounds.put("jTextField2", new Rectangle JavaDoc(82, 11, 90, 20));
68         baselinePosition.put("jTextField2-90-20", new Integer JavaDoc(14));
69         compBounds.put("jTextField1", new Rectangle JavaDoc(82, 37, 90, 20));
70         baselinePosition.put("jTextField1-90-20", new Integer JavaDoc(14));
71         ld.updateCurrentState();
72         // < UPDATE CURRENT STATE
73
// > START RESIZING
74
baselinePosition.put("jTextField2-90-20", new Integer JavaDoc(14));
75         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
76         {
77             String JavaDoc[] compIds = new String JavaDoc[] {
78                 "jTextField2"
79                 };
80             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
81                 new Rectangle JavaDoc(82, 11, 90, 20)
82                 };
83             Point JavaDoc hotspot = new Point JavaDoc(82,22);
84             int[] resizeEdges = new int[] {
85                 0,
86                     -1
87                 };
88             boolean inLayout = true;
89             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
90         }
91         // < START RESIZING
92
prefPadding.put("jLabel1-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
93
// > MOVE
94
{
95             Point JavaDoc p = new Point JavaDoc(52,20);
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, 124, 20)
101                 };
102             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
103         }
104         // < MOVE
105
prefPadding.put("jLabel1-jTextField2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
106
// > MOVE
107
{
108             Point JavaDoc p = new Point JavaDoc(51,20);
109             String JavaDoc containerId= "Form";
110             boolean autoPositioning = true;
111             boolean lockDimension = false;
112             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
113                 new Rectangle JavaDoc(48, 11, 124, 20)
114                 };
115             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
116         }
117         // < MOVE
118
// > END MOVING
119
ld.endMoving(true);
120         // < END MOVING
121
ld.externalSizeChangeHappened();
122         // > UPDATE CURRENT STATE
123
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
124         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 40, 68, 14));
125         baselinePosition.put("jLabel2-68-14", new Integer JavaDoc(11));
126         compPrefSize.put("jLabel2", new Dimension JavaDoc(68, 14));
127         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
128         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
129         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
130         compBounds.put("jTextField1", new Rectangle JavaDoc(82, 37, 90, 20));
131         baselinePosition.put("jTextField1-90-20", new Integer JavaDoc(14));
132         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
133         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 11, 124, 20));
134         baselinePosition.put("jTextField2-124-20", new Integer JavaDoc(14));
135         compPrefSize.put("jTextField2", new Dimension JavaDoc(59, 20));
136         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
137         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 40, 68, 14));
138         baselinePosition.put("jLabel2-68-14", new Integer JavaDoc(11));
139         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
140         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
141         compBounds.put("jTextField1", new Rectangle JavaDoc(82, 37, 90, 20));
142         baselinePosition.put("jTextField1-90-20", new Integer JavaDoc(14));
143         compBounds.put("jTextField2", new Rectangle JavaDoc(48, 11, 124, 20));
144         baselinePosition.put("jTextField2-124-20", new Integer JavaDoc(14));
145         ld.updateCurrentState();
146         // < UPDATE CURRENT STATE
147
}
148     
149 }
150
Popular Tags