Search in sources :

Example 1 with Path2D

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

the class FreePlaneEdgeShape 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 2 with Path2D

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

the class LSquareEdgeShape 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 3 with Path2D

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

the class LSquareEdgeShape 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 4 with Path2D

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

the class ArrowOnEdge method makeOnLine.

private void makeOnLine(boolean forShadow, DefaultCamera2D camera) {
    ConnectorSkeleton skel = theConnector.skel;
    double off = 0;
    Vector2 theDirection;
    if (skel.isPoly()) {
        off = ShapeUtil.evalTargetRadius2D(skel.apply(skel.size() - 2), skel.to(), theEdge.to, camera);
        theDirection = new Vector2(skel.to().x - skel.apply(skel.size() - 2).x, skel.to().y - skel.apply(skel.size() - 2).y);
    } else {
        off = ShapeUtil.evalTargetRadius2D(skel.from(), skel.to(), theEdge.to, camera);
        theDirection = new Vector2(skel.to().x - skel.from().x, skel.to().y - skel.from().y);
    }
    theDirection.normalize();
    double x = theCenter.x - (theDirection.x() * off);
    double y = theCenter.y - (theDirection.y() * off);
    Vector2 perp = new Vector2(theDirection.y(), -theDirection.x());
    perp.normalize();
    theDirection.scalarMult(theSize.x);
    perp.scalarMult(theSize.y);
    if (forShadow) {
        x += shadowable.theShadowOff.x;
        y += shadowable.theShadowOff.y;
    }
    // Create a polygon.
    theShape = new Path2D(5, true);
    theShape.moveTo(x, y);
    theShape.lineTo(x - theDirection.x() + perp.x(), y - theDirection.y() + perp.y());
    theShape.lineTo(x - theDirection.x() - perp.x(), y - theDirection.y() - perp.y());
    theShape.closePath();
}
Also used : Vector2(org.graphstream.ui.geom.Vector2) Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D) ConnectorSkeleton(org.graphstream.ui.javafx.renderer.ConnectorSkeleton)

Example 5 with Path2D

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

the class ArrowOnEdge method makeOnCurve.

private void makeOnCurve(boolean forShadow, DefaultCamera2D camera) {
    Tuple<Point2, Double> tuple = CubicCurve.approxIntersectionPointOnCurve(theEdge, theConnector, camera);
    Point2 p1 = tuple.x;
    double t = tuple.y;
    Style style = theEdge.getStyle();
    Point3 p2 = CubicCurve.eval(theConnector.fromPos(), theConnector.byPos1(), theConnector.byPos2(), theConnector.toPos(), t - 0.05f);
    // XXX The choice of the number above (0.05f) is problematic
    Vector2 dir = new Vector2(p1.x - p2.x, p1.y - p2.y);
    // Clearly it should be chosen according to the length
    dir.normalize();
    // of the arrow compared to the length of the curve, however
    dir.scalarMult(theSize.x);
    // computing the curve length (see CubicCurve) is costly. XXX
    Vector2 per = new Vector2(dir.y(), -dir.x());
    per.normalize();
    per.scalarMult(theSize.y);
    // Create a polygon.
    theShape = new Path2D(5, true);
    theShape.moveTo(p1.x, p1.y);
    theShape.lineTo(p1.x - dir.x() + per.x(), p1.y - dir.y() + per.y());
    theShape.lineTo(p1.x - dir.x() - per.x(), p1.y - dir.y() - per.y());
    theShape.closePath();
}
Also used : Point3(org.graphstream.ui.geom.Point3) Point2(org.graphstream.ui.geom.Point2) Vector2(org.graphstream.ui.geom.Vector2) Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D) Style(org.graphstream.ui.graphicGraph.stylesheet.Style)

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