java类java.awt.geom.Path2D的实例源码

FourierDescriptor.java 文件源码 项目:imagingbook-common 阅读 21 收藏 0 点赞 0 评论 0
public Path2D makeEllipse(Complex G1, Complex G2, int m, double xOffset, double yOffset) {
    Path2D path = new Path2D.Float();
    int recPoints = Math.max(minReconstructionSamples, G.length * 3);
    for (int i = 0; i < recPoints; i++) {
        double t = (double) i / recPoints;
        Complex p1 = this.getEllipsePoint(G1, G2, m, t);
        double xt = p1.re();
        double yt = p1.im();
        if (i == 0) {
            path.moveTo(xt + xOffset, yt + yOffset);
        }
        else {
            path.lineTo(xt + xOffset, yt + yOffset);
        }
    }
    path.closePath();
    return path;
}
LandscapeStackOverflow.java 文件源码 项目:openjdk-jdk10 阅读 19 收藏 0 点赞 0 评论 0
public int print( Graphics graphics, PageFormat format, int index ) {
    Graphics2D g2d = (Graphics2D)graphics;

    double scalex = g2d.getTransform().getScaleX();
    double scaley = g2d.getTransform().getScaleY();

    double centerx = ( format.getImageableX() +
                     ( format.getImageableWidth() / 2 ) ) * scalex;
    double centery = ( format.getImageableY() +
                     ( format.getImageableHeight() / 2 ) ) * scaley;

    // The following 2 lines cause an error when printing in landscape.
    g2d.scale( 1 / scalex, 1 / scaley );
    g2d.translate( centerx, centery );

    Path2D.Double path = new Path2D.Double();
    path.moveTo( -scalex * 72, -scaley * 72 );
    path.lineTo( -scalex * 72, scaley * 72 );
    path.lineTo( scalex * 72, scaley * 72 );
    path.lineTo( scalex * 72, -scaley * 72 );
    path.closePath();

    g2d.draw( path );

    return index == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
}
Path2DCopyConstructor.java 文件源码 项目:jdk8u-jdk 阅读 24 收藏 0 点赞 0 评论 0
static void testAddClose(Path2D pathA, boolean isEmpty) {
    try {
        addClose(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddClose: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddClose: passed.");
}
Path2DCopyConstructor.java 文件源码 项目:openjdk-jdk10 阅读 31 收藏 0 点赞 0 评论 0
static void testAddLine(Path2D pathA, boolean isEmpty) {
    try {
        addLines(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddLine: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddLine: passed.");
}
VisualisationPanel.java 文件源码 项目:AI-RRT-Motion-Planning 阅读 61 收藏 0 点赞 0 评论 0
public void paintState(Graphics2D g2, ASVConfig s) {
    if (s == null) {
        return;
    }
    Path2D.Float path = new Path2D.Float();

    List<Point2D> points = s.getASVPositions();
    Point2D p = points.get(0);
    path.moveTo(p.getX(), p.getY());
    for (int i = 1; i < points.size(); i++) {
        p = points.get(i);
        path.lineTo(p.getX(), p.getY());
    }
    path.transform(transform);
    g2.draw(path);
    if (animating || !displayingSolution) {
        p = transform.transform(points.get(0), null);
        Color color = g2.getColor();
        Stroke stroke = g2.getStroke();
        g2.setColor(Color.BLACK);
        g2.setStroke(new BasicStroke(1));
        g2.draw(new Ellipse2D.Double(p.getX() - 4, p.getY() - 4, 8, 8));
        g2.setColor(color);
        g2.setStroke(stroke);
    }
}
Path2DCopyConstructor.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
static void testGetBounds(Path2D pathA, Path2D pathB) {
    final Rectangle rA = pathA.getBounds();
    final Rectangle rB = pathB.getBounds();

    if (!rA.equals(rB)) {
        throw new IllegalStateException("Bounds are not equals [" + rA
            + "|" + rB + "] !");
    }
    final Rectangle2D r2dA = pathA.getBounds2D();
    final Rectangle2D r2dB = pathB.getBounds2D();

    if (!equalsRectangle2D(r2dA, r2dB)) {
        throw new IllegalStateException("Bounds2D are not equals ["
            + r2dA + "|" + r2dB + "] !");
    }
    log("testGetBounds: passed.");
}
RendererContext.java 文件源码 项目:openjdk-jdk10 阅读 34 收藏 0 点赞 0 评论 0
Path2D.Float getPath2D() {
    // resolve reference:
    Path2D.Float p2d
        = (refPath2D != null) ? refPath2D.get() : null;

    // create a new Path2D ?
    if (p2d == null) {
        p2d = new Path2D.Float(Path2D.WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K

        // update weak reference:
        refPath2D = new WeakReference<Path2D.Float>(p2d);
    }
    // reset the path anyway:
    p2d.reset();
    return p2d;
}
GDIRenderer.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
    Path2D.Float p2df;
    int transX;
    int transY;
    if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
            p2df = (Path2D.Float)s;
        } else {
            p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
    } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
    }
    try {
        doShape((GDIWindowSurfaceData)sg2d.surfaceData,
                sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
                transX, transY, p2df, isfill);
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
}
PathGraphics.java 文件源码 项目:openjdk-jdk10 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Draws a sequence of connected lines defined by
 * arrays of <i>x</i> and <i>y</i> coordinates.
 * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
 * The figure is not closed if the first point
 * differs from the last point.
 * @param       xPoints an array of <i>x</i> points
 * @param       yPoints an array of <i>y</i> points
 * @param       nPoints the total number of points
 * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
 * @since       1.1
 */
public void drawPolyline(int xPoints[], int yPoints[],
                         int nPoints) {

    if (nPoints == 2) {
        draw(new Line2D.Float(xPoints[0], yPoints[0],
                              xPoints[1], yPoints[1]));
    } else if (nPoints > 2) {
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD, nPoints);
        path.moveTo(xPoints[0], yPoints[0]);
        for(int i = 1; i < nPoints; i++) {
            path.lineTo(xPoints[i], yPoints[i]);
        }
        draw(path);
    }
}
Path2DCopyConstructor.java 文件源码 项目:openjdk-jdk10 阅读 22 收藏 0 点赞 0 评论 0
static void testAddCubic(Path2D pathA, boolean isEmpty) {
    try {
        addCubics(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddCubic: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddCubic: passed.");
}
PolygonClustering.java 文件源码 项目:loom 阅读 20 收藏 0 点赞 0 评论 0
private Map<Object, List<Fibre>> polygonClustering(final List<Path2D.Double> polygons, final Integer defaultPolygon,
        final List<Fibre> input, final List<String> attributes, final Map<OperationErrorCode, String> errors,
        final OperationContext context) {
    Map<Object, List<Fibre>> result;

    result = new ConcurrentHashMap<Object, List<Fibre>>();

    input.stream().forEach(le -> {
        List<Double> values = LoomQueryUtils.convertAttributesToNumbers(attributes, le, errors, context);
        int polygonIndex = this.findContainer(polygons, defaultPolygon, values.get(0), values.get(1));

        if (result.get(polygonIndex) == null) {
            result.put(polygonIndex, new LinkedList<Fibre>());
        }
        result.get(polygonIndex).add(le);
    });

    return result;
}
Test7019861.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
public static void main(String[] argv) throws Exception {
    BufferedImage im = getWhiteImage(30, 30);
    Graphics2D g2 = (Graphics2D)im.getGraphics();
    g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
    g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    g2.setBackground(Color.white);
    g2.setColor(Color.black);

    Path2D p = getPath(0, 0, 20);
    g2.draw(p);

    if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
        throw new Exception("This pixel should be black");
    }
}
X11Renderer.java 文件源码 项目:openjdk-jdk10 阅读 22 收藏 0 点赞 0 评论 0
private void doPath(SunGraphics2D sg2d, Shape s, boolean isFill) {
    Path2D.Float p2df;
    int transx, transy;
    if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
            p2df = (Path2D.Float)s;
        } else {
            p2df = new Path2D.Float(s);
        }
        transx = sg2d.transX;
        transy = sg2d.transY;
    } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transx = 0;
        transy = 0;
    }
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDoPath(sg2d, sg2d.surfaceData.getNativeOps(), xgc,
                transx, transy, p2df, isFill);
    } finally {
        SunToolkit.awtUnlock();
    }
}
GDIRenderer.java 文件源码 项目:jdk8u-jdk 阅读 23 收藏 0 点赞 0 评论 0
void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
    Path2D.Float p2df;
    int transX;
    int transY;
    if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
            p2df = (Path2D.Float)s;
        } else {
            p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
    } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
    }
    try {
        doShape((GDIWindowSurfaceData)sg2d.surfaceData,
                sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
                transX, transY, p2df, isfill);
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
}
Path2DCopyConstructor.java 文件源码 项目:openjdk-jdk10 阅读 19 收藏 0 点赞 0 评论 0
static void testAddQuad(Path2D pathA, boolean isEmpty) {
    try {
        addQuads(pathA);
    }
    catch (IllegalPathStateException ipse) {
        if (isEmpty) {
            log("testAddQuad: passed "
                + "(expected IllegalPathStateException catched).");
            return;
        } else {
            throw ipse;
        }
    }
    if (isEmpty) {
        throw new IllegalStateException("IllegalPathStateException not thrown !");
    }
    log("testAddQuad: passed.");
}
X11Renderer.java 文件源码 项目:jdk8u-jdk 阅读 26 收藏 0 点赞 0 评论 0
private void doPath(SunGraphics2D sg2d, Shape s, boolean isFill) {
    Path2D.Float p2df;
    int transx, transy;
    if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
            p2df = (Path2D.Float)s;
        } else {
            p2df = new Path2D.Float(s);
        }
        transx = sg2d.transX;
        transy = sg2d.transY;
    } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transx = 0;
        transy = 0;
    }
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDoPath(sg2d, sg2d.surfaceData.getNativeOps(), xgc,
                transx, transy, p2df, isFill);
    } finally {
        SunToolkit.awtUnlock();
    }
}
BufferedRenderPipe.java 文件源码 项目:openjdk-jdk10 阅读 18 收藏 0 点赞 0 评论 0
public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        if (s instanceof Polygon) {
            if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                Polygon p = (Polygon)s;
                drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
                return;
            }
        }
        Path2D.Float p2df;
        int transx, transy;
        if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
            if (s instanceof Path2D.Float) {
                p2df = (Path2D.Float)s;
            } else {
                p2df = new Path2D.Float(s);
            }
            transx = sg2d.transX;
            transy = sg2d.transY;
        } else {
            p2df = new Path2D.Float(s, sg2d.transform);
            transx = 0;
            transy = 0;
        }
        drawPath(sg2d, p2df, transx, transy);
    } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
        ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
        try {
            fillSpans(sg2d, si, 0, 0);
        } finally {
            si.dispose();
        }
    } else {
        fill(sg2d, sg2d.stroke.createStrokedShape(s));
    }
}
MapUtilities.java 文件源码 项目:litiengine 阅读 21 收藏 0 点赞 0 评论 0
public static Path2D convertPolylineToPath(final IMapObject mapObject) {
  if (mapObject == null || mapObject.getPolyline() == null || mapObject.getPolyline().getPoints().isEmpty()) {
    return null;
  }

  Path2D path = new Path2D.Float();
  path.moveTo(mapObject.getLocation().getX(), mapObject.getLocation().getY());
  for (int i = 1; i < mapObject.getPolyline().getPoints().size(); i++) {
    Point2D point = mapObject.getPolyline().getPoints().get(i);
    path.lineTo(mapObject.getLocation().getX() + point.getX(), mapObject.getLocation().getY() + point.getY());
  }

  return path;
}
TabbedImpl.java 文件源码 项目:incubator-netbeans 阅读 20 收藏 0 点赞 0 评论 0
@Override
protected Shape getDropIndication( TopComponent draggedTC, Point location ) {
    location = SwingUtilities.convertPoint( getComponent(), location, getTabDisplayer() );
    Path2D res = new Path2D.Double();
    Rectangle tabRect = getTabDisplayer().dropIndication( draggedTC, location );
    if( null != tabRect ) {
        tabRect = SwingUtilities.convertRectangle( getTabDisplayer(), tabRect, container );
        res.append( tabRect, false );
    }
    res.append( container.getContentArea(), false );
    return res;
}
ProgressBarUI.java 文件源码 项目:rapidminer 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Creates the shape for a single part of the intermediate bar.
 *
 * @param x
 * @param width
 * @param h
 * @param verticval
 * @return
 */
