本文整理了Java中java.awt.Graphics2D.addRenderingHints()
方法的一些代码示例,展示了Graphics2D.addRenderingHints()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.addRenderingHints()
方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:addRenderingHints
暂无
代码示例来源:origin: stackoverflow.com
public static BufferedImage resize(BufferedImage image, int width, int height) {
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TRANSLUCENT);
Graphics2D g2d = (Graphics2D) bi.createGraphics();
g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
g2d.drawImage(image, 0, 0, width, height, null);
g2d.dispose();
return bi;
}
代码示例来源:origin: org.apache.poi/poi
public void addRenderingHints(Map<?, ?> map)
{
getG2D().addRenderingHints(map);
}
代码示例来源:origin: org.apache.poi/poi
/**
* Compute the cumulative height occupied by the text
*
* @param oldGraphics the graphics context, which properties are to be copied, may be null
* @return the height in points
*/
public double getTextHeight(Graphics2D oldGraphics) {
// dry-run in a 1x1 image and return the vertical advance
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
if (oldGraphics != null) {
graphics.addRenderingHints(oldGraphics.getRenderingHints());
graphics.setTransform(oldGraphics.getTransform());
}
DrawFactory.getInstance(graphics).fixFonts(graphics);
return drawParagraphs(graphics, 0, 0);
}
代码示例来源:origin: kevin-wayne/algs4
RenderingHints.VALUE_ANTIALIAS_ON);
hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
offscreen.addRenderingHints(hints);
代码示例来源:origin: kevin-wayne/algs4
RenderingHints.VALUE_ANTIALIAS_ON);
hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
offscreen.addRenderingHints(hints);
代码示例来源:origin: apache/pdfbox
@Override
public void addRenderingHints(Map<?,?> hints)
{
groupG2D.addRenderingHints(hints);
alphaG2D.addRenderingHints(hints);
}
代码示例来源:origin: apache/pdfbox
/**
* Sets high-quality rendering hints on the current Graphics2D.
*/
private void setRenderingHints()
{
graphics.addRenderingHints(renderingHints);
}
代码示例来源:origin: geotools/geotools
public void addRenderingHints(Map<?, ?> hints) {
delegate.addRenderingHints(hints);
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Returns a <code>Graphics2D</code> version of the specified graphics
* that has been initialized with the proper rendering hints.
*
* @param g The graphics context for which to get a
* <code>Graphics2D</code>.
* @return The <code>Graphics2D</code>.
*/
private Graphics2D getGraphics2D(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
if (aaHints!=null) {
g2d.addRenderingHints(aaHints);
}
if (fractionalFontMetricsEnabled) {
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
}
return g2d;
}
代码示例来源:origin: stackoverflow.com
String str = "A quick brown fox jumps over the lazy dog";
Toolkit tk = Toolkit.getDefaultToolkit();
Map desktopHints = (Map)(tk.getDesktopProperty("awt.font.desktophints"));
Graphics2D g2d = (Graphics2D)g;
if(desktopHints != null) {
g2d.addRenderingHints(desktopHints);
}
g2d.drawString(str, someX, someY);
代码示例来源:origin: stackoverflow.com
import javax.swing.ImageIcon;
import java.awt.image.BufferedImage;
import java.awt.Image;
import java.awt.Color;
import java.awt.Graphics2D;
import java.io.File;
import javax.imageio.ImageIO;
import java.awt.RenderingHints;
public class ImgUtils {
public BufferedImage scaleImage(int WIDTH, int HEIGHT, String filename) {
BufferedImage bi = null;
try {
ImageIcon ii = new ImageIcon(filename);//path to image
bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D) bi.createGraphics();
g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY));
g2d.drawImage(ii.getImage(), 0, 0, WIDTH, HEIGHT, null);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return bi;
}
}
代码示例来源:origin: stackoverflow.com
BufferedImage bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D)bi.createGraphics();
g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY));
boolean b = g2d.drawImage(ii.getImage(), 0, 0, 50, 50, null);
代码示例来源:origin: bobbylight/RSyntaxTextArea
g.addRenderingHints(hints);
g.drawImage(master, 0,0, width,height, null);
g.dispose();
代码示例来源:origin: org.netbeans.api/org-openide-awt
public @Override void paint(Graphics g, JComponent c) {
((Graphics2D) g).addRenderingHints(getHints());
HtmlRendererImpl r = (HtmlRendererImpl) c;
if (r.isCentered()) {
paintIconAndTextCentered(g, r);
} else {
paintIconAndText(g, r);
}
}
代码示例来源:origin: stackoverflow.com
bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D) bi.createGraphics();
g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
g2d.drawImage(ii.getImage(), 0, 0, WIDTH, HEIGHT, null);
} catch (Exception e) {
代码示例来源:origin: org.netbeans.api/org-openide-awt
((Graphics2D) g).addRenderingHints(getHints());
代码示例来源:origin: de.sciss/jsyntaxpane
/**
* Sets the Rendering Hints o nthe Graphics. This is used so that
* any painters can set the Rendering Hits to match the view.
* @param g2d
*/
public static void setRenderingHits(Graphics2D g2d) {
g2d.addRenderingHints(sysHints);
}
代码示例来源:origin: org.apache.pdfbox/pdfbox
@Override
public void addRenderingHints(Map<?,?> hints)
{
groupG2D.addRenderingHints(hints);
alphaG2D.addRenderingHints(hints);
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
g.setFont(getFont());
if (aaHints!=null) {
((Graphics2D)g).addRenderingHints(aaHints);
代码示例来源:origin: org.netbeans.api/org-netbeans-swing-plaf
public static final void configureRenderingHints (Graphics g) {
if (noAntialias) return;
Graphics2D g2d = (Graphics2D) g;
g2d.addRenderingHints(getHints());
}
内容来源于网络,如有侵权,请联系作者删除!