当前位置: 首页>>代码示例>>Java>>正文


Java VolatileImage.IMAGE_RESTORED属性代码示例

本文整理汇总了Java中java.awt.image.VolatileImage.IMAGE_RESTORED属性的典型用法代码示例。如果您正苦于以下问题:Java VolatileImage.IMAGE_RESTORED属性的具体用法?Java VolatileImage.IMAGE_RESTORED怎么用?Java VolatileImage.IMAGE_RESTORED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.image.VolatileImage的用法示例。


在下文中一共展示了VolatileImage.IMAGE_RESTORED属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintImage

/**
 * Paints the image at the specified location.  This method assumes
 * scaling has already been done, and simply paints the background
 * image "as-is."
 *
 * @param g The graphics context.
 * @param x The x-coordinate at which to paint.
 * @param y The y-coordinate at which to paint.
 */
@Override
protected void paintImage(Graphics g, int x, int y) {
	if (bgImage != null) {
		do {
			int rc = bgImage.validate(null);//getGraphicsConfiguration());
			if (rc==VolatileImage.IMAGE_RESTORED) {
				// FIXME:  If the image needs to be restored are its width
				// and height still valid??  If not, we'll need to cache
				// these values...
				renderImage(bgImage.getWidth(), bgImage.getHeight(),
					getScalingHint());
			}
			g.drawImage(bgImage, x,y, null);
		} while (bgImage.contentsLost());
	}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:25,代码来源:VolatileImageBackgroundPainterStrategy.java

示例2: 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

示例3: 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

示例4: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:AltTabCrashTest.java

示例5: 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

示例6: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SharedMemoryPixmapsTest.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: testScale

private static void testScale(double scaleX, double scaleY,
                              GraphicsConfiguration gc) throws Exception
{

    BufferedImage buffImage = new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT,
                                                BufferedImage.TYPE_INT_RGB);
    Graphics g = buffImage.createGraphics();

    VolatileImage vImg = createVolatileImage(gc);

    int attempts = 0;
    do {

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

        int returnCode = vImg.validate(gc);
        if (returnCode == VolatileImage.IMAGE_RESTORED) {
            // Contents need to be restored
            renderOffscreen(vImg, gc, scaleX, scaleY); // restore contents
        } else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) {
            // old vImg doesn't work with new GraphicsConfig; re-create it
            vImg = createVolatileImage(gc);
            renderOffscreen(vImg, gc, scaleX, scaleY);
        }
        g.drawImage(vImg, 0, 0, null);
        attempts++;
    } while (vImg.contentsLost());

    g.dispose();

    int x = scale(X + N * DX, scaleX) + 1;
    int y = scale(Y + N * DY, scaleY) + 1;
    int w = scale(W, scaleX) - 2;
    int h = scale(H, scaleY) - 2;

    for (int i = x; i < x + w; i++) {
        for (int j = y; j < y + h; j++) {
            if (buffImage.getRGB(i, j) != FILL_COLOR.getRGB()) {
                throw new RuntimeException("Wrong rectangle color!");
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:CopyScaledAreaTest.java


注:本文中的java.awt.image.VolatileImage.IMAGE_RESTORED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。