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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @author Igor V. Stolyarov
22 package java.awt.image.renderable;
24 import java.awt.RenderingHints;
25 import java.awt.Shape;
26 import java.awt.geom.AffineTransform;
29 * The Class RenderContext stores data on how an image is to be rendered: the
30 * affine transform, the area of interest, and the rendering hints.
34 public class RenderContext implements Cloneable {
37 * The affine transform.
39 AffineTransform transform;
42 * The area of interest.
47 * The rendering hints.
52 * Instantiates a new render context.
55 * the affine transform.
57 * the area of interest.
59 * the rendering hints.
61 public RenderContext(AffineTransform usr2dev, Shape aoi, RenderingHints hints) {
62 this.transform = (AffineTransform)usr2dev.clone();
68 * Instantiates a new render context with no specified hints.
71 * the affine transform.
73 * the area of interest.
75 public RenderContext(AffineTransform usr2dev, Shape aoi) {
76 this(usr2dev, aoi, null);
80 * Instantiates a new render context with no specified area of interest.
83 * the affine transform.
85 * the rendering hints.
87 public RenderContext(AffineTransform usr2dev, RenderingHints hints) {
88 this(usr2dev, null, hints);
92 * Instantiates a new render context with no rendering hints or area of
96 * the affine transform.
98 public RenderContext(AffineTransform usr2dev) {
99 this(usr2dev, null, null);
103 public Object clone() {
104 return new RenderContext(transform, aoi, hints);
108 * Sets the affine transform for this render context.
110 * @param newTransform
111 * the new affine transform.
113 public void setTransform(AffineTransform newTransform) {
114 transform = (AffineTransform)newTransform.clone();
118 * Concatenates the current transform with the specified transform (so they
119 * are applied with the specified transform acting first) and sets the
120 * resulting transform as the affine transform of this rendering context.
122 * @param modTransform
123 * the new transform which modifies the current transform.
125 * {@link RenderContext#preConcatenateTransform(AffineTransform)}
129 public void preConcetenateTransform(AffineTransform modTransform) {
130 preConcatenateTransform(modTransform);
134 * Concatenates the current transform with the specified transform (so they
135 * are applied with the specified transform acting first) and sets the
136 * resulting transform as the affine transform of this rendering context.
138 * @param modTransform
139 * the new transform which modifies the current transform.
141 public void preConcatenateTransform(AffineTransform modTransform) {
142 transform.preConcatenate(modTransform);
146 * Concatenate the specified transform with the current transform.
148 * @param modTransform
149 * the new transform which modifies the current transform.
151 * {@link RenderContext#concatenateTransform(AffineTransform)}.
154 public void concetenateTransform(AffineTransform modTransform) {
155 concatenateTransform(modTransform);
159 * Concatenate the specified transform with the current transform.
161 * @param modTransform
162 * the new transform which modifies the current transform.
164 public void concatenateTransform(AffineTransform modTransform) {
165 transform.concatenate(modTransform);
169 * Gets the transform.
171 * @return the transform.
173 public AffineTransform getTransform() {
174 return (AffineTransform)transform.clone();
178 * Sets the area of interest.
181 * the new area of interest.
183 public void setAreaOfInterest(Shape newAoi) {
188 * Gets the area of interest.
190 * @return the area of interest.
192 public Shape getAreaOfInterest() {
197 * Sets the rendering hints.
200 * the new rendering hints.
202 public void setRenderingHints(RenderingHints hints) {
207 * Gets the rendering hints.
209 * @return the rendering hints.
211 public RenderingHints getRenderingHints() {