@Override public void mousePressed(MouseEvent e) { example = new Example(); examples.add(example); example.error = getError(); double zoomFactor = getZoomFactor(); example.digitized.moveTo(e.getX() / zoomFactor, e.getY() / zoomFactor); canvas.repaint(); }
public static BezierPath toBezierPath(final PathIterator iterator) { final BezierPath path = new BezierPath(); final double[] segment = new double[6]; for (; !iterator.isDone(); iterator.next()) { final int type = iterator.currentSegment(segment); switch (type) { case PathIterator.SEG_MOVETO: path.moveTo(segment[0], segment[1]); break; case PathIterator.SEG_LINETO: path.lineTo(segment[0], segment[1]); break; case PathIterator.SEG_QUADTO: path.quadTo(segment[0], segment[1], segment[2], segment[3]); break; case PathIterator.SEG_CUBICTO: path.curveTo(segment[0], segment[1], segment[2], segment[3], segment[4], segment[5]); break; case PathIterator.SEG_CLOSE: path.setClosed(true); break; } } return path; }
public static void main(final String[] args) { BezierPath path1 = new BezierPath(); path1.moveTo(0, 0); path1.lineTo(100, 0); path1.lineTo(100, 100); path1.lineTo(0, 0); final GeneralPath path2 = new GeneralPath(); path2.moveTo(0, 0); path2.lineTo(100, 0); path2.lineTo(100, 100); path2.closePath(); // path1 = toBezierPath(path2.getPathIterator(new AffineTransform())); final BezierPath path3 = new BezierPath(); path3.moveTo(0, 100); path3.lineTo(100, 0); path3.lineTo(100, 100); path3.lineTo(0, 100); path1 = subtract(path1, path3); show(path1.toGeneralPath()); }
case NORTH : default : triangle.moveTo((float) (r.x + r.width / 2), (float) r.y); triangle.lineTo((float) (r.x + r.width), (float) (r.y + r.height)); triangle.lineTo((float) r.x, (float) (r.y + r.height)); break; case NORTH_EAST : triangle.moveTo((float) (r.x), (float) r.y); triangle.lineTo((float) (r.x + r.width), (float) (r.y)); triangle.lineTo((float) (r.x + r.width), (float) (r.y + r.height)); break; case EAST : triangle.moveTo((float) (r.x), (float) (r.y)); triangle.lineTo((float) (r.x + r.width), (float) (r.y + r.height / 2d)); triangle.lineTo((float) r.x, (float) (r.y + r.height)); break; case SOUTH_EAST : triangle.moveTo((float) (r.x + r.width), (float) (r.y)); triangle.lineTo((float) (r.x + r.width), (float) (r.y + r.height)); triangle.lineTo((float) (r.x), (float) (r.y + r.height)); break; case SOUTH : triangle.moveTo((float) (r.x + r.width / 2), (float) (r.y + r.height)); triangle.lineTo((float) r.x, (float) r.y); triangle.lineTo((float) (r.x + r.width), (float) r.y); break; case SOUTH_WEST : triangle.moveTo((float) (r.x + r.width), (float) (r.y + r.height)); triangle.lineTo((float) (r.x), (float) (r.y + r.height));
if (bezierPath != null) add(bezierPath, false); bezierPath = new BezierPath(); bezierPath.moveTo(segment[0], segment[1]); break; case PathIterator.SEG_LINETO:
if (bezierPath != null) add(bezierPath, false); bezierPath = new BezierPath(); bezierPath.moveTo(segment[0], segment[1]); break; case PathIterator.SEG_LINETO:
bp.moveTo(coords[0], coords[1]); break; case PathIterator.SEG_LINETO:
bp.moveTo(coords[0], coords[1]); break; case PathIterator.SEG_LINETO: