KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fonts > FontType


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: FontType.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.fonts;
21
22 import org.apache.avalon.framework.ValuedEnum;
23
24 /**
25  * This class enumerates all supported font types.
26  */

27 public class FontType extends ValuedEnum {
28
29     /**
30      * Collective identifier for "other" font types
31      */

32     public static final FontType OTHER = new FontType("Other", 0);
33     /**
34      * Adobe Type 0 fonts
35      */

36     public static final FontType TYPE0 = new FontType("Type0", 1);
37     /**
38      * Adobe Type 1 fonts
39      */

40     public static final FontType TYPE1 = new FontType("Type1", 2);
41     /**
42      * Adobe Multiple Master Type 1 fonts
43      */

44     public static final FontType MMTYPE1 = new FontType("MMType1", 3);
45     /**
46      * Adobe Type 3 fonts ("user-defined" fonts)
47      */

48     public static final FontType TYPE3 = new FontType("Type3", 4);
49     /**
50      * TrueType fonts
51      */

52     public static final FontType TRUETYPE = new FontType("TrueType", 5);
53
54
55     /**
56      * @see org.apache.avalon.framework.Enum#Enum(String)
57      */

58     protected FontType(String JavaDoc name, int value) {
59         super(name, value);
60     }
61
62
63     /**
64      * Returns the FontType by name.
65      * @param name Name of the font type to look up
66      * @return the font type
67      */

68     public static FontType byName(String JavaDoc name) {
69         if (name.equalsIgnoreCase(FontType.OTHER.getName())) {
70             return FontType.OTHER;
71         } else if (name.equalsIgnoreCase(FontType.TYPE0.getName())) {
72             return FontType.TYPE0;
73         } else if (name.equalsIgnoreCase(FontType.TYPE1.getName())) {
74             return FontType.TYPE1;
75         } else if (name.equalsIgnoreCase(FontType.MMTYPE1.getName())) {
76             return FontType.MMTYPE1;
77         } else if (name.equalsIgnoreCase(FontType.TYPE3.getName())) {
78             return FontType.TYPE3;
79         } else if (name.equalsIgnoreCase(FontType.TRUETYPE.getName())) {
80             return FontType.TRUETYPE;
81         } else {
82             throw new IllegalArgumentException JavaDoc("Invalid font type: " + name);
83         }
84     }
85     
86     
87     /**
88      * Returns the FontType by value.
89      * @param value Value of the font type to look up
90      * @return the font type
91      */

92     public static FontType byValue(int value) {
93         if (value == FontType.OTHER.getValue()) {
94             return FontType.OTHER;
95         } else if (value == FontType.TYPE0.getValue()) {
96             return FontType.TYPE0;
97         } else if (value == FontType.TYPE1.getValue()) {
98             return FontType.TYPE1;
99         } else if (value == FontType.MMTYPE1.getValue()) {
100             return FontType.MMTYPE1;
101         } else if (value == FontType.TYPE3.getValue()) {
102             return FontType.TYPE3;
103         } else if (value == FontType.TRUETYPE.getValue()) {
104             return FontType.TRUETYPE;
105         } else {
106             throw new IllegalArgumentException JavaDoc("Invalid font type: " + value);
107         }
108     }
109     
110 }
111
Popular Tags