0N/A/*
3909N/A * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.pisces;
0N/A
0N/Aimport java.awt.Shape;
0N/Aimport java.awt.BasicStroke;
0N/Aimport java.awt.geom.Path2D;
0N/Aimport java.awt.geom.AffineTransform;
0N/Aimport java.awt.geom.PathIterator;
0N/A
0N/Aimport sun.awt.geom.PathConsumer2D;
0N/Aimport sun.java2d.pipe.Region;
0N/Aimport sun.java2d.pipe.RenderingEngine;
0N/Aimport sun.java2d.pipe.AATileGenerator;
0N/A
0N/Apublic class PiscesRenderingEngine extends RenderingEngine {
2639N/A private static enum NormMode {OFF, ON_NO_AA, ON_WITH_AA}
2639N/A
0N/A /**
0N/A * Create a widened path as specified by the parameters.
0N/A * <p>
0N/A * The specified {@code src} {@link Shape} is widened according
0N/A * to the specified attribute parameters as per the
0N/A * {@link BasicStroke} specification.
0N/A *
0N/A * @param src the source path to be widened
0N/A * @param width the width of the widened path as per {@code BasicStroke}
0N/A * @param caps the end cap decorations as per {@code BasicStroke}
0N/A * @param join the segment join decorations as per {@code BasicStroke}
0N/A * @param miterlimit the miter limit as per {@code BasicStroke}
0N/A * @param dashes the dash length array as per {@code BasicStroke}
0N/A * @param dashphase the initial dash phase as per {@code BasicStroke}
0N/A * @return the widened path stored in a new {@code Shape} object
0N/A * @since 1.7
0N/A */
0N/A public Shape createStrokedShape(Shape src,
0N/A float width,
0N/A int caps,
0N/A int join,
0N/A float miterlimit,
0N/A float dashes[],
0N/A float dashphase)
0N/A {
0N/A final Path2D p2d = new Path2D.Float();
0N/A
0N/A strokeTo(src,
0N/A null,
0N/A width,
2639N/A NormMode.OFF,
0N/A caps,
0N/A join,
0N/A miterlimit,
0N/A dashes,
0N/A dashphase,
2956N/A new PathConsumer2D() {
2638N/A public void moveTo(float x0, float y0) {
2638N/A p2d.moveTo(x0, y0);
0N/A }
2638N/A public void lineTo(float x1, float y1) {
2638N/A p2d.lineTo(x1, y1);
0N/A }
2956N/A public void closePath() {
0N/A p2d.closePath();
0N/A }
2956N/A public void pathDone() {}
2956N/A public void curveTo(float x1, float y1,
2956N/A float x2, float y2,
2956N/A float x3, float y3) {
2956N/A p2d.curveTo(x1, y1, x2, y2, x3, y3);
2956N/A }
2956N/A public void quadTo(float x1, float y1, float x2, float y2) {
2956N/A p2d.quadTo(x1, y1, x2, y2);
2956N/A }
2956N/A public long getNativeConsumer() {
2956N/A throw new InternalError("Not using a native peer");
2956N/A }
0N/A });
0N/A return p2d;
0N/A }
0N/A
0N/A /**
0N/A * Sends the geometry for a widened path as specified by the parameters
0N/A * to the specified consumer.
0N/A * <p>
0N/A * The specified {@code src} {@link Shape} is widened according
0N/A * to the parameters specified by the {@link BasicStroke} object.
0N/A * Adjustments are made to the path as appropriate for the
0N/A * {@link VALUE_STROKE_NORMALIZE} hint if the {@code normalize}
0N/A * boolean parameter is true.
0N/A * Adjustments are made to the path as appropriate for the
0N/A * {@link VALUE_ANTIALIAS_ON} hint if the {@code antialias}
0N/A * boolean parameter is true.
0N/A * <p>
0N/A * The geometry of the widened path is forwarded to the indicated
0N/A * {@link PathConsumer2D} object as it is calculated.
0N/A *
0N/A * @param src the source path to be widened
0N/A * @param bs the {@code BasicSroke} object specifying the
0N/A * decorations to be applied to the widened path
0N/A * @param normalize indicates whether stroke normalization should
0N/A * be applied
0N/A * @param antialias indicates whether or not adjustments appropriate
0N/A * to antialiased rendering should be applied
0N/A * @param consumer the {@code PathConsumer2D} instance to forward
0N/A * the widened geometry to
0N/A * @since 1.7
0N/A */
0N/A public void strokeTo(Shape src,
0N/A AffineTransform at,
0N/A BasicStroke bs,
0N/A boolean thin,
0N/A boolean normalize,
0N/A boolean antialias,
0N/A final PathConsumer2D consumer)
0N/A {
2639N/A NormMode norm = (normalize) ?
2639N/A ((antialias) ? NormMode.ON_WITH_AA : NormMode.ON_NO_AA)
2639N/A : NormMode.OFF;
2956N/A strokeTo(src, at, bs, thin, norm, antialias, consumer);
0N/A }
0N/A
0N/A void strokeTo(Shape src,
0N/A AffineTransform at,
0N/A BasicStroke bs,
0N/A boolean thin,
2639N/A NormMode normalize,
0N/A boolean antialias,
2956N/A PathConsumer2D pc2d)
0N/A {
0N/A float lw;
0N/A if (thin) {
0N/A if (antialias) {
1685N/A lw = userSpaceLineWidth(at, 0.5f);
0N/A } else {
1685N/A lw = userSpaceLineWidth(at, 1.0f);
0N/A }
0N/A } else {
0N/A lw = bs.getLineWidth();
0N/A }
0N/A strokeTo(src,
0N/A at,
0N/A lw,
2638N/A normalize,
0N/A bs.getEndCap(),
0N/A bs.getLineJoin(),
0N/A bs.getMiterLimit(),
0N/A bs.getDashArray(),
0N/A bs.getDashPhase(),
2956N/A pc2d);
0N/A }
0N/A
1685N/A private float userSpaceLineWidth(AffineTransform at, float lw) {
1685N/A
1685N/A double widthScale;
1685N/A
1685N/A if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM |
1685N/A AffineTransform.TYPE_GENERAL_SCALE)) != 0) {
1685N/A widthScale = Math.sqrt(at.getDeterminant());
1685N/A } else {
1685N/A /* First calculate the "maximum scale" of this transform. */
1685N/A double A = at.getScaleX(); // m00
1685N/A double C = at.getShearX(); // m01
1685N/A double B = at.getShearY(); // m10
1685N/A double D = at.getScaleY(); // m11
1685N/A
1685N/A /*
1685N/A * Given a 2 x 2 affine matrix [ A B ] such that
1685N/A * [ C D ]
1685N/A * v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to
1685N/A * find the maximum magnitude (norm) of the vector v'
1685N/A * with the constraint (x^2 + y^2 = 1).
1685N/A * The equation to maximize is
1685N/A * |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2)
1685N/A * or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2).
1685N/A * Since sqrt is monotonic we can maximize |v'|^2
1685N/A * instead and plug in the substitution y = sqrt(1 - x^2).
1685N/A * Trigonometric equalities can then be used to get
1685N/A * rid of most of the sqrt terms.
1685N/A */
1685N/A
1685N/A double EA = A*A + B*B; // x^2 coefficient
1685N/A double EB = 2*(A*C + B*D); // xy coefficient
1685N/A double EC = C*C + D*D; // y^2 coefficient
1685N/A
1685N/A /*
1685N/A * There is a lot of calculus omitted here.
1685N/A *
1685N/A * Conceptually, in the interests of understanding the
1685N/A * terms that the calculus produced we can consider
1685N/A * that EA and EC end up providing the lengths along
1685N/A * the major axes and the hypot term ends up being an
1685N/A * adjustment for the additional length along the off-axis
1685N/A * angle of rotated or sheared ellipses as well as an
1685N/A * adjustment for the fact that the equation below
1685N/A * averages the two major axis lengths. (Notice that
1685N/A * the hypot term contains a part which resolves to the
1685N/A * difference of these two axis lengths in the absence
1685N/A * of rotation.)
1685N/A *
1685N/A * In the calculus, the ratio of the EB and (EA-EC) terms
1685N/A * ends up being the tangent of 2*theta where theta is
1685N/A * the angle that the long axis of the ellipse makes
1685N/A * with the horizontal axis. Thus, this equation is
1685N/A * calculating the length of the hypotenuse of a triangle
1685N/A * along that axis.
1685N/A */
1685N/A
1685N/A double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC));
1685N/A /* sqrt omitted, compare to squared limits below. */
1685N/A double widthsquared = ((EA + EC + hypot)/2.0);
1685N/A
1685N/A widthScale = Math.sqrt(widthsquared);
1685N/A }
1685N/A
1685N/A return (float) (lw / widthScale);
1685N/A }
1685N/A
0N/A void strokeTo(Shape src,
0N/A AffineTransform at,
0N/A float width,
2639N/A NormMode normalize,
0N/A int caps,
0N/A int join,
0N/A float miterlimit,
0N/A float dashes[],
0N/A float dashphase,
2956N/A PathConsumer2D pc2d)
0N/A {
3444N/A // We use strokerat and outat so that in Stroker and Dasher we can work only
2956N/A // with the pre-transformation coordinates. This will repeat a lot of
2956N/A // computations done in the path iterator, but the alternative is to
2956N/A // work with transformed paths and compute untransformed coordinates
2956N/A // as needed. This would be faster but I do not think the complexity
2956N/A // of working with both untransformed and transformed coordinates in
2956N/A // the same code is worth it.
2956N/A // However, if a path's width is constant after a transformation,
2956N/A // we can skip all this untransforming.
2956N/A
2956N/A // If normalization is off we save some transformations by not
2956N/A // transforming the input to pisces. Instead, we apply the
2956N/A // transformation after the path processing has been done.
2956N/A // We can't do this if normalization is on, because it isn't a good
2956N/A // idea to normalize before the transformation is applied.
3444N/A AffineTransform strokerat = null;
2956N/A AffineTransform outat = null;
2956N/A
2956N/A PathIterator pi = null;
2956N/A
2638N/A if (at != null && !at.isIdentity()) {
2956N/A final double a = at.getScaleX();
2956N/A final double b = at.getShearX();
2956N/A final double c = at.getShearY();
2956N/A final double d = at.getScaleY();
2956N/A final double det = a * d - c * b;
2956N/A if (Math.abs(det) <= 2 * Float.MIN_VALUE) {
2956N/A // this rendering engine takes one dimensional curves and turns
2956N/A // them into 2D shapes by giving them width.
2956N/A // However, if everything is to be passed through a singular
2956N/A // transformation, these 2D shapes will be squashed down to 1D
2956N/A // again so, nothing can be drawn.
2956N/A
2956N/A // Every path needs an initial moveTo and a pathDone. If these
3444N/A // are not there this causes a SIGSEGV in libawt.so (at the time
2956N/A // of writing of this comment (September 16, 2010)). Actually,
3444N/A // I am not sure if the moveTo is necessary to avoid the SIGSEGV
2956N/A // but the pathDone is definitely needed.
2956N/A pc2d.moveTo(0, 0);
2956N/A pc2d.pathDone();
2956N/A return;
2956N/A }
2956N/A
2956N/A // If the transform is a constant multiple of an orthogonal transformation
2956N/A // then every length is just multiplied by a constant, so we just
2956N/A // need to transform input paths to stroker and tell stroker
2956N/A // the scaled width. This condition is satisfied if
2956N/A // a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we
2956N/A // leave a bit of room for error.
2956N/A if (nearZero(a*b + c*d, 2) && nearZero(a*a+c*c - (b*b+d*d), 2)) {
2956N/A double scale = Math.sqrt(a*a + c*c);
2956N/A if (dashes != null) {
2956N/A dashes = java.util.Arrays.copyOf(dashes, dashes.length);
2956N/A for (int i = 0; i < dashes.length; i++) {
2956N/A dashes[i] = (float)(scale * dashes[i]);
2956N/A }
2956N/A dashphase = (float)(scale * dashphase);
2956N/A }
2956N/A width = (float)(scale * width);
2956N/A pi = src.getPathIterator(at);
2956N/A if (normalize != NormMode.OFF) {
2956N/A pi = new NormalizingPathIterator(pi, normalize);
2956N/A }
3444N/A // by now strokerat == null && outat == null. Input paths to
3444N/A // stroker (and maybe dasher) will have the full transform at
3444N/A // applied to them and nothing will happen to the output paths.
2956N/A } else {
2956N/A if (normalize != NormMode.OFF) {
3444N/A strokerat = at;
2956N/A pi = src.getPathIterator(at);
2956N/A pi = new NormalizingPathIterator(pi, normalize);
3444N/A // by now strokerat == at && outat == null. Input paths to
3444N/A // stroker (and maybe dasher) will have the full transform at
3444N/A // applied to them, then they will be normalized, and then
3444N/A // the inverse of *only the non translation part of at* will
3444N/A // be applied to the normalized paths. This won't cause problems
3444N/A // in stroker, because, suppose at = T*A, where T is just the
3444N/A // translation part of at, and A is the rest. T*A has already
3444N/A // been applied to Stroker/Dasher's input. Then Ainv will be
3444N/A // applied. Ainv*T*A is not equal to T, but it is a translation,
3444N/A // which means that none of stroker's assumptions about its
3444N/A // input will be violated. After all this, A will be applied
3444N/A // to stroker's output.
2956N/A } else {
3444N/A outat = at;
2956N/A pi = src.getPathIterator(null);
3444N/A // outat == at && strokerat == null. This is because if no
3444N/A // normalization is done, we can just apply all our
3444N/A // transformations to stroker's output.
2956N/A }
2956N/A }
2956N/A } else {
2956N/A // either at is null or it's the identity. In either case
2956N/A // we don't transform the path.
2956N/A pi = src.getPathIterator(null);
2956N/A if (normalize != NormMode.OFF) {
2956N/A pi = new NormalizingPathIterator(pi, normalize);
2956N/A }
0N/A }
2956N/A
3444N/A // by now, at least one of outat and strokerat will be null. Unless at is not
3444N/A // a constant multiple of an orthogonal transformation, they will both be
3444N/A // null. In other cases, outat == at if normalization is off, and if
3444N/A // normalization is on, strokerat == at.
2956N/A pc2d = TransformingPathConsumer2D.transformConsumer(pc2d, outat);
3444N/A pc2d = TransformingPathConsumer2D.deltaTransformConsumer(pc2d, strokerat);
2956N/A pc2d = new Stroker(pc2d, width, caps, join, miterlimit);
0N/A if (dashes != null) {
2956N/A pc2d = new Dasher(pc2d, dashes, dashphase);
0N/A }
3444N/A pc2d = TransformingPathConsumer2D.inverseDeltaTransformConsumer(pc2d, strokerat);
2956N/A pathTo(pi, pc2d);
2956N/A }
2956N/A
2956N/A private static boolean nearZero(double num, int nulps) {
2956N/A return Math.abs(num) < nulps * Math.ulp(num);
2639N/A }
0N/A
2639N/A private static class NormalizingPathIterator implements PathIterator {
2639N/A
2639N/A private final PathIterator src;
2639N/A
2639N/A // the adjustment applied to the current position.
2639N/A private float curx_adjust, cury_adjust;
2639N/A // the adjustment applied to the last moveTo position.
2639N/A private float movx_adjust, movy_adjust;
2639N/A
2639N/A // constants used in normalization computations
2639N/A private final float lval, rval;
2639N/A
2639N/A NormalizingPathIterator(PathIterator src, NormMode mode) {
2639N/A this.src = src;
2639N/A switch (mode) {
2639N/A case ON_NO_AA:
2639N/A // round to nearest (0.25, 0.25) pixel
2639N/A lval = rval = 0.25f;
2639N/A break;
2639N/A case ON_WITH_AA:
2639N/A // round to nearest pixel center
2639N/A lval = 0f;
2639N/A rval = 0.5f;
2639N/A break;
2639N/A case OFF:
2639N/A throw new InternalError("A NormalizingPathIterator should " +
2639N/A "not be created if no normalization is being done");
2639N/A default:
2639N/A throw new InternalError("Unrecognized normalization mode");
2639N/A }
2639N/A }
2639N/A
2639N/A public int currentSegment(float[] coords) {
2639N/A int type = src.currentSegment(coords);
2639N/A
2639N/A int lastCoord;
2639N/A switch(type) {
2639N/A case PathIterator.SEG_CUBICTO:
2639N/A lastCoord = 4;
2639N/A break;
2639N/A case PathIterator.SEG_QUADTO:
2639N/A lastCoord = 2;
2639N/A break;
2639N/A case PathIterator.SEG_LINETO:
2639N/A case PathIterator.SEG_MOVETO:
2639N/A lastCoord = 0;
2639N/A break;
2639N/A case PathIterator.SEG_CLOSE:
2639N/A // we don't want to deal with this case later. We just exit now
2639N/A curx_adjust = movx_adjust;
2639N/A cury_adjust = movy_adjust;
2639N/A return type;
2639N/A default:
2639N/A throw new InternalError("Unrecognized curve type");
2639N/A }
2639N/A
2639N/A // normalize endpoint
2956N/A float x_adjust = (float)Math.floor(coords[lastCoord] + lval) +
2956N/A rval - coords[lastCoord];
2956N/A float y_adjust = (float)Math.floor(coords[lastCoord+1] + lval) +
2956N/A rval - coords[lastCoord + 1];
2639N/A
2639N/A coords[lastCoord ] += x_adjust;
2639N/A coords[lastCoord + 1] += y_adjust;
2639N/A
2639N/A // now that the end points are done, normalize the control points
2639N/A switch(type) {
2639N/A case PathIterator.SEG_CUBICTO:
2639N/A coords[0] += curx_adjust;
2639N/A coords[1] += cury_adjust;
2639N/A coords[2] += x_adjust;
2639N/A coords[3] += y_adjust;
2639N/A break;
2639N/A case PathIterator.SEG_QUADTO:
2639N/A coords[0] += (curx_adjust + x_adjust) / 2;
2639N/A coords[1] += (cury_adjust + y_adjust) / 2;
2639N/A break;
2639N/A case PathIterator.SEG_LINETO:
2639N/A break;
2639N/A case PathIterator.SEG_MOVETO:
2639N/A movx_adjust = x_adjust;
2639N/A movy_adjust = y_adjust;
2639N/A break;
2639N/A case PathIterator.SEG_CLOSE:
2639N/A throw new InternalError("This should be handled earlier.");
2639N/A }
2639N/A curx_adjust = x_adjust;
2639N/A cury_adjust = y_adjust;
2639N/A return type;
2639N/A }
2639N/A
2639N/A public int currentSegment(double[] coords) {
2639N/A float[] tmp = new float[6];
2639N/A int type = this.currentSegment(tmp);
2639N/A for (int i = 0; i < 6; i++) {
2639N/A coords[i] = (float) tmp[i];
2639N/A }
2639N/A return type;
2639N/A }
2639N/A
2639N/A public int getWindingRule() {
2639N/A return src.getWindingRule();
2639N/A }
2639N/A
2639N/A public boolean isDone() {
2639N/A return src.isDone();
2639N/A }
2639N/A
2639N/A public void next() {
2639N/A src.next();
2639N/A }
0N/A }
0N/A
2956N/A static void pathTo(PathIterator pi, PathConsumer2D pc2d) {
2956N/A RenderingEngine.feedConsumer(pi, pc2d);
2956N/A pc2d.pathDone();
0N/A }
0N/A
0N/A /**
0N/A * Construct an antialiased tile generator for the given shape with
0N/A * the given rendering attributes and store the bounds of the tile
0N/A * iteration in the bbox parameter.
0N/A * The {@code at} parameter specifies a transform that should affect
0N/A * both the shape and the {@code BasicStroke} attributes.
0N/A * The {@code clip} parameter specifies the current clip in effect
0N/A * in device coordinates and can be used to prune the data for the
0N/A * operation, but the renderer is not required to perform any
0N/A * clipping.
0N/A * If the {@code BasicStroke} parameter is null then the shape
0N/A * should be filled as is, otherwise the attributes of the
0N/A * {@code BasicStroke} should be used to specify a draw operation.
0N/A * The {@code thin} parameter indicates whether or not the
0N/A * transformed {@code BasicStroke} represents coordinates smaller
0N/A * than the minimum resolution of the antialiasing rasterizer as
0N/A * specified by the {@code getMinimumAAPenWidth()} method.
0N/A * <p>
0N/A * Upon returning, this method will fill the {@code bbox} parameter
0N/A * with 4 values indicating the bounds of the iteration of the
0N/A * tile generator.
0N/A * The iteration order of the tiles will be as specified by the
0N/A * pseudo-code:
0N/A * <pre>
0N/A * for (y = bbox[1]; y < bbox[3]; y += tileheight) {
0N/A * for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
0N/A * }
0N/A * }
0N/A * </pre>
0N/A * If there is no output to be rendered, this method may return
0N/A * null.
0N/A *
0N/A * @param s the shape to be rendered (fill or draw)
0N/A * @param at the transform to be applied to the shape and the
0N/A * stroke attributes
0N/A * @param clip the current clip in effect in device coordinates
0N/A * @param bs if non-null, a {@code BasicStroke} whose attributes
0N/A * should be applied to this operation
0N/A * @param thin true if the transformed stroke attributes are smaller
0N/A * than the minimum dropout pen width
0N/A * @param normalize true if the {@code VALUE_STROKE_NORMALIZE}
0N/A * {@code RenderingHint} is in effect
0N/A * @param bbox returns the bounds of the iteration
0N/A * @return the {@code AATileGenerator} instance to be consulted
0N/A * for tile coverages, or null if there is no output to render
0N/A * @since 1.7
0N/A */
0N/A public AATileGenerator getAATileGenerator(Shape s,
0N/A AffineTransform at,
0N/A Region clip,
0N/A BasicStroke bs,
0N/A boolean thin,
0N/A boolean normalize,
0N/A int bbox[])
0N/A {
2638N/A Renderer r;
2639N/A NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF;
0N/A if (bs == null) {
2639N/A PathIterator pi;
2639N/A if (normalize) {
2956N/A pi = new NormalizingPathIterator(s.getPathIterator(at), norm);
2639N/A } else {
2956N/A pi = s.getPathIterator(at);
2639N/A }
2638N/A r = new Renderer(3, 3,
2638N/A clip.getLoX(), clip.getLoY(),
2638N/A clip.getWidth(), clip.getHeight(),
2956N/A pi.getWindingRule());
0N/A pathTo(pi, r);
0N/A } else {
2638N/A r = new Renderer(3, 3,
2638N/A clip.getLoX(), clip.getLoY(),
2638N/A clip.getWidth(), clip.getHeight(),
2956N/A PathIterator.WIND_NON_ZERO);
2639N/A strokeTo(s, at, bs, thin, norm, true, r);
0N/A }
0N/A r.endRendering();
2956N/A PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
0N/A ptg.getBbox(bbox);
0N/A return ptg;
0N/A }
0N/A
3265N/A public AATileGenerator getAATileGenerator(double x, double y,
3265N/A double dx1, double dy1,
3265N/A double dx2, double dy2,
3265N/A double lw1, double lw2,
3265N/A Region clip,
3265N/A int bbox[])
3265N/A {
3265N/A // REMIND: Deal with large coordinates!
3265N/A double ldx1, ldy1, ldx2, ldy2;
3265N/A boolean innerpgram = (lw1 > 0 && lw2 > 0);
3265N/A
3265N/A if (innerpgram) {
3265N/A ldx1 = dx1 * lw1;
3265N/A ldy1 = dy1 * lw1;
3265N/A ldx2 = dx2 * lw2;
3265N/A ldy2 = dy2 * lw2;
3265N/A x -= (ldx1 + ldx2) / 2.0;
3265N/A y -= (ldy1 + ldy2) / 2.0;
3265N/A dx1 += ldx1;
3265N/A dy1 += ldy1;
3265N/A dx2 += ldx2;
3265N/A dy2 += ldy2;
3265N/A if (lw1 > 1 && lw2 > 1) {
3265N/A // Inner parallelogram was entirely consumed by stroke...
3265N/A innerpgram = false;
3265N/A }
3265N/A } else {
3265N/A ldx1 = ldy1 = ldx2 = ldy2 = 0;
3265N/A }
3265N/A
3265N/A Renderer r = new Renderer(3, 3,
3444N/A clip.getLoX(), clip.getLoY(),
3444N/A clip.getWidth(), clip.getHeight(),
3444N/A PathIterator.WIND_EVEN_ODD);
3265N/A
3265N/A r.moveTo((float) x, (float) y);
3265N/A r.lineTo((float) (x+dx1), (float) (y+dy1));
3265N/A r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
3265N/A r.lineTo((float) (x+dx2), (float) (y+dy2));
3265N/A r.closePath();
3265N/A
3265N/A if (innerpgram) {
3265N/A x += ldx1 + ldx2;
3265N/A y += ldy1 + ldy2;
3265N/A dx1 -= 2.0 * ldx1;
3265N/A dy1 -= 2.0 * ldy1;
3265N/A dx2 -= 2.0 * ldx2;
3265N/A dy2 -= 2.0 * ldy2;
3265N/A r.moveTo((float) x, (float) y);
3265N/A r.lineTo((float) (x+dx1), (float) (y+dy1));
3265N/A r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
3265N/A r.lineTo((float) (x+dx2), (float) (y+dy2));
3265N/A r.closePath();
3265N/A }
3265N/A
3265N/A r.pathDone();
3265N/A
3265N/A r.endRendering();
3265N/A PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
3265N/A ptg.getBbox(bbox);
3265N/A return ptg;
3265N/A }
3265N/A
0N/A /**
0N/A * Returns the minimum pen width that the antialiasing rasterizer
0N/A * can represent without dropouts occuring.
0N/A * @since 1.7
0N/A */
0N/A public float getMinimumAAPenSize() {
0N/A return 0.5f;
0N/A }
0N/A
0N/A static {
0N/A if (PathIterator.WIND_NON_ZERO != Renderer.WIND_NON_ZERO ||
0N/A PathIterator.WIND_EVEN_ODD != Renderer.WIND_EVEN_ODD ||
0N/A BasicStroke.JOIN_MITER != Stroker.JOIN_MITER ||
0N/A BasicStroke.JOIN_ROUND != Stroker.JOIN_ROUND ||
0N/A BasicStroke.JOIN_BEVEL != Stroker.JOIN_BEVEL ||
0N/A BasicStroke.CAP_BUTT != Stroker.CAP_BUTT ||
0N/A BasicStroke.CAP_ROUND != Stroker.CAP_ROUND ||
0N/A BasicStroke.CAP_SQUARE != Stroker.CAP_SQUARE)
0N/A {
0N/A throw new InternalError("mismatched renderer constants");
0N/A }
0N/A }
0N/A}
2639N/A