< prev index next >
modules/javafx.graphics/src/main/java/com/sun/prism/impl/shape/ShapeUtil.java
Print this page
*** 23,37 ****
--- 23,40 ----
* questions.
*/
package com.sun.prism.impl.shape;
+ import com.sun.javafx.geom.Path2D;
+ import com.sun.javafx.geom.PathConsumer2D;
import com.sun.javafx.geom.RectBounds;
import com.sun.javafx.geom.Shape;
import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.prism.BasicStroke;
import com.sun.prism.impl.PrismSettings;
+ import com.sun.prism.impl.PrismSettings.RasterizerType;
public class ShapeUtil {
private static final ShapeRasterizer shapeRasterizer;
static {
*** 59,68 ****
--- 62,105 ----
boolean close, boolean antialiasedShape)
{
return shapeRasterizer.getMaskData(shape, stroke, xformBounds, xform, close, antialiasedShape);
}
+ public static Shape createCenteredStrokedShape(Shape s, BasicStroke stroke)
+ {
+ if (PrismSettings.rasterizerSpec == RasterizerType.DoubleMarlin) {
+ return DMarlinRasterizer.createCenteredStrokedShape(s, stroke);
+ }
+ if (PrismSettings.rasterizerSpec == RasterizerType.FloatMarlin) {
+ return MarlinRasterizer.createCenteredStrokedShape(s, stroke);
+ }
+ // JavaPisces fallback:
+ return createCenteredStrokedShapeOpenPisces(s, stroke);
+ }
+
+ private static Shape createCenteredStrokedShapeOpenPisces(Shape s, BasicStroke stroke)
+ {
+ final float lw = (stroke.getType() == BasicStroke.TYPE_CENTERED) ?
+ stroke.getLineWidth() : stroke.getLineWidth() * 2.0f;
+
+ final Path2D p2d = new Path2D(Path2D.WIND_NON_ZERO);
+
+ PathConsumer2D pc2d =
+ new com.sun.openpisces.Stroker(p2d, lw, stroke.getEndCap(),
+ stroke.getLineJoin(),
+ stroke.getMiterLimit());
+
+ if (stroke.isDashed()) {
+ pc2d = new com.sun.openpisces.Dasher(pc2d, stroke.getDashArray(),
+ stroke.getDashPhase());
+ }
+ com.sun.prism.impl.shape.OpenPiscesPrismUtils.feedConsumer(
+ s.getPathIterator(null), pc2d);
+
+ return p2d;
+ }
+
/**
* Private constructor to prevent instantiation.
*/
private ShapeUtil() {
}
< prev index next >