KickJava   Java API By Example, From Geeks To Geeks.

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


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 // Resizing without snapping.
31
public class ALT_Resizing07Test extends LayoutTestCase {
32
33     public ALT_Resizing07Test(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 textfield slightly to the left, then to the right - almost to the
45
// right border but still without snapping. Effective alignment should not change.
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("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
51         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
52         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
53         compBounds.put("jTextField1", new Rectangle JavaDoc(103, 11, 59, 20));
54         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
55         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
56         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
57         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
58         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
59         compBounds.put("jTextField1", new Rectangle JavaDoc(103, 11, 59, 20));
60         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
61         ld.updateCurrentState();
62         // < UPDATE CURRENT STATE
63
// > START RESIZING
64
baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
65         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
66         {
67             String JavaDoc[] compIds = new String JavaDoc[] {
68                 "jTextField1"
69                 };
70             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
71                 new Rectangle JavaDoc(103, 11, 59, 20)
72                 };
73             Point JavaDoc hotspot = new Point JavaDoc(102,19);
74             int[] resizeEdges = new int[] {
75                 0,
76                     -1
77                 };
78             boolean inLayout = true;
79             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
80         }
81         // < START RESIZING
82
prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
83
// > MOVE
84
{
85             Point JavaDoc p = new Point JavaDoc(89,22);
86             String JavaDoc containerId= "Form";
87             boolean autoPositioning = true;
88             boolean lockDimension = false;
89             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
90                 new Rectangle JavaDoc(90, 11, 72, 20)
91                 };
92             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
93         }
94         // < MOVE
95
prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
96
// > MOVE
97
{
98             Point JavaDoc p = new Point JavaDoc(88,22);
99             String JavaDoc containerId= "Form";
100             boolean autoPositioning = true;
101             boolean lockDimension = false;
102             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
103                 new Rectangle JavaDoc(89, 11, 73, 20)
104                 };
105             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
106         }
107         // < MOVE
108
// > END MOVING
109
prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
110
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
111
ld.endMoving(true);
112         // < END MOVING
113
ld.externalSizeChangeHappened();
114         // > UPDATE CURRENT STATE
115
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
116         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
117         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
118         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
119         compBounds.put("jTextField1", new Rectangle JavaDoc(89, 11, 73, 20));
120         baselinePosition.put("jTextField1-73-20", new Integer JavaDoc(14));
121         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
122         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
123         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
124         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
125         compBounds.put("jTextField1", new Rectangle JavaDoc(89, 11, 73, 20));
126         baselinePosition.put("jTextField1-73-20", new Integer JavaDoc(14));
127         ld.updateCurrentState();
128         // < UPDATE CURRENT STATE
129
// > START RESIZING
130
baselinePosition.put("jTextField1-73-20", new Integer JavaDoc(14));
131         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
132         {
133             String JavaDoc[] compIds = new String JavaDoc[] {
134                 "jTextField1"
135                 };
136             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
137                 new Rectangle JavaDoc(89, 11, 73, 20)
138                 };
139             Point JavaDoc hotspot = new Point JavaDoc(161,18);
140             int[] resizeEdges = new int[] {
141                 1,
142                     -1
143                 };
144             boolean inLayout = true;
145             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
146         }
147         // < START RESIZING
148
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
149
// > MOVE
150
{
151             Point JavaDoc p = new Point JavaDoc(380,24);
152             String JavaDoc containerId= "Form";
153             boolean autoPositioning = true;
154             boolean lockDimension = false;
155             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
156                 new Rectangle JavaDoc(89, 11, 292, 20)
157                 };
158             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
159         }
160         // < MOVE
161
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
162
// > MOVE
163
{
164             Point JavaDoc p = new Point JavaDoc(379,24);
165             String JavaDoc containerId= "Form";
166             boolean autoPositioning = true;
167             boolean lockDimension = false;
168             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
169                 new Rectangle JavaDoc(89, 11, 291, 20)
170                 };
171             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
172         }
173         // < MOVE
174
// > END MOVING
175
prefPadding.put("jLabel1-jTextField1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
176
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
177
ld.endMoving(true);
178         // < END MOVING
179
ld.externalSizeChangeHappened();
180         // > UPDATE CURRENT STATE
181
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
182         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
183         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
184         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
185         compBounds.put("jTextField1", new Rectangle JavaDoc(89, 11, 291, 20));
186         baselinePosition.put("jTextField1-291-20", new Integer JavaDoc(14));
187         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
188         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
189         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
190         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
191         compBounds.put("jTextField1", new Rectangle JavaDoc(89, 11, 291, 20));
192         baselinePosition.put("jTextField1-291-20", new Integer JavaDoc(14));
193         ld.updateCurrentState();
194         // < UPDATE CURRENT STATE
195
}
196     
197 }
198
Popular Tags