001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * PositionData.java
044: *
045: * Created on October 29, 2004, 12:33 PM
046: */
047:
048: package org.netbeans.modules.css.visual.model;
049:
050: import javax.swing.DefaultComboBoxModel;
051:
052: /**
053: * Position data to initialize the Style Editor GUI
054: * based on value and unit
055: * @author Winston Prakash
056: * @version 1.0
057: */
058: public class PositionData {
059: /**
060: * Holds value of property topUnit.
061: */
062: private String topUnit = "px"; //NOI18N
063:
064: /**
065: * Holds value of property rightUnit.
066: */
067: private String rightUnit = "px"; //NOI18N
068:
069: /**
070: * Holds value of property leftUnit.
071: */
072: private String leftUnit = "px"; //NOI18N
073:
074: /**
075: * Holds value of property bottomUnit.
076: */
077: private String bottomUnit = "px"; //NOI18N
078:
079: /**
080: * Holds value of property widthUnit.
081: */
082: private String widthUnit = "px"; //NOI18N
083:
084: /**
085: * Holds value of property heightUnit.
086: */
087: private String heightUnit = "px"; //NOI18N
088:
089: /**
090: * Holds value of property bottomValue.
091: */
092: private String bottomValue = "";
093:
094: /**
095: * Holds value of property heightValue.
096: */
097: private String heightValue = "";
098:
099: /**
100: * Holds value of property leftValue.
101: */
102: private String leftValue = "";
103:
104: /**
105: * Holds value of property rightValue.
106: */
107: private String rightValue = "";
108:
109: /**
110: * Holds value of property topValue.
111: */
112: private String topValue = "";
113:
114: /**
115: * Holds value of property widthValue.
116: */
117: private String widthValue = "";
118:
119: public void setTop(String topStr) {
120: topUnit = getUnit(topStr);
121: topValue = topStr.replaceAll(topUnit, "").trim();
122: }
123:
124: public void setBottom(String bottomStr) {
125: bottomUnit = getUnit(bottomStr);
126: bottomValue = bottomStr.replaceAll(bottomUnit, "").trim();
127: }
128:
129: public void setLeft(String leftStr) {
130: leftUnit = getUnit(leftStr);
131: leftValue = leftStr.replaceAll(leftUnit, "").trim();
132: }
133:
134: public void setRight(String rightStr) {
135: rightUnit = getUnit(rightStr);
136: rightValue = rightStr.replaceAll(rightUnit, "").trim();
137: }
138:
139: public void setWidth(String widthStr) {
140: widthUnit = getUnit(widthStr);
141: widthValue = widthStr.replaceAll(widthUnit, "").trim();
142: }
143:
144: public void setHeight(String heightStr) {
145: heightUnit = getUnit(heightStr);
146: heightValue = heightStr.replaceAll(heightUnit, "").trim();
147: }
148:
149: private String getUnit(String positionStr) {
150: DefaultComboBoxModel unitList = new PositionModel()
151: .getPositionUnitList();
152: for (int i = 0; i < unitList.getSize(); i++) {
153: String unit = (String) unitList.getElementAt(i);
154: if (positionStr.trim().endsWith(unit)) {
155: return unit;
156: }
157: }
158: return "";
159: }
160:
161: /**
162: * Getter for property topUnit.
163: * @return Value of property topUnit.
164: */
165: public String getTopUnit() {
166:
167: return this .topUnit;
168: }
169:
170: /**
171: * Setter for property topUnit.
172: * @param topUnit New value of property topUnit.
173: */
174: public void setTopUnit(java.lang.String topUnit) {
175:
176: this .topUnit = topUnit;
177: }
178:
179: /**
180: * Getter for property rightUnit.
181: * @return Value of property rightUnit.
182: */
183: public String getRightUnit() {
184:
185: return this .rightUnit;
186: }
187:
188: /**
189: * Setter for property rightUnit.
190: * @param rightUnit New value of property rightUnit.
191: */
192: public void setRightUnit(java.lang.String rightUnit) {
193:
194: this .rightUnit = rightUnit;
195: }
196:
197: /**
198: * Getter for property leftUnit.
199: * @return Value of property leftUnit.
200: */
201: public String getLeftUnit() {
202:
203: return this .leftUnit;
204: }
205:
206: /**
207: * Setter for property leftUnit.
208: * @param leftUnit New value of property leftUnit.
209: */
210: public void setLeftUnit(java.lang.String leftUnit) {
211:
212: this .leftUnit = leftUnit;
213: }
214:
215: /**
216: * Getter for property bottomUnit.
217: * @return Value of property bottomUnit.
218: */
219: public String getBottomUnit() {
220:
221: return this .bottomUnit;
222: }
223:
224: /**
225: * Setter for property bottomUnit.
226: * @param bottomUnit New value of property bottomUnit.
227: */
228: public void setBottomUnit(java.lang.String bottom) {
229: }
230:
231: /**
232: * Getter for property widthUnit.
233: * @return Value of property widthUnit.
234: */
235: public String getWidthUnit() {
236:
237: return this .widthUnit;
238: }
239:
240: /**
241: * Setter for property widthUnit.
242: * @param widthUnit New value of property widthUnit.
243: */
244: public void setWidthUnit(java.lang.String widthUnit) {
245:
246: this .widthUnit = widthUnit;
247: }
248:
249: /**
250: * Getter for property heightUnit.
251: * @return Value of property heightUnit.
252: */
253: public String getHeightUnit() {
254:
255: return this .heightUnit;
256: }
257:
258: /**
259: * Setter for property heightUnit.
260: * @param heightUnit New value of property heightUnit.
261: */
262: public void setHeightUnit(java.lang.String heightUnit) {
263:
264: this .heightUnit = heightUnit;
265: }
266:
267: /**
268: * Getter for property bottomValue.
269: * @return Value of property bottomValue.
270: */
271: public String getBottomValue() {
272:
273: return this .bottomValue;
274: }
275:
276: /**
277: * Setter for property bottomValue.
278: * @param bottomValue New value of property bottomValue.
279: */
280: public void setBottomValue(String bottomValue) {
281:
282: this .bottomValue = bottomValue;
283: }
284:
285: /**
286: * Getter for property heightValue.
287: * @return Value of property heightValue.
288: */
289: public String getHeightValue() {
290:
291: return this .heightValue;
292: }
293:
294: /**
295: * Setter for property heightValue.
296: * @param heightValue New value of property heightValue.
297: */
298: public void setHeightValue(String heightValue) {
299:
300: this .heightValue = heightValue;
301: }
302:
303: /**
304: * Getter for property leftValue.
305: * @return Value of property leftValue.
306: */
307: public String getLeftValue() {
308:
309: return this .leftValue;
310: }
311:
312: /**
313: * Setter for property leftValue.
314: * @param leftValue New value of property leftValue.
315: */
316: public void setLeftValue(String leftValue) {
317:
318: this .leftValue = leftValue;
319: }
320:
321: /**
322: * Getter for property rightValue.
323: * @return Value of property rightValue.
324: */
325: public String getRightValue() {
326:
327: return this .rightValue;
328: }
329:
330: /**
331: * Setter for property rightValue.
332: * @param rightValue New value of property rightValue.
333: */
334: public void setRightValue(String rightValue) {
335:
336: this .rightValue = rightValue;
337: }
338:
339: /**
340: * Getter for property topValue.
341: * @return Value of property topValue.
342: */
343: public String getTopValue() {
344:
345: return this .topValue;
346: }
347:
348: /**
349: * Setter for property topValue.
350: * @param topValue New value of property topValue.
351: */
352: public void setTopValue(String topValue) {
353:
354: this .topValue = topValue;
355: }
356:
357: /**
358: * Getter for property widthValue.
359: * @return Value of property widthValue.
360: */
361: public String getWidthValue() {
362:
363: return this .widthValue;
364: }
365:
366: /**
367: * Setter for property widthValue.
368: * @param widthValue New value of property widthValue.
369: */
370: public void setWidthValue(String widthValue) {
371:
372: this.widthValue = widthValue;
373: }
374: }
|