KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class ALT_Resizing06Test extends LayoutTestCase {
31
32     public ALT_Resizing06Test(String JavaDoc name) {
33         super(name);
34         try {
35         className = this.getClass().getName();
36         className = className.substring(className.lastIndexOf('.') + 1, className.length());
37             startingFormFile = FileUtil.toFileObject(new File JavaDoc(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
38         } catch (IOException JavaDoc ioe) {
39             fail(ioe.toString());
40         }
41     }
42
43     // Resize indented textfield to the right. The indent as well as the parallel
44
// group with the labels should preserve.
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, 11, 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(20, 31, 59, 20));
53         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
54         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
55         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
56         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
57         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
58         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
59         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
60         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
61         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 59, 20));
62         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
63         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
64         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
65         ld.updateCurrentState();
66         // < UPDATE CURRENT STATE
67
// > START RESIZING
68
baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
69         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
70         {
71             String JavaDoc[] compIds = new String JavaDoc[] {
72                 "jTextField1"
73                 };
74             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
75                 new Rectangle JavaDoc(20, 31, 59, 20)
76                 };
77             Point JavaDoc hotspot = new Point JavaDoc(79,40);
78             int[] resizeEdges = new int[] {
79                 1,
80                     -1
81                 };
82             boolean inLayout = true;
83             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
84         }
85         // < START RESIZING
86
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
87
// > MOVE
88
{
89             Point JavaDoc p = new Point JavaDoc(125,46);
90             String JavaDoc containerId= "Form";
91             boolean autoPositioning = true;
92             boolean lockDimension = false;
93             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
94                 new Rectangle JavaDoc(20, 31, 105, 20)
95                 };
96             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
97         }
98         // < MOVE
99
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
100
// > MOVE
101
{
102             Point JavaDoc p = new Point JavaDoc(126,46);
103             String JavaDoc containerId= "Form";
104             boolean autoPositioning = true;
105             boolean lockDimension = false;
106             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
107                 new Rectangle JavaDoc(20, 31, 106, 20)
108                 };
109             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
110         }
111         // < MOVE
112
// > END MOVING
113
prefPaddingInParent.put("Form-jLabel1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
114
prefPaddingInParent.put("Form-jLabel2-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
115
prefPaddingInParent.put("Form-jTextField1-0-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("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
122         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
123         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
124         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
125         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
126         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
127         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 106, 20));
128         baselinePosition.put("jTextField1-106-20", new Integer JavaDoc(14));
129         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
130         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
131         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
132         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
133         compBounds.put("jLabel2", new Rectangle JavaDoc(10, 57, 34, 14));
134         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
135         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 106, 20));
136         baselinePosition.put("jTextField1-106-20", new Integer JavaDoc(14));
137         ld.updateCurrentState();
138         // < UPDATE CURRENT STATE
139
}
140     
141 }
142
Popular Tags