From b81d633ce58c55634353800fd18c0ef95ec7e78e Mon Sep 17 00:00:00 2001 From: bancika Date: Sun, 16 Jan 2011 09:07:01 +0000 Subject: [PATCH] improve curve detection --- .../DIYLC/src/org/diylc/presenter/G2DWrapper.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/G2DWrapper.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/G2DWrapper.java index e7123a58..b0fcb7ed 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/G2DWrapper.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/G2DWrapper.java @@ -50,7 +50,7 @@ import java.util.Map; class G2DWrapper extends Graphics2D { public static int LINE_SENSITIVITY_MARGIN = 2; - public static int CURVE_SENSITIVITY = 10; + public static int CURVE_SENSITIVITY = 6; private boolean drawingComponent = false; @@ -189,10 +189,9 @@ class G2DWrapper extends Graphics2D { * @param curve */ private void addCubicCurveArea(CubicCurve2D curve) { - double d = curve.getP1().distance(curve.getP2()); // When end points are close enough, approximate the curve with a // straight line. - if (d < CURVE_SENSITIVITY) { + if (curve.getFlatness() < CURVE_SENSITIVITY) { appendShapeOutline(new Line2D.Double(curve.getP1(), curve.getP2())); } else { CubicCurve2D leftSubcurve = new CubicCurve2D.Double(); @@ -210,10 +209,9 @@ class G2DWrapper extends Graphics2D { * @param curve */ private void addQuadCurveArea(QuadCurve2D curve) { - double d = curve.getP1().distance(curve.getP2()); // When end points are close enough, approximate the curve with a // straight line. - if (d < CURVE_SENSITIVITY) { + if (curve.getFlatness() < CURVE_SENSITIVITY) { appendShapeOutline(new Line2D.Double(curve.getP1(), curve.getP2())); } else { QuadCurve2D leftSubcurve = new QuadCurve2D.Double();