private Path2D createIntermediateShape(double x, double width, double h) {
    int offset = 10;

    Path2D path = new Path2D.Double();
    path.append(new Line2D.Double(x, h, x + offset, 0), true);
    path.append(new Line2D.Double(x + offset, 0, x + width + offset, 0), true);
    path.append(new Line2D.Double(x + width + offset, 0, x + width, h), true);
    path.append(new Line2D.Double(x + width, h, x, h), true);

    return path;
}
ProcessPath.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
public static boolean drawPath(DrawHandler dhnd,
                               Path2D.Float p2df,
                               int transX, int transY)
{
    return doProcessPath(new DrawProcessHandler(dhnd,
                                                noopEndSubPathHandler),
                         p2df, transX, transY);
}
GeneralRenderer.java 文件源码 项目:openjdk-jdk10 阅读 16 收藏 0 点赞 0 评论 0
public void DrawPath(SunGraphics2D sg2d, SurfaceData sData,
                     int transx, int transy,
                     Path2D.Float p2df)
{
    PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData);
    ProcessPath.drawPath(
        new PixelWriterDrawHandler(sData, pw, sg2d.getCompClip(),
                                   sg2d.strokeHint),
        p2df, transx, transy
    );
}
ResourceConnection.java 文件源码 项目:onprom 阅读 21 收藏 0 点赞 0 评论 0
private Path2D drawArrow(int x1, int y1, int x2, int y2) {
  Path2D context = new Path2D.Float();
  int headlen = 10;   // length of head in pixels
  double angle = Math.atan2(y2 - y1, x2 - x1);
  context.moveTo(x1, y1);
  context.lineTo(x2, y2);
  context.lineTo(x2 - headlen * Math.cos(angle - Math.PI / 6), y2 - headlen * Math.sin(angle - Math.PI / 6));
  context.moveTo(x2, y2);
  context.lineTo(x2 - headlen * Math.cos(angle + Math.PI / 6), y2 - headlen * Math.sin(angle + Math.PI / 6));
  context.closePath();
  return context;
}
GraphicsJLabel.java 文件源码 项目:Progetto-B 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Creates a new GraphicsJLabel
 */
public GraphicsJLabel() {
    super();
    myPath = new Path2D.Double();
    xx = new double[]{0, 0, 0};
    yy = new double[]{0, 0, 0};
}
Path2DCopyConstructor.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
static void testFlattening(Path2D pathA, Path2D pathB) {
    final PathIterator itA = pathA.getPathIterator(at, FLATNESS);
    final PathIterator itB = pathB.getPathIterator(at, FLATNESS);

    float[] coordsA = new float[6];
    float[] coordsB = new float[6];

    int n = 0;
    for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) {
        int typeA = itA.currentSegment(coordsA);
        int typeB = itB.currentSegment(coordsB);

        if (typeA != typeB) {
            throw new IllegalStateException("Path-segment[" + n + "] "
                + "type are not equals [" + typeA + "|" + typeB + "] !");
        }
        // Take care of floating-point precision:
        if (!equalsArrayEps(coordsA, coordsB, getLength(typeA))) {
            throw new IllegalStateException("Path-segment[" + n + "] coords"
                + " are not equals [" + Arrays.toString(coordsA) + "|"
                + Arrays.toString(coordsB) + "] !");
        }
    }
    if (!itA.isDone() || !itB.isDone()) {
        throw new IllegalStateException("Paths do not have same lengths !");
    }
    log("testFlattening: " + n + " segments.");
}
JVertexView.java 文件源码 项目:JavaGraph 阅读 25 收藏 0 点赞 0 评论 0
/** Creates a diamond shape inscribed in the bounds given in the parameters. */
private Shape createDiamondShape(double x, double y, double width, double height) {
    GeneralPath result = new GeneralPath(Path2D.WIND_NON_ZERO, 5);
    result.moveTo(x + width / 2, y);
    result.lineTo(x + width, y + height / 2);
    result.lineTo(x + width / 2, y + height);
    result.lineTo(x, y + height / 2);
    result.closePath();
    return result;
}
XMLDiagram.java 文件源码 项目:ramus 阅读 66 收藏 0 点赞 0 评论 0
private void paintYPin(Graphics2D g, int number) {
    double y = top;
    for (int i = 0; i < number; i++) {
        y += yBounds[i].getSize().getHeight();
    }
    g.setColor(Color.black);

    double max = 6;

    g.setPaint(new GradientPaint(new Point2D.Double(LEFT - max, y - max),
            Color.green, new Point2D.Double(LEFT + max, y + max),
            Color.black));

    GeneralPath path1 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4);
    GeneralPath path2 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4);
    path1.moveTo(LEFT - 5, y);
    path1.lineTo(LEFT - 5 - max, y + max / 2);
    path1.lineTo(LEFT - 5 - max, y - max / 2);
    path1.lineTo(LEFT - 5, y);

    path2.moveTo(5 + LEFT + width, y);
    path2.lineTo(5 + LEFT + width + max, y + max / 2);
    path2.lineTo(5 + LEFT + width + max, y - max / 2);
    path2.lineTo(5 + LEFT + width, y);

    g.fill(path1);
    g.setPaint(new GradientPaint(new Point2D.Double(LEFT + width - max, y
            - max), Color.black, new Point2D.Double(LEFT + max + width, y
            + max), Color.green));
    g.fill(path2);
    g.setColor(Color.gray);
    g.draw(path1);
    g.draw(path2);
}
ArrowPainter.java 文件源码 项目:ramus 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Малює кінець стрілки.
 *
 * @param g    Область для виводу стрілки.
 * @param x    Координата x кінця стрілки.
 * @param y    Координата y кінця стрілки.
 * @param type Напрямок направленості стрілки, MovingPanel.RIGHT,...
 */

public void paintArrowEnd(final Graphics2D g, double x1, double y1,
                          final double xD, final double yD, int type) {
    final float x = (float) xD;
    final float y = (float) yD;
    final GeneralPath t = new GeneralPath(Path2D.WIND_EVEN_ODD, 3);
    t.moveTo(x, y);
    final float arrowWidth = (float) movingArea
            .getIDoubleOrdinate(ARROW_WIDTH);
    final float arrowHeight = (float) movingArea
            .getIDoubleOrdinate(ARROW_HEIGHT);
    type = MovingPanel.getOpposite(type);
    switch (type) {
        case MovingPanel.BOTTOM: {
            t.lineTo(x - arrowWidth, y - arrowHeight);
            t.lineTo(x + arrowWidth, y - arrowHeight);
        }
        break;
        case MovingPanel.RIGHT: {
            t.lineTo(x - arrowHeight, y - arrowWidth);
            t.lineTo(x - arrowHeight, y + arrowWidth);
        }
        break;
        case MovingPanel.TOP: {
            t.lineTo(x - arrowWidth, y + arrowHeight);
            t.lineTo(x + arrowWidth, y + arrowHeight);
        }
        break;
        case MovingPanel.LEFT: {
            t.lineTo(x + arrowHeight, y - arrowWidth);
            t.lineTo(x + arrowHeight, y + arrowWidth);
        }
        break;
    }
    t.closePath();
    g.fill(t);
}
RoiUtils.java 文件源码 项目:imagingbook-common 阅读 21 收藏 0 点赞 0 评论 0
@Deprecated
public static Roi makePolygon(Point2D[] points, double strokeWidth, Color color) {
    Path2D poly = new Path2D.Double();
    if (points.length > 0) {
        poly.moveTo(points[0].getX(), points[0].getY());
        for (int i = 1; i < points.length; i++) {
            poly.lineTo(points[i].getX(), points[i].getY());
        }
        poly.closePath();
    }
    Roi shapeRoi = new ShapeRoi(poly);
    shapeRoi.setStrokeWidth(strokeWidth);
    shapeRoi.setStrokeColor(color);
    return shapeRoi;
}
DMarlinRenderingEngine.java 文件源码 项目:openjdk-jdk10 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Create a widened path as specified by the parameters.
 * <p>
 * The specified {@code src} {@link Shape} is widened according
 * to the specified attribute parameters as per the
 * {@link BasicStroke} specification.
 *
 * @param src the source path to be widened
 * @param width the width of the widened path as per {@code BasicStroke}
 * @param caps the end cap decorations as per {@code BasicStroke}
 * @param join the segment join decorations as per {@code BasicStroke}
 * @param miterlimit the miter limit as per {@code BasicStroke}
 * @param dashes the dash length array as per {@code BasicStroke}
 * @param dashphase the initial dash phase as per {@code BasicStroke}
 * @return the widened path stored in a new {@code Shape} object
 * @since 1.7
 */
@Override
public Shape createStrokedShape(Shape src,
                                float width,
                                int caps,
                                int join,
                                float miterlimit,
                                float[] dashes,
                                float dashphase)
{
    final DRendererContext rdrCtx = getRendererContext();
    try {
        // initialize a large copyable Path2D to avoid a lot of array growing:
        final Path2D.Double p2d = rdrCtx.getPath2D();

        strokeTo(rdrCtx,
                 src,
                 null,
                 width,
                 NormMode.OFF,
                 caps,
                 join,
                 miterlimit,
                 dashes,
                 dashphase,
                 rdrCtx.transformerPC2D.wrapPath2d(p2d)
                );

        // Use Path2D copy constructor (trim)
        return new Path2D.Double(p2d);

    } finally {
        // recycle the DRendererContext instance
        returnRendererContext(rdrCtx);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号