1 /*
2 * Copyright (c) 1995, 2004, 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
62 cropX = x;
63 cropY = y;
64 cropW = w;
65 cropH = h;
66 }
67
68 /**
69 * Passes along the properties from the source object after adding a
70 * property indicating the cropped region.
71 * This method invokes <code>super.setProperties</code>,
72 * which might result in additional properties being added.
73 * <p>
74 * Note: This method is intended to be called by the
75 * <code>ImageProducer</code> of the <code>Image</code> whose pixels
76 * are being filtered. Developers using
77 * this class to filter pixels from an image should avoid calling
78 * this method directly since that operation could interfere
79 * with the filtering operation.
80 */
81 public void setProperties(Hashtable<?,?> props) {
82 Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
83 p.put("croprect", new Rectangle(cropX, cropY, cropW, cropH));
84 super.setProperties(p);
85 }
86
87 /**
88 * Override the source image's dimensions and pass the dimensions
89 * of the rectangular cropped region to the ImageConsumer.
90 * <p>
91 * Note: This method is intended to be called by the
92 * <code>ImageProducer</code> of the <code>Image</code> whose
93 * pixels are being filtered. Developers using
94 * this class to filter pixels from an image should avoid calling
95 * this method directly since that operation could interfere
96 * with the filtering operation.
97 * @see ImageConsumer
98 */
99 public void setDimensions(int w, int h) {
100 consumer.setDimensions(cropW, cropH);
101 }
|
1 /*
2 * Copyright (c) 1995, 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
62 cropX = x;
63 cropY = y;
64 cropW = w;
65 cropH = h;
66 }
67
68 /**
69 * Passes along the properties from the source object after adding a
70 * property indicating the cropped region.
71 * This method invokes <code>super.setProperties</code>,
72 * which might result in additional properties being added.
73 * <p>
74 * Note: This method is intended to be called by the
75 * <code>ImageProducer</code> of the <code>Image</code> whose pixels
76 * are being filtered. Developers using
77 * this class to filter pixels from an image should avoid calling
78 * this method directly since that operation could interfere
79 * with the filtering operation.
80 */
81 public void setProperties(Hashtable<?,?> props) {
82 @SuppressWarnings("unchecked")
83 Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
84 p.put("croprect", new Rectangle(cropX, cropY, cropW, cropH));
85 super.setProperties(p);
86 }
87
88 /**
89 * Override the source image's dimensions and pass the dimensions
90 * of the rectangular cropped region to the ImageConsumer.
91 * <p>
92 * Note: This method is intended to be called by the
93 * <code>ImageProducer</code> of the <code>Image</code> whose
94 * pixels are being filtered. Developers using
95 * this class to filter pixels from an image should avoid calling
96 * this method directly since that operation could interfere
97 * with the filtering operation.
98 * @see ImageConsumer
99 */
100 public void setDimensions(int w, int h) {
101 consumer.setDimensions(cropW, cropH);
102 }
|