Search in sources :

Example 21 with Point3

use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.

the class ConnectorSkeleton method setLine.

public void setLine(double x0, double y0, double z0, double x1, double y1, double z1) {
    kind = EdgeShapeKind.LINE;
    if (points.size() != 2)
        points = new EdgePoints(2);
    points.update(0, new Point3(x0, y0, z0));
    points.update(1, new Point3(x1, y1, z1));
}
Also used : Point3(org.graphstream.ui.geom.Point3) EdgePoints(org.graphstream.ui.javafx.util.EdgePoints)

Example 22 with Point3

use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.

the class ShowCubics method showCtrlPoints.

/**
 * Show the control polygons.
 */
public void showCtrlPoints(GraphicsContext g, Camera camera, ConnectorSkeleton skel) {
    if (showControlPolygon && skel.isCurve()) {
        Point3 from = skel.from();
        Point3 ctrl1 = skel.apply(1);
        Point3 ctrl2 = skel.apply(2);
        Point3 to = skel.to();
        Paint colorStroke = g.getStroke();
        Paint colorFill = g.getFill();
        double stroke = g.getLineWidth();
        double px6 = camera.getMetrics().px1 * 6;
        double px3 = camera.getMetrics().px1 * 3;
        g.setStroke(Color.RED);
        g.setFill(Color.RED);
        g.fillOval(from.x - px3, from.y - px3, px6, px6);
        if (ctrl1 != null) {
            g.fillOval(ctrl1.x - px3, ctrl1.y - px3, px6, px6);
            g.fillOval(ctrl2.x - px3, ctrl2.y - px3, px6, px6);
            g.setLineWidth(camera.getMetrics().px1);
            g.strokeLine(ctrl1.x, ctrl1.y, ctrl2.x, ctrl2.y);
            g.strokeLine(from.x, from.y, ctrl1.x, ctrl1.y);
            g.strokeLine(ctrl2.x, ctrl2.y, to.x, to.y);
        }
        g.fillOval(to.x - px3, to.y - px3, px6, px6);
        g.setStroke(colorStroke);
        g.setFill(colorFill);
        g.setLineWidth(stroke);
    }
}
Also used : Point3(org.graphstream.ui.geom.Point3) Paint(javafx.scene.paint.Paint)

Example 23 with Point3

use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.

the class LSquareEdgeShape method makeSingle.

private void makeSingle(DefaultCamera2D camera, double sox, double soy, double swx, double swy) {
    Point3 from = new Point3(skel.from().x + sox, skel.from().y + soy, 0);
    Point3 to = new Point3(skel.to().x + sox, skel.to().y + soy, 0);
    Vector2 mainDir = new Vector2(from, to);
    double length = mainDir.length();
    double angle = mainDir.y() / length;
    Point3 inter = null;
    if (angle > 0.707107f || angle < -0.707107f) {
        // North or south.
        inter = new Point3(from.x, to.y, 0);
    } else {
        // East or west.
        inter = new Point3(to.x, from.y, 0);
    }
    if (sox == 0 && soy == 0) {
        Point3[] pts = { from, inter, to };
        skel.setPoly(pts);
    }
    theShape = new Path2D(5, false);
    theShape.moveTo(from.x, from.y);
    theShape.lineTo(inter.x, inter.y);
    theShape.lineTo(to.x, to.y);
}
Also used : Point3(org.graphstream.ui.geom.Point3) Vector2(org.graphstream.ui.geom.Vector2) Path2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)

Example 24 with Point3

use of org.graphstream.ui.geom.Point3 in project gs-ui-javafx by graphstream.

the class LineShape method make.

@Override
public void make(Backend backend, DefaultCamera2D camera) {
    Point3 from = skel.from();
    Point3 to = skel.to();
    if (skel.isCurve()) {
        Point3 ctrl1 = skel.apply(1);
        Point3 ctrl2 = skel.apply(2);
        theShapeC = new CubicCurve2D(from.x, from.y, ctrl1.x, ctrl1.y, ctrl2.x, ctrl2.y, to.x, to.y);
        theShape = theShapeC;
    } else {
        theShapeL = new Line2D(from.x, from.y, to.x, to.y);
        theShape = theShapeL;
    }
}
Also used : Point3(org.graphstream.ui.geom.Point3) CubicCurve2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.CubicCurve2D) Line2D(org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Line2D)

Example 25 with Point3

use of org.graphstream.ui.geom.Point3 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

Point3 (org.graphstream.ui.geom.Point3)28 Vector2 (org.graphstream.ui.geom.Vector2)6 Path2D (org.graphstream.ui.javafx.renderer.shape.javafx.baseShapes.Form.Path2D)4 EdgePoints (org.graphstream.ui.javafx.util.EdgePoints)4 Point2 (org.graphstream.ui.geom.Point2)3 Style (org.graphstream.ui.graphicGraph.stylesheet.Style)3 AreaSkeleton (org.graphstream.ui.javafx.renderer.AreaSkeleton)3 Point2D (javafx.geometry.Point2D)2 Node (org.graphstream.graph.Node)2 FxDefaultView (org.graphstream.ui.fx_viewer.FxDefaultView)2 FxViewer (org.graphstream.ui.fx_viewer.FxViewer)2 GraphicNode (org.graphstream.ui.graphicGraph.GraphicNode)2 FxGraphRenderer (org.graphstream.ui.javafx.FxGraphRenderer)2 Tuple (org.graphstream.ui.javafx.util.AttributeUtils.Tuple)2 Viewer (org.graphstream.ui.view.Viewer)2 ViewerPipe (org.graphstream.ui.view.ViewerPipe)2 Random (java.util.Random)1 Scene (javafx.scene.Scene)1 GraphicsContext (javafx.scene.canvas.GraphicsContext)1 Paint (javafx.scene.paint.Paint)1