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 23 * questions. 24 */ 25 26 package java.awt.image; 27 28 /** 29 * The interface for objects which can produce the image data for Images. 30 * Each image contains an ImageProducer which is used to reconstruct 31 * the image whenever it is needed, for example, when a new size of the 32 * Image is scaled, or when the width or height of the Image is being 33 * requested. 34 * 35 * @see ImageConsumer 36 * 37 * @author Jim Graham 38 */ 39 public interface ImageProducer { 40 /** 41 * Registers an {@code ImageConsumer} with the 42 * {@code ImageProducer} for access to the image data 43 * during a later reconstruction of the {@code Image}. 44 * The {@code ImageProducer} may, at its discretion, 45 * start delivering the image data to the consumer 46 * using the {@code ImageConsumer} interface immediately, 47 * or when the next available image reconstruction is triggered 92 * that the {@code ImageProducer} attempt to resend 93 * the image data one more time in TOPDOWNLEFTRIGHT order 94 * so that higher quality conversion algorithms which 95 * depend on receiving pixels in order can be used to 96 * produce a better output version of the image. The 97 * {@code ImageProducer} is free to 98 * ignore this call if it cannot resend the data in that 99 * order. If the data can be resent, the 100 * {@code ImageProducer} should respond by executing 101 * the following minimum set of {@code ImageConsumer} 102 * method calls: 103 * <pre>{@code 104 * ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >); 105 * ic.setPixels(...); // As many times as needed 106 * ic.imageComplete(); 107 * }</pre> 108 * @param ic the specified {@code ImageConsumer} 109 * @see ImageConsumer#setHints 110 */ 111 public void requestTopDownLeftRightResend(ImageConsumer ic); 112 } | 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 23 * questions. 24 */ 25 26 package java.awt.image; 27 28 import java.util.Arrays; 29 import java.util.List; 30 31 /** 32 * The interface for objects which can produce the image data for Images. 33 * Each image contains an ImageProducer which is used to reconstruct 34 * the image whenever it is needed, for example, when a new size of the 35 * Image is scaled, or when the width or height of the Image is being 36 * requested. 37 * 38 * @see ImageConsumer 39 * 40 * @author Jim Graham 41 */ 42 public interface ImageProducer { 43 /** 44 * Registers an {@code ImageConsumer} with the 45 * {@code ImageProducer} for access to the image data 46 * during a later reconstruction of the {@code Image}. 47 * The {@code ImageProducer} may, at its discretion, 48 * start delivering the image data to the consumer 49 * using the {@code ImageConsumer} interface immediately, 50 * or when the next available image reconstruction is triggered 95 * that the {@code ImageProducer} attempt to resend 96 * the image data one more time in TOPDOWNLEFTRIGHT order 97 * so that higher quality conversion algorithms which 98 * depend on receiving pixels in order can be used to 99 * produce a better output version of the image. The 100 * {@code ImageProducer} is free to 101 * ignore this call if it cannot resend the data in that 102 * order. If the data can be resent, the 103 * {@code ImageProducer} should respond by executing 104 * the following minimum set of {@code ImageConsumer} 105 * method calls: 106 * <pre>{@code 107 * ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >); 108 * ic.setPixels(...); // As many times as needed 109 * ic.imageComplete(); 110 * }</pre> 111 * @param ic the specified {@code ImageConsumer} 112 * @see ImageConsumer#setHints 113 */ 114 public void requestTopDownLeftRightResend(ImageConsumer ic); 115 116 /** 117 * Returns {@code true} if {@code ImageProducer} consist of a set of 118 * image producers which can be used for {@code MultiResolutionImage} 119 * construction. 120 * 121 * @return {@code true} if {@code ImageProducer} consist of a set of 122 * image producers 123 * 124 * @see #getResolutionVariantItems 125 * @see MultiResolutionImage 126 * 127 * @since 9 128 */ 129 default boolean isMultiResolutionImageProducer() { 130 return false; 131 } 132 133 /** 134 * Gets a readable list of all resolution variant items consisting of 135 * {@code ImageProducer} and associated scale factors. The provided 136 * resolution variant items can be used for {@code MultiResolutionImage} 137 * construction. 138 * The list must be nonempty and contain at least one resolution variant item. 139 * <p> 140 * Note that many implementations might return an unmodifiable list. 141 * 142 * @return list of resolution variant items. 143 * @see #isMultiResolutionImageProducer 144 * @see MultiResolutionImage 145 * 146 * @since 9 147 */ 148 default List<ResolutionVariantItem<ImageProducer>> getResolutionVariantItems() { 149 return Arrays.asList(new ResolutionVariantItem<>(this, 1, 1)); 150 } 151 } |