Search in sources :

Example 6 with RenderingHints

use of java.awt.RenderingHints in project jgnash by ccavanaugh.

the class VerticalTextIcon method paintIcon.

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    Graphics2D g2 = (Graphics2D) g;
    RenderingHints oldHints = g2.getRenderingHints();
    Font oldFont = g.getFont();
    Color oldColor = g.getColor();
    AffineTransform oldTransform = g2.getTransform();
    if (fm == null) {
        fm = g.getFontMetrics(font);
    }
    g2.setRenderingHints(renderHints);
    g.setFont(font);
    g.setColor(Color.black);
    if (clockwise) {
        g2.translate(x + getIconWidth(), y);
        g2.rotate(Math.PI / 2);
    } else {
        g2.translate(x, y + getIconHeight());
        g2.rotate(-Math.PI / 2);
    }
    //g.drawString(text, 0, fm.getLeading() + fm.getAscent());
    g.drawString(text, 0, fm.getLeading() + fm.getAscent() - (fm.getDescent() / 2));
    g.setFont(oldFont);
    g.setColor(oldColor);
    g2.setTransform(oldTransform);
    g2.setRenderingHints(oldHints);
}
Also used : Color(java.awt.Color) AffineTransform(java.awt.geom.AffineTransform) RenderingHints(java.awt.RenderingHints) Font(java.awt.Font) Graphics2D(java.awt.Graphics2D)

Example 7 with RenderingHints

use of java.awt.RenderingHints in project libgdx by libgdx.

the class ShadowEffect method blur.

private void blur(BufferedImage image) {
    float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1];
    Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix);
    Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix);
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints);
    ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints);
    BufferedImage scratchImage = EffectUtil.getScratchImage();
    for (int i = 0; i < blurPasses; i++) {
        gaussianOp1.filter(image, scratchImage);
        gaussianOp2.filter(scratchImage, image);
    }
}
Also used : ConvolveOp(java.awt.image.ConvolveOp) Kernel(java.awt.image.Kernel) RenderingHints(java.awt.RenderingHints) BufferedImage(java.awt.image.BufferedImage)

Example 8 with RenderingHints

use of java.awt.RenderingHints in project openblocks by mikaelhg.

the class Comment method paint.

/**
     * overrides javax.Swing.JPanel.paint()
     */
public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.addRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
    if (active) {
        g2.setColor(getBorderColor().brighter());
    } else {
        g2.setColor(getBorderColor());
    }
    g2.fill(body);
    if (active) {
        g2.setColor(Comment.background.brighter());
    } else {
        g2.setColor(Comment.background);
    }
    g2.fill(textarea);
    if (active) {
        g2.setColor(Color.white);
    } else {
        g2.setColor(Color.lightGray);
    }
    g2.draw(textarea);
    if (active) {
        g2.setColor(Color.lightGray.brighter());
    } else {
        g2.setColor(Color.lightGray);
    }
    g2.fill(resize);
    super.paint(g);
}
Also used : RenderingHints(java.awt.RenderingHints) Graphics2D(java.awt.Graphics2D)

Example 9 with RenderingHints

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

the class PostEventQueue method getDesktopAAHintsByName.

/* "false", "off", ""default" aren't explicitly tested, they
     * just fall through to produce a null return which all are equated to
     * "false".
     */
private static RenderingHints getDesktopAAHintsByName(String hintname) {
    Object aaHint = null;
    hintname = hintname.toLowerCase(Locale.ENGLISH);
    if (hintname.equals("on")) {
        aaHint = VALUE_TEXT_ANTIALIAS_ON;
    } else if (hintname.equals("gasp")) {
        aaHint = VALUE_TEXT_ANTIALIAS_GASP;
    } else if (hintname.equals("lcd") || hintname.equals("lcd_hrgb")) {
        aaHint = VALUE_TEXT_ANTIALIAS_LCD_HRGB;
    } else if (hintname.equals("lcd_hbgr")) {
        aaHint = VALUE_TEXT_ANTIALIAS_LCD_HBGR;
    } else if (hintname.equals("lcd_vrgb")) {
        aaHint = VALUE_TEXT_ANTIALIAS_LCD_VRGB;
    } else if (hintname.equals("lcd_vbgr")) {
        aaHint = VALUE_TEXT_ANTIALIAS_LCD_VBGR;
    }
    if (aaHint != null) {
        RenderingHints map = new RenderingHints(null);
        map.put(KEY_TEXT_ANTIALIASING, aaHint);
        return map;
    } else {
        return null;
    }
}
Also used : RenderingHints(java.awt.RenderingHints)

Example 10 with RenderingHints

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

the class GeneralCompositePipe method startSequence.

public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR, int[] abox) {
    RenderingHints hints = sg.getRenderingHints();
    ColorModel model = sg.getDeviceColorModel();
    PaintContext paintContext = sg.paint.createContext(model, devR, s.getBounds2D(), sg.cloneTransform(), hints);
    CompositeContext compositeContext = sg.composite.createContext(paintContext.getColorModel(), model, hints);
    return new TileContext(sg, paintContext, compositeContext, model);
}
Also used : CompositeContext(java.awt.CompositeContext) ColorModel(java.awt.image.ColorModel) PaintContext(java.awt.PaintContext) 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