Search in sources :

Example 6 with LayoutPathImpl

use of sun.font.LayoutPathImpl in project jdk8u_jdk by JetBrains.

the class TextLayout method getBlackBoxBounds.

/**
     * Returns the black box bounds of the characters in the specified range.
     * The black box bounds is an area consisting of the union of the bounding
     * boxes of all the glyphs corresponding to the characters between start
     * and limit.  This area can be disjoint.
     * @param firstEndpoint one end of the character range
     * @param secondEndpoint the other end of the character range.  Can be
     * less than <code>firstEndpoint</code>.
     * @return a <code>Shape</code> enclosing the black box bounds.  This is
     *     in standard coordinates.
     */
public Shape getBlackBoxBounds(int firstEndpoint, int secondEndpoint) {
    ensureCache();
    if (firstEndpoint > secondEndpoint) {
        int t = firstEndpoint;
        firstEndpoint = secondEndpoint;
        secondEndpoint = t;
    }
    if (firstEndpoint < 0 || secondEndpoint > characterCount) {
        throw new IllegalArgumentException("Invalid range passed to TextLayout.getBlackBoxBounds()");
    }
    /*
         * return an area that consists of the bounding boxes of all the
         * characters from firstEndpoint to limit
         */
    GeneralPath result = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    if (firstEndpoint < characterCount) {
        for (int logIndex = firstEndpoint; logIndex < secondEndpoint; logIndex++) {
            Rectangle2D r = textLine.getCharBounds(logIndex);
            if (!r.isEmpty()) {
                result.append(r, false);
            }
        }
    }
    if (dx != 0 || dy != 0) {
        AffineTransform tx = AffineTransform.getTranslateInstance(dx, dy);
        result = (GeneralPath) tx.createTransformedShape(result);
    }
    LayoutPathImpl lp = textLine.getLayoutPath();
    if (lp != null) {
        result = (GeneralPath) lp.mapShape(result);
    }
    //return new Highlight(result, false);
    return result;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) LayoutPathImpl(sun.font.LayoutPathImpl) Rectangle2D(java.awt.geom.Rectangle2D) AffineTransform(java.awt.geom.AffineTransform)

Aggregations

LayoutPathImpl (sun.font.LayoutPathImpl)6 GeneralPath (java.awt.geom.GeneralPath)3 Shape (java.awt.Shape)2 AffineTransform (java.awt.geom.AffineTransform)1 Point2D (java.awt.geom.Point2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 CoreMetrics (sun.font.CoreMetrics)1