Debian Codegraph @

src/main/java/org/jfree/pdf/shading/Shading.java

raw
1 /* =====================================================================
2 * JFreePDF : a fast, light-weight PDF library for the Java(tm) platform
3 * =====================================================================
4 *
5 * (C)opyright 2013-2022, by David Gilbert. All rights reserved.
6 *
7 * https://github.com/jfree/orsonpdf
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
23 * Other names may be trademarks of their respective owners.]
24 *
25 * If you do not wish to be bound by the terms of the GPL, an alternative
26 * runtime license is available to JFree sponsors:
27 *
28 * https://github.com/sponsors/jfree
29 *
30 */
31
32 package org.jfree.pdf.shading;
33
34 import org.jfree.pdf.dictionary.Dictionary;
35 import org.jfree.pdf.internal.PDFObject;
36 import org.jfree.pdf.util.Args;
37
38 /**
39 * A PDF shading object (this class is abstract, subclasses implement
40 * particular shading types).
41 */
42 public abstract class Shading extends PDFObject {
43
44 /** The shading type. */
45 private ShadingType shadingType;
46
47 /** The dictionary. */
48 protected Dictionary dictionary;
49
50 /**
51 * Creates a new shading instance.
52 *
53 * @param number the PDF object number.
54 * @param shadingType the shading type ({@code null} not permitted).
55 */
56 protected Shading(int number, ShadingType shadingType) {
57 super(number);
58 Args.nullNotPermitted(shadingType, "shadingType");
59 this.shadingType = shadingType;
60 this.dictionary = new Dictionary();
61 this.dictionary.put("/ShadingType", String.valueOf(
62 shadingType.getNumber()));
63 }
64
65 /**
66 * Returns the shading type.
67 *
68 * @return The shading type (never {@code null}).
69 */
70 public ShadingType getShadingType() {
71 return this.shadingType;
72 }
73
74 /**
75 * Returns the bytes that go between the 'obj' and 'endobj' in the
76 * PDF output for this object.
77 *
78 * @return A byte array.
79 */
80 @Override
81 public byte[] getObjectBytes() {
82 return this.dictionary.toPDFBytes();
83 }
84 }