KickJava   Java API By Example, From Geeks To Geeks.

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


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.HashMap JavaDoc;
28 import org.openide.filesystems.FileObject;
29 import org.openide.filesystems.FileUtil;
30 import org.netbeans.modules.form.RADComponent;
31
32 public class ALT_Resizing01Test extends LayoutTestCase {
33
34     public ALT_Resizing01Test(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 JInternalFrame down-right from its default size to snap to other components
46
// (jTextArea1 and jButton2).
47
public void doChanges0() {
48         ld.externalSizeChangeHappened();
49         // > UPDATE CURRENT STATE
50
contInterior.put("jInternalFrame1", new Rectangle JavaDoc(13, 54, 18, 0));
51         compBounds.put("jInternalFrame1", new Rectangle JavaDoc(10, 31, 24, 26));
52         baselinePosition.put("jInternalFrame1-24-26", new Integer JavaDoc(-1));
53         compMinSize.put("jInternalFrame1", new Dimension JavaDoc(30, 26));
54         compPrefSize.put("jInternalFrame1", new Dimension JavaDoc(24, 26));
55         hasExplicitPrefSize.put("jInternalFrame1", new Boolean JavaDoc(false));
56         hasExplicitPrefSize.put("jInternalFrame1", new Boolean JavaDoc(false));
57         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
58         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
59         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
60         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
61         compBounds.put("jInternalFrame1", new Rectangle JavaDoc(10, 31, 24, 26));
62         baselinePosition.put("jInternalFrame1-24-26", new Integer JavaDoc(-1));
63         compBounds.put("jScrollPane1", new Rectangle JavaDoc(286, 11, 104, 64));
64         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
65         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(104, 64));
66         compBounds.put("jButton1", new Rectangle JavaDoc(315, 266, 75, 23));
67         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
68         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
69         compBounds.put("jButton2", new Rectangle JavaDoc(234, 266, 75, 23));
70         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
71         compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
72         prefPadding.put("jButton2-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
73
prefPaddingInParent.put("Form-jButton2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
74
prefPaddingInParent.put("Form-jLabel1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
75
prefPaddingInParent.put("Form-jInternalFrame1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
76
prefPaddingInParent.put("Form-jScrollPane1-0-1", 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("jLabel1-jInternalFrame1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
79
prefPaddingInParent.put("Form-jScrollPane1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
80
prefPaddingInParent.put("Form-jLabel1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
81
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
82
prefPaddingInParent.put("Form-jButton2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
83
ld.updateCurrentState();
84         // < UPDATE CURRENT STATE
85
// > START RESIZING
86
{
87             String JavaDoc[] compIds = new String JavaDoc[] {
88                 "jInternalFrame1"
89                 };
90             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
91                 new Rectangle JavaDoc(10, 31, 24, 26)
92                 };
93             Point JavaDoc hotspot = new Point JavaDoc(35,55);
94             int[] resizeEdges = new int[] {
95                 1
96                     ,1
97                 };
98             boolean inLayout = true;
99             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
100         }
101         baselinePosition.put("jInternalFrame1-24-26", new Integer JavaDoc(-1));
102         compMinSize.put("jInternalFrame1", new Dimension JavaDoc(30, 26));
103         // < START RESIZING
104
prefPaddingInParent.put("Form-jInternalFrame1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
105
prefPadding.put("jInternalFrame1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
106
prefPadding.put("jInternalFrame1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
107
prefPadding.put("jInternalFrame1-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
108
// > MOVE
109
{
110             Point JavaDoc p = new Point JavaDoc(276,252);
111             String JavaDoc containerId= "Form";
112             boolean autoPositioning = true;
113             boolean lockDimension = false;
114             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
115                 new Rectangle JavaDoc(10, 31, 270, 229)
116                 };
117             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
118         }
119         // < MOVE
120
prefPaddingInParent.put("Form-jInternalFrame1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
121
prefPadding.put("jInternalFrame1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
122
prefPadding.put("jInternalFrame1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
123
prefPadding.put("jInternalFrame1-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
124
// > MOVE
125
{
126             Point JavaDoc p = new Point JavaDoc(276,253);
127             String JavaDoc containerId= "Form";
128             boolean autoPositioning = true;
129             boolean lockDimension = false;
130             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
131                 new Rectangle JavaDoc(10, 31, 270, 229)
132                 };
133             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
134         }
135         // < MOVE
136
// > END MOVING
137
prefPadding.put("jScrollPane1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
138
prefPadding.put("jScrollPane1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
139
prefPadding.put("jInternalFrame1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
140
prefPadding.put("jInternalFrame1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
141
contInterior.put("jInternalFrame1", new Rectangle JavaDoc(13, 54, 264, 203));
142         compBounds.put("jInternalFrame1", new Rectangle JavaDoc(10, 31, 270, 229));
143         baselinePosition.put("jInternalFrame1-270-229", new Integer JavaDoc(-1));
144         compMinSize.put("jInternalFrame1", new Dimension JavaDoc(30, 26));
145         compPrefSize.put("jInternalFrame1", new Dimension JavaDoc(24, 26));
146         hasExplicitPrefSize.put("jInternalFrame1", new Boolean JavaDoc(false));
147         hasExplicitPrefSize.put("jInternalFrame1", new Boolean JavaDoc(false));
148         ld.endMoving(true);
149         // < END MOVING
150
ld.externalSizeChangeHappened();
151         // > UPDATE CURRENT STATE
152
contInterior.put("jInternalFrame1", new Rectangle JavaDoc(13, 54, 264, 203));
153         compBounds.put("jInternalFrame1", new Rectangle JavaDoc(10, 31, 270, 229));
154         baselinePosition.put("jInternalFrame1-270-229", new Integer JavaDoc(-1));
155         compMinSize.put("jInternalFrame1", new Dimension JavaDoc(30, 26));
156         compPrefSize.put("jInternalFrame1", new Dimension JavaDoc(270, 229));
157         hasExplicitPrefSize.put("jInternalFrame1", new Boolean JavaDoc(false));
158         hasExplicitPrefSize.put("jInternalFrame1", new Boolean JavaDoc(false));
159         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
160         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
161         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
162         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
163         compBounds.put("jScrollPane1", new Rectangle JavaDoc(286, 11, 104, 64));
164         baselinePosition.put("jScrollPane1-104-64", new Integer JavaDoc(0));
165         compPrefSize.put("jScrollPane1", new Dimension JavaDoc(104, 64));
166         compBounds.put("jButton1", new Rectangle JavaDoc(315, 266, 75, 23));
167         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
168         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
169         compBounds.put("jButton2", new Rectangle JavaDoc(234, 266, 75, 23));
170         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
171         compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
172         compBounds.put("jInternalFrame1", new Rectangle JavaDoc(10, 31, 270, 229));
173         baselinePosition.put("jInternalFrame1-270-229", new Integer JavaDoc(-1));
174         prefPadding.put("jLabel1-jScrollPane1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
175
prefPadding.put("jInternalFrame1-jScrollPane1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
176
prefPadding.put("jButton2-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
177
prefPaddingInParent.put("Form-jButton2-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
178
prefPaddingInParent.put("Form-jLabel1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
179
prefPaddingInParent.put("Form-jInternalFrame1-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
180
prefPaddingInParent.put("Form-jScrollPane1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
181
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
182
prefPadding.put("jLabel1-jInternalFrame1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
183
prefPaddingInParent.put("Form-jScrollPane1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
184
prefPaddingInParent.put("Form-jLabel1-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
185
prefPadding.put("jScrollPane1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
186
prefPadding.put("jScrollPane1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
187
prefPadding.put("jInternalFrame1-jButton1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
188
prefPadding.put("jInternalFrame1-jButton2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
189
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
190
prefPaddingInParent.put("Form-jButton2-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
191
ld.updateCurrentState();
192         // < UPDATE CURRENT STATE
193
}
194     
195 }
196
Popular Tags