Search in sources :

Example 6 with PathPartList

use of com.ait.lienzo.client.core.types.PathPartList in project lienzo-core by ahome-it.

the class PolyLine method parse.

@Override
public boolean parse(final Attributes attr) {
    Point2DArray list = attr.getPoints();
    if (null != list) {
        list = list.noAdjacentPoints();
        final int size = list.size();
        if (size > 1) {
            final PathPartList path = getPathPartList();
            path.M(list.get(0));
            final double corner = getCornerRadius();
            if (corner <= 0) {
                for (int i = 1; i < size; i++) {
                    path.L(list.get(i));
                }
            } else {
                Geometry.drawArcJoinedLines(path, list, corner);
            }
            return true;
        }
    }
    return false;
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) PathPartList(com.ait.lienzo.client.core.types.PathPartList)

Example 7 with PathPartList

use of com.ait.lienzo.client.core.types.PathPartList 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)

Example 8 with PathPartList

use of com.ait.lienzo.client.core.types.PathPartList in project lienzo-core by ahome-it.

the class AbstractMultiPathPartShape method prepare.

@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha) {
    final double radius = getCornerRadius();
    if (radius != 0) {
        m_cornerPoints = new NFastArrayList<>();
        for (int i = 0; i < m_points.size(); i++) {
            final PathPartList baseList = m_points.get(i);
            final Point2DArray basePoints = baseList.getPoints();
            final PathPartList cornerList = new PathPartList();
            Geometry.drawArcJoinedLines(cornerList, baseList, basePoints, radius);
            m_cornerPoints.add(cornerList);
        }
    }
    if (false == validSizeConstraints()) {
        throw new IllegalArgumentException("Constraints are either smaller or larger than size.");
    }
    return true;
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) PathPartList(com.ait.lienzo.client.core.types.PathPartList)

Example 9 with PathPartList

use of com.ait.lienzo.client.core.types.PathPartList in project lienzo-core by ahome-it.

the class AbstractMultiPathPartShape method drawWithoutTransforms.

@Override
protected void drawWithoutTransforms(final Context2D context, double alpha, final BoundingBox bounds) {
    final Attributes attr = getAttributes();
    alpha = alpha * attr.getAlpha();
    if (alpha <= 0) {
        return;
    }
    if (prepare(context, attr, alpha)) {
        NFastArrayList<PathPartList> points = m_points;
        if (getCornerRadius() > 0) {
            points = m_cornerPoints;
        }
        final int size = points.size();
        if (size < 1) {
            return;
        }
        for (int i = 0; i < size; i++) {
            setAppliedShadow(false);
            final PathPartList list = points.get(i);
            if (list.size() > 1) {
                boolean fill = false;
                if (context.path(list)) {
                    fill = fill(context, attr, alpha);
                }
                stroke(context, attr, alpha, fill);
            }
        }
    }
}
Also used : PathPartList(com.ait.lienzo.client.core.types.PathPartList)

Example 10 with PathPartList

use of com.ait.lienzo.client.core.types.PathPartList in project lienzo-core by ahome-it.

the class AbstractMultiPathPartShape method getBoundingBox.

@Override
public BoundingBox getBoundingBox() {
    NFastArrayList<PathPartList> points = m_points;
    if (getCornerRadius() > 0) {
        points = m_cornerPoints;
    }
    final int size = points.size();
    if (size < 1) {
        return new BoundingBox(0, 0, 0, 0);
    }
    final BoundingBox bbox = new BoundingBox();
    for (int i = 0; i < size; i++) {
        bbox.add(points.get(i).getBoundingBox());
    }
    return bbox;
}
Also used : BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) PathPartList(com.ait.lienzo.client.core.types.PathPartList)

Aggregations

PathPartList (com.ait.lienzo.client.core.types.PathPartList)10 Point2D (com.ait.lienzo.client.core.types.Point2D)3 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)3 NFastDoubleArrayJSO (com.ait.tooling.nativetools.client.collection.NFastDoubleArrayJSO)3 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)2 PathPartEntryJSO (com.ait.lienzo.client.core.types.PathPartEntryJSO)2 Context2D (com.ait.lienzo.client.core.Context2D)1 Attributes (com.ait.lienzo.client.core.shape.Attributes)1 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)1 PickerPart (com.ait.lienzo.client.core.shape.wires.PickerPart)1 ImageData (com.ait.lienzo.client.core.types.ImageData)1 ScratchPad (com.ait.lienzo.client.core.util.ScratchPad)1 Direction (com.ait.lienzo.shared.core.types.Direction)1 NFastStringMap (com.ait.tooling.nativetools.client.collection.NFastStringMap)1 JSONArray (com.google.gwt.json.client.JSONArray)1 JSONObject (com.google.gwt.json.client.JSONObject)1 Test (org.junit.Test)1