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;
}
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;
}
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;
}
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);
}
}
}
}
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;
}
Aggregations