KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > pdf > PDFResourceContext


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: PDFResourceContext.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.pdf;
21
22 /**
23  * The PDF resource context.
24  *
25  * There is one of these for every page in a PDF document. The object
26  * specifies the dimensions of the page and references a /Resources
27  * object, a contents stream and the page's parent in the page
28  * hierarchy.
29  *
30  * Modified by Mark Lillywhite, mark-fop@inomial.com. The Parent
31  * object was being referred to by reference, but all that we
32  * ever used from the Parent was its PDF object ID, and according
33  * to the memory profile this was causing OOM issues. So, we store
34  * only the object ID of the parent, rather than the parent itself.
35  */

36 public class PDFResourceContext extends PDFObject {
37
38     /**
39      * the page's /Resource object
40      */

41     protected PDFResources resources;
42
43     /**
44      * the list of annotation objects for this page
45      */

46     protected PDFAnnotList annotList;
47
48     /**
49      * Creates a new ResourceContext.
50      * @param resources the /Resources object
51      */

52     public PDFResourceContext(PDFResources resources) {
53         /* generic creation of object */
54         super();
55
56         /* set fields using parameters */
57         //this.document = doc;
58
this.resources = resources;
59         this.annotList = null;
60     }
61
62     /**
63      * Get the resources for this resource context.
64      *
65      * @return the resources in this resource context
66      */

67     public PDFResources getPDFResources() {
68         return this.resources;
69     }
70
71     /**
72      * set this page's annotation list
73      *
74      * @param annot a PDFAnnotList list of annotations
75      */

76     public void addAnnotation(PDFObject annot) {
77         if (this.annotList == null) {
78             this.annotList = getDocument().getFactory().makeAnnotList();
79         }
80         this.annotList.addAnnot(annot);
81     }
82
83     /**
84      * Get the current annotations.
85      *
86      * @return the current annotation list
87      */

88     public PDFAnnotList getAnnotations() {
89         return this.annotList;
90     }
91
92     /**
93      * A a GState to this resource context.
94      *
95      * @param gstate the GState to add
96      */

97     public void addGState(PDFGState gstate) {
98         getPDFResources().addGState(gstate);
99     }
100
101     /**
102      * Add the shading to the current resource context.
103      *
104      * @param shading the shading to add
105      */

106     public void addShading(PDFShading shading) {
107         getPDFResources().addShading(shading);
108     }
109
110 }
111
Popular Tags