⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppsvgimageproducer.java

📁 一个用Java写的
💻 JAVA
字号:
/****************************************************************** * Copyright (C) 2002-2006 Andrew Girow. All rights reserved.     * * ---------------------------------------------------------------* * This software is published under the terms of the TinyLine     * * License, a copy of which has been included with this           * * distribution in the TINYLINE_LICENSE.TXT file.                 * *                                                                * * For more information on the TinyLine,                          * * please see <http://www.tinyline.com/>.                         * *****************************************************************/package com.tinyline.app;import java.awt.Rectangle;import java.awt.image.*;import com.tinyline.svg.*;import com.tinyline.tiny2d.TinyRect;import com.tinyline.tiny2d.TinyPixbuf;/** * The <tt>PPSVGImageProducer</tt> is the J2ME Personal Profile * implementation of the SVGImageProducer interface. * <p> * @author (C) Andrew Girow * @version 1.9 * <p> */public class PPSVGImageProducer implements SVGImageProducer, ImageProducer{    /** The Color Model for this SVGRaster */    private ColorModel model;    /** The ImageConsumer associated with this PPSVGRaster */    private ImageConsumer theConsumer;    private SVGRaster  raster;    /**     * Constructs a new <tt>PPSVGRaster</tt>.     */    public PPSVGImageProducer(SVGRaster renderer)    {        raster = renderer;    }    /**     * Sets the ImageConsumer for this renderer     * @param imageconsumer the specified <code>ImageConsumer</code>     */    public void setConsumer(ImageConsumer consumer)    {        theConsumer = consumer;    }    /**     * Returns true if this renderer has a consumer; otherwise     * returns false     */    public boolean hasConsumer()    {        return (theConsumer != null);    }    /**     * Sends a rectangular region of the buffer of pixels to any     * ImageConsumers that are currently interested in the data for     * this image and notify them that a frame is complete.     */    public void sendPixels()    {        TinyPixbuf pixbuf = raster.getPixelBuffer();        int pixelscan     = pixbuf.width;        int pixeloffset   = pixelscan * raster.clipRect.ymin + raster.clipRect.xmin;        theConsumer.setPixels(raster.clipRect.xmin, raster.clipRect.ymin,          raster.clipRect.xmax - raster.clipRect.xmin, raster.clipRect.ymax - raster.clipRect.ymin, model,          pixbuf.pixels32, pixeloffset, pixelscan);    }    /**     * Sends pixel data to the ImageConsumer     */    public void  imageComplete()    {        theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE); // 2    }    // end of SVGPlayer    /**     * Adds an ImageConsumer to the list of consumers interested in     * data for this image.     * @param imageconsumer the specified <code>ImageConsumer</code>     */    public synchronized void addConsumer(ImageConsumer imageconsumer)    {        theConsumer = imageconsumer;    }    /**     * Determines if an ImageConsumer is on the list of consumers currently     * interested in data for this image.     * @param imageconsumer the specified <code>ImageConsumer</code>     * @return <code>true</code> if the <code>ImageConsumer</code>     * is on the list; <code>false</code> otherwise.     */    public boolean isConsumer(ImageConsumer imageconsumer)    {        return theConsumer == imageconsumer;    }    /**     * Removes an ImageConsumer from the list of consumers interested in     * data for this image.     * @param imageconsumer the specified <code>ImageConsumer</code>     */    public synchronized void removeConsumer(ImageConsumer imageconsumer)    {        if(theConsumer == imageconsumer)            theConsumer = null;    }    /**     * Requests that a given ImageConsumer have the image data delivered     * one more time in top-down, left-right order.     * @param imageconsumer the specified <code>ImageConsumer</code>     */    public void requestTopDownLeftRightResend(ImageConsumer imageconsumer)    {    }    /**     * Adds an ImageConsumer to the list of consumers interested in     * data for this image and immediately starts delivery of the     * image data through the ImageConsumer interface.     * @param imageconsumer the specified <code>ImageConsumer</code>     * image data through the ImageConsumer interface.     */    public void startProduction(ImageConsumer imageconsumer)    {        addConsumer(imageconsumer);        if(theConsumer == null) return;        initConsumer();        raster.invalidate();        raster.clearRect(raster.clipRect);        sendPixels();        theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE); // 2    }    /**     * Sets an ImageProducer object of this <tt>PPSVGRaster</tt>     * which is used to produce data for an Image object     *     * @param w The width of the associated Image object.     * @param h The height of the associated Image object.     * <P>COORDINATES ARE IN DEVICE SPACE.</P>     * @param colormodel  The ColorModel.     *     */    public synchronized void setColorModel(ColorModel colormodel)    {        model = colormodel;    }    /** Inits the ImageConsumer */    private final void initConsumer()    {        if(theConsumer == null) return;        TinyPixbuf pixbuf = raster.getPixelBuffer();        theConsumer.setDimensions(pixbuf.width, pixbuf.height);        theConsumer.setColorModel(model);        int hints = ImageConsumer.TOPDOWNLEFTRIGHT | ImageConsumer.SINGLEPASS;        theConsumer.setHints(hints);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -