KickJava   Java API By Example, From Geeks To Geeks.

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


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 that resizing snaps next to a parallel group.
31
public class ALT_Resizing08Test extends LayoutTestCase {
32
33     public ALT_Resizing08Test(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 text field to the right to snap next to the group of labels and button.
45
public void doChanges0() {
46         ld.externalSizeChangeHappened();
47         // > UPDATE CURRENT STATE
48
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
49         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
50         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
51         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
52         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
53         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
54         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
55         compBounds.put("jButton1", new Rectangle JavaDoc(315, 37, 75, 23));
56         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
57         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
58         compBounds.put("jLabel3", new Rectangle JavaDoc(315, 14, 34, 14));
59         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
60         compPrefSize.put("jLabel3", new Dimension JavaDoc(34, 14));
61         compBounds.put("jLabel2", new Rectangle JavaDoc(355, 14, 34, 14));
62         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
63         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
64         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
65         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
66         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
67         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 59, 20));
68         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
69         compBounds.put("jButton1", new Rectangle JavaDoc(315, 37, 75, 23));
70         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
71         compBounds.put("jLabel3", new Rectangle JavaDoc(315, 14, 34, 14));
72         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
73         compBounds.put("jLabel2", new Rectangle JavaDoc(355, 14, 34, 14));
74         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
75         ld.updateCurrentState();
76         // < UPDATE CURRENT STATE
77
// > START RESIZING
78
baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
79         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
80         {
81             String JavaDoc[] compIds = new String JavaDoc[] {
82                 "jTextField1"
83                 };
84             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
85                 new Rectangle JavaDoc(48, 11, 59, 20)
86                 };
87             Point JavaDoc hotspot = new Point JavaDoc(105,21);
88             int[] resizeEdges = new int[] {
89                 1,
90                     -1
91                 };
92             boolean inLayout = true;
93             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
94         }
95         // < START RESIZING
96
prefPadding.put("jTextField1-jLabel3-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
97
prefPadding.put("jTextField1-jLabel2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
98
prefPadding.put("jTextField1-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
99
prefPadding.put("jTextField1-jLabel3-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
100
// > MOVE
101
{
102             Point JavaDoc p = new Point JavaDoc(306,31);
103             String JavaDoc containerId= "Form";
104             boolean autoPositioning = true;
105             boolean lockDimension = false;
106             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
107                 new Rectangle JavaDoc(48, 11, 261, 20)
108                 };
109             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
110         }
111         // < MOVE
112
prefPadding.put("jTextField1-jLabel3-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
113
prefPadding.put("jTextField1-jLabel2-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
114
prefPadding.put("jTextField1-jButton1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
115
prefPadding.put("jTextField1-jLabel3-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
116
// > MOVE
117
{
118             Point JavaDoc p = new Point JavaDoc(307,31);
119             String JavaDoc containerId= "Form";
120             boolean autoPositioning = true;
121             boolean lockDimension = false;
122             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
123                 new Rectangle JavaDoc(48, 11, 261, 20)
124                 };
125             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
126         }
127         // < MOVE
128
// > END MOVING
129
ld.endMoving(true);
130         // < END MOVING
131
ld.externalSizeChangeHappened();
132         // > UPDATE CURRENT STATE
133
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
134         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
135         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
136         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
137         compBounds.put("jButton1", new Rectangle JavaDoc(315, 37, 75, 23));
138         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
139         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
140         compBounds.put("jLabel3", new Rectangle JavaDoc(315, 14, 34, 14));
141         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
142         compPrefSize.put("jLabel3", new Dimension JavaDoc(34, 14));
143         compBounds.put("jLabel2", new Rectangle JavaDoc(355, 14, 34, 14));
144         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
145         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
146         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 261, 20));
147         baselinePosition.put("jTextField1-261-20", new Integer JavaDoc(14));
148         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
149         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
150         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 14, 34, 14));
151         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
152         compBounds.put("jButton1", new Rectangle JavaDoc(315, 37, 75, 23));
153         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
154         compBounds.put("jLabel3", new Rectangle JavaDoc(315, 14, 34, 14));
155         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
156         compBounds.put("jLabel2", new Rectangle JavaDoc(355, 14, 34, 14));
157         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
158         compBounds.put("jTextField1", new Rectangle JavaDoc(48, 11, 261, 20));
159         baselinePosition.put("jTextField1-261-20", new Integer JavaDoc(14));
160         ld.updateCurrentState();
161         // < UPDATE CURRENT STATE
162
}
163     
164 }
165
Popular Tags