use of com.ait.lienzo.client.core.types.Point2DArray 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.Point2DArray in project lienzo-core by ahome-it.
the class Parallelogram method parse.
private boolean parse(final Attributes attr) {
final double wide = attr.getWidth();
final double high = attr.getHeight();
if ((wide > 0) && (high > 0)) {
final double skew = attr.getSkew();
final Point2DArray list = new Point2DArray();
if (skew >= 0) {
list.push(skew, 0);
list.push(wide, 0);
list.push(wide - skew, high);
list.push(0, high);
} else {
list.push(0, 0);
list.push(wide - Math.abs(skew), 0);
list.push(wide, high);
list.push(Math.abs(skew), high);
}
final Point2D p0 = list.get(0);
m_list.M(p0);
final double corner = getCornerRadius();
if (corner <= 0) {
final int size = list.size();
for (int i = 1; i < size; i++) {
m_list.L(list.get(i));
}
m_list.Z();
} else {
Geometry.drawArcJoinedLines(m_list, list.push(p0), corner);
}
return true;
}
return false;
}
use of com.ait.lienzo.client.core.types.Point2DArray in project lienzo-core by ahome-it.
the class Polygon method parse.
private boolean parse(final Attributes attr) {
Point2DArray list = attr.getPoints();
if (null != list) {
list = list.noAdjacentPoints();
final int size = list.size();
if (size > 1) {
final Point2D point = list.get(0);
m_list.M(point);
final double corner = getCornerRadius();
if (corner <= 0) {
for (int i = 1; i < size; i++) {
m_list.L(list.get(i));
}
m_list.Z();
} else {
Geometry.drawArcJoinedLines(m_list, list.push(point), corner);
}
return true;
}
}
return false;
}
use of com.ait.lienzo.client.core.types.Point2DArray in project lienzo-core by ahome-it.
the class QuadraticCurve method prepare.
/**
* Draws this quadratic curve
*
* @param context
*/
@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha) {
final Point2DArray points = attr.getControlPoints();
if ((points != null) && (points.size() == 3)) {
context.beginPath();
final Point2D p0 = points.get(0);
final Point2D p1 = points.get(1);
final Point2D p2 = points.get(2);
context.moveTo(p0.getX(), p0.getY());
context.quadraticCurveTo(p1.getX(), p1.getY(), p2.getX(), p2.getY());
return true;
}
return false;
}
use of com.ait.lienzo.client.core.types.Point2DArray in project lienzo-core by ahome-it.
the class RegularPolygon method parse.
private boolean parse(final Attributes attr) {
final int sides = attr.getSides();
final double radius = attr.getRadius();
if ((sides > 2) && (radius > 0)) {
m_list.M(0, 0 - radius);
final double corner = getCornerRadius();
if (corner <= 0) {
for (int n = 1; n < sides; n++) {
final double theta = ((n * 2 * Math.PI) / sides);
m_list.L(radius * Math.sin(theta), -1 * radius * Math.cos(theta));
}
m_list.Z();
} else {
final Point2DArray list = new Point2DArray(0, 0 - radius);
for (int n = 1; n < sides; n++) {
final double theta = ((n * 2 * Math.PI) / sides);
list.push(radius * Math.sin(theta), -1 * radius * Math.cos(theta));
}
Geometry.drawArcJoinedLines(m_list, list.push(0, 0 - radius), corner);
}
return true;
}
return false;
}
Aggregations