Search in sources :

Example 16 with NFastDoubleArrayJSO

use of com.ait.tooling.nativetools.client.collection.NFastDoubleArrayJSO in project lienzo-core by ahome-it.

the class OrthogonalPolyLine method parse.

@Override
public boolean parse(final Attributes attr) {
    Point2DArray points = attr.getControlPoints();
    points = correctBreakDistance(points, m_breakDistance);
    if (null != points) {
        if (points.size() > 1) {
            final double headOffset = attr.getHeadOffset();
            final double correction = attr.getCorrectionOffset();
            Direction headDirection = attr.getHeadDirection();
            final Direction tailDirection = attr.getTailDirection();
            if (headDirection == NONE) {
                final Point2D p0 = points.get(0);
                final Point2D p1 = points.get(1);
                final double headOffsetAndCorrect = headOffset + correction;
                headDirection = getHeadDirection(points, null, headDirection, tailDirection, p0, p1, headOffsetAndCorrect, correction, this);
            }
            final NFastDoubleArrayJSO opoint = drawOrthogonalLinePoints(points, headDirection, tailDirection, correction, this, m_breakDistance, true);
            m_headOffsetPoint = points.get(0);
            m_tailOffsetPoint = points.get(points.size() - 1);
            if (null != opoint) {
                final PathPartList list = getPathPartList();
                list.M(m_headOffsetPoint.getX(), m_headOffsetPoint.getY());
                final double radius = getCornerRadius();
                m_computedPoint2DArray = Point2DArray.fromNFastDoubleArrayJSO(opoint);
                if (radius > 0) {
                    Geometry.drawArcJoinedLines(list, m_computedPoint2DArray, radius);
                } else {
                    final int size = opoint.size();
                    // start at 2, as M is for opoint[0]
                    for (int i = 2; i < size; i += 2) {
                        list.L(opoint.get(i), opoint.get(i + 1));
                    }
                }
                return true;
            }
        }
    }
    m_computedPoint2DArray = null;
    return false;
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) NFastDoubleArrayJSO(com.ait.tooling.nativetools.client.collection.NFastDoubleArrayJSO) Point2D(com.ait.lienzo.client.core.types.Point2D) Direction(com.ait.lienzo.shared.core.types.Direction) PathPartList(com.ait.lienzo.client.core.types.PathPartList)

Aggregations

NFastDoubleArrayJSO (com.ait.tooling.nativetools.client.collection.NFastDoubleArrayJSO)16 Point2D (com.ait.lienzo.client.core.types.Point2D)6 PathPartEntryJSO (com.ait.lienzo.client.core.types.PathPartEntryJSO)4 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)3 PathPartList (com.ait.lienzo.client.core.types.PathPartList)3 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)2 Direction (com.ait.lienzo.shared.core.types.Direction)2 Context2D (com.ait.lienzo.client.core.Context2D)1 Path2D (com.ait.lienzo.client.core.Path2D)1 ImageData (com.ait.lienzo.client.core.types.ImageData)1 ScratchPad (com.ait.lienzo.client.core.util.ScratchPad)1 NFastStringMap (com.ait.tooling.nativetools.client.collection.NFastStringMap)1