Stroker.java revision 2638
2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 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 0N/A * Constant value for join style. 0N/A * Constant value for join style. 0N/A * Constant value for join style. 0N/A * Constant value for end cap style. 0N/A * Constant value for end cap style. 0N/A * Constant value for end cap style. 0N/A // For any pen offset (pen_dx, pen_dy) that does not depend on 0N/A // the line orientation, the pen should be transformed so that: 0N/A // pen_dx' = m00*pen_dx + m01*pen_dy 0N/A // pen_dy' = m10*pen_dx + m11*pen_dy 0N/A // For a round pen, this means: 0N/A // pen_dx(r, theta) = r*cos(theta) 0N/A // pen_dy(r, theta) = r*sin(theta) 0N/A // pen_dx'(r, theta) = r*(m00*cos(theta) + m01*sin(theta)) 0N/A // pen_dy'(r, theta) = r*(m10*cos(theta) + m11*sin(theta)) 0N/A * Constructs a <code>Stroker</code>. 0N/A * @param output an output <code>LineSink</code>. 2638N/A * @param lineWidth the desired line width in pixels 0N/A * @param capStyle the desired end cap style, one of 0N/A * <code>CAP_BUTT</code>, <code>CAP_ROUND</code> or 0N/A * <code>CAP_SQUARE</code>. 0N/A * @param joinStyle the desired line join style, one of 0N/A * <code>JOIN_MITER</code>, <code>JOIN_ROUND</code> or 0N/A * <code>JOIN_BEVEL</code>. 2638N/A * @param miterLimit the desired miter limit 0N/A * @param transform a <code>Transform4</code> object indicating 0N/A * the transform that has been previously applied to all incoming 0N/A * coordinates. This is required in order to produce consistently 0N/A * shaped end caps and joins. 2638N/A // pisces used to use fixed point arithmetic with 16 decimal digits. I 2638N/A // didn't want to change the values of the constants below when I converted 2638N/A // it to floating point, so that's why the divisions by 2^16 are there. 0N/A // Return the intersection point of the lines (ix0, iy0) -> (ix1, iy1) 0N/A // and (ix0p, iy0p) -> (ix1p, iy1p) in m[0] and m[1] 0N/A // Compute miter length in untransformed coordinates 0N/A // System.out.println("Stroker.moveTo(" + x0/65536.0 + ", " + y0/65536.0 + ")"); 0N/A // not closing the path, do the previous lineTo 0N/A // System.out.println("Stroker.lineJoin()"); 0N/A // System.out.println("Stroker.lineTo(" + x1/65536.0 + ", " + y1/65536.0 + ")"); 0N/A // staying in the starting point 0N/A // not closing the path, do the previous lineTo 0N/A drawMiter(
px0,
py0,
x0,
y0,
x1,
y1,
omx,
omy,
mx,
my,
0N/A // Draw internal joins as round 0N/A // System.out.println("Stroker.close()"); 0N/A // ignore the previous lineTo 0N/A // Draw penultimate join 0N/A drawMiter(
px0,
py0,
x0,
y0,
sx0,
sy0,
omx,
omy,
mx,
my,
ccw);
0N/A // Draw internal joins as round 0N/A // Draw final join on the outside 0N/A // Draw final join on the inside 0N/A // System.out.println("Stroker.end()"); 0N/A // not closing the path, do the previous lineTo 0N/A // System.out.println("Stroker.emitMoveTo(" + x0/65536.0 + ", " + y0/65536.0 + ")"); 0N/A // System.out.println("Stroker.emitLineTo(" + x0/65536.0 + ", " + y0/65536.0 + ")"); 0N/A // System.out.println("Stroker.emitClose()");