KickJava   Java API By Example, From Geeks To Geeks.

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


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 mouse resizing of component (not container) to default size.
31
public class ALT_DefaultSize01Test extends LayoutTestCase {
32
33     public ALT_DefaultSize01Test(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 (shrink) button from right to default size.
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("jButton1", new Rectangle JavaDoc(10, 11, 137, 23));
50         baselinePosition.put("jButton1-137-23", new Integer JavaDoc(15));
51         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
52         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
53         compBounds.put("jButton1", new Rectangle JavaDoc(10, 11, 137, 23));
54         baselinePosition.put("jButton1-137-23", new Integer JavaDoc(15));
55         ld.updateCurrentState();
56         // < UPDATE CURRENT STATE
57
// > START RESIZING
58
baselinePosition.put("jButton1-137-23", new Integer JavaDoc(15));
59         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
60         {
61             String JavaDoc[] compIds = new String JavaDoc[] {
62                 "jButton1"
63                 };
64             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
65                 new Rectangle JavaDoc(10, 11, 137, 23)
66                 };
67             Point JavaDoc hotspot = new Point JavaDoc(148,21);
68             int[] resizeEdges = new int[] {
69                 1,
70                     -1
71                 };
72             boolean inLayout = true;
73             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
74         }
75         // < START RESIZING
76
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
77
// > MOVE
78
{
79             Point JavaDoc p = new Point JavaDoc(89,25);
80             String JavaDoc containerId= "Form";
81             boolean autoPositioning = true;
82             boolean lockDimension = false;
83             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
84                 new Rectangle JavaDoc(10, 11, 75, 23)
85                 };
86             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
87         }
88         // < MOVE
89
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
90
// > MOVE
91
{
92             Point JavaDoc p = new Point JavaDoc(88,25);
93             String JavaDoc containerId= "Form";
94             boolean autoPositioning = true;
95             boolean lockDimension = false;
96             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
97                 new Rectangle JavaDoc(10, 11, 75, 23)
98                 };
99             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
100         }
101         // < MOVE
102
// > END MOVING
103
prefPaddingInParent.put("Form-jButton1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
104
prefPaddingInParent.put("Form-jButton1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
105
ld.endMoving(true);
106         // < END MOVING
107
ld.externalSizeChangeHappened();
108         // > UPDATE CURRENT STATE
109
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
110         compBounds.put("jButton1", new Rectangle JavaDoc(10, 11, 75, 23));
111         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
112         compPrefSize.put("jButton1", new Dimension JavaDoc(75, 23));
113         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
114         compBounds.put("jButton1", new Rectangle JavaDoc(10, 11, 75, 23));
115         baselinePosition.put("jButton1-75-23", new Integer JavaDoc(15));
116         ld.updateCurrentState();
117         // < UPDATE CURRENT STATE
118
}
119     
120 }
121
Popular Tags