KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > documents > contents > XObjects


1 /*
2   Copyright 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
3
4   Contributors:
5     * Stefano Chizzolini (original code developer, info@stefanochizzolini.it):
6       contributed code is Copyright 2006 by Stefano Chizzolini.
7
8   This file should be part of the source code distribution of "PDF Clown library"
9   (the Program): see the accompanying README files for more info.
10
11   This Program is free software; you can redistribute it and/or modify it under
12   the terms of the GNU General Public License as published by the Free Software
13   Foundation; either version 2 of the License, or (at your option) any later version.
14
15   This Program is distributed in the hope that it will be useful, but WITHOUT ANY
16   WARRANTY, either expressed or implied; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18
19   You should have received a copy of the GNU General Public License along with this
20   Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
21
22   Redistribution and use, with or without modification, are permitted provided that such
23   redistributions retain the above copyright notice, license and disclaimer, along with
24   this list of conditions.
25 */

26
27 package it.stefanochizzolini.clown.documents.contents;
28
29 import it.stefanochizzolini.clown.documents.contents.xObjects.XObject;
30 import it.stefanochizzolini.clown.documents.Document;
31 import it.stefanochizzolini.clown.objects.PdfDictionary;
32 import it.stefanochizzolini.clown.objects.PdfDirectObject;
33 import it.stefanochizzolini.clown.objects.PdfIndirectObject;
34 import it.stefanochizzolini.clown.objects.PdfName;
35 import it.stefanochizzolini.clown.objects.PdfObjectWrapper;
36 import it.stefanochizzolini.clown.objects.PdfReference;
37 import it.stefanochizzolini.clown.util.NotImplementedException;
38
39 import java.util.ArrayList JavaDoc;
40 import java.util.Collection JavaDoc;
41 import java.util.Map JavaDoc;
42 import java.util.Set JavaDoc;
43
44 /**
45   External objects collection [PDF:1.6:3.7.2].
46 */

47 public class XObjects
48   extends PdfObjectWrapper<PdfDictionary>
49   implements Map JavaDoc<PdfName,XObject>
50 {
51   // <class>
52
// <dynamic>
53
// <constructors>
54
public XObjects(
55     Document context
56     )
57   {
58     super(
59       context.getFile(),
60       new PdfDictionary()
61       );
62   }
63
64   XObjects(
65     PdfDirectObject baseObject,
66     PdfIndirectObject container
67     )
68   {
69     super(
70       baseObject,
71       container
72       );
73   }
74   // </constructors>
75

76   // <interface>
77
// <public>
78
public Object JavaDoc clone(
79     Document context
80     )
81   {throw new NotImplementedException();}
82
83   /**
84     Gets the key associated to a given value.
85   */

86   public PdfName getKey(
87     XObject value
88     )
89   {return getBaseDataObject().getKey(value.getBaseObject());}
90
91   // <Map>
92
public void clear(
93     )
94   {getBaseDataObject().clear();}
95
96   public boolean containsKey(
97     Object JavaDoc key
98     )
99   {return getBaseDataObject().containsKey(key);}
100
101   public boolean containsValue(
102     Object JavaDoc value
103     )
104   {return getBaseDataObject().containsValue(((XObject)value).getBaseObject());}
105
106   public Set JavaDoc<Map.Entry JavaDoc<PdfName,XObject>> entrySet(
107     )
108   {throw new NotImplementedException();}
109
110   public boolean equals(
111     PdfDirectObject object
112     )
113   {throw new NotImplementedException();}
114
115   public XObject get(
116     Object JavaDoc key
117     )
118   {
119     return XObject.wrap(
120       (PdfReference)getBaseDataObject().get(key)
121       );
122   }
123
124   public int hashCode(
125     )
126   {throw new NotImplementedException();}
127
128   public boolean isEmpty(
129     )
130   {return getBaseDataObject().isEmpty();}
131
132   public Set JavaDoc<PdfName> keySet(
133     )
134   {return getBaseDataObject().keySet();}
135
136   public XObject put(
137     PdfName key,
138     XObject value
139     )
140   {
141     return XObject.wrap(
142       (PdfReference)getBaseDataObject().put(key,value.getBaseObject())
143       );
144   }
145
146   public void putAll(
147     Map JavaDoc<? extends PdfName,? extends XObject> entries
148     )
149   {throw new NotImplementedException();}
150
151   public XObject remove(
152     Object JavaDoc key
153     )
154   {
155     return XObject.wrap(
156       (PdfReference)getBaseDataObject().remove(key)
157       );
158   }
159
160   public int size(
161     )
162   {return getBaseDataObject().size();}
163
164   public Collection JavaDoc<XObject> values(
165     )
166   {
167     /*
168       NOTE: We have to encapsulate raw objects into XObject-derived ones.
169     */

170     // Get the raw objects!
171
Collection JavaDoc<PdfDirectObject> objects = getBaseDataObject().values();
172     // Get room for the corresponding Font collection!
173
Collection JavaDoc<XObject> values = new ArrayList JavaDoc<XObject>(objects.size());
174     // Populating the collection...
175
for(PdfDirectObject object : objects)
176     {values.add(XObject.wrap((PdfReference)object));}
177
178     return values;
179   }
180   // </Map>
181
// </public>
182
// </interface>
183
// </dynamic>
184
// </class>
185
}
Popular Tags