KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > etymon > pj > object > PjFontType1


1 package com.etymon.pj.object;
2
3 import java.io.*;
4 import java.util.*;
5 import com.etymon.pj.*;
6 import com.etymon.pj.exception.*;
7
8 /**
9    A representation of a PDF type 1 font dictionary.
10    @author Nassib Nassar
11 */

12 public class PjFontType1
13     extends PjFont {
14
15     /**
16       Creates a new type 1 font dictionary.
17     */

18     public PjFontType1() {
19         super();
20         _h.put(PjName.SUBTYPE, PjName.TYPE1);
21     }
22
23     /**
24        Creates a type 1 font dictionary as a wrapper around a Hashtable.
25        @param h the Hashtable to use for this dictionary.
26     */

27     public PjFontType1(Hashtable h) {
28         super(h);
29     }
30
31     /**
32        Examines a dictionary to see if it is a PDF type 1 font.
33        @param dictionary the dictionary to examine.
34        @return true if the dictionary could be interpreted as a
35        valid PjFontType1 object.
36     */

37     public static boolean isLike(PjDictionary dictionary) {
38         Hashtable h = dictionary.getHashtable();
39         // check if the Type is Font and Subtype is Type1
40
try {
41             PjName type = (PjName)(h.get(PjName.TYPE));
42             if (type == null) {
43                 return false;
44             }
45             if ( ! type.equals(PjName.FONT) ) {
46                 return false;
47             }
48             PjName subtype = (PjName)(h.get(PjName.SUBTYPE));
49             if (subtype == null) {
50                 return false;
51             }
52             if ( ! subtype.equals(PjName.TYPE1) ) {
53                 return false;
54             }
55         }
56         catch (ClassCastException JavaDoc e) {
57             return false;
58         }
59         return true;
60     }
61
62     /**
63        Returns a deep copy of this object.
64        @return a deep copy of this object.
65        @exception CloneNotSupportedException if the instance can not be cloned.
66     */

67     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
68         return new PjFontType1(cloneHt());
69     }
70         
71 }
72
Popular Tags