当前位置: 首页>>代码示例>>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;未经允许,请勿转载。