001: /*
002: Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004: Contributors:
005: * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006: contributed code is Copyright © 2006 by Stefano Chizzolini.
007:
008: This file should be part of the source code distribution of "PDF Clown library"
009: (the Program): see the accompanying README files for more info.
010:
011: This Program is free software; you can redistribute it and/or modify it under
012: the terms of the GNU General Public License as published by the Free Software
013: Foundation; either version 2 of the License, or (at your option) any later version.
014:
015: This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016: WARRANTY, either expressed or implied; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019: You should have received a copy of the GNU General Public License along with this
020: Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022: Redistribution and use, with or without modification, are permitted provided that such
023: redistributions retain the above copyright notice, license and disclaimer, along with
024: this list of conditions.
025: */
026:
027: package it.stefanochizzolini.clown.documents.contents;
028:
029: import it.stefanochizzolini.clown.documents.Document;
030: import it.stefanochizzolini.clown.documents.contents.fonts.Font;
031: import it.stefanochizzolini.clown.objects.PdfDictionary;
032: import it.stefanochizzolini.clown.objects.PdfDirectObject;
033: import it.stefanochizzolini.clown.objects.PdfIndirectObject;
034: import it.stefanochizzolini.clown.objects.PdfName;
035: import it.stefanochizzolini.clown.objects.PdfObjectWrapper;
036: import it.stefanochizzolini.clown.objects.PdfReference;
037: import it.stefanochizzolini.clown.util.NotImplementedException;
038:
039: import java.util.ArrayList;
040: import java.util.Collection;
041: import java.util.Map;
042: import java.util.Set;
043:
044: /**
045: Fonts collection [PDF:1.6:3.7.2].
046: */
047: public class Fonts extends PdfObjectWrapper<PdfDictionary> implements
048: Map<PdfName, Font> {
049: // <class>
050: // <dynamic>
051: // <constructors>
052: public Fonts(Document context) {
053: super (context.getFile(), new PdfDictionary());
054: }
055:
056: Fonts(PdfDirectObject baseObject, PdfIndirectObject container) {
057: super (baseObject, container);
058: }
059:
060: // </constructors>
061:
062: // <interface>
063: // <public>
064: @Override
065: public Fonts clone(Document context) {
066: throw new NotImplementedException();
067: }
068:
069: /**
070: Gets the key associated to a given value.
071: */
072: public PdfName getKey(Font value) {
073: return getBaseDataObject().getKey(value.getBaseObject());
074: }
075:
076: // <Map>
077: public void clear() {
078: getBaseDataObject().clear();
079: }
080:
081: public boolean containsKey(Object key) {
082: return getBaseDataObject().containsKey(key);
083: }
084:
085: public boolean containsValue(Object value) {
086: return getBaseDataObject().containsValue(
087: ((Font) value).getBaseObject());
088: }
089:
090: public Set<Map.Entry<PdfName, Font>> entrySet() {
091: throw new NotImplementedException();
092: }
093:
094: public boolean equals(PdfDirectObject object) {
095: throw new NotImplementedException();
096: }
097:
098: public Font get(Object key) {
099: return Font.wrap((PdfReference) getBaseDataObject().get(key));
100: }
101:
102: public int hashCode() {
103: throw new NotImplementedException();
104: }
105:
106: public boolean isEmpty() {
107: return getBaseDataObject().isEmpty();
108: }
109:
110: public Set<PdfName> keySet() {
111: return getBaseDataObject().keySet();
112: }
113:
114: public Font put(PdfName key, Font value) {
115: return Font.wrap((PdfReference) getBaseDataObject().put(key,
116: value.getBaseObject()));
117: }
118:
119: public void putAll(Map<? extends PdfName, ? extends Font> entries) {
120: throw new NotImplementedException();
121: }
122:
123: public Font remove(Object key) {
124: return Font
125: .wrap((PdfReference) getBaseDataObject().remove(key));
126: }
127:
128: public int size() {
129: return getBaseDataObject().size();
130: }
131:
132: public Collection<Font> values() {
133: /*
134: NOTE: We have to encapsulate raw objects into Font-derived ones.
135: */
136: // Get the raw objects!
137: Collection<PdfDirectObject> objects = getBaseDataObject()
138: .values();
139: // Get room for the corresponding Font collection!
140: Collection<Font> values = new ArrayList<Font>(objects.size());
141: // Populating the Font collection...
142: for (PdfDirectObject object : objects) {
143: values.add(Font.wrap((PdfReference) object));
144: }
145:
146: return values;
147: }
148: // </Map>
149: // </public>
150: // </interface>
151: // </dynamic>
152: // </class>
153: }
|