KickJava   Java API By Example, From Geeks To Geeks.

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


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_Resizing05Test extends LayoutTestCase {
31
32     public ALT_Resizing05Test(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 text field to the right. The indent gap should preserve.
44
public void doChanges0() {
45         ld.externalSizeChangeHappened();
46         // > UPDATE CURRENT STATE
47
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
48         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
49         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
50         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
51         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 59, 20));
52         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
53         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
54         contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
55         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
56         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
57         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 59, 20));
58         baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
59         ld.updateCurrentState();
60         // < UPDATE CURRENT STATE
61
// > START RESIZING
62
baselinePosition.put("jTextField1-59-20", new Integer JavaDoc(14));
63         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
64         {
65             String JavaDoc[] compIds = new String JavaDoc[] {
66                 "jTextField1"
67                 };
68             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
69                 new Rectangle JavaDoc(20, 31, 59, 20)
70                 };
71             Point JavaDoc hotspot = new Point JavaDoc(80,42);
72             int[] resizeEdges = new int[] {
73                 1,
74                     -1
75                 };
76             boolean inLayout = true;
77             ld.startResizing(compIds, bounds, hotspot, resizeEdges, inLayout);
78         }
79         // < START RESIZING
80
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
81
// > MOVE
82
{
83             Point JavaDoc p = new Point JavaDoc(120,49);
84             String JavaDoc containerId= "Form";
85             boolean autoPositioning = true;
86             boolean lockDimension = false;
87             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
88                 new Rectangle JavaDoc(20, 31, 99, 20)
89                 };
90             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
91         }
92         // < MOVE
93
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
94
// > MOVE
95
{
96             Point JavaDoc p = new Point JavaDoc(121,49);
97             String JavaDoc containerId= "Form";
98             boolean autoPositioning = true;
99             boolean lockDimension = false;
100             Rectangle JavaDoc[] bounds = new Rectangle JavaDoc[] {
101                 new Rectangle JavaDoc(20, 31, 100, 20)
102                 };
103             ld.move(p, containerId, autoPositioning, lockDimension, bounds);
104         }
105         // < MOVE
106
// > END MOVING
107
prefPaddingInParent.put("Form-jTextField1-0-1", new Integer JavaDoc(10)); // parentId-compId-dimension-compAlignment
108
prefPaddingInParent.put("Form-jTextField1-1-1", new Integer JavaDoc(11)); // parentId-compId-dimension-compAlignment
109
ld.endMoving(true);
110         // < END MOVING
111
ld.externalSizeChangeHappened();
112         // > UPDATE CURRENT STATE
113
contInterior.put("Form", new Rectangle JavaDoc(0, 0, 400, 300));
114         compBounds.put("jLabel1", new Rectangle JavaDoc(10, 11, 34, 14));
115         baselinePosition.put("jLabel1-34-14", new Integer JavaDoc(11));
116         compPrefSize.put("jLabel1", new Dimension JavaDoc(34, 14));
117         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 100, 20));
118         baselinePosition.put("jTextField1-100-20", new Integer JavaDoc(14));
119         compPrefSize.put("jTextField1", new Dimension JavaDoc(59, 20));
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         compBounds.put("jTextField1", new Rectangle JavaDoc(20, 31, 100, 20));
124         baselinePosition.put("jTextField1-100-20", new Integer JavaDoc(14));
125         ld.updateCurrentState();
126         // < UPDATE CURRENT STATE
127
}
128     
129 }
130
Popular Tags