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 java.util.StringTokenizer;
044: import javax.swing.DefaultComboBoxModel;
045:
046: /**
047: *
048: * @author Winston Prakash
049: */
050: public class TextBlockData {
051: /**
052: * Holds value of property verticalAlignUnit.
053: */
054: private String verticalAlignUnit = "px"; //NOI18N
055:
056: /**
057: * Holds value of property verticalAlignValue.
058: */
059: private String verticalAlignValue = "";
060:
061: /**
062: * Holds value of property indentationUnit.
063: */
064: private String indentationUnit = "px"; //NOI18N
065:
066: /**
067: * Holds value of property wordSpacingUnit.
068: */
069: private String wordSpacingUnit = "px"; //NOI18N
070:
071: /**
072: * Holds value of property indentationValue.
073: */
074: private String indentationValue = "";
075:
076: /**
077: * Holds value of property wordSpacingValue.
078: */
079: private String wordSpacingValue = "";
080:
081: /**
082: * Holds value of property letterSpacingUnit.
083: */
084: private String letterSpacingUnit = "px"; //NOI18N
085:
086: /**
087: * Holds value of property letterSpacingValue.
088: */
089: private String letterSpacingValue = "";
090:
091: /**
092: * Holds value of property lineHeightUnit.
093: */
094: private String lineHeightUnit = "px"; //NOI18N
095:
096: /**
097: * Holds value of property lineHeightValue.
098: */
099: private String lineHeightValue;
100:
101: public void setVerticalAlign(String verticalAlignStr) {
102: verticalAlignUnit = getUnit(verticalAlignStr);
103: verticalAlignValue = verticalAlignStr.replaceAll(
104: verticalAlignUnit, "").trim();
105: }
106:
107: public void setIndentation(String indentationStr) {
108: indentationUnit = getUnit(indentationStr);
109: indentationValue = indentationStr.replaceAll(indentationUnit,
110: "").trim();
111: }
112:
113: public void setWordSpacing(String wordSpacingStr) {
114: wordSpacingUnit = getUnit(wordSpacingStr);
115: wordSpacingValue = wordSpacingStr.replaceAll(wordSpacingUnit,
116: "").trim();
117: }
118:
119: public void setLetterSpacing(String letterSpacingStr) {
120: letterSpacingUnit = getUnit(letterSpacingStr);
121: letterSpacingValue = letterSpacingStr.replaceAll(
122: letterSpacingUnit, "").trim();
123: }
124:
125: public void setLineHeight(String lineHeightStr) {
126: lineHeightUnit = getUnit(lineHeightStr);
127: lineHeightValue = lineHeightStr.replaceAll(lineHeightUnit, "")
128: .trim();
129: }
130:
131: private String getUnit(String textBlockStr) {
132: DefaultComboBoxModel unitList = new TextBlockModel()
133: .getTextBlockUnitList();
134: for (int i = 0; i < unitList.getSize(); i++) {
135: String unit = (String) unitList.getElementAt(i);
136: if (textBlockStr.trim().endsWith(unit)) {
137: return unit;
138: }
139: }
140: return "";
141: }
142:
143: /**
144: * Getter for property verticalAlignUnit.
145: * @return Value of property verticalAlignUnit.
146: */
147: public String getVerticalAlignUnit() {
148:
149: return this .verticalAlignUnit;
150: }
151:
152: /**
153: * Setter for property verticalAlignUnit.
154: * @param verticalAlignUnit New value of property verticalAlignUnit.
155: */
156: public void setVerticalAlignUnit(String verticalAlignUnit) {
157:
158: this .verticalAlignUnit = verticalAlignUnit;
159: }
160:
161: /**
162: * Getter for property verticalAlignValue.
163: * @return Value of property verticalAlignValue.
164: */
165: public String getVerticalAlignValue() {
166:
167: return this .verticalAlignValue;
168: }
169:
170: /**
171: * Setter for property verticalAlignValue.
172: * @param verticalAlignValue New value of property verticalAlignValue.
173: */
174: public void setVerticalAlignValue(String verticalAlignValue) {
175:
176: this .verticalAlignValue = verticalAlignValue;
177: }
178:
179: /**
180: * Getter for property indentationUnit.
181: * @return Value of property indentationUnit.
182: */
183: public String getIndentationUnit() {
184:
185: return this .indentationUnit;
186: }
187:
188: /**
189: * Setter for property indentationUnit.
190: * @param indentationUnit New value of property indentationUnit.
191: */
192: public void setIndentationUnit(java.lang.String indentationUnit) {
193:
194: this .indentationUnit = indentationUnit;
195: }
196:
197: /**
198: * Getter for property wordSpacingUnit.
199: * @return Value of property wordSpacingUnit.
200: */
201: public String getWordSpacingUnit() {
202:
203: return this .wordSpacingUnit;
204: }
205:
206: /**
207: * Setter for property wordSpacingUnit.
208: * @param wordSpacingUnit New value of property wordSpacingUnit.
209: */
210: public void setWordSpacingUnit(String wordSpacingUnit) {
211:
212: this .wordSpacingUnit = wordSpacingUnit;
213: }
214:
215: /**
216: * Getter for property indentationValue.
217: * @return Value of property indentationValue.
218: */
219: public String getIndentationValue() {
220:
221: return this .indentationValue;
222: }
223:
224: /**
225: * Setter for property indentationValue.
226: * @param indentationValue New value of property indentationValue.
227: */
228: public void setIndentationValue(String indentationValue) {
229:
230: this .indentationValue = indentationValue;
231: }
232:
233: /**
234: * Getter for property wordSpacingValue.
235: * @return Value of property wordSpacingValue.
236: */
237: public String getWordSpacingValue() {
238:
239: return this .wordSpacingValue;
240: }
241:
242: /**
243: * Setter for property wordSpacingValue.
244: * @param wordSpacingValue New value of property wordSpacingValue.
245: */
246: public void setWordSpacingValue(String wordSpacingValue) {
247:
248: this .wordSpacingValue = wordSpacingValue;
249: }
250:
251: /**
252: * Getter for property letterSpacingUnit.
253: * @return Value of property letterSpacingUnit.
254: */
255: public String getLetterSpacingUnit() {
256:
257: return this .letterSpacingUnit;
258: }
259:
260: /**
261: * Setter for property letterSpacingUnit.
262: * @param letterSpacingUnit New value of property letterSpacingUnit.
263: */
264: public void setLetterSpacingUnit(String letterSpacingUnit) {
265:
266: this .letterSpacingUnit = letterSpacingUnit;
267: }
268:
269: /**
270: * Getter for property letterSpacingValue.
271: * @return Value of property letterSpacingValue.
272: */
273: public String getLetterSpacingValue() {
274:
275: return this .letterSpacingValue;
276: }
277:
278: /**
279: * Setter for property letterSpacingValue.
280: * @param letterSpacingValue New value of property letterSpacingValue.
281: */
282: public void setLetterSpacingValue(String letterSpacingValue) {
283:
284: this .letterSpacingValue = letterSpacingValue;
285: }
286:
287: /**
288: * Getter for property lineHeightUnit.
289: * @return Value of property lineHeightUnit.
290: */
291: public String getLineHeightUnit() {
292:
293: return this .lineHeightUnit;
294: }
295:
296: /**
297: * Setter for property lineHeightUnit.
298: * @param lineHeightUnit New value of property lineHeightUnit.
299: */
300: public void setLineHeightUnit(String lineHeightUnit) {
301:
302: this .lineHeightUnit = lineHeightUnit;
303: }
304:
305: /**
306: * Getter for property lineHeightValue.
307: * @return Value of property lineHeightValue.
308: */
309: public String getLineHeightValue() {
310:
311: return this .lineHeightValue;
312: }
313:
314: /**
315: * Setter for property lineHeightValue.
316: * @param lineHeightValue New value of property lineHeightValue.
317: */
318: public void setLineHeightValue(String lineHeightValue) {
319:
320: this.lineHeightValue = lineHeightValue;
321: }
322:
323: }
|