Search in sources :

Example 6 with Point3

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

the class SpriteRenderer method renderShadow.

@Override
public void renderShadow(Backend bck, DefaultCamera2D camera, GraphicElement element) {
    GraphicSprite sprite = (GraphicSprite) element;
    Point3 pos = camera.getSpritePosition(sprite, new Point3(), StyleConstants.Units.GU);
    AreaSkeleton skel = getOrSetAreaSkeleton(element);
    shape.configureForElement(bck, element, skel, camera);
    shape.renderShadow(bck, camera, element, skel);
}
Also used : GraphicSprite(org.graphstream.ui.graphicGraph.GraphicSprite) Point3(org.graphstream.ui.geom.Point3)

Example 7 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 8 with Point3

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

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

the class Tuple method renderAlong.

@Override
public void renderAlong(Backend backend, DefaultCamera2D camera, IconAndText iconAndText, ConnectorSkeleton skel) {
    Point3 p = skel.pointOnShape(0.5);
    renderGu2Px(backend, camera, iconAndText, p.x, p.y, 0, positionTextAndIconPx);
}
Also used : Point3(org.graphstream.ui.geom.Point3)

Example 10 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)

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