KickJava   Java API By Example, From Geeks To Geeks.

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


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 // Test for subordinate resizing interval (creating fixed parallel group).
31
// A fixed component surrounded with fixed gaps (and components) is resized to
32
// right align with a parallel component which forces it to become resizing,
33
// preserving fixed gaps around it.
34
public class ALT_ParallelPosition17Test extends LayoutTestCase {
35         
36     public ALT_ParallelPosition17Test(String JavaDoc name) {
37         super(name);
38         try {
39         className = this.getClass().getName();
40         className = className.substring(className.lastIndexOf('.') + 1, className.length());
41             startingFormFile = FileUtil.toFileObject(new File JavaDoc(url.getFile() + goldenFilesPath + className + "-StartingForm.form").getCanonicalFile());
42         } catch (IOException JavaDoc ioe) {
43             fail(ioe.toString());
44         }
45     }
46
47     // Resize jButton1 to right align with the toggle button.
48
public void doChanges0() {
49         ld.externalSizeChangeHappened();
50         // > UPDATE CURRENT STATE
51
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
52         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
53         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
54         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(179, 23));
55         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 44, 34, 14));
56         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
57         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
58         compBounds.put("jButton1", new Rectangle JavaDoc(87, 40, 75, 23));
59         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
60         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
61         compBounds.put("jButton2", new Rectangle JavaDoc(215, 40, 75, 23));
62         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
63         compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
64         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
65         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
66         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
67         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 44, 34, 14));
68         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
69         compBounds.put("jButton1", new Rectangle JavaDoc(87, 40, 75, 23));
70         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
71         compBounds.put("jButton2", new Rectangle JavaDoc(215, 40, 75, 23));
72         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
73         ld.updateCurrentState();
74         // < UPDATE CURRENT STATE
75
// > START RESIZING
76
baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
77         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
78         {
79             String JavaDoc[] compIds = new String JavaDoc[] {
80                 "jButton1"
81                 };
82             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
83                 new Rectangle JavaDoc(87, 40, 75, 23)
84                 };
85             Point JavaDoc hotspot = new Point JavaDoc(164,52);
86             int[] resizeEdges = new int[] {
87                 1,
88                     -1
89                 };
90             boolean inLayout = true;
91             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
92         }
93         // < START RESIZING
94
prefPadding.put("jButton1-jButton2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
95
// > MOVE
96
{
97             Point JavaDoc p = new Point JavaDoc(183,51);
98             String JavaDoc containerId= "Form";
99             boolean autoPositioning = true;
100             boolean lockDimension = false;
101             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
102                 new Rectangle JavaDoc(87, 40, 94, 23)
103                 };
104             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
105         }
106         // < MOVE
107
prefPadding.put("jButton1-jButton2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
108
// > MOVE
109
{
110             Point JavaDoc p = new Point JavaDoc(184,51);
111             String JavaDoc containerId= "Form";
112             boolean autoPositioning = true;
113             boolean lockDimension = false;
114             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
115                 new Rectangle JavaDoc(87, 40, 102, 23)
116                 };
117             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
118         }
119         // < MOVE
120
// > END MOVING
121
prefPadding.put("jLabel1-jButton1-0-0-0", new Integer JavaDoc(4)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
122
prefPadding.put("jButton1-jButton2-0-0-0", new Integer JavaDoc(6)); // comp1Id-comp2Id-dimension-comp2Alignment-paddingType
123
compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
124         ld.endMoving(true);
125         // < END MOVING
126
ld.externalSizeChangeHappened();
127         // > UPDATE CURRENT STATE
128
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
129         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
130         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
131         compPrefSize.put("jToggleButton1", new Dimension JavaDoc(179, 23));
132         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 44, 34, 14));
133         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
134         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
135         compBounds.put("jButton2", new Rectangle JavaDoc(215, 40, 75, 23));
136         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
137         compPrefSize.put("jButton2", new Dimension JavaDoc(75, 23));
138         compBounds.put("jButton1", new Rectangle JavaDoc(87, 40, 102, 23));
139         baselinePosition.put("jButton1-102-23", new Integer JavaDoc(15));
140         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
141         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
142         compBounds.put("jToggleButton1", new Rectangle JavaDoc(10, 11, 179, 23));
143         baselinePosition.put("jToggleButton1-179-23", new Integer JavaDoc(15));
144         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 44, 34, 14));
145         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
146         compBounds.put("jButton2", new Rectangle JavaDoc(215, 40, 75, 23));
147         baselinePosition.put("jButton2-75-23", new Integer JavaDoc(15));
148         compBounds.put("jButton1", new Rectangle JavaDoc(87, 40, 102, 23));
149         baselinePosition.put("jButton1-102-23", new Integer JavaDoc(15));
150         ld.updateCurrentState();
151         // < UPDATE CURRENT STATE
152
}
153     
154 }
155
Popular Tags