Search in sources :

Example 1 with Style

use of org.graphstream.ui.graphicGraph.stylesheet.Style 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)

Example 2 with Style

use of org.graphstream.ui.graphicGraph.stylesheet.Style in project gs-ui-javafx by graphstream.

the class CircleOnEdge 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.1f);
    Vector2 dir = new Vector2(p1.x - p2.x, p1.y - p2.y);
    dir.normalize();
    dir.scalarMult(theSize.x / 2);
    // Create a polygon.
    theShape.setFrame((p1.x - dir.x()) - (theSize.x / 2), (p1.y - dir.y()) - (theSize.y / 2), theSize.x, theSize.y);
}
Also used : Point3(org.graphstream.ui.geom.Point3) Point2(org.graphstream.ui.geom.Point2) Vector2(org.graphstream.ui.geom.Vector2) Style(org.graphstream.ui.graphicGraph.stylesheet.Style)

Example 3 with Style

use of org.graphstream.ui.graphicGraph.stylesheet.Style in project gs-ui-javafx by graphstream.

the class DiamondOnEdge 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();
    Point2 p2 = CubicCurve.eval(theConnector.fromPos(), theConnector.byPos1(), theConnector.byPos2(), theConnector.toPos(), t - 0.1f);
    Vector2 dir = new Vector2(p1.x - p2.x, p1.y - p2.y);
    dir.normalize();
    dir.scalarMult(theSize.x);
    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() / 2 + per.x(), p1.y - dir.y() / 2 + per.y());
    theShape.lineTo(p1.x - dir.x(), p1.y - dir.y());
    theShape.lineTo(p1.x - dir.x() / 2 - per.x(), p1.y - dir.y() / 2 - per.y());
    theShape.closePath();
}
Also used : 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)

Example 4 with Style

use of org.graphstream.ui.graphicGraph.stylesheet.Style in project gs-ui-javafx by graphstream.

the class ImageOnEdge 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.1f);
    Vector2 dir = new Vector2(p1.x - p2.x, p1.y - p2.y);
    dir.normalize();
    double iw = camera.getMetrics().lengthToGu(image.getWidth(), Units.PX) / 2;
    double x = p1.x - (dir.x() * iw);
    double y = p1.y - (dir.y() * iw);
    if (forShadow) {
        x += shadowable.theShadowOff.x;
        y += shadowable.theShadowOff.y;
    }
    p = camera.transformGuToPx(x, y, 0);
    angle = Math.acos(dir.dotProduct(1, 0));
    if (dir.y() > 0)
        angle = (Math.PI - angle);
}
Also used : Point3(org.graphstream.ui.geom.Point3) Point2(org.graphstream.ui.geom.Point2) Vector2(org.graphstream.ui.geom.Vector2) Style(org.graphstream.ui.graphicGraph.stylesheet.Style)

Aggregations

Point2 (org.graphstream.ui.geom.Point2)4 Vector2 (org.graphstream.ui.geom.Vector2)4 Style (org.graphstream.ui.graphicGraph.stylesheet.Style)4 Point3 (org.graphstream.ui.geom.Point3)3 Path2D (org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)2