KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > visual > model > PositionData


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * PositionData.java
22  *
23  * Created on October 29, 2004, 12:33 PM
24  */

25
26 package org.netbeans.modules.css.visual.model;
27
28 import javax.swing.DefaultComboBoxModel JavaDoc;
29
30 /**
31  * Position data to initialize the Style Editor GUI
32  * based on value and unit
33  * @author Winston Prakash
34  * @version 1.0
35  */

36 public class PositionData {
37     /**
38      * Holds value of property topUnit.
39      */

40     private String JavaDoc topUnit="px"; //NOI18N
41

42     /**
43      * Holds value of property rightUnit.
44      */

45     private String JavaDoc rightUnit="px"; //NOI18N
46

47     /**
48      * Holds value of property leftUnit.
49      */

50     private String JavaDoc leftUnit="px"; //NOI18N
51

52     /**
53      * Holds value of property bottomUnit.
54      */

55     private String JavaDoc bottomUnit="px"; //NOI18N
56

57     /**
58      * Holds value of property widthUnit.
59      */

60     private String JavaDoc widthUnit="px"; //NOI18N
61

62     /**
63      * Holds value of property heightUnit.
64      */

65     private String JavaDoc heightUnit="px"; //NOI18N
66

67     /**
68      * Holds value of property bottomValue.
69      */

70     private String JavaDoc bottomValue="";
71
72     /**
73      * Holds value of property heightValue.
74      */

75     private String JavaDoc heightValue="";
76
77     /**
78      * Holds value of property leftValue.
79      */

80     private String JavaDoc leftValue="";
81
82     /**
83      * Holds value of property rightValue.
84      */

85     private String JavaDoc rightValue="";
86
87     /**
88      * Holds value of property topValue.
89      */

90     private String JavaDoc topValue="";
91
92     /**
93      * Holds value of property widthValue.
94      */

95     private String JavaDoc widthValue="";
96
97     public void setTop(String JavaDoc topStr){
98         topUnit = getUnit(topStr);
99         topValue = topStr.replaceAll(topUnit,"").trim();
100     }
101
102     public void setBottom(String JavaDoc bottomStr){
103         bottomUnit = getUnit(bottomStr);
104         bottomValue = bottomStr.replaceAll(bottomUnit,"").trim();
105     }
106
107     public void setLeft(String JavaDoc leftStr){
108         leftUnit = getUnit(leftStr);
109         leftValue = leftStr.replaceAll(leftUnit,"").trim();
110     }
111
112     public void setRight(String JavaDoc rightStr){
113         rightUnit = getUnit(rightStr);
114         rightValue = rightStr.replaceAll(rightUnit,"").trim();
115     }
116
117     public void setWidth(String JavaDoc widthStr){
118         widthUnit = getUnit(widthStr);
119         widthValue = widthStr.replaceAll(widthUnit,"").trim();
120     }
121
122     public void setHeight(String JavaDoc heightStr){
123         heightUnit = getUnit(heightStr);
124         heightValue = heightStr.replaceAll(heightUnit,"").trim();
125     }
126
127     private String JavaDoc getUnit(String JavaDoc positionStr){
128         DefaultComboBoxModel JavaDoc unitList = new PositionModel().getPositionUnitList();
129         for(int i=0; i< unitList.getSize(); i++){
130             String JavaDoc unit = (String JavaDoc)unitList.getElementAt(i);
131             if(positionStr.trim().endsWith(unit)){
132                 return unit;
133             }
134         }
135         return "";
136     }
137
138     /**
139      * Getter for property topUnit.
140      * @return Value of property topUnit.
141      */

142     public String JavaDoc getTopUnit() {
143
144         return this.topUnit;
145     }
146
147     /**
148      * Setter for property topUnit.
149      * @param topUnit New value of property topUnit.
150      */

151     public void setTopUnit(java.lang.String JavaDoc topUnit) {
152
153         this.topUnit = topUnit;
154     }
155
156     /**
157      * Getter for property rightUnit.
158      * @return Value of property rightUnit.
159      */

160     public String JavaDoc getRightUnit() {
161
162         return this.rightUnit;
163     }
164
165     /**
166      * Setter for property rightUnit.
167      * @param rightUnit New value of property rightUnit.
168      */

169     public void setRightUnit(java.lang.String JavaDoc rightUnit) {
170
171         this.rightUnit = rightUnit;
172     }
173
174     /**
175      * Getter for property leftUnit.
176      * @return Value of property leftUnit.
177      */

178     public String JavaDoc getLeftUnit() {
179
180         return this.leftUnit;
181     }
182     
183     /**
184      * Setter for property leftUnit.
185      * @param leftUnit New value of property leftUnit.
186      */

187     public void setLeftUnit(java.lang.String JavaDoc leftUnit) {
188         
189         this.leftUnit = leftUnit;
190     }
191     
192     /**
193      * Getter for property bottomUnit.
194      * @return Value of property bottomUnit.
195      */

196     public String JavaDoc getBottomUnit() {
197         
198         return this.bottomUnit;
199     }
200     
201     /**
202      * Setter for property bottomUnit.
203      * @param bottomUnit New value of property bottomUnit.
204      */

205     public void setBottomUnit(java.lang.String JavaDoc bottom) {
206     }
207     
208     
209     /**
210      * Getter for property widthUnit.
211      * @return Value of property widthUnit.
212      */

213     public String JavaDoc getWidthUnit() {
214         
215         return this.widthUnit;
216     }
217     
218     /**
219      * Setter for property widthUnit.
220      * @param widthUnit New value of property widthUnit.
221      */

222     public void setWidthUnit(java.lang.String JavaDoc widthUnit) {
223         
224         this.widthUnit = widthUnit;
225     }
226     
227     /**
228      * Getter for property heightUnit.
229      * @return Value of property heightUnit.
230      */

231     public String JavaDoc getHeightUnit() {
232         
233         return this.heightUnit;
234     }
235     
236     /**
237      * Setter for property heightUnit.
238      * @param heightUnit New value of property heightUnit.
239      */

240     public void setHeightUnit(java.lang.String JavaDoc heightUnit) {
241         
242         this.heightUnit = heightUnit;
243     }
244     
245     /**
246      * Getter for property bottomValue.
247      * @return Value of property bottomValue.
248      */

249     public String JavaDoc getBottomValue() {
250         
251         return this.bottomValue;
252     }
253     
254     /**
255      * Setter for property bottomValue.
256      * @param bottomValue New value of property bottomValue.
257      */

258     public void setBottomValue(String JavaDoc bottomValue) {
259         
260         this.bottomValue = bottomValue;
261     }
262     
263     /**
264      * Getter for property heightValue.
265      * @return Value of property heightValue.
266      */

267     public String JavaDoc getHeightValue() {
268         
269         return this.heightValue;
270     }
271     
272     /**
273      * Setter for property heightValue.
274      * @param heightValue New value of property heightValue.
275      */

276     public void setHeightValue(String JavaDoc heightValue) {
277         
278         this.heightValue = heightValue;
279     }
280     
281     /**
282      * Getter for property leftValue.
283      * @return Value of property leftValue.
284      */

285     public String JavaDoc getLeftValue() {
286         
287         return this.leftValue;
288     }
289     
290     /**
291      * Setter for property leftValue.
292      * @param leftValue New value of property leftValue.
293      */

294     public void setLeftValue(String JavaDoc leftValue) {
295         
296         this.leftValue = leftValue;
297     }
298     
299     /**
300      * Getter for property rightValue.
301      * @return Value of property rightValue.
302      */

303     public String JavaDoc getRightValue() {
304         
305         return this.rightValue;
306     }
307     
308     /**
309      * Setter for property rightValue.
310      * @param rightValue New value of property rightValue.
311      */

312     public void setRightValue(String JavaDoc rightValue) {
313         
314         this.rightValue = rightValue;
315     }
316     
317     /**
318      * Getter for property topValue.
319      * @return Value of property topValue.
320      */

321     public String JavaDoc getTopValue() {
322         
323         return this.topValue;
324     }
325     
326     /**
327      * Setter for property topValue.
328      * @param topValue New value of property topValue.
329      */

330     public void setTopValue(String JavaDoc topValue) {
331         
332         this.topValue = topValue;
333     }
334     
335     /**
336      * Getter for property widthValue.
337      * @return Value of property widthValue.
338      */

339     public String JavaDoc getWidthValue() {
340         
341         return this.widthValue;
342     }
343     
344     /**
345      * Setter for property widthValue.
346      * @param widthValue New value of property widthValue.
347      */

348     public void setWidthValue(String JavaDoc widthValue) {
349         
350         this.widthValue = widthValue;
351     }
352 }
353
Popular Tags