Package com.emitrom.lienzo.client.core.types

Examples of com.emitrom.lienzo.client.core.types.Point2DArray


     */
    public Line(double x1, double y1, double x2, double y2)
    {
        super(ShapeType.LINE);

        setPoints(new Point2DArray(new Point2D(x1, y1), new Point2D(x2, y2)));
    }
View Full Code Here


     * @param context
     */
    @Override
    public boolean prepare(Context2D context, Attributes attr, double alpha)
    {
        Point2DArray list = getPoints();

        if ((null != list) && (list.getLength() == 2))
        {
            if (attr.isDefined(Attribute.DASH_ARRAY))
            {
                if (false == LienzoGlobals.getInstance().isNativeLineDashSupported())
                {
                    DashArray dash = getDashArray();

                    if (dash != null)
                    {
                        double[] data = dash.getNormalizedArray();

                        if (data.length > 0)
                        {
                            if (setStrokeParams(context, attr, alpha))
                            {
                                Point2D p0 = list.getPoint(0);

                                Point2D p1 = list.getPoint(1);

                                context.beginPath();

                                drawDashedLine(context, p0.getX(), p0.getY(), p1.getX(), p1.getY(), data, attr.getStrokeWidth() / 2);
                            }
                            return true;
                        }
                    }
                }
            }
            Point2D point = list.getPoint(0);

            context.beginPath();

            context.moveTo(point.getX(), point.getY());

            point = list.getPoint(1);

            context.lineTo(point.getX(), point.getY());

            return true;
        }
View Full Code Here

     */
    public BezierCurve(double x, double y, double controlX1, double controlY1, double controlX2, double controlY2, double endX, double endY)
    {
        super(ShapeType.BEZIER_CURVE);

        setControlPoints(new Point2DArray(new Point2D(x, y), new Point2D(controlX1, controlY1), new Point2D(controlX2, controlY2), new Point2D(endX, endY)));
    }
View Full Code Here

     * @param context the {@link Context2D} used to draw this bezier curve.
     */
    @Override
    public boolean prepare(Context2D context, Attributes attr, double alpha)
    {
        Point2DArray points = getControlPoints();

        if ((points != null) && (points.getLength() == 4))
        {
            context.beginPath();

            Point2D p0 = points.getPoint(0);

            Point2D p1 = points.getPoint(1);

            Point2D p2 = points.getPoint(2);

            Point2D p3 = points.getPoint(3);

            context.moveTo(p0.getX(), p0.getY());

            context.bezierCurveTo(p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY());

View Full Code Here

     * @param context
     */
    @Override
    public boolean prepare(Context2D context, Attributes attr, double alpha)
    {
        Point2DArray list = getPoints();

        if ((null != list) && (list.getLength() >= 2))
        {
            final int leng = list.getLength();

            Point2D point = list.getPoint(0);

            context.beginPath();

            context.moveTo(point.getX(), point.getY());

            for (int i = 1; i < leng; i++)
            {
                point = list.getPoint(i);

                context.lineTo(point.getX(), point.getY());
            }
            return true;
        }
View Full Code Here

     */
    public Arrow(Point2D start, Point2D end, double baseWidth, double headWidth, double arrowAngle, double baseAngle, ArrowType arrowType)
    {
        super(ShapeType.ARROW);

        setPoints(new Point2DArray(start, end));

        setBaseWidth(baseWidth);

        setHeadWidth(headWidth);

View Full Code Here

     * @param context the {@link Context2D} used to draw this arrow.
     */
    @Override
    public boolean prepare(Context2D context, Attributes attr, double alpha)
    {
        Point2DArray list = getPolygon(); // is null for invalid arrow definition

        if ((null != list) && (list.getLength() > 2))
        {
            Point2D point = list.getPoint(0);

            context.beginPath();

            context.moveTo(point.getX(), point.getY());

            final int leng = list.getLength();

            for (int i = 1; i < leng; i++)
            {
                point = list.getPoint(i);

                context.lineTo(point.getX(), point.getY());
            }
            context.closePath();

View Full Code Here

         * dx ->
         */

        if (m_polygon == null)
        {
            Point2DArray arr = new Point2DArray();
            try
            {
                ArrowType type = getArrowType();
                double a = Geometry.toRadians(getArrowAngle());
                double sina = Math.sin(a);
                double cosa = Math.cos(a);
                // NOTE: b is not the base angle here, it's the corner EAB
                // i.e. going from E to A to B, where B is point[2] and A is the
                // intersection of the midline (thru S and E)
                // and the line thru point [1] and [2].
                double b_degrees = 180 - getBaseAngle() - getArrowAngle();
                double b = Geometry.toRadians(b_degrees);
                double sinb = Math.sin(b);
                double cosb = Math.cos(b);
                double w = getBaseWidth();
                double aw = getHeadWidth();

                Point2D s = getStart(); // arr.getPoint(0);
                Point2D e = getEnd(); // arr.getPoint(1);
                Point2D dv = e.minus(s);
                Point2D dx = dv.unit(); // unit vector in the direction of SE
                Point2D dy = dx.perpendicular();

                if (type == ArrowType.AT_END || type == ArrowType.AT_END_TAPERED || type == ArrowType.AT_BOTH_ENDS)
                {
                    // cosa*r
                    //
                    // S----+---E
                    // | a/ sina*r=aw/2
                    // sina*r | / r
                    // |/
                    // 2
                    //
                    double r = aw / (2 * sina);
                    double z = r * cosa;
                    Point2D p2 = e.minus(dx.times(z)).minus(dy.times(aw / 2));
                    Point2D p4 = e.minus(dx.times(z)).plus(dy.times(aw / 2));

                    // cosb*r2
                    //
                    // 1---+
                    // \b |
                    // \ | sinb*r2=(aw-w)/2
                    // r2 \|
                    // 2
                    //

                    Point2D p1 = p2.plus(dy.times((aw - w) / 2));
                    Point2D p5 = p4.minus(dy.times((aw - w) / 2));
                    if (b_degrees != 90)
                    {
                        double r2 = (aw - w) / (2 * sinb);
                        Point2D d1 = dx.times(r2 * cosb);
                        p1 = p1.minus(d1);
                        p5 = p5.minus(d1);
                    }

                    arr.push(p1);
                    arr.push(p2);
                    arr.push(e);
                    arr.push(p4);
                    arr.push(p5);
                }
                else if (type == ArrowType.AT_START)
                {
                    Point2D q0 = e.plus(dy.times(-w / 2));
                    Point2D q6 = e.plus(dy.times(w / 2));
                    arr.push(q0);
                    arr.push(q6);
                }
                else
                // ArrowType.AT_START_TAPERED
                {
                    arr.push(e);
                }

                if (type == ArrowType.AT_START || type == ArrowType.AT_START_TAPERED || type == ArrowType.AT_BOTH_ENDS)
                {
                    // cosa*r
                    //
                    // S----+---E
                    // | a/ sina*r=aw/2
                    // sina*r | / r
                    // |/
                    // 2
                    //
                    double r = aw / (2 * sina);
                    double z = r * cosa;
                    Point2D q2 = s.plus(dx.times(z)).minus(dy.times(aw / 2));
                    Point2D q4 = s.plus(dx.times(z)).plus(dy.times(aw / 2));

                    // cosb*r2
                    //
                    // 1---+
                    // \b |
                    // \ | sinb*r2=(aw-w)/2
                    // r2 \|
                    // 2
                    //

                    Point2D q1 = q2.plus(dy.times((aw - w) / 2));
                    Point2D q5 = q4.minus(dy.times((aw - w) / 2));
                    if (b_degrees != 90)
                    {
                        double r2 = (aw - w) / (2 * sinb);
                        Point2D d1 = dx.times(r2 * cosb);
                        q1 = q1.plus(d1);
                        q5 = q5.plus(d1);
                    }

                    arr.push(q5);
                    arr.push(q4);
                    arr.push(s);
                    arr.push(q2);
                    arr.push(q1);
                }
                else if (type == ArrowType.AT_END)
                {
                    Point2D p0 = s.plus(dy.times(-w / 2));
                    Point2D p6 = s.plus(dy.times(w / 2));

                    arr.push(p6);
                    arr.push(p0);
                }
                else
                // ArrowType.AT_END_TAPERED
                {
                    arr.push(s);
                }
            }
            catch (GeometryException e)
            {
                // This can happen e.g. when S and E are the same point.
View Full Code Here

                if (n2 * size > max)
                {
                    n2--;
                }
                Point2DArray points = line.getPoints();

                Point2D p1 = points.getPoint(0);

                Point2D p2 = points.getPoint(1);

                if (vertical)
                {
                    p1.setY(y1);

View Full Code Here

     * @param context
     */
    @Override
    public boolean prepare(Context2D context, Attributes attr, double alpha)
    {
        Point2DArray list = getPoints();

        if ((null != list) && (list.getLength() > 2))
        {
            Point2D point = list.getPoint(0);

            context.beginPath();

            context.moveTo(point.getX(), point.getY());

            final int leng = list.getLength();

            for (int i = 1; i < leng; i++)
            {
                point = list.getPoint(i);

                context.lineTo(point.getX(), point.getY());
            }
            context.closePath();

View Full Code Here

TOP

Related Classes of com.emitrom.lienzo.client.core.types.Point2DArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.