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


Java RenderingHints.Key方法代码示例

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


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

示例1: getHints

import java.awt.RenderingHints; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static final Map getHints() {
    //XXX We REALLY need to put this in a graphics utils lib
    if (hintsMap == null) {
        //Thanks to Phil Race for making this possible
        hintsMap = (Map<RenderingHints.Key, Object>)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
        if (hintsMap == null) {
            hintsMap = new HashMap<RenderingHints.Key, Object>();
            hintsMap.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        }
    }
    return hintsMap;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ToolbarContainer.java

示例2: rescaleImage

import java.awt.RenderingHints; //导入方法依赖的package包/类
/**
 * Rescales the displayed image to be the specified size.
 *
 * @param width The new width of the image.
 * @param height The new height of the image.
 * @param hint The scaling hint to use.
 */
@Override
protected void rescaleImage(int width, int height, int hint) {

	Image master = getMasterImage();
	if (master!=null) {

		Map<RenderingHints.Key, Object> hints =
				new HashMap<RenderingHints.Key, Object>();
		switch (hint) {
			default:
			case Image.SCALE_AREA_AVERAGING:
			case Image.SCALE_SMOOTH:
				hints.put(RenderingHints.KEY_INTERPOLATION,
						RenderingHints.VALUE_INTERPOLATION_BICUBIC);
				hints.put(RenderingHints.KEY_RENDERING,
						RenderingHints.VALUE_RENDER_QUALITY);
				hints.put(RenderingHints.KEY_ANTIALIASING,
						RenderingHints.VALUE_ANTIALIAS_ON);
		}

		bgImage = createAcceleratedImage(width, height);
		Graphics2D g = bgImage.createGraphics();
		g.addRenderingHints(hints);
		g.drawImage(master, 0,0, width,height, null);
		g.dispose();

	}
	else {
		bgImage = null;
	}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:39,代码来源:BufferedImageBackgroundPainterStrategy.java

示例3: setAntiAliasingEnabled

import java.awt.RenderingHints; //导入方法依赖的package包/类
/**
 * Sets whether anti-aliasing is enabled in this editor.  This method
 * fires a property change event of type {@link #ANTIALIAS_PROPERTY}.
 *
 * @param enabled Whether anti-aliasing is enabled.
 * @see #getAntiAliasingEnabled()
 */
public void setAntiAliasingEnabled(boolean enabled) {

	boolean currentlyEnabled = aaHints!=null;

	if (enabled!=currentlyEnabled) {

		if (enabled) {
			aaHints = RSyntaxUtilities.getDesktopAntiAliasHints();
			// If the desktop query method comes up empty, use the standard
			// Java2D greyscale method.  Note this will likely NOT be as
			// nice as what would be used if the getDesktopAntiAliasHints()
			// call worked.
			if (aaHints==null) {
				Map<RenderingHints.Key, Object> temp =
						new HashMap<RenderingHints.Key, Object>();
				temp.put(RenderingHints.KEY_TEXT_ANTIALIASING,
						RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
				aaHints = temp;
			}
		}
		else {
			aaHints = null;
		}

		// We must be connected to a screen resource for our graphics
		// to be non-null.
		if (isDisplayable()) {
			refreshFontMetrics(getGraphics2D(getGraphics()));
		}
		firePropertyChange(ANTIALIAS_PROPERTY, !enabled, enabled);
		repaint();

	}

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:43,代码来源:RSyntaxTextArea.java

示例4: setDefaultAntiAliasingState

import java.awt.RenderingHints; //导入方法依赖的package包/类
/**
 * Sets anti-aliasing to whatever the user's desktop value is.
 *
 * @see #getAntiAliasingEnabled()
 */
private void setDefaultAntiAliasingState() {

	// Most accurate technique, but not available on all OSes.
	aaHints = RSyntaxUtilities.getDesktopAntiAliasHints();
	if (aaHints==null) {

		Map<RenderingHints.Key, Object> temp =
				new HashMap<RenderingHints.Key, Object>();

		// In Java 6+, you can figure out what text AA hint Swing uses for
		// JComponents...
		JLabel label = new JLabel();
		FontMetrics fm = label.getFontMetrics(label.getFont());
		Object hint = null;
		//FontRenderContext frc = fm.getFontRenderContext();
		//hint = fm.getAntiAliasingHint();
		try {
			Method m = FontMetrics.class.getMethod("getFontRenderContext");
			FontRenderContext frc = (FontRenderContext)m.invoke(fm);
			m = FontRenderContext.class.getMethod("getAntiAliasingHint");
			hint = m.invoke(frc);
		} catch (RuntimeException re) {
			throw re; // FindBugs
		} catch (Exception e) {
			// Swallow, either Java 1.5, or running in an applet
		}

		// If not running Java 6+, default to AA enabled on Windows where
		// the software AA is pretty fast, and default (e.g. disabled) on
		// non-Windows.  Note that OS X always uses AA no matter what
		// rendering hints you give it, so this is a moot point there.
		//System.out.println("Rendering hint: " + hint);
		if (hint==null) {
			String os = System.getProperty("os.name").toLowerCase();
			if (os.contains("windows")) {
				hint = RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
			}
			else {
				hint = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
			}
		}
		temp.put(RenderingHints.KEY_TEXT_ANTIALIASING, hint);

		aaHints = temp;

	}

	// We must be connected to a screen resource for our graphics
	// to be non-null.
	if (isDisplayable()) {
		refreshFontMetrics(getGraphics2D(getGraphics()));
	}
	repaint();

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:61,代码来源:RSyntaxTextArea.java


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