Debian Codegraph @

src/main/java/org/jfree/pdf/function/ExponentialInterpolationFunction.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.function;
33
34 import org.jfree.pdf.util.PDFUtils;
35
36 /**
37 * A PDF "Type 2" function.
38 */
39 public final class ExponentialInterpolationFunction extends Function {
40
41 double n;
42
43 float[] c0;
44
45 float[] c1;
46
47 /**
48 * Creates a new function.
49 *
50 * @param number the PDF object number.
51 * @param c0 the function result at 0.0.
52 * @param c1 the function result at 1.0.
53 */
54 public ExponentialInterpolationFunction(int number, float[] c0,
55 float[] c1) {
56 super(number, FunctionType.EXPONENTIAL_INTERPOLATION);
57 this.dictionary.put("/N", "1");
58 this.n = 1;
59 setC0(c0);
60 setC1(c1);
61 }
62
63 /**
64 * Returns the interpolation exponent. The default value is {@code 1}.
65 *
66 * @return The interpolation exponent.
67 */
68 public double getN() {
69 return this.n;
70 }
71
72 /**
73 * Sets the interpolation exponent.
74 *
75 * @param n the new interpolation exponent.
76 */
77 public void setN(double n) {
78 this.n = n;
79 this.dictionary.put("/N", String.valueOf(n));
80 }
81
82 /**
83 * Returns the function result when x is 0.0. The returned array is a
84 * copy.
85 *
86 * @return The function result when x is 0.0.
87 */
88 public float[] getC0() {
89 return this.c0.clone();
90 }
91
92 /**
93 * Sets the function result to be used when x is 0.0. The array passed to
94 * this method will be copied.
95 *
96 * @param c0 the function result ({@code null} not permitted).
97 */
98 public void setC0(float[] c0) {
99 this.c0 = c0.clone();
100 this.dictionary.put("/C0", PDFUtils.toPDFArray(c0));
101 }
102
103 /**
104 * Returns the function result when x is 1.0. The returned array is a
105 * copy.
106 *
107 * @return The function result when x is 1.0.
108 */
109 public float[] getC1() {
110 return this.c1.clone();
111 }
112
113 /**
114 * Sets the function result to be used when x is 1.0. The array passed to
115 * this method will be copied.
116 *
117 * @param c1 the function result ({@code null} not permitted).
118 */
119 public void setC1(float[] c1) {
120 this.c1 = c1.clone();
121 this.dictionary.put("/C1", PDFUtils.toPDFArray(c1));
122 }
123 }