Package org.antlr.xjlib.appkit.gview.base

Examples of org.antlr.xjlib.appkit.gview.base.Vector2D


        else
            buildHorizontalLeftPath(true);
    }

    public void buildVerticalPath() {
        Vector2D start_ = link.getStartWithOffset();
        Vector2D end_ = link.getEndWithOffset();

        if(link.start.x > link.end.x+link.outOffsetLength && link.startDirection == Anchor2D.DIRECTION_LEFT) {
            path.add(link.start);
            path.add(link.end.x, link.start.y);
            path.add(link.end);

            link.label.setPosition(link.end.x+(link.start.x-link.end.x)*0.5, link.start.y-LABEL_OFFSET);
        } else if(link.start.x < link.end.x-link.outOffsetLength && link.startDirection == Anchor2D.DIRECTION_RIGHT) {
            path.add(link.start);
            path.add(link.end.x, link.start.y);
            path.add(link.end);

            link.label.setPosition(link.end.x+(link.start.x-link.end.x)*0.5, link.start.y-LABEL_OFFSET);
        } else if(link.start.y-GElementRect.DEFAULT_HEIGHT*0.5<end_.y+10) {

            Vector2D p1 = new Vector2D(link.end.x, link.start.y+GElementRect.DEFAULT_HEIGHT*0.5+10);
            Vector2D p2 = new Vector2D(start_.x, p1.y);

            path.add(link.start);
            path.add(start_);
            path.add(p2);
            path.add(p1);
            path.add(link.end);

            link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, LABEL_OFFSET));
        } else {
            Vector2D ab = start_.sub(link.end);
            Vector2D p1 = new Vector2D(link.end.x, link.end.y+ab.y*0.5);
            Vector2D p2 = new Vector2D(p1.x+ab.x, p1.y);
            Vector2D p3 = new Vector2D(p2.x, start_.y);

            path.add(link.start);
            path.add(start_);
            path.add(p3);
            path.add(p2);
View Full Code Here


            link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, -LABEL_OFFSET));
        }
    }

    public void buildHorizontalPath() {
        Vector2D start_ = link.getStartWithOffset();
        Vector2D end_ = link.getEndWithOffset();

        Vector2D ab = link.start.sub(end_);
        Vector2D p1 = new Vector2D(end_.x+ab.x*0.5, end_.y);
        Vector2D p2 = new Vector2D(p1.x, start_.y);

        path.add(link.start);
        path.add(start_);
        path.add(p2);
        path.add(p1);
        path.add(end_);
        path.add(link.end);

        link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
    }
