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.contents.colorSpaces.ColorSpace;
030: import it.stefanochizzolini.clown.documents.Document;
031: import it.stefanochizzolini.clown.objects.PdfDictionary;
032: import it.stefanochizzolini.clown.objects.PdfName;
033: import it.stefanochizzolini.clown.objects.PdfDirectObject;
034: import it.stefanochizzolini.clown.objects.PdfIndirectObject;
035: import it.stefanochizzolini.clown.objects.PdfObjectWrapper;
036: import it.stefanochizzolini.clown.util.NotImplementedException;
037:
038: import java.util.ArrayList;
039: import java.util.Collection;
040: import java.util.Map;
041: import java.util.Set;
042:
043: /**
044: Color spaces collection [PDF:1.6:3.7.2].
045: */
046: public class ColorSpaces extends PdfObjectWrapper<PdfDictionary>
047: implements Map<PdfName, ColorSpace> {
048: // <class>
049: // <dynamic>
050: // <constructors>
051: public ColorSpaces(Document context) {
052: super (context.getFile(), new PdfDictionary());
053: }
054:
055: ColorSpaces(PdfDirectObject baseObject, PdfIndirectObject container) {
056: super (baseObject, container);
057: }
058:
059: // </constructors>
060:
061: // <interface>
062: // <public>
063: @Override
064: public ColorSpaces clone(Document context) {
065: throw new NotImplementedException();
066: }
067:
068: /**
069: Gets the key associated to a given value.
070: */
071: public PdfName getKey(ColorSpace value) {
072: return getBaseDataObject().getKey(value.getBaseObject());
073: }
074:
075: // <Map>
076: public void clear() {
077: getBaseDataObject().clear();
078: }
079:
080: public boolean containsKey(Object key) {
081: return getBaseDataObject().containsKey(key);
082: }
083:
084: public boolean containsValue(Object value) {
085: return getBaseDataObject().containsValue(
086: ((ColorSpace) value).getBaseObject());
087: }
088:
089: public Set<Map.Entry<PdfName, ColorSpace>> entrySet() {
090: throw new NotImplementedException();
091: }
092:
093: public boolean equals(PdfDirectObject object) {
094: throw new NotImplementedException();
095: }
096:
097: public ColorSpace get(Object key) {
098: return ColorSpace.wrap(getBaseDataObject().get(key),
099: getContainer());
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 ColorSpace put(PdfName key, ColorSpace value) {
115: return ColorSpace.wrap(getBaseDataObject().put(key,
116: value.getBaseObject()), getContainer());
117: }
118:
119: public void putAll(
120: Map<? extends PdfName, ? extends ColorSpace> entries) {
121: throw new NotImplementedException();
122: }
123:
124: public ColorSpace remove(Object key) {
125: return ColorSpace.wrap(getBaseDataObject().remove(key),
126: getContainer());
127: }
128:
129: public int size() {
130: return getBaseDataObject().size();
131: }
132:
133: public Collection<ColorSpace> values() {
134: /*
135: NOTE: We have to encapsulate raw objects into ColorSpace-derived ones.
136: */
137: // Get the raw objects!
138: Collection<PdfDirectObject> objects = getBaseDataObject()
139: .values();
140: // Get room for the corresponding Font collection!
141: Collection<ColorSpace> values = new ArrayList<ColorSpace>(
142: objects.size());
143: // Populating the collection...
144: for (PdfDirectObject object : objects) {
145: values.add(ColorSpace.wrap(object, getContainer()));
146: }
147:
148: return values;
149: }
150: // </Map>
151: // </public>
152: // </interface>
153: // </dynamic>
154: // </class>
155: }
|