1 /*
2 * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
127 */
128 public RescaleOp (float scaleFactor, float offset, RenderingHints hints) {
129 length = 1;
130 this.scaleFactors = new float[1];
131 this.offsets = new float[1];
132 this.scaleFactors[0] = scaleFactor;
133 this.offsets[0] = offset;
134 this.hints = hints;
135 }
136
137 /**
138 * Returns the scale factors in the given array. The array is also
139 * returned for convenience. If scaleFactors is null, a new array
140 * will be allocated.
141 * @param scaleFactors the array to contain the scale factors of
142 * this <code>RescaleOp</code>
143 * @return the scale factors of this <code>RescaleOp</code>.
144 */
145 final public float[] getScaleFactors (float scaleFactors[]) {
146 if (scaleFactors == null) {
147 return (float[]) this.scaleFactors.clone();
148 }
149 System.arraycopy (this.scaleFactors, 0, scaleFactors, 0,
150 Math.min(this.scaleFactors.length,
151 scaleFactors.length));
152 return scaleFactors;
153 }
154
155 /**
156 * Returns the offsets in the given array. The array is also returned
157 * for convenience. If offsets is null, a new array
158 * will be allocated.
159 * @param offsets the array to contain the offsets of
160 * this <code>RescaleOp</code>
161 * @return the offsets of this <code>RescaleOp</code>.
162 */
163 final public float[] getOffsets(float offsets[]) {
164 if (offsets == null) {
165 return (float[]) this.offsets.clone();
166 }
167
168 System.arraycopy (this.offsets, 0, offsets, 0,
169 Math.min(this.offsets.length, offsets.length));
170 return offsets;
171 }
172
173 /**
174 * Returns the number of scaling factors and offsets used in this
175 * RescaleOp.
176 * @return the number of scaling factors and offsets of this
177 * <code>RescaleOp</code>.
178 */
179 final public int getNumFactors() {
180 return length;
181 }
182
183
184 /**
185 * Creates a ByteLookupTable to implement the rescale.
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
127 */
128 public RescaleOp (float scaleFactor, float offset, RenderingHints hints) {
129 length = 1;
130 this.scaleFactors = new float[1];
131 this.offsets = new float[1];
132 this.scaleFactors[0] = scaleFactor;
133 this.offsets[0] = offset;
134 this.hints = hints;
135 }
136
137 /**
138 * Returns the scale factors in the given array. The array is also
139 * returned for convenience. If scaleFactors is null, a new array
140 * will be allocated.
141 * @param scaleFactors the array to contain the scale factors of
142 * this <code>RescaleOp</code>
143 * @return the scale factors of this <code>RescaleOp</code>.
144 */
145 final public float[] getScaleFactors (float scaleFactors[]) {
146 if (scaleFactors == null) {
147 return this.scaleFactors.clone();
148 }
149 System.arraycopy (this.scaleFactors, 0, scaleFactors, 0,
150 Math.min(this.scaleFactors.length,
151 scaleFactors.length));
152 return scaleFactors;
153 }
154
155 /**
156 * Returns the offsets in the given array. The array is also returned
157 * for convenience. If offsets is null, a new array
158 * will be allocated.
159 * @param offsets the array to contain the offsets of
160 * this <code>RescaleOp</code>
161 * @return the offsets of this <code>RescaleOp</code>.
162 */
163 final public float[] getOffsets(float offsets[]) {
164 if (offsets == null) {
165 return this.offsets.clone();
166 }
167
168 System.arraycopy (this.offsets, 0, offsets, 0,
169 Math.min(this.offsets.length, offsets.length));
170 return offsets;
171 }
172
173 /**
174 * Returns the number of scaling factors and offsets used in this
175 * RescaleOp.
176 * @return the number of scaling factors and offsets of this
177 * <code>RescaleOp</code>.
178 */
179 final public int getNumFactors() {
180 return length;
181 }
182
183
184 /**
185 * Creates a ByteLookupTable to implement the rescale.
|