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


Java Component.getGraphicsConfiguration方法代码示例

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


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

示例1: paint

import java.awt.Component; //导入方法依赖的package包/类
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,代码行数:37,代码来源:AbstractCachedPainter.java

示例2: getScreenBounds

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Get size of screen accounting for the screen insets (i.e. Windows taskbar)
 *
 * @return
 */
public static Rectangle getScreenBounds(Component c) {
  final Rectangle bounds =
    new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
  final GraphicsConfiguration config = c.getGraphicsConfiguration();
  final Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
  bounds.translate(insets.left, insets.top);
  bounds.setSize(bounds.width - insets.left - insets.right,
                 bounds.height - insets.top - insets.bottom);
  return bounds;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:Info.java

示例3: setDestination

import java.awt.Component; //导入方法依赖的package包/类
public void setDestination(TestEnvironment env) {
    Component c = env.getCanvas();
    GraphicsConfiguration gc = c.getGraphicsConfiguration();
    int w = env.getWidth();
    int h = env.getHeight();
    if (transparency == 0) {
        env.setTestImage(gc.createCompatibleImage(w, h));
    } else {
        env.setTestImage(gc.createCompatibleImage(w, h, transparency));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:Destinations.java

示例4: ScreenResolution

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Constructor where the resolution is computed.
 *
 * @param comp - the frame of the gui - needed to get the resolution of the screen where the app is showed
 */
public ScreenResolution(Component comp) {
    //set the current screen resolution                
    GraphicsConfiguration graphicsCfg = comp.getGraphicsConfiguration();
    DisplayMode displayMode = graphicsCfg.getDevice().getDisplayMode();
    resolution = new Dimension(displayMode.getWidth(), displayMode.getHeight());
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:12,代码来源:ScreenResolution.java

示例5: SunVolatileImage

import java.awt.Component; //导入方法依赖的package包/类
public SunVolatileImage(Component comp,
                        int width, int height, Object context)
{
    this(comp, comp.getGraphicsConfiguration(),
         width, height, context, null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:SunVolatileImage.java

示例6: setScreenResolution

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Saves the resolution of the screen where the component is showed.
 *
 * @param comp - the frame for which the resolution of the containing screen is needed
 */
public void setScreenResolution(Component comp) {
    GraphicsConfiguration graphicsCfg = comp.getGraphicsConfiguration();
    DisplayMode displayMode = graphicsCfg.getDevice().getDisplayMode();
    resolution = new Dimension(displayMode.getWidth(), displayMode.getHeight());
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:11,代码来源:ScreenResolution.java


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