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


Java VolatileImage.IMAGE_INCOMPATIBLE屬性代碼示例

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


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

示例1: drawBackingStoreImage

private void drawBackingStoreImage(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    GraphicsConfiguration gc = g2d.getDeviceConfiguration();
    if (vImg == null ||
        vImg.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
        /* Create a new volatile image */
        vImg = createVolatileImage(PANEL_WIDTH, PANEL_HEIGHT / 3);
    }

    Graphics vImgGraphics = vImg.createGraphics();
    vImgGraphics.setColor(Color.WHITE);
    vImgGraphics.fillRect(0, 0, PANEL_WIDTH, PANEL_HEIGHT / 3);
    drawInfo(vImgGraphics,
             PANEL_X,
             PANEL_Y,
             "Backbuffer",
             Color.MAGENTA);
    g.drawImage(vImg, 0, PANEL_Y * 2, this);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:VolatileImageConfigurationTest.java

示例2: initVI

void initVI() {
    int res;
    if (vi == null) {
        res = VolatileImage.IMAGE_INCOMPATIBLE;
    } else {
        res = vi.validate(getGraphicsConfiguration());
    }
    if (res == VolatileImage.IMAGE_INCOMPATIBLE) {
        if (vi != null) vi.flush();
        vi = createVolatileImage(IMAGE_SIZE, IMAGE_SIZE);
        vi.validate(getGraphicsConfiguration());
        res = VolatileImage.IMAGE_RESTORED;
    }
    if (res == VolatileImage.IMAGE_RESTORED) {
        Graphics vig = vi.getGraphics();
        vig.setColor(Color.red);
        vig.fillRect(0, 0, vi.getWidth(), vi.getHeight());
        vig.dispose();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:SharedMemoryPixmapsTest.java

示例3: validateBuffer

/**
 * Description of the Method
 *
 * @param g Description of the Parameter
 * @return Description of the Return Value
 */
public boolean validateBuffer(Graphics2D g) {
    int w = getWidth();
    int h = getHeight();
    if (w <= 0 || h <= 0) {
        return false;
    }

    clip = new Rectangle(0, 0, w, h);
    if (buffer == null || buffer.getWidth() != clip.width || buffer.getHeight() != clip.height) {
        buffer = g.getDeviceConfiguration().createCompatibleVolatileImage(clip.width, clip.height, Transparency.OPAQUE);
        init();
        return true;
    }
    if (buffer.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) {
        buffer.flush();
        buffer = g.getDeviceConfiguration().createCompatibleVolatileImage(clip.width, clip.height, Transparency.OPAQUE);
        init();
        return true;
    }
    return false;
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:27,代碼來源:YassBasicRenderer.java

示例4: paintBackBuffer

/**
 * Description of the Method
 *
 * @param g Description of the Parameter
 */
public void paintBackBuffer(Graphics2D g) {
    final int MAX_TRIES = 10;
    for (int i = 0; i < MAX_TRIES; i++) {
        g.drawImage(backVolImage, 0, 0, this);
        if (!backVolImage.contentsLost()) {
            return;
        }
        switch (backVolImage.validate(g.getDeviceConfiguration())) {
            case VolatileImage.IMAGE_INCOMPATIBLE:
                backVolImage.flush();
                backVolImage = g.getDeviceConfiguration().createCompatibleVolatileImage(image.getWidth(), image.getHeight());
            case VolatileImage.IMAGE_RESTORED:
                Graphics2D gc = backVolImage.createGraphics();
                gc.drawImage(image, 0, 0, Color.white, null);
                gc.dispose();
                break;
        }
    }
    g.drawImage(image, 0, 0, Color.white, null);
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:25,代碼來源:YassSongFlow.java

示例5: initBackbuffer

private void initBackbuffer() {
    createBackbuffer();

    int res = bb.validate(getGraphicsConfiguration());
    if (res == VolatileImage.IMAGE_INCOMPATIBLE) {
        bb = null;
        createBackbuffer();
        bb.validate(getGraphicsConfiguration());
        res = VolatileImage.IMAGE_RESTORED;
    }
    if (res == VolatileImage.IMAGE_RESTORED) {
        Graphics g = bb.getGraphics();
        g.setColor(new Color(rnd.nextInt(0x00ffffff)));
        g.fillRect(0, 0, bb.getWidth(), bb.getHeight());

        volSprite = createVolatileImage(100, 100);
    }
    volSprite.validate(getGraphicsConfiguration());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:DisplayChangeVITest.java

示例6: initVI

private static void initVI(GraphicsConfiguration gc) {
    int res;
    if (destVI == null) {
        res = VolatileImage.IMAGE_INCOMPATIBLE;
    } else {
        res = destVI.validate(gc);
    }
    if (res == VolatileImage.IMAGE_INCOMPATIBLE) {
        if (destVI != null) destVI.flush();
        destVI = gc.createCompatibleVolatileImage(IMAGE_SIZE, IMAGE_SIZE);
        destVI.validate(gc);
        res = VolatileImage.IMAGE_RESTORED;
    }
    if (res == VolatileImage.IMAGE_RESTORED) {
        Graphics vig = destVI.getGraphics();
        vig.setColor(Color.red);
        vig.fillRect(0, 0, destVI.getWidth(), destVI.getHeight());
        vig.dispose();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:AcceleratedScaleTest.java

示例7: render

public void render(Graphics g)  {
    do {
        height = getBounds().height;
        width = getBounds().width;
        if (vimg == null) {
            vimg = createVolatileImage(width, height);
            renderOffscreen();
        }
        int returnCode = vimg.validate(getGraphicsConfiguration());
        if (returnCode == VolatileImage.IMAGE_RESTORED) {
            renderOffscreen();
        } else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) {
            vimg = getGraphicsConfiguration().
                createCompatibleVolatileImage(width, height);
            renderOffscreen();
        } else if (returnCode == VolatileImage.IMAGE_OK) {
            renderOffscreen();
        }
        g.drawImage(vimg, 0, 0, this);
    } while (vimg.contentsLost());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:AltTabCrashTest.java

示例8: accelerateImage

public VolatileImage accelerateImage(BufferedImage bi) {
    VolatileImage testVI = f.createVolatileImage(TEST_W, TEST_H);
    do {
        if (testVI.validate(f.getGraphicsConfiguration()) ==
            VolatileImage.IMAGE_INCOMPATIBLE)
        {
            testVI = f.createVolatileImage(TEST_W, TEST_H);
        }
        Graphics2D g = testVI.createGraphics();
        g.setComposite(AlphaComposite.Src);
        g.setColor(Color.green);
        g.fillRect(0, 0, TEST_W, TEST_H);

        g.drawImage(bi, 0, 0, null);
        g.drawImage(bi, 0, 0, null);
        g.drawImage(bi, 0, 0, null);
        g.dispose();
    } while (testVI.contentsLost());

    return testVI;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:JPEGsNotAcceleratedTest.java

示例9: paint

public void paint(Component c, Graphics g, int x, int y, int w, int h, Object[] args) {
	if (w <= 0 || h <= 0) {
		return;
	}
	Object key = getClass();
	GraphicsConfiguration config = c.getGraphicsConfiguration();
	Cache cache = getCache(key);
	Image image = cache.getImage(key, config, w, h, args);
	int attempts = 0;
	do {
		boolean draw = false;
		if (image instanceof VolatileImage) {
			switch (((VolatileImage) image).validate(config)) {
				case VolatileImage.IMAGE_INCOMPATIBLE:
					((VolatileImage) image).flush();
					image = null;
					break;
				case VolatileImage.IMAGE_RESTORED:
					draw = true;
					break;
			}
		}
		if (image == null) {
			image = createImage(c, w, h, config);
			cache.setImage(key, config, w, h, args, image);
			draw = true;
		}
		if (draw) {
			Graphics g2 = image.getGraphics();
			paintToImage(c, g2, w, h, args);
			g2.dispose();
		}

		paintImage(c, g, x, y, w, h, image, args);
	} while (image instanceof VolatileImage && ((VolatileImage) image).contentsLost() && ++attempts < 3);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:36,代碼來源:AbstractCachedPainter.java

示例10: revalidate

void revalidate(boolean checkSize) {
    validatedContents = false;

    if (backBuffers == null) {
        return;
    }

    if (checkSize) {
        Insets insets = getInsets_NoClientCode();
        if (getWidth() != width || getHeight() != height ||
            !insets.equals(this.insets)) {
            // component has been resized; recreate the backbuffers
            createBackBuffers(backBuffers.length);
            validatedContents = true;
        }
    }

    // now validate the backbuffer
    GraphicsConfiguration gc = getGraphicsConfiguration_NoClientCode();
    int returnCode =
        backBuffers[backBuffers.length - 1].validate(gc);
    if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) {
        if (checkSize) {
            createBackBuffers(backBuffers.length);
            // backbuffers were recreated, so validate again
            backBuffers[backBuffers.length - 1].validate(gc);
        }
        // else case means we're called from Swing on the toolkit
        // thread, don't recreate buffers as that'll deadlock
        // (creating VolatileImages invokes getting GraphicsConfig
        // which grabs treelock).
        validatedContents = true;
    } else if (returnCode == VolatileImage.IMAGE_RESTORED) {
        validatedContents = true;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:36,代碼來源:Component.java

示例11: paintBackBuffer

/**
 * Description of the Method
 *
 * @param g Description of the Parameter
 */
public synchronized void paintBackBuffer(Graphics2D g) {
    final int MAX_TRIES = 5;
    for (int i = 0; i < MAX_TRIES; i++) {

        // switch (backVolImage.validate(g.getDeviceConfiguration())) {
        switch (backVolImage.validate(getGraphicsConfiguration())) {
            case VolatileImage.IMAGE_INCOMPATIBLE:
                backVolImage.flush();
                backVolImage = null;
                image.flush();
                image = null;
                plainVolImage.flush();
                plainVolImage = null;
                image = g.getDeviceConfiguration().createCompatibleImage(
                        clip.width, clip.height, Transparency.TRANSLUCENT);
                backVolImage = g.getDeviceConfiguration()
                        .createCompatibleVolatileImage(clip.width, clip.height,
                                Transparency.OPAQUE);
                plainVolImage = g.getDeviceConfiguration()
                        .createCompatibleVolatileImage(clip.width, clip.height,
                                Transparency.OPAQUE);
                // backVolImage = createVolatileImage(clip.width, clip.height);
            case VolatileImage.IMAGE_RESTORED:
                Graphics2D gc = backVolImage.createGraphics();
                gc.drawImage(image, 0, 0, Color.white, null);
                gc.dispose();
                break;
        }

        g.drawImage(backVolImage, clip.x, clip.y, this);
        if (!backVolImage.contentsLost()) {
            return;
        }
        System.out.println("contents lost (" + i + ")");
    }
    g.drawImage(image, clip.x, clip.y, clip.x + clip.width, clip.y
            + clip.height, 0, 0, clip.width, clip.height, Color.white, this);
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:43,代碼來源:YassSheet.java

示例12: paint

/**
 * Paints a region of a component
 *
 * @param paintingComponent Component to paint
 * @param bufferComponent Component to obtain buffer for
 * @param g Graphics to paint to
 * @param x X-coordinate
 * @param y Y-coordinate
 * @param w Width
 * @param h Height
 * @return true if painting was successful.
 */
public boolean paint(JComponent paintingComponent,
                     JComponent bufferComponent, Graphics g,
                     int x, int y, int w, int h) {
    // First attempt to use VolatileImage buffer for performance.
    // If this fails (which should rarely occur), fallback to a
    // standard Image buffer.
    boolean paintCompleted = false;
    Image offscreen;
    if (repaintManager.useVolatileDoubleBuffer() &&
        (offscreen = getValidImage(repaintManager.
        getVolatileOffscreenBuffer(bufferComponent, w, h))) != null) {
        VolatileImage vImage = (java.awt.image.VolatileImage)offscreen;
        GraphicsConfiguration gc = bufferComponent.
                                    getGraphicsConfiguration();
        for (int i = 0; !paintCompleted &&
                 i < RepaintManager.VOLATILE_LOOP_MAX; i++) {
            if (vImage.validate(gc) ==
                           VolatileImage.IMAGE_INCOMPATIBLE) {
                repaintManager.resetVolatileDoubleBuffer(gc);
                offscreen = repaintManager.getVolatileOffscreenBuffer(
                    bufferComponent,w, h);
                vImage = (java.awt.image.VolatileImage)offscreen;
            }
            paintDoubleBuffered(paintingComponent, vImage, g, x, y,
                                w, h);
            paintCompleted = !vImage.contentsLost();
        }
    }
    // VolatileImage painting loop failed, fallback to regular
    // offscreen buffer
    if (!paintCompleted && (offscreen = getValidImage(
              repaintManager.getOffscreenBuffer(
              bufferComponent, w, h))) != null) {
        paintDoubleBuffered(paintingComponent, offscreen, g, x, y, w,
                            h);
        paintCompleted = true;
    }
    return paintCompleted;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:51,代碼來源:RepaintManager.java

示例13: validateSprite

public void validateSprite() {
    int result =
        ((VolatileImage)image).validate(getGraphicsConfiguration());
    if (result == VolatileImage.IMAGE_INCOMPATIBLE) {
        image = createSprite();
        result = VolatileImage.IMAGE_RESTORED;
    }
    if (result == VolatileImage.IMAGE_RESTORED) {
        Graphics g = image.getGraphics();
        g.setColor(color);
        g.fillRect(0, 0, image.getWidth(null), image.getHeight(null));
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:AltTabCrashTest.java

示例14: test

void test() {
    createVImg();
    do {
        int valCode = vImg.validate(getDefaultGC());
        if (valCode == VolatileImage.IMAGE_INCOMPATIBLE) {
            createVImg();
        }
        Graphics2D g = vImg.createGraphics();
        draw(g);
        BufferedImage bi = vImg.getSnapshot();
        test(bi);
        write(bi);
    } while (vImg.contentsLost());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:AcceleratedXORModeTest.java

示例15: renderOffscreen

private static void renderOffscreen(VolatileImage vImg,
                                    GraphicsConfiguration conf,
                                    double scaleX,
                                    double scaleY)
{
    int attempts = 0;
    do {

        if (attempts > 10) {
            throw new RuntimeException("Too many attempts!");
        }

        if (vImg.validate(conf) == VolatileImage.IMAGE_INCOMPATIBLE) {
            // old vImg doesn't work with new GraphicsConfig; re-create it
            vImg = createVolatileImage(conf);
        }
        Graphics2D g = vImg.createGraphics();
        //
        // miscellaneous rendering commands...
        //
        g.setColor(BACKGROUND_COLOR);
        g.fillRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
        g.scale(scaleX, scaleY);

        g.setColor(FILL_COLOR);
        g.fillRect(X, Y, W, H);

        for (int i = 0; i < N; i++) {
            g.copyArea(X + i * DX, Y + i * DY, W, H, DX, DY);
        }
        g.dispose();
        attempts++;
    } while (vImg.contentsLost());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:CopyScaledAreaTest.java


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