當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageConsumer.setHints方法代碼示例

本文整理匯總了Java中java.awt.image.ImageConsumer.setHints方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageConsumer.setHints方法的具體用法?Java ImageConsumer.setHints怎麽用?Java ImageConsumer.setHints使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.image.ImageConsumer的用法示例。


在下文中一共展示了ImageConsumer.setHints方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setFullBufferUpdates

import java.awt.image.ImageConsumer; //導入方法依賴的package包/類
/**
 * Specifies whether this animated memory image should always be
 * updated by sending the complete buffer of pixels whenever
 * there is a change.
 * This flag is ignored if the animation flag is not turned on
 * through the setAnimated() method.
 * <p>This method should be called immediately after the
 * MemoryImageSource is constructed and before an image is
 * created with it to ensure that all ImageConsumers will
 * receive the correct pixel delivery hints.
 * @param fullbuffers <code>true</code> if the complete pixel
 *             buffer should always
 * be sent
 * @see #setAnimated
 */
public synchronized void setFullBufferUpdates(boolean fullbuffers) {
    if (this.fullbuffers == fullbuffers) {
        return;
    }
    this.fullbuffers = fullbuffers;
    if (animating) {
        Enumeration enum_ = theConsumers.elements();
        while (enum_.hasMoreElements()) {
            ImageConsumer ic = (ImageConsumer) enum_.nextElement();
            ic.setHints(fullbuffers
                        ? (ImageConsumer.TOPDOWNLEFTRIGHT |
                           ImageConsumer.COMPLETESCANLINES)
                        : ImageConsumer.RANDOMPIXELORDER);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:32,代碼來源:MemoryImageSource.java

示例2: initConsumer

import java.awt.image.ImageConsumer; //導入方法依賴的package包/類
private void initConsumer(ImageConsumer ic) {
    if (isConsumer(ic)) {
        ic.setDimensions(width, height);
    }
    if (isConsumer(ic)) {
        ic.setProperties(properties);
    }
    if (isConsumer(ic)) {
        ic.setColorModel(model);
    }
    if (isConsumer(ic)) {
        ic.setHints(animating
                    ? (fullbuffers
                       ? (ImageConsumer.TOPDOWNLEFTRIGHT |
                          ImageConsumer.COMPLETESCANLINES)
                       : ImageConsumer.RANDOMPIXELORDER)
                    : (ImageConsumer.TOPDOWNLEFTRIGHT |
                       ImageConsumer.COMPLETESCANLINES |
                       ImageConsumer.SINGLEPASS |
                       ImageConsumer.SINGLEFRAME));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:MemoryImageSource.java

示例3: setFullBufferUpdates

import java.awt.image.ImageConsumer; //導入方法依賴的package包/類
/**
 * Specifies whether this animated memory image should always be
 * updated by sending the complete buffer of pixels whenever
 * there is a change.
 * This flag is ignored if the animation flag is not turned on
 * through the setAnimated() method.
 * <p>This method should be called immediately after the
 * MemoryImageSource is constructed and before an image is
 * created with it to ensure that all ImageConsumers will
 * receive the correct pixel delivery hints.
 * @param fullbuffers {@code true} if the complete pixel
 *             buffer should always
 * be sent
 * @see #setAnimated
 */
public synchronized void setFullBufferUpdates(boolean fullbuffers) {
    if (this.fullbuffers == fullbuffers) {
        return;
    }
    this.fullbuffers = fullbuffers;
    if (animating) {
        Enumeration<ImageConsumer> enum_ = theConsumers.elements();
        while (enum_.hasMoreElements()) {
            ImageConsumer ic = enum_.nextElement();
            ic.setHints(fullbuffers
                        ? (ImageConsumer.TOPDOWNLEFTRIGHT |
                           ImageConsumer.COMPLETESCANLINES)
                        : ImageConsumer.RANDOMPIXELORDER);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:MemoryImageSource.java

示例4: run

import java.awt.image.ImageConsumer; //導入方法依賴的package包/類
/**
 * The runnable method for this class. This will produce an image using
 * the current RenderableImage and RenderContext and send it to all the
 * ImageConsumer currently registered with this class.
 */
public void run() {
    // First get the rendered image
    RenderedImage rdrdImage;
    if (rc != null) {
        rdrdImage = rdblImage.createRendering(rc);
    } else {
        rdrdImage = rdblImage.createDefaultRendering();
    }

    // And its ColorModel
    ColorModel colorModel = rdrdImage.getColorModel();
    Raster raster = rdrdImage.getData();
    SampleModel sampleModel = raster.getSampleModel();
    DataBuffer dataBuffer = raster.getDataBuffer();

    if (colorModel == null) {
        colorModel = ColorModel.getRGBdefault();
    }
    int minX = raster.getMinX();
    int minY = raster.getMinY();
    int width = raster.getWidth();
    int height = raster.getHeight();

    Enumeration<ImageConsumer> icList;
    ImageConsumer ic;
    // Set up the ImageConsumers
    icList = ics.elements();
    while (icList.hasMoreElements()) {
        ic = icList.nextElement();
        ic.setDimensions(width,height);
        ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT |
                    ImageConsumer.COMPLETESCANLINES |
                    ImageConsumer.SINGLEPASS |
                    ImageConsumer.SINGLEFRAME);
    }

    // Get RGB pixels from the raster scanline by scanline and
    // send to consumers.
    int pix[] = new int[width];
    int i,j;
    int numBands = sampleModel.getNumBands();
    int tmpPixel[] = new int[numBands];
    for (j = 0; j < height; j++) {
        for(i = 0; i < width; i++) {
            sampleModel.getPixel(i, j, tmpPixel, dataBuffer);
            pix[i] = colorModel.getDataElement(tmpPixel, 0);
        }
        // Now send the scanline to the Consumers
        icList = ics.elements();
        while (icList.hasMoreElements()) {
            ic = icList.nextElement();
            ic.setPixels(0, j, width, 1, colorModel, pix, 0, width);
        }
    }

    // Now tell the consumers we're done.
    icList = ics.elements();
    while (icList.hasMoreElements()) {
        ic = icList.nextElement();
        ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:68,代碼來源:RenderableImageProducer.java


注:本文中的java.awt.image.ImageConsumer.setHints方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。