KickJava   Java API By Example, From Geeks To Geeks.

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


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 // Testing gap accommodation to indent.
31
public class ALT_Indent04Test extends LayoutTestCase {
32
33     public ALT_Indent04Test(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     // Add a new label indented under jLabel3. The gap between jLabel1 and
45
// jLabel2 should be divided to consider also the indent gap - jLabel2
46
// should not move.
47
public void doChanges0() {
48         ld.externalSizeChangeHappened();
49         // > UPDATE CURRENT STATE
50
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
51         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 73, 34, 14));
52         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
53         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
54         compBounds.put("jLabel2", new Rectangle JavaDoc(175, 73, 34, 14));
55         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
56         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
57         compBounds.put("jLabel3", new Rectangle JavaDoc(78, 53, 34, 14));
58         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
59         compPrefSize.put("jLabel3", new Dimension JavaDoc(34, 14));
60         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
61         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 73, 34, 14));
62         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
63         compBounds.put("jLabel2", new Rectangle JavaDoc(175, 73, 34, 14));
64         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
65         compBounds.put("jLabel3", new Rectangle JavaDoc(78, 53, 34, 14));
66         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
67         ld.updateCurrentState();
68         // < UPDATE CURRENT STATE
69
lc = new LayoutComponent("jLabel4", false);
70         // > START ADDING
71
baselinePosition.put("jLabel4-34-14", new Integer JavaDoc(11));
72         {
73             LayoutComponent[] comps = new LayoutComponent[] { lc };
74             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
75                 new Rectangle JavaDoc(0, 0, 34, 14)
76                 };
77             String JavaDoc defaultContId = null;
78             Point JavaDoc hotspot = new Point JavaDoc(13,7);
79             ld.startAdding(comps, bounds, hotspot, defaultContId);
80         }
81         // < START ADDING
82
prefPaddingInParent.put("Form-jLabel4-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
83
prefPaddingInParent.put("Form-jLabel4-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
84
prefPadding.put("jLabel3-jLabel4-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
85
prefPadding.put("jLabel4-jLabel3-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
86
prefPadding.put("jLabel1-jLabel4-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
87
prefPadding.put("jLabel2-jLabel4-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
88
prefPadding.put("jLabel4-jLabel1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
89
prefPadding.put("jLabel4-jLabel2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
90
prefPaddingInParent.put("Form-jLabel4-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
91
prefPaddingInParent.put("Form-jLabel4-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
92
prefPadding.put("jLabel1-jLabel4-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
93
prefPadding.put("jLabel4-jLabel1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
94
prefPadding.put("jLabel2-jLabel4-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
95
prefPadding.put("jLabel4-jLabel2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
96
prefPadding.put("jLabel3-jLabel4-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
97
// > MOVE
98
{
99             Point JavaDoc p = new Point JavaDoc(100,85);
100             String JavaDoc containerId= "Form";
101             boolean autoPositioning = true;
102             boolean lockDimension = false;
103             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
104                 new Rectangle JavaDoc(88, 73, 34, 14)
105                 };
106             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
107         }
108         // < MOVE
109
prefPaddingInParent.put("Form-jLabel4-1-0", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
110
prefPaddingInParent.put("Form-jLabel4-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
111
prefPadding.put("jLabel3-jLabel4-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
112
prefPadding.put("jLabel4-jLabel3-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
113
prefPadding.put("jLabel1-jLabel4-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
114
prefPadding.put("jLabel2-jLabel4-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
115
prefPadding.put("jLabel4-jLabel1-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
116
prefPadding.put("jLabel4-jLabel2-1-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
117
prefPaddingInParent.put("Form-jLabel4-0-0", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
118
prefPaddingInParent.put("Form-jLabel4-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
119
prefPadding.put("jLabel1-jLabel4-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
120
prefPadding.put("jLabel4-jLabel1-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
121
prefPadding.put("jLabel2-jLabel4-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
122
prefPadding.put("jLabel4-jLabel2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
123
prefPadding.put("jLabel3-jLabel4-0-0-2", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
124
// > MOVE
125
{
126             Point JavaDoc p = new Point JavaDoc(101,84);
127             String JavaDoc containerId= "Form";
128             boolean autoPositioning = true;
129             boolean lockDimension = false;
130             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
131                 new Rectangle JavaDoc(88, 73, 34, 14)
132                 };
133             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
134         }
135         // < MOVE
136
// > END MOVING
137
compPrefSize.put("jLabel4", new Dimension JavaDoc(34, 14));
138         compPrefSize.put("jLabel4", new Dimension JavaDoc(34, 14));
139         prefPadding.put("jLabel1-jLabel4-0-0-0", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
140
prefPadding.put("jLabel4-jLabel2-0-0-0", new Integer JavaDoc(10)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
141
ld.endMoving(true);
142         // < END MOVING
143
ld.externalSizeChangeHappened();
144         // > UPDATE CURRENT STATE
145
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
146         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 73, 34, 14));
147         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
148         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
149         compBounds.put("jLabel2", new Rectangle JavaDoc(175, 73, 34, 14));
150         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
151         compPrefSize.put("jLabel2", new Dimension JavaDoc(34, 14));
152         compBounds.put("jLabel3", new Rectangle JavaDoc(78, 53, 34, 14));
153         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
154         compPrefSize.put("jLabel3", new Dimension JavaDoc(34, 14));
155         compBounds.put("jLabel4", new Rectangle JavaDoc(88, 73, 34, 14));
156         baselinePosition.put("jLabel4-34-14", new Integer JavaDoc(11));
157         compPrefSize.put("jLabel4", new Dimension JavaDoc(34, 14));
158         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
159         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 73, 34, 14));
160         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
161         compBounds.put("jLabel2", new Rectangle JavaDoc(175, 73, 34, 14));
162         baselinePosition.put("jLabel2-34-14", new Integer JavaDoc(11));
163         compBounds.put("jLabel3", new Rectangle JavaDoc(78, 53, 34, 14));
164         baselinePosition.put("jLabel3-34-14", new Integer JavaDoc(11));
165         compBounds.put("jLabel4", new Rectangle JavaDoc(88, 73, 34, 14));
166         baselinePosition.put("jLabel4-34-14", new Integer JavaDoc(11));
167         ld.updateCurrentState();
168         // < UPDATE CURRENT STATE
169
}
170     
171 }
172
Popular Tags