/** * Convenience method for getting the start point. */ @Override public Point2D.Double getStartPoint() { return getPoint(0, 0); }
@Override public Point2D.Double locate(Figure owner) { BezierFigure plf = (BezierFigure) owner; if (index < plf.getNodeCount()) { return plf.getPoint(index, coord); } return new Point2D.Double(0, 0); }
/** * Convenience method for getting the end point. */ @Override public Point2D.Double getEndPoint() { return getPoint(getNodeCount() - 1, 0); }
@Override public Rectangle2D.Double getDrawingArea() { Rectangle2D.Double r = super.getDrawingArea(); if (getNodeCount() > 1) { if (get(START_DECORATION) != null) { Point2D.Double p1 = getPoint(0, 0); Point2D.Double p2 = getPoint(1, 0); r.add(get(START_DECORATION).getDrawingArea(this, p1, p2)); } if (get(END_DECORATION) != null) { Point2D.Double p1 = getPoint(getNodeCount() - 1, 0); Point2D.Double p2 = getPoint(getNodeCount() - 2, 0); r.add(get(END_DECORATION).getDrawingArea(this, p1, p2)); } } return r; }
protected Point getLocation() { if (getBezierFigure().getNodeCount() > index) { Point2D.Double p = getBezierFigure().getPoint(index, controlPointIndex); if (getTransformOwner().get(TRANSFORM) != null) { getTransformOwner().get(TRANSFORM).transform(p, p); } return view.drawingToView(p); } else { return new Point(10, 10); } }
protected Point getLocation() { if (getOwner().getNodeCount() > index) { Point2D.Double p = getOwner().getPoint(index, 0); if (getTransformOwner().get(TRANSFORM) != null) { getTransformOwner().get(TRANSFORM).transform(p, p); } return view.drawingToView(p); } else { return new Point(10, 10); } }
if (newValue.keepColinear) { Point2D.Double p = figure.getPoint(index, controlPointIndex); double a = Math.PI + Math.atan2(p.y - newValue.y[0], p.x - newValue.x[0]); int c2 = (controlPointIndex == 1) ? 2 : 1;
protected void addPointToFigure(Point2D.Double newPoint) { int pointCount = createdFigure.getNodeCount(); createdFigure.willChange(); if (pointCount < 2) { createdFigure.addNode(new BezierPath.Node(newPoint)); } else { Point2D.Double endPoint = createdFigure.getEndPoint(); Point2D.Double secondLastPoint = (pointCount <= 1) ? endPoint : createdFigure.getPoint(pointCount - 2, 0); if (newPoint.equals(endPoint)) { // nothing to do } else if (pointCount > 1 && Geom.lineContainsPoint(newPoint.x, newPoint.y, secondLastPoint.x, secondLastPoint.y, endPoint.x, endPoint.y, 0.9f / getView().getScaleFactor())) { createdFigure.setPoint(pointCount - 1, 0, newPoint); } else { createdFigure.addNode(new BezierPath.Node(newPoint)); } } createdFigure.changed(); }