Search in sources :

Example 6 with Path2D

use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.

the class AngleShape method makeLoop.

private void makeLoop(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
    double fromx = skel.apply(0).x + sox;
    double fromy = skel.apply(0).y + soy;
    double tox = skel.apply(3).x + sox;
    double toy = skel.apply(3).y + soy;
    double c1x = skel.apply(1).x + sox;
    double c1y = skel.apply(1).y + soy;
    double c2x = skel.apply(2).x + sox;
    double c2y = skel.apply(2).y + soy;
    Vector2 dirFrom = new Vector2(c1x - fromx, c1y - fromy);
    Vector2 dirTo = new Vector2(tox - c2x, toy - c2y);
    Vector2 mainDir = new Vector2(c2x - c1x, c2y - c1y);
    Vector2 perpFrom = new Vector2(dirFrom.y(), -dirFrom.x());
    perpFrom.normalize();
    Vector2 mid1 = new Vector2(dirFrom);
    mid1.sub(mainDir);
    mid1.normalize();
    Vector2 mid2 = new Vector2(mainDir);
    mid2.sub(dirTo);
    mid2.normalize();
    perpFrom.scalarMult(theSize * 0.5f);
    if (isDirected) {
        mid1.scalarMult(theSize * 0.8f);
        mid2.scalarMult(theSize * 0.6f);
    } else {
        mid1.scalarMult(theSize * 0.99f);
        mid2.scalarMult(theSize * 0.99f);
    }
    theShape = new Path2D(20, true);
    theShape.moveTo(fromx + perpFrom.x(), fromy + perpFrom.y());
    if (isDirected) {
        theShape.curveTo(c1x + mid1.x(), c1y + mid1.y(), c2x + mid2.x(), c2y + mid2.y(), tox, toy);
        theShape.curveTo(c2x - mid2.x(), c2y - mid2.y(), c1x - mid1.x(), c1y - mid1.y(), fromx - perpFrom.x(), fromy - perpFrom.y());
    } else {
        Vector2 perpTo = new Vector2(dirTo.y(), -dirTo.x());
        perpTo.normalize();
        perpTo.scalarMult(theSize * 0.5f);
        theShape.curveTo(c1x + mid1.x(), c1y + mid1.y(), c2x + mid2.x(), c2y + mid2.y(), tox + perpTo.x(), toy + perpTo.y());
        theShape.lineTo(tox - perpTo.x(), toy - perpTo.y());
        theShape.curveTo(c2x - mid2.x(), c2y - mid2.y(), c1x - mid1.x(), c1y - mid1.y(), fromx - perpFrom.x(), fromy - perpFrom.y());
    }
    theShape.closePath();
}
Also used : Vector2(org.graphstream.ui.geom.Vector2) Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)

Example 7 with Path2D

use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.

the class AngleShape method makeOnLine.

private void makeOnLine(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
    double fromx = skel.from().x + sox;
    double fromy = skel.from().y + soy;
    double tox = skel.to().x + sox;
    double toy = skel.to().y + soy;
    Vector2 dir = new Vector2(tox - fromx, toy - fromy);
    Vector2 perp = new Vector2(dir.y(), -dir.x());
    // 1/2 perp vector to the from point.
    perp.normalize();
    perp.scalarMult((theSize + swx) / 2f);
    theShape = new Path2D(10, true);
    theShape.moveTo(fromx + perp.x(), fromy + perp.y());
    if (isDirected) {
        theShape.lineTo(tox, toy);
    } else {
        theShape.lineTo(tox + perp.x(), toy + perp.y());
        theShape.lineTo(tox - perp.x(), toy - perp.y());
    }
    theShape.lineTo(fromx - perp.x(), fromy - perp.y());
    theShape.closePath();
}
Also used : Vector2(org.graphstream.ui.geom.Vector2) Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)

Example 8 with Path2D

use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.

the class CubicCurveShape method makeMulti.

private void makeMulti(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
    double fromx = skel.apply(0).x + sox;
    double fromy = skel.apply(0).y + soy;
    double tox = skel.apply(3).x + sox;
    double toy = skel.apply(3).y + soy;
    double c1x = skel.apply(1).x + sox;
    double c1y = skel.apply(1).y + soy;
    double c2x = skel.apply(2).x + sox;
    double c2y = skel.apply(2).y + soy;
    theShape = new Path2D(5, false);
    theShape.moveTo(fromx, fromy);
    theShape.curveTo(c1x, c1y, c2x, c2y, tox, toy);
}
Also used : Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)

Example 9 with Path2D

use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.

the class CubicCurveShape method makeLoop.

private void makeLoop(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
    double fromx = skel.apply(0).x + sox;
    double fromy = skel.apply(0).y + soy;
    double tox = skel.apply(3).x + sox;
    double toy = skel.apply(3).y + soy;
    double c1x = skel.apply(1).x + sox;
    double c1y = skel.apply(1).y + soy;
    double c2x = skel.apply(2).x + sox;
    double c2y = skel.apply(2).y + soy;
    theShape = new Path2D(5, false);
    theShape.moveTo(fromx, fromy);
    theShape.curveTo(c1x, c1y, c2x, c2y, tox, toy);
}
Also used : Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)

Example 10 with Path2D

use of org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D in project gs-ui-javafx by graphstream.

the class CubicCurveShape method makeSingle.

private void makeSingle(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
    double fromx = skel.from().x + sox;
    double fromy = skel.from().y + soy;
    double tox = skel.to().x + sox;
    double toy = skel.to().y + soy;
    Vector2 mainDir = new Vector2(skel.from(), skel.to());
    double length = mainDir.length();
    double angle = mainDir.y() / length;
    double c1x = 0.0;
    double c1y = 0.0;
    double c2x = 0.0;
    double c2y = 0.0;
    if (angle > 0.707107f || angle < -0.707107f) {
        // North or south.
        c1x = fromx + mainDir.x() / 2;
        c2x = c1x;
        c1y = fromy;
        c2y = toy;
    } else {
        // East or west.
        c1x = fromx;
        c2x = tox;
        c1y = fromy + mainDir.y() / 2;
        c2y = c1y;
    }
    theShape = new Path2D(5, false);
    theShape.moveTo(fromx, fromy);
    theShape.curveTo(c1x, c1y, c2x, c2y, tox, toy);
    if (sox == 0 && soy == 0) {
        skel.setCurve(fromx, fromy, 0, c1x, c1y, 0, c2x, c2y, 0, tox, toy, 0);
    }
}
Also used : Vector2(org.graphstream.ui.geom.Vector2) Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)

Aggregations

Path2D (org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)35 Vector2 (org.graphstream.ui.geom.Vector2)15 Point3 (org.graphstream.ui.geom.Point3)4 Point2 (org.graphstream.ui.geom.Point2)2 Style (org.graphstream.ui.graphicGraph.stylesheet.Style)2 ConnectorSkeleton (org.graphstream.ui.javafx.renderer.ConnectorSkeleton)1 Triplet (org.graphstream.ui.javafx.renderer.Skeleton.Triplet)1