Search in sources :

Example 11 with RenderingHints

use of java.awt.RenderingHints in project jdk8u_jdk by JetBrains.

the class AffineTransformOp method getRenderingHints.

/**
     * Returns the rendering hints used by this transform operation.
     *
     * @return The <CODE>RenderingHints</CODE> object associated with this op.
     */
public final RenderingHints getRenderingHints() {
    if (hints == null) {
        Object val;
        switch(interpolationType) {
            case TYPE_NEAREST_NEIGHBOR:
                val = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
                break;
            case TYPE_BILINEAR:
                val = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
                break;
            case TYPE_BICUBIC:
                val = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
                break;
            default:
                // Should never get here
                throw new InternalError("Unknown interpolation type " + interpolationType);
        }
        hints = new RenderingHints(RenderingHints.KEY_INTERPOLATION, val);
    }
    return hints;
}
Also used : RenderingHints(java.awt.RenderingHints)

Example 12 with RenderingHints

use of java.awt.RenderingHints in project jabref by JabRef.

the class JTextAreaWithPlaceholder method paintComponent.

@Override
protected void paintComponent(Graphics graphics) {
    super.paintComponent(graphics);
    if (this.getText().isEmpty()) {
        Font prev = graphics.getFont();
        Color prevColor = graphics.getColor();
        graphics.setColor(UIManager.getColor("textInactiveText"));
        int textHeight = graphics.getFontMetrics().getHeight();
        int x = this.getInsets().left;
        Graphics2D g2d = (Graphics2D) graphics;
        RenderingHints hints = g2d.getRenderingHints();
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2d.drawString(textWhenNotFocused, x, textHeight + this.getInsets().top);
        g2d.setRenderingHints(hints);
        graphics.setFont(prev);
        graphics.setColor(prevColor);
    }
}
Also used : Color(java.awt.Color) Font(java.awt.Font) RenderingHints(java.awt.RenderingHints) Graphics2D(java.awt.Graphics2D)

Example 13 with RenderingHints

use of java.awt.RenderingHints in project jabref by JabRef.

the class JTextFieldWithPlaceholder method paintComponent.

@Override
protected void paintComponent(Graphics graphics) {
    super.paintComponent(graphics);
    if (this.getText().isEmpty()) {
        int height = this.getHeight();
        Font prev = graphics.getFont();
        Color prevColor = graphics.getColor();
        graphics.setColor(UIManager.getColor("textInactiveText"));
        int textHeight = graphics.getFontMetrics().getHeight();
        int textBottom = (((height - textHeight) / 2) + textHeight) - 4;
        int x = this.getInsets().left;
        Graphics2D g2d = (Graphics2D) graphics;
        RenderingHints hints = g2d.getRenderingHints();
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2d.drawString(textWhenNotFocused, x, textBottom);
        g2d.setRenderingHints(hints);
        graphics.setFont(prev);
        graphics.setColor(prevColor);
    }
}
Also used : Color(java.awt.Color) Font(java.awt.Font) RenderingHints(java.awt.RenderingHints) Graphics2D(java.awt.Graphics2D)

Example 14 with RenderingHints

use of java.awt.RenderingHints in project poi by apache.

the class PPGraphics2D method setRenderingHints.

/**
     * Replaces the values of all preferences for the rendering
     * algorithms with the specified <code>hints</code>.
     * The existing values for all rendering hints are discarded and
     * the new set of known hints and values are initialized from the
     * specified {@link Map} object.
     * Hint categories include controls for rendering quality and
     * overall time/quality trade-off in the rendering process.
     * Refer to the <code>RenderingHints</code> class for definitions of
     * some common keys and values.
     * @param hints the rendering hints to be set
     * @see RenderingHints
     */
public void setRenderingHints(Map<?, ?> hints) {
    this._hints = new RenderingHints(null);
    this._hints.putAll(hints);
}
Also used : RenderingHints(java.awt.RenderingHints)

Aggregations

RenderingHints (java.awt.RenderingHints)14 Graphics2D (java.awt.Graphics2D)6 Color (java.awt.Color)4 Font (java.awt.Font)3 CompositeContext (java.awt.CompositeContext)2 BufferedImage (java.awt.image.BufferedImage)2 ColorModel (java.awt.image.ColorModel)2 BasicStroke (java.awt.BasicStroke)1 Composite (java.awt.Composite)1 PaintContext (java.awt.PaintContext)1 Point (java.awt.Point)1 Shape (java.awt.Shape)1 AffineTransform (java.awt.geom.AffineTransform)1 ConvolveOp (java.awt.image.ConvolveOp)1 Kernel (java.awt.image.Kernel)1 Raster (java.awt.image.Raster)1 WritableRaster (java.awt.image.WritableRaster)1