001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Ilya S. Okomin
019: * @version $Revision$
020: */package java.awt.font;
021:
022: import java.io.InvalidObjectException;
023: import java.text.AttributedCharacterIterator.Attribute;
024: import java.util.HashMap;
025: import java.util.Map;
026:
027: import org.apache.harmony.awt.internal.nls.Messages;
028:
029: public final class TextAttribute extends Attribute {
030: private static final long serialVersionUID = 7744112784117861702L;
031:
032: // set of available text attributes
033: private static final Map<String, TextAttribute> attrMap = new HashMap<String, TextAttribute>();
034:
035: protected TextAttribute(String name) {
036: super (name);
037: attrMap.put(name, this );
038: }
039:
040: @Override
041: protected Object readResolve() throws InvalidObjectException {
042: TextAttribute result = attrMap.get(this .getName());
043: if (result != null) {
044: return result;
045: }
046: // awt.194=Unknown attribute name
047: throw new InvalidObjectException(Messages.getString("awt.194")); //$NON-NLS-1$
048: }
049:
050: public static final TextAttribute BACKGROUND = new TextAttribute(
051: "background"); //$NON-NLS-1$
052:
053: public static final TextAttribute BIDI_EMBEDDING = new TextAttribute(
054: "bidi_embedding"); //$NON-NLS-1$
055:
056: public static final TextAttribute CHAR_REPLACEMENT = new TextAttribute(
057: "char_replacement"); //$NON-NLS-1$
058:
059: public static final TextAttribute FAMILY = new TextAttribute(
060: "family"); //$NON-NLS-1$
061:
062: public static final TextAttribute FONT = new TextAttribute("font"); //$NON-NLS-1$
063:
064: public static final TextAttribute FOREGROUND = new TextAttribute(
065: "foreground"); //$NON-NLS-1$
066:
067: public static final TextAttribute INPUT_METHOD_HIGHLIGHT = new TextAttribute(
068: "input method highlight"); //$NON-NLS-1$
069:
070: public static final TextAttribute INPUT_METHOD_UNDERLINE = new TextAttribute(
071: "input method underline"); //$NON-NLS-1$
072:
073: public static final TextAttribute JUSTIFICATION = new TextAttribute(
074: "justification"); //$NON-NLS-1$
075:
076: public static final Float JUSTIFICATION_FULL = new Float(1.0f);
077:
078: public static final Float JUSTIFICATION_NONE = new Float(0.0f);
079:
080: public static final TextAttribute NUMERIC_SHAPING = new TextAttribute(
081: "numeric_shaping"); //$NON-NLS-1$
082:
083: public static final TextAttribute POSTURE = new TextAttribute(
084: "posture"); //$NON-NLS-1$
085:
086: public static final Float POSTURE_REGULAR = new Float(0.0f);
087:
088: public static final Float POSTURE_OBLIQUE = new Float(0.20f);
089:
090: public static final TextAttribute RUN_DIRECTION = new TextAttribute(
091: "run_direction"); //$NON-NLS-1$
092:
093: public static final Boolean RUN_DIRECTION_LTR = new Boolean(false);
094:
095: public static final Boolean RUN_DIRECTION_RTL = new Boolean(true);
096:
097: public static final TextAttribute SIZE = new TextAttribute("size"); //$NON-NLS-1$
098:
099: public static final TextAttribute STRIKETHROUGH = new TextAttribute(
100: "strikethrough"); //$NON-NLS-1$
101:
102: public static final Boolean STRIKETHROUGH_ON = new Boolean(true);
103:
104: public static final TextAttribute SUPERSCRIPT = new TextAttribute(
105: "superscript"); //$NON-NLS-1$
106:
107: public static final Integer SUPERSCRIPT_SUB = new Integer(-1);
108:
109: public static final Integer SUPERSCRIPT_SUPER = new Integer(1);
110:
111: public static final TextAttribute SWAP_COLORS = new TextAttribute(
112: "swap_colors"); //$NON-NLS-1$
113:
114: public static final Boolean SWAP_COLORS_ON = new Boolean(true);
115:
116: public static final TextAttribute TRANSFORM = new TextAttribute(
117: "transform"); //$NON-NLS-1$
118:
119: public static final TextAttribute UNDERLINE = new TextAttribute(
120: "underline"); //$NON-NLS-1$
121:
122: public static final Integer UNDERLINE_ON = new Integer(0);
123:
124: public static final Integer UNDERLINE_LOW_ONE_PIXEL = new Integer(1);
125:
126: public static final Integer UNDERLINE_LOW_TWO_PIXEL = new Integer(2);
127:
128: public static final Integer UNDERLINE_LOW_DOTTED = new Integer(3);
129:
130: public static final Integer UNDERLINE_LOW_GRAY = new Integer(4);
131:
132: public static final Integer UNDERLINE_LOW_DASHED = new Integer(5);
133:
134: public static final TextAttribute WEIGHT = new TextAttribute(
135: "weight"); //$NON-NLS-1$
136:
137: public static final Float WEIGHT_EXTRA_LIGHT = new Float(0.5f);
138:
139: public static final Float WEIGHT_LIGHT = new Float(0.75f);
140:
141: public static final Float WEIGHT_DEMILIGHT = new Float(0.875f);
142:
143: public static final Float WEIGHT_REGULAR = new Float(1.0f);
144:
145: public static final Float WEIGHT_SEMIBOLD = new Float(1.25f);
146:
147: public static final Float WEIGHT_MEDIUM = new Float(1.5f);
148:
149: public static final Float WEIGHT_DEMIBOLD = new Float(1.75f);
150:
151: public static final Float WEIGHT_BOLD = new Float(2.0f);
152:
153: public static final Float WEIGHT_HEAVY = new Float(2.25f);
154:
155: public static final Float WEIGHT_EXTRABOLD = new Float(2.5f);
156:
157: public static final Float WEIGHT_ULTRABOLD = new Float(2.75f);
158:
159: public static final TextAttribute WIDTH = new TextAttribute("width"); //$NON-NLS-1$
160:
161: public static final Float WIDTH_CONDENSED = new Float(0.75f);
162:
163: public static final Float WIDTH_SEMI_CONDENSED = new Float(0.875f);
164:
165: public static final Float WIDTH_REGULAR = new Float(1.0f);
166:
167: public static final Float WIDTH_SEMI_EXTENDED = new Float(1.25f);
168:
169: public static final Float WIDTH_EXTENDED = new Float(1.5f);
170:
171: }
|