src/share/classes/java/awt/image/ReplicateScaleFilter.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 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


 104                                                 ") must be non-zero");
 105         }
 106         destWidth = width;
 107         destHeight = height;
 108     }
 109 
 110     /**
 111      * Passes along the properties from the source object after adding a
 112      * property indicating the scale applied.
 113      * This method invokes <code>super.setProperties</code>,
 114      * which might result in additional properties being added.
 115      * <p>
 116      * Note: This method is intended to be called by the
 117      * <code>ImageProducer</code> of the <code>Image</code> whose pixels
 118      * are being filtered. Developers using
 119      * this class to filter pixels from an image should avoid calling
 120      * this method directly since that operation could interfere
 121      * with the filtering operation.
 122      */
 123     public void setProperties(Hashtable<?,?> props) {

 124         Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
 125         String key = "rescale";
 126         String val = destWidth + "x" + destHeight;
 127         Object o = p.get(key);
 128         if (o != null && o instanceof String) {
 129             val = ((String) o) + ", " + val;
 130         }
 131         p.put(key, val);
 132         super.setProperties(p);
 133     }
 134 
 135     /**
 136      * Override the dimensions of the source image and pass the dimensions
 137      * of the new scaled size to the ImageConsumer.
 138      * <p>
 139      * Note: This method is intended to be called by the
 140      * <code>ImageProducer</code> of the <code>Image</code> whose pixels
 141      * are being filtered. Developers using
 142      * this class to filter pixels from an image should avoid calling
 143      * this method directly since that operation could interfere


   1 /*
   2  * Copyright (c) 1996, 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


 104                                                 ") must be non-zero");
 105         }
 106         destWidth = width;
 107         destHeight = height;
 108     }
 109 
 110     /**
 111      * Passes along the properties from the source object after adding a
 112      * property indicating the scale applied.
 113      * This method invokes <code>super.setProperties</code>,
 114      * which might result in additional properties being added.
 115      * <p>
 116      * Note: This method is intended to be called by the
 117      * <code>ImageProducer</code> of the <code>Image</code> whose pixels
 118      * are being filtered. Developers using
 119      * this class to filter pixels from an image should avoid calling
 120      * this method directly since that operation could interfere
 121      * with the filtering operation.
 122      */
 123     public void setProperties(Hashtable<?,?> props) {
 124         @SuppressWarnings("unchecked")
 125         Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
 126         String key = "rescale";
 127         String val = destWidth + "x" + destHeight;
 128         Object o = p.get(key);
 129         if (o != null && o instanceof String) {
 130             val = ((String) o) + ", " + val;
 131         }
 132         p.put(key, val);
 133         super.setProperties(p);
 134     }
 135 
 136     /**
 137      * Override the dimensions of the source image and pass the dimensions
 138      * of the new scaled size to the ImageConsumer.
 139      * <p>
 140      * Note: This method is intended to be called by the
 141      * <code>ImageProducer</code> of the <code>Image</code> whose pixels
 142      * are being filtered. Developers using
 143      * this class to filter pixels from an image should avoid calling
 144      * this method directly since that operation could interfere