View Full Code Here

        link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
    }

    public void buildHorizontalLeftPath(boolean left) {
        Vector2D start_ = link.getStartWithOffset();
        Vector2D end_ = link.getEndWithOffset();

        double farest_x;
        double farest_y = Math.max(end_.y, start_.y+GElementRect.DEFAULT_HEIGHT*0.5+10);

        if(left)
            farest_x = Math.min(end_.x-GElementRect.DEFAULT_WIDTH*0.5-10, start_.x);
        else
            farest_x = Math.max(end_.x+GElementRect.DEFAULT_WIDTH*0.5+10, start_.x);
       
        Vector2D p1 = new Vector2D(end_.x, farest_y);
        Vector2D p2 = new Vector2D(farest_x, p1.y);
        Vector2D p3 = new Vector2D(p2.x, start_.y);

        path.add(link.start);
        path.add(p3);
        path.add(p2);
        path.add(p1);
View Full Code Here

    public void setMouse(Vector2D mouse) {
        setDirection(mouse.sub(end));
    }

    public void setFlatenessByMouse(Vector2D mouse) {
        Vector2D corde = getEndWithOffset().sub(getStartWithOffset());
        double dot = mouse.sub(getStartWithOffset()).dot(corde.normalize());
        corde.setLength(dot);

        Vector2D z = getStartWithOffset().add(corde);
        Vector2D f = mouse.sub(z);
        double cross = corde.cross(f);
        if(cross == 0)
            setFlateness(0);
        else
            setFlateness(-2*f.length()*cross/Math.abs(cross));
    }
View Full Code Here

        if(selfLoop) {
            if(cubic == null)
                cubic = new CubicCurve2D.Double();

            Vector2D corde = direction.copy();
            corde.stretch(1.7);
            if(corde.length()<100)
                corde.setLength(100);

            corde.rotate(-40);
            cubic.ctrlx1 = getStartWithOffset().getX()+corde.getX();
            cubic.ctrly1 = getStartWithOffset().getY()+corde.getY();

            corde.rotate(+80);
            cubic.ctrlx2 = getStartWithOffset().getX()+corde.getX();
            cubic.ctrly2 = getStartWithOffset().getY()+corde.getY();

            // Move the start/end point according to offset

            Vector2D v1 = new Vector2D(cubic.ctrlx1, cubic.ctrly1).sub(getStartWithOffset());
            Vector2D v2 = new Vector2D(cubic.ctrlx2, cubic.ctrly2).sub(getStartWithOffset());

            v1 = v1.normalize();
            v1.stretch(startTangentOffset);

            v2 = v2.normalize();
            v2.stretch(endTangentOffset);

            cubic.x1 = getStartWithOffset().getX()+v1.getX();
            cubic.y1 = getStartWithOffset().getY()+v1.getY();
            cubic.x2 = getEndWithOffset().getX()+v2.getX();
            cubic.y2 = getEndWithOffset().getY()+v2.getY();

            // Position of the label

            Vector2D vlabel = direction.copy();
            vlabel.setLength(vlabel.length()+15);
            if(vlabel.length()<75)
                vlabel.setLength(75);

            Vector2D plabel = getStartWithOffset().add(vlabel);
            label.setPosition(plabel);

            // Create the arrow at the end of the path

            arrow.setAnchor(cubic.x2, cubic.y2);
            arrow.setDirection(new Vector2D(cubic.ctrlx2-cubic.x2, cubic.ctrly2-cubic.y2));

            shape = cubic;
        } else {
            Vector2D middle = getEndWithOffset().sub(getStartWithOffset());
            middle.stretch(0.5);

            Vector2D height = middle.normalize();
            height.rotate(-90);

            if(flateness == 0)
                height.setLength(0.01);
            else
                height.setLength(flateness);

            Vector2D ctrl = middle.add(height);

            if(quad == null)
                quad = new QuadCurve2D.Double();

            quad.x1 = getStartWithOffset().getX();
            quad.y1 = getStartWithOffset().getY();
            quad.x2 = getEndWithOffset().getX();
            quad.y2 = getEndWithOffset().getY();
            quad.ctrlx = getStartWithOffset().getX()+ctrl.getX();
            quad.ctrly = getStartWithOffset().getY()+ctrl.getY();

            Vector2D controlPoint = new Vector2D(quad.ctrlx, quad.ctrly);

            // Move the start/end point according to offset

            Vector2D v1 = controlPoint.sub(getStartWithOffset());
            Vector2D v2 = controlPoint.sub(getEndWithOffset());

            v1 = v1.normalize();
            v1.stretch(startTangentOffset);

            v2 = v2.normalize();
            v2.stretch(endTangentOffset);

            quad.x1 = getStartWithOffset().getX()+v1.getX();
            quad.y1 = getStartWithOffset().getY()+v1.getY();
            quad.x2 = getEndWithOffset().getX()+v2.getX();
            quad.y2 = getEndWithOffset().getY()+v2.getY();

            // Position of the label

            pmiddle = new Vector2D(quad.x1+(quad.x2-quad.x1)*0.5, quad.y1+(quad.y2-quad.y1)*0.5);
            vlabel = new Vector2D(quad.x2-quad.x1, quad.y2-quad.y1).rotate(90*(flateness<0?1:-1));

            vlabel.setLength(Math.abs(flateness)*0.5+20);
            label.setPosition(pmiddle.add(vlabel));

            // Create the arrow at the end of the path
View Full Code Here

        dragging = false;
    }

    public void mouseDragged(MouseEvent e, Point mousePosition) {
        if(dragElement != null) {
            Vector2D mouse = Vector2D.vector(mousePosition);
            Vector2D position = mouse.sub(dragElementOffset);

            view.showAndAjustPositionToMagnetics(position);
            dragElement.moveToPosition(position);

            delegate.eventChangeDone();
View Full Code Here

        else
            buildHorizontalLeftPath(true);
    }

    public void buildVerticalPath() {
        Vector2D start_ = link.getStartWithOffset();
        Vector2D end_ = link.getEndWithOffset();

        if(link.end.x > link.start.x+link.outOffsetLength && link.endDirection == Anchor2D.DIRECTION_LEFT) {
            path.add(link.start);
            path.add(link.start.x, link.end.y);
            path.add(link.end);

            link.label.setPosition(link.start.x+(link.end.x-link.start.x)*0.5, link.end.y-LABEL_OFFSET);
        } else if(link.end.x < link.start.x-link.outOffsetLength && link.endDirection == Anchor2D.DIRECTION_RIGHT) {
            path.add(link.start);
            path.add(link.start.x, link.end.y);
            path.add(link.end);

            link.label.setPosition(link.start.x+(link.end.x-link.start.x)*0.5, link.end.y-LABEL_OFFSET);
        } else if(link.end.y-GElementRect.DEFAULT_HEIGHT*0.5<start_.y+10) {

            Vector2D p1 = new Vector2D(link.start.x, link.end.y+GElementRect.DEFAULT_HEIGHT*0.5+10);
            Vector2D p2 = new Vector2D(end_.x, p1.y);

            path.add(link.start);
            path.add(p1);
            path.add(p2);
            path.add(end_);
            path.add(link.end);

            link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, LABEL_OFFSET));
        } else {
            Vector2D ab = end_.sub(link.start);
            Vector2D p1 = new Vector2D(link.start.x, link.start.y+ab.y*0.5);
            Vector2D p2 = new Vector2D(p1.x+ab.x, p1.y);
            Vector2D p3 = new Vector2D(p2.x, end_.y);

            path.add(link.start);
            path.add(p1);
            path.add(p2);
            path.add(p3);
View Full Code Here

            link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, -LABEL_OFFSET));
        }
    }

    public void buildHorizontalPath() {
        Vector2D start_ = link.getStartWithOffset();
        Vector2D end_ = link.getEndWithOffset();

        Vector2D ab = link.end.sub(start_);
        Vector2D p1 = new Vector2D(start_.x+ab.x*0.5, start_.y);
        Vector2D p2 = new Vector2D(p1.x, end_.y);

        path.add(link.start);
        path.add(start_);
        path.add(p1);
        path.add(p2);
        path.add(end_);
        path.add(link.end);

        link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
    }
View Full Code Here

        link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
    }

    public void buildHorizontalLeftPath(boolean left) {
        Vector2D start_ = link.getStartWithOffset();
        Vector2D end_ = link.getEndWithOffset();

        double farest_x;
        double farest_y = Math.max(start_.y, end_.y+GElementRect.DEFAULT_HEIGHT*0.5+10);

        if(left)
            farest_x = Math.min(start_.x-GElementRect.DEFAULT_WIDTH*0.5-10, end_.x);
        else
            farest_x = Math.max(start_.x+GElementRect.DEFAULT_WIDTH*0.5+10, end_.x);
       
        Vector2D p1 = new Vector2D(start_.x, farest_y);
        Vector2D p2 = new Vector2D(farest_x, p1.y);
        Vector2D p3 = new Vector2D(p2.x, end_.y);

        path.add(link.start);
        path.add(start_);
        path.add(p1);
        path.add(p2);
View Full Code Here

        if(delegate != null)
            delegate.smoothScrollingDidComplete();
    }

    public void computeVector() {
        v = new Vector2D(dest.x-source.x, dest.y-source.y);
    }
View Full Code Here

TOP

Related Classes of org.antlr.xjlib.appkit.gview.base.Vector2D

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.