/** * Creates a new group in the given document where the new group is a collection of "brush * strokes" that represent a "sketch" of the passed circle. In our case the brush strokes are * simple circles. * * @param document * @param circle * @return */ private Element circleToSketch(SVGDocument document, SVGCircleElement circle) { // Turn the circle into a path // We start the path at the maximal x and y point float circleX = circle.getCx().getAnimVal().getValue(); float circleY = circle.getCy().getAnimVal().getValue(); float circleR = circle.getR().getAnimVal().getValue(); List<CubicCurve2D.Float> spline = circleToPath(circleX, circleY, circleR); return splineToSketch(document, spline); }
public void handleEvent(Event evt) { String cx = String.valueOf(Math.floor(Math.random() * 1200)); String cy = String.valueOf(Math.floor(Math.random() * 400)); String r = String.valueOf(Math.floor(Math.random() * 100)); SVGCircleElement circle = (SVGCircleElement) doc.createElementNS(svgNS, "circle"); circle.setAttribute("cx", cx); circle.setAttribute("cy", cy); circle.setAttribute("r", r); circle.setAttribute("fill", "red"); circle.setAttribute("stroke", "blue"); circle.setAttribute("stroke-width", "10"); doc.getDocumentElement().appendChild(circle); System.out.println("Added circle at (" + cx + ", " + cy + ")"); }