use of com.ait.lienzo.shared.core.types.Direction in project lienzo-core by ahome-it.
the class OrthogonalPolyLine method drawOrthogonalLinePoints.
private static final NFastDoubleArrayJSO drawOrthogonalLinePoints(final Point2DArray points, final Direction headDirection, final Direction tailDirection, final double correction, final OrthogonalPolyLine pline, final double breakDistance, final boolean write) {
final NFastDoubleArrayJSO buffer = NFastDoubleArrayJSO.make();
Point2D p0 = points.get(0);
p0 = correctP0(headDirection, correction, pline, write, buffer, p0);
Direction direction = headDirection;
final int size = points.size();
Point2D p1;
Point2D p2;
for (int i = 1; i < (size - 1); i++) {
p1 = points.get(i);
p2 = points.get(i + 1);
direction = drawOrthogonalLineSegment(buffer, direction, null, p0.getX(), p0.getY(), p1.getX(), p1.getY(), p2.getX(), p2.getY(), write);
if (null == direction) {
return null;
}
p0 = p1;
}
p1 = points.get(size - 1);
drawTail(points, buffer, direction, tailDirection, p0, p1, correction, pline);
return buffer;
}
use of com.ait.lienzo.shared.core.types.Direction 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;
}
Aggregations