< prev index next >

modules/javafx.graphics/src/main/java/com/sun/marlin/DStroker.java

Print this page




 122                     rdrCtx.stats.stat_array_str_polystack_curves,
 123                     rdrCtx.stats.stat_array_str_polystack_types)
 124             : new PolyStack(rdrCtx);
 125 
 126         this.curve = rdrCtx.curve;
 127         this.curveSplitter = rdrCtx.curveClipSplitter;
 128     }
 129 
 130     /**
 131      * Inits the <code>DStroker</code>.
 132      *
 133      * @param pc2d an output <code>DPathConsumer2D</code>.
 134      * @param lineWidth the desired line width in pixels
 135      * @param capStyle the desired end cap style, one of
 136      * <code>CAP_BUTT</code>, <code>CAP_ROUND</code> or
 137      * <code>CAP_SQUARE</code>.
 138      * @param joinStyle the desired line join style, one of
 139      * <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or
 140      * <code>JOIN_BEVEL</code>.
 141      * @param miterLimit the desired miter limit
 142      * @param scale scaling factor applied to clip boundaries
 143      * @param rdrOffX renderer's coordinate offset on X axis
 144      * @param rdrOffY renderer's coordinate offset on Y axis
 145      * @param subdivideCurves true to indicate to subdivide curves, false if dasher does
 146      * @return this instance
 147      */
 148     public DStroker init(final DPathConsumer2D pc2d,
 149                          final double lineWidth,
 150                          final int capStyle,
 151                          final int joinStyle,
 152                          final double miterLimit,
 153                          final double scale,
 154                          double rdrOffX,
 155                          double rdrOffY,
 156                          final boolean subdivideCurves)
 157     {
 158         this.out = pc2d;
 159 
 160         this.lineWidth2 = lineWidth / 2.0d;
 161         this.invHalfLineWidth2Sq = 1.0d / (2.0d * lineWidth2 * lineWidth2);
 162         this.monotonize = subdivideCurves;
 163 
 164         this.capStyle = capStyle;
 165         this.joinStyle = joinStyle;
 166 
 167         final double limit = miterLimit * lineWidth2;
 168         this.miterLimitSq = limit * limit;
 169 
 170         this.prev = CLOSE;
 171 
 172         rdrCtx.stroking = 1;
 173 
 174         if (rdrCtx.doClip) {
 175             // Adjust the clipping rectangle with the stroker margin (miter limit, width)
 176             double margin = lineWidth2;
 177 
 178             if (capStyle == CAP_SQUARE) {
 179                 margin *= SQRT_2;
 180             }
 181             if ((joinStyle == JOIN_MITER) && (margin < limit)) {
 182                 margin = limit;
 183             }
 184             if (scale != 1.0d) {
 185                 margin  *= scale;
 186                 rdrOffX *= scale;
 187                 rdrOffY *= scale;
 188             }
 189             // add a small rounding error:
 190             margin += 1e-3d;
 191 
 192             // bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY
 193             // adjust clip rectangle (ymin, ymax, xmin, xmax):
 194             final double[] _clipRect = rdrCtx.clipRect;
 195             _clipRect[0] -= margin - rdrOffY;
 196             _clipRect[1] += margin + rdrOffY;
 197             _clipRect[2] -= margin - rdrOffX;
 198             _clipRect[3] += margin + rdrOffX;
 199             this.clipRect = _clipRect;
 200 





 201             // initialize curve splitter here for stroker & dasher:
 202             if (DO_CLIP_SUBDIVIDER) {
 203                 subdivide = subdivideCurves;
 204                 // adjust padded clip rectangle:
 205                 curveSplitter.init();
 206             } else {
 207                 subdivide = false;
 208             }
 209         } else {
 210             this.clipRect = null;
 211             this.cOutCode = 0;
 212             this.sOutCode = 0;
 213         }
 214         return this; // fluent API
 215     }
 216 
 217     public void disableClipping() {
 218         this.clipRect = null;
 219         this.cOutCode = 0;
 220         this.sOutCode = 0;




 122                     rdrCtx.stats.stat_array_str_polystack_curves,
 123                     rdrCtx.stats.stat_array_str_polystack_types)
 124             : new PolyStack(rdrCtx);
 125 
 126         this.curve = rdrCtx.curve;
 127         this.curveSplitter = rdrCtx.curveClipSplitter;
 128     }
 129 
 130     /**
 131      * Inits the <code>DStroker</code>.
 132      *
 133      * @param pc2d an output <code>DPathConsumer2D</code>.
 134      * @param lineWidth the desired line width in pixels
 135      * @param capStyle the desired end cap style, one of
 136      * <code>CAP_BUTT</code>, <code>CAP_ROUND</code> or
 137      * <code>CAP_SQUARE</code>.
 138      * @param joinStyle the desired line join style, one of
 139      * <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or
 140      * <code>JOIN_BEVEL</code>.
 141      * @param miterLimit the desired miter limit



 142      * @param subdivideCurves true to indicate to subdivide curves, false if dasher does
 143      * @return this instance
 144      */
 145     public DStroker init(final DPathConsumer2D pc2d,
 146                          final double lineWidth,
 147                          final int capStyle,
 148                          final int joinStyle,
 149                          final double miterLimit,



 150                          final boolean subdivideCurves)
 151     {
 152         this.out = pc2d;
 153 
 154         this.lineWidth2 = lineWidth / 2.0d;
 155         this.invHalfLineWidth2Sq = 1.0d / (2.0d * lineWidth2 * lineWidth2);
 156         this.monotonize = subdivideCurves;
 157 
 158         this.capStyle = capStyle;
 159         this.joinStyle = joinStyle;
 160 
 161         final double limit = miterLimit * lineWidth2;
 162         this.miterLimitSq = limit * limit;
 163 
 164         this.prev = CLOSE;
 165 
 166         rdrCtx.stroking = 1;
 167 
 168         if (rdrCtx.doClip) {
 169             // Adjust the clipping rectangle with the stroker margin (miter limit, width)
 170             double margin = lineWidth2;
 171 
 172             if (capStyle == CAP_SQUARE) {
 173                 margin *= SQRT_2;
 174             }
 175             if ((joinStyle == JOIN_MITER) && (margin < limit)) {
 176                 margin = limit;
 177             }







 178 
 179             // bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY
 180             // adjust clip rectangle (ymin, ymax, xmin, xmax):
 181             final double[] _clipRect = rdrCtx.clipRect;
 182             _clipRect[0] -= margin;
 183             _clipRect[1] += margin;
 184             _clipRect[2] -= margin;
 185             _clipRect[3] += margin;
 186             this.clipRect = _clipRect;
 187 
 188             if (MarlinConst.DO_LOG_CLIP) {
 189                 MarlinUtils.logInfo("clipRect (stroker): "
 190                                     + Arrays.toString(rdrCtx.clipRect));
 191             }
 192 
 193             // initialize curve splitter here for stroker & dasher:
 194             if (DO_CLIP_SUBDIVIDER) {
 195                 subdivide = subdivideCurves;
 196                 // adjust padded clip rectangle:
 197                 curveSplitter.init();
 198             } else {
 199                 subdivide = false;
 200             }
 201         } else {
 202             this.clipRect = null;
 203             this.cOutCode = 0;
 204             this.sOutCode = 0;
 205         }
 206         return this; // fluent API
 207     }
 208 
 209     public void disableClipping() {
 210         this.clipRect = null;
 211         this.cOutCode = 0;
 212         this.sOutCode = 0;


< prev index next >