KickJava   Java API By Example, From Geeks To Geeks.

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


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  * TextDecorationData.java
22  *
23  * Created on October 21, 2004, 1:49 PM
24  */

25
26 package org.netbeans.modules.css.visual.model;
27
28 import java.util.StringTokenizer JavaDoc;
29
30 /**
31  * Data structure for the Text Decoration data
32  * @author Winston Prakash
33  * @version 1.0
34  */

35 public class TextDecorationData {
36
37     private boolean noDecorationEnabled = false;
38     private boolean underlineEnabled = false;
39     private boolean overlineEnabled = false;
40     private boolean lineThroughEnabled = false;
41     private boolean blinkEnabled = false;
42
43     /** Creates a new instance of TextDecorationData */
44     public TextDecorationData() {
45     }
46
47     public void setDecoration(String JavaDoc decorationStr){
48         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(decorationStr);
49         enableUnderline(false);
50         enableOverline(false);
51         enableLineThrough(false);
52         enableBlink(false);
53         enableNoDecoration(false);
54         while(st.hasMoreTokens()){
55             String JavaDoc token = st.nextToken();
56             if(token.trim().equals("underline")){ //NOI18N
57
enableUnderline(true);
58             }
59             if(token.trim().equals("overline")){ //NOI18N
60
enableOverline(true);
61             }
62             if(token.trim().equals("line-through")){ //NOI18N
63
enableLineThrough(true);
64             }
65             if(token.trim().equals("blink")){ //NOI18N
66
enableBlink(true);
67             }
68             if(token.trim().equals("none")){ //NOI18N
69
enableNoDecoration(true);
70             }
71         }
72     }
73
74     /**
75      * Enable/disable the underling of text.
76      */

77     public void enableUnderline(boolean underlineEnabled) {
78         this.underlineEnabled = underlineEnabled;
79     }
80
81     public boolean underlineEnabled() {
82         return underlineEnabled;
83     }
84
85     /**
86      * Enable/disable the overlining of text.
87      */

88     public void enableOverline(boolean overlineEnabled) {
89         this.overlineEnabled = overlineEnabled;
90     }
91
92     public boolean overlineEnabled() {
93         return overlineEnabled;
94     }
95
96     /**
97      * Enable/disable the line through effect of text.
98      */

99     public void enableLineThrough(boolean lineThroughEnabled) {
100         this.lineThroughEnabled = lineThroughEnabled;
101     }
102
103     public boolean lineThroughEnabled() {
104         return lineThroughEnabled;
105     }
106
107     /**
108      * Enable/disable text blinking.
109      */

110     public void enableBlink(boolean blinkEnabled) {
111         this.blinkEnabled = blinkEnabled;
112     }
113
114     public boolean blinkEnabled() {
115         return blinkEnabled;
116     }
117
118     /**
119      * Enable/disable text blinking.
120      */

121     public void enableNoDecoration(boolean noDecorationEnabled) {
122         this.noDecorationEnabled = noDecorationEnabled;
123         if(noDecorationEnabled){
124             enableUnderline(false);
125             enableOverline(false);
126             enableLineThrough(false);
127             enableBlink(false);
128         }
129     }
130
131     public boolean noDecorationEnabled() {
132         return noDecorationEnabled;
133     }
134
135     public String JavaDoc toString(){
136         String JavaDoc textDecoration="";
137         if(noDecorationEnabled){
138             return "none"; //NOI18N
139
}
140         if(underlineEnabled){
141             textDecoration += " underline"; //NOI18N
142
}
143         if(overlineEnabled){
144             textDecoration += " overline"; //NOI18N
145
}
146         if(lineThroughEnabled){
147             textDecoration += " line-through"; //NOI18N
148
}
149         if(blinkEnabled){
150             textDecoration += " blink"; //NOI18N
151
}
152
153         return textDecoration;
154     }
155
156
157 }
158
Popular Tags