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: package org.netbeans.modules.visualweb.propertyeditors.css.model;
042:
043: import javax.swing.DefaultComboBoxModel;
044:
045: /**
046: * Position data to initialize the Style Editor GUI
047: * based on value and unit
048: * @author Winston Prakash
049: */
050: public class PositionData {
051: /**
052: * Holds value of property topUnit.
053: */
054: private String topUnit = "px"; //NOI18N
055:
056: /**
057: * Holds value of property rightUnit.
058: */
059: private String rightUnit = "px"; //NOI18N
060:
061: /**
062: * Holds value of property leftUnit.
063: */
064: private String leftUnit = "px"; //NOI18N
065:
066: /**
067: * Holds value of property bottomUnit.
068: */
069: private String bottomUnit = "px"; //NOI18N
070:
071: /**
072: * Holds value of property widthUnit.
073: */
074: private String widthUnit = "px"; //NOI18N
075:
076: /**
077: * Holds value of property heightUnit.
078: */
079: private String heightUnit = "px"; //NOI18N
080:
081: /**
082: * Holds value of property bottomValue.
083: */
084: private String bottomValue = "";
085:
086: /**
087: * Holds value of property heightValue.
088: */
089: private String heightValue = "";
090:
091: /**
092: * Holds value of property leftValue.
093: */
094: private String leftValue = "";
095:
096: /**
097: * Holds value of property rightValue.
098: */
099: private String rightValue = "";
100:
101: /**
102: * Holds value of property topValue.
103: */
104: private String topValue = "";
105:
106: /**
107: * Holds value of property widthValue.
108: */
109: private String widthValue = "";
110:
111: public void setTop(String topStr) {
112: topUnit = getUnit(topStr);
113: topValue = topStr.replaceAll(topUnit, "").trim();
114: }
115:
116: public void setBottom(String bottomStr) {
117: bottomUnit = getUnit(bottomStr);
118: bottomValue = bottomStr.replaceAll(bottomUnit, "").trim();
119: }
120:
121: public void setLeft(String leftStr) {
122: leftUnit = getUnit(leftStr);
123: leftValue = leftStr.replaceAll(leftUnit, "").trim();
124: }
125:
126: public void setRight(String rightStr) {
127: rightUnit = getUnit(rightStr);
128: rightValue = rightStr.replaceAll(rightUnit, "").trim();
129: }
130:
131: public void setWidth(String widthStr) {
132: widthUnit = getUnit(widthStr);
133: widthValue = widthStr.replaceAll(widthUnit, "").trim();
134: }
135:
136: public void setHeight(String heightStr) {
137: heightUnit = getUnit(heightStr);
138: heightValue = heightStr.replaceAll(heightUnit, "").trim();
139: }
140:
141: private String getUnit(String positionStr) {
142: DefaultComboBoxModel unitList = new PositionModel()
143: .getPositionUnitList();
144: for (int i = 0; i < unitList.getSize(); i++) {
145: String unit = (String) unitList.getElementAt(i);
146: if (positionStr.trim().endsWith(unit)) {
147: return unit;
148: }
149: }
150: return "";
151: }
152:
153: /**
154: * Getter for property topUnit.
155: * @return Value of property topUnit.
156: */
157: public String getTopUnit() {
158:
159: return this .topUnit;
160: }
161:
162: /**
163: * Setter for property topUnit.
164: * @param topUnit New value of property topUnit.
165: */
166: public void setTopUnit(java.lang.String topUnit) {
167:
168: this .topUnit = topUnit;
169: }
170:
171: /**
172: * Getter for property rightUnit.
173: * @return Value of property rightUnit.
174: */
175: public String getRightUnit() {
176:
177: return this .rightUnit;
178: }
179:
180: /**
181: * Setter for property rightUnit.
182: * @param rightUnit New value of property rightUnit.
183: */
184: public void setRightUnit(java.lang.String rightUnit) {
185:
186: this .rightUnit = rightUnit;
187: }
188:
189: /**
190: * Getter for property leftUnit.
191: * @return Value of property leftUnit.
192: */
193: public String getLeftUnit() {
194:
195: return this .leftUnit;
196: }
197:
198: /**
199: * Setter for property leftUnit.
200: * @param leftUnit New value of property leftUnit.
201: */
202: public void setLeftUnit(java.lang.String leftUnit) {
203:
204: this .leftUnit = leftUnit;
205: }
206:
207: /**
208: * Getter for property bottomUnit.
209: * @return Value of property bottomUnit.
210: */
211: public String getBottomUnit() {
212:
213: return this .bottomUnit;
214: }
215:
216: /**
217: * Setter for property bottomUnit.
218: * @param bottomUnit New value of property bottomUnit.
219: */
220: public void setBottomUnit(java.lang.String bottom) {
221: }
222:
223: /**
224: * Getter for property widthUnit.
225: * @return Value of property widthUnit.
226: */
227: public String getWidthUnit() {
228:
229: return this .widthUnit;
230: }
231:
232: /**
233: * Setter for property widthUnit.
234: * @param widthUnit New value of property widthUnit.
235: */
236: public void setWidthUnit(java.lang.String widthUnit) {
237:
238: this .widthUnit = widthUnit;
239: }
240:
241: /**
242: * Getter for property heightUnit.
243: * @return Value of property heightUnit.
244: */
245: public String getHeightUnit() {
246:
247: return this .heightUnit;
248: }
249:
250: /**
251: * Setter for property heightUnit.
252: * @param heightUnit New value of property heightUnit.
253: */
254: public void setHeightUnit(java.lang.String heightUnit) {
255:
256: this .heightUnit = heightUnit;
257: }
258:
259: /**
260: * Getter for property bottomValue.
261: * @return Value of property bottomValue.
262: */
263: public String getBottomValue() {
264:
265: return this .bottomValue;
266: }
267:
268: /**
269: * Setter for property bottomValue.
270: * @param bottomValue New value of property bottomValue.
271: */
272: public void setBottomValue(String bottomValue) {
273:
274: this .bottomValue = bottomValue;
275: }
276:
277: /**
278: * Getter for property heightValue.
279: * @return Value of property heightValue.
280: */
281: public String getHeightValue() {
282:
283: return this .heightValue;
284: }
285:
286: /**
287: * Setter for property heightValue.
288: * @param heightValue New value of property heightValue.
289: */
290: public void setHeightValue(String heightValue) {
291:
292: this .heightValue = heightValue;
293: }
294:
295: /**
296: * Getter for property leftValue.
297: * @return Value of property leftValue.
298: */
299: public String getLeftValue() {
300:
301: return this .leftValue;
302: }
303:
304: /**
305: * Setter for property leftValue.
306: * @param leftValue New value of property leftValue.
307: */
308: public void setLeftValue(String leftValue) {
309:
310: this .leftValue = leftValue;
311: }
312:
313: /**
314: * Getter for property rightValue.
315: * @return Value of property rightValue.
316: */
317: public String getRightValue() {
318:
319: return this .rightValue;
320: }
321:
322: /**
323: * Setter for property rightValue.
324: * @param rightValue New value of property rightValue.
325: */
326: public void setRightValue(String rightValue) {
327:
328: this .rightValue = rightValue;
329: }
330:
331: /**
332: * Getter for property topValue.
333: * @return Value of property topValue.
334: */
335: public String getTopValue() {
336:
337: return this .topValue;
338: }
339:
340: /**
341: * Setter for property topValue.
342: * @param topValue New value of property topValue.
343: */
344: public void setTopValue(String topValue) {
345:
346: this .topValue = topValue;
347: }
348:
349: /**
350: * Getter for property widthValue.
351: * @return Value of property widthValue.
352: */
353: public String getWidthValue() {
354:
355: return this .widthValue;
356: }
357:
358: /**
359: * Setter for property widthValue.
360: * @param widthValue New value of property widthValue.
361: */
362: public void setWidthValue(String widthValue) {
363:
364: this.widthValue = widthValue;
365: }
366: }
|