Search in sources :

Example 76 with GeneralPath

use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.

the class TextLine method getOutline.

public Shape getOutline(AffineTransform tx) {
    GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
        TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
        dstShape.append(tlc.getOutline(locs[n], locs[n + 1]), false);
    }
    if (tx != null) {
        dstShape.transform(tx);
    }
    return dstShape;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) TextLineComponent(sun.font.TextLineComponent)

Example 77 with GeneralPath

use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.

the class CompositeStrike method getGlyphVectorOutline.

/* The physical font slot for each glyph is encoded in the glyph ID
     * To be as efficient as possible we find a run of glyphs from the
     * same slot and create a temporary array of these glyphs decoded
     * to the slot. The slot font is then queried for the GeneralPath
     * for that run of glyphs. GeneralPaths from each run are appended
     * to create the shape for the whole glyph array.
     */
GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) {
    GeneralPath path = null;
    GeneralPath gp;
    int glyphIndex = 0;
    int[] tmpGlyphs;
    while (glyphIndex < glyphs.length) {
        int start = glyphIndex;
        int slot = glyphs[glyphIndex] >>> 24;
        while (glyphIndex < glyphs.length && (glyphs[glyphIndex + 1] >>> 24) == slot) {
            glyphIndex++;
        }
        int tmpLen = glyphIndex - start + 1;
        tmpGlyphs = new int[tmpLen];
        for (int i = 0; i < tmpLen; i++) {
            tmpGlyphs[i] = glyphs[i] & SLOTMASK;
        }
        gp = getStrikeForSlot(slot).getGlyphVectorOutline(tmpGlyphs, x, y);
        if (path == null) {
            path = gp;
        } else if (gp != null) {
            path.append(gp, false);
        }
    }
    if (path == null) {
        return new GeneralPath();
    } else {
        return path;
    }
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 78 with GeneralPath

use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.

the class FileFontStrike method getGlyphOutline.

GeneralPath getGlyphOutline(int glyphCode, float x, float y) {
    GeneralPath gp = null;
    ConcurrentHashMap<Integer, GeneralPath> outlineMap = null;
    if (outlineMapRef != null) {
        outlineMap = outlineMapRef.get();
        if (outlineMap != null) {
            gp = (GeneralPath) outlineMap.get(glyphCode);
        }
    }
    if (gp == null) {
        gp = fileFont.getGlyphOutline(pScalerContext, glyphCode, 0, 0);
        if (outlineMap == null) {
            outlineMap = new ConcurrentHashMap<Integer, GeneralPath>();
            outlineMapRef = new WeakReference<ConcurrentHashMap<Integer, GeneralPath>>(outlineMap);
        }
        outlineMap.put(glyphCode, gp);
    }
    // mutable!
    gp = (GeneralPath) gp.clone();
    if (x != 0f || y != 0f) {
        gp.transform(AffineTransform.getTranslateInstance(x, y));
    }
    return gp;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 79 with GeneralPath

use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.

the class StandardGlyphVector method getGlyphLogicalBounds.

public Shape getGlyphLogicalBounds(int ix) {
    if (ix < 0 || ix >= glyphs.length) {
        throw new IndexOutOfBoundsException("ix = " + ix);
    }
    Shape[] lbcache;
    if (lbcacheRef == null || (lbcache = (Shape[]) lbcacheRef.get()) == null) {
        lbcache = new Shape[glyphs.length];
        lbcacheRef = new SoftReference(lbcache);
    }
    Shape result = lbcache[ix];
    if (result == null) {
        setFRCTX();
        initPositions();
        // !!! ought to return a rectangle2d for simple cases, though the following works for all
        // get the position, the tx offset, and the x,y advance and x,y adl.  The
        // shape is the box formed by adv (width) and adl (height) offset by
        // the position plus the tx offset minus the ascent.
        ADL adl = new ADL();
        GlyphStrike gs = getGlyphStrike(ix);
        gs.getADL(adl);
        Point2D.Float adv = gs.strike.getGlyphMetrics(glyphs[ix]);
        float wx = adv.x;
        float wy = adv.y;
        float hx = adl.descentX + adl.leadingX + adl.ascentX;
        float hy = adl.descentY + adl.leadingY + adl.ascentY;
        float x = positions[ix * 2] + gs.dx - adl.ascentX;
        float y = positions[ix * 2 + 1] + gs.dy - adl.ascentY;
        GeneralPath gp = new GeneralPath();
        gp.moveTo(x, y);
        gp.lineTo(x + wx, y + wy);
        gp.lineTo(x + wx + hx, y + wy + hy);
        gp.lineTo(x + hx, y + hy);
        gp.closePath();
        result = new DelegatingShape(gp);
        lbcache[ix] = result;
    }
    return result;
}
Also used : Shape(java.awt.Shape) SoftReference(java.lang.ref.SoftReference) GeneralPath(java.awt.geom.GeneralPath) Point2D(java.awt.geom.Point2D)

Example 80 with GeneralPath

use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.

the class GraphicComponent method handleGetOutline.

public Shape handleGetOutline(float x, float y) {
    double[] matrix = { 1, 0, 0, 1, x, y };
    if (graphicCount == 1) {
        AffineTransform tx = new AffineTransform(matrix);
        return graphic.getOutline(tx);
    }
    GeneralPath gp = new GeneralPath();
    for (int i = 0; i < graphicCount; ++i) {
        AffineTransform tx = new AffineTransform(matrix);
        gp.append(graphic.getOutline(tx), false);
        matrix[4] += graphicAdvance;
    }
    return gp;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) AffineTransform(java.awt.geom.AffineTransform)

Aggregations

GeneralPath (java.awt.geom.GeneralPath)96 Point (java.awt.Point)14 AffineTransform (java.awt.geom.AffineTransform)14 PathIterator (java.awt.geom.PathIterator)14 Graphics2D (java.awt.Graphics2D)8 Rectangle2D (java.awt.geom.Rectangle2D)8 Color (java.awt.Color)7 Paint (java.awt.Paint)7 BasicStroke (java.awt.BasicStroke)6 Point2D (java.awt.geom.Point2D)6 Stroke (java.awt.Stroke)5 Area (java.awt.geom.Area)4 Shape (java.awt.Shape)3 CubicCurve2D (java.awt.geom.CubicCurve2D)3 LayoutPathImpl (sun.font.LayoutPathImpl)3 GradientPaint (java.awt.GradientPaint)2 Rectangle (java.awt.Rectangle)2 Line2D (java.awt.geom.Line2D)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 JBColor (com.intellij.ui.JBColor)1