Search in sources :

Example 1 with Point3

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

the class Area method configureAreaForElement.

/**
 * Select the general size and position of the shape.
 * This is done according to:
 *   - The style,
 *   - Eventually the element specific size attribute,
 *   - Eventually the element contents (decor).
 */
public void configureAreaForElement(Backend backend, DefaultCamera2D camera, AreaSkeleton skel, GraphicElement element, ShapeDecor decor) {
    Point3 pos = camera.getNodeOrSpritePositionGU(element, null);
    if (fit) {
        Tuple<Double, Double> decorSize = decor.size(backend, camera, skel.iconAndText);
        if (decorSize.val1 == 0 || decorSize.val2 == 0)
            sizeForElement(element.getStyle(), camera, element);
        positionAndFit(camera, skel, element, pos.x, pos.y, decorSize.val1, decorSize.val2);
    } else {
        sizeForElement(element.getStyle(), camera, element);
        positionAndFit(camera, skel, element, pos.x, pos.y, 0, 0);
    }
}
Also used : Point3(org.graphstream.ui.geom.Point3)

Example 2 with Point3

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

the class Tuple method renderGu2Px.

/* We choose here to replace the transform (GU->PX) into a the identity to draw
	 * The text and icon. Is this the best way ? Maybe should we merely scale the 
	 * font size to render the text at the correct size ? How to handle the icon in
	 * this case ? 
	 */
protected void renderGu2Px(Backend backend, DefaultCamera2D camera, IconAndText iconAndText, double x, double y, double angle, FunctionIn<Backend, Point3, IconAndText, Double, Point3> positionPx) {
    GraphicsContext g = backend.graphics2D();
    Point3 p = camera.transformGuToPx(x, y, 0);
    Affine Tx = g.getTransform();
    g.setTransform(new Affine());
    p = positionPx.apply(backend, p, iconAndText, angle);
    iconAndText.render(backend, camera, p.x, p.y);
    g.setTransform(Tx);
}
Also used : Point3(org.graphstream.ui.geom.Point3) GraphicsContext(javafx.scene.canvas.GraphicsContext) Affine(javafx.scene.transform.Affine)

Example 3 with Point3

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

the class FxGraphRenderer method moveElementAtPx.

public void moveElementAtPx(GraphicElement element, double x, double y) {
    Point3 p = camera.transformPxToGu(x, y);
    element.move(p.x, p.y, element.getZ());
}
Also used : Point3(org.graphstream.ui.geom.Point3)

Example 4 with Point3

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

the class ConnectorSkeleton method segmentsLengths.

/**
 * Compute the length of each segment between the points making up this edge. This is mostly
 * only useful for polylines. The results of this method is cached. It is only recomputed when
 * a points changes in the shape. There are size-1 segments if the are size points. The segment
 * 0 is between points 0 and 1.
 */
public double[] segmentsLengths() {
    if (lengths == null) {
        if (isPoly()) {
            int n = points.size();
            lengthsSum = 0;
            if (n > 0) {
                lengths = new double[points.size() - 1];
                Point3 prev = points.get(0);
                Point3 next = null;
                for (int i = 1; i < n; i++) {
                    next = points.get(i);
                    lengths[i - 1] = next.distance(prev);
                    lengthsSum += lengths[i - 1];
                    prev = next;
                }
            } else {
                lengths = new double[0];
            }
        } else if (isCurve()) {
            throw new RuntimeException("segmentsLengths for curve ....");
        } else {
            lengths = new double[1];
            lengths[0] = points.get(0).distance(points.get(3));
            lengthsSum = lengths[0];
        }
    }
    return lengths;
}
Also used : Point3(org.graphstream.ui.geom.Point3)

Example 5 with Point3

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

the class ConnectorSkeleton method setPoly.

public void setPoly(Object aSetOfPoints) {
    if (!kind.equals(EdgeShapeKind.POLYLINE)) {
        kind = EdgeShapeKind.POLYLINE;
        Point3[] thePoints = getPoints(aSetOfPoints);
        points = new EdgePoints(thePoints.length);
        points.copy(thePoints);
        lengths = null;
    }
}
Also used : Point3(org.graphstream.ui.geom.Point3) EdgePoints(org.graphstream.ui.javafx.util.EdgePoints)

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