Example usage for java.awt RenderingHints VALUE_FRACTIONALMETRICS_ON

List of usage examples for java.awt RenderingHints VALUE_FRACTIONALMETRICS_ON

Introduction

In this page you can find the example usage for java.awt RenderingHints VALUE_FRACTIONALMETRICS_ON.

Prototype

Object VALUE_FRACTIONALMETRICS_ON

To view the source code for java.awt RenderingHints VALUE_FRACTIONALMETRICS_ON.

Click Source Link

Document

Font fractional metrics hint value -- character glyphs are positioned with sub-pixel accuracy.

Usage

From source file:org.jcurl.core.swing.WCComponent.java

private BufferedImage renderPng(final String watermark) {
    final BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g2 = (Graphics2D) img.getGraphics();
    {/*from   w  w w.  j  av  a  2 s. c o m*/
        final Map<Key, Object> hints = new HashMap<Key, Object>();
        hints.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        hints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        hints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
        hints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        hints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        hints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
        hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2.addRenderingHints(hints);
    }
    final Font f0 = g2.getFont();
    paint(g2);
    g2.setTransform(new AffineTransform());
    if (watermark != null) {
        if (log.isDebugEnabled())
            log.debug(f0);
        g2.setFont(f0);
        g2.setColor(new Color(0, 0, 0, 128));
        g2.drawString(watermark, 10, 20);
    }
    g2.dispose();
    return img;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

private PdfGraphics2D() {
    dg2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

/**
 * Constructor for PDFGraphics2D.//from w w w. jav  a 2  s . c  o m
 */
public PdfGraphics2D(final PdfContentByte cb, final float width, final float height,
        final PdfOutputProcessorMetaData metaData) {
    this.metaData = metaData;
    dg2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

    this.transform = new AffineTransform();

    paint = Color.black;
    background = Color.white;
    setFont(new Font("sanserif", Font.PLAIN, 12));
    this.cb = cb;
    cb.saveState();
    this.width = width;
    this.height = height;
    clip = new Area(new Rectangle2D.Float(0, 0, width, height));
    clip(clip);
    oldStroke = strokeOne;
    stroke = strokeOne;
    originalStroke = strokeOne;
    setStrokeDiff(stroke, null);
    cb.saveState();
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

/**
 * @see Graphics2D#getFontRenderContext()
 *//*w w  w.  ja va  2 s.c o  m*/
@Override
public FontRenderContext getFontRenderContext() {
    final boolean antialias = RenderingHints.VALUE_TEXT_ANTIALIAS_ON
            .equals(getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING));
    final boolean fractions = RenderingHints.VALUE_FRACTIONALMETRICS_ON
            .equals(getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS));
    return new FontRenderContext(new AffineTransform(), antialias, fractions);
}

From source file:tufts.vue.RichTextBox.java

public void paintComponent(Graphics g) {
    if (TestDebug || DEBUG.TEXT)
        out("paintComponent @ " + getX() + "," + getY() + " parent=" + getParent());

    final MapViewer viewer = (MapViewer) javax.swing.SwingUtilities.getAncestorOfClass(MapViewer.class, this);
    Graphics2D g2d = (Graphics2D) g;
    if (viewer != null) {
        g2d.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, viewer.AA_ON);
        g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

    }/*from   w ww  .  j  av a 2s .c o m*/
    // turn on anti-aliasing -- the cursor repaint loop doesn't
    // set anti-aliasing, so text goes jiggy around cursor/in selection if we don't do this
    ////  g.clipRect(0, 0,getWidth(), getAdjustedHeight());

    super.paintComponent(g2d);

    //super.paintComponent(g);
    if (true) {
        // draw a border (we don't want to add one because that changes the preferred size at a bad time)
        //  g.setColor(Color.gray);
        g.setClip(null);
        final int xpad = 1;
        final int ypad = 1;
        g.drawRect(-xpad, -ypad, (int) ((getWidth()) + xpad * 2 - 1), (int) ((getHeight()) + ypad * 2 - 1));
    }
}