Search in sources :

Example 1 with GraphicSprite

use of org.graphstream.ui.graphicGraph.GraphicSprite 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 2 with GraphicSprite

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

the class SpriteFlowShape method configureForElement.

@Override
public void configureForElement(Backend bck, GraphicElement element, Skeleton skel, DefaultCamera2D camera) {
    GraphicSprite sprite = (GraphicSprite) element;
    if (sprite.isAttachedToEdge()) {
        GraphicEdge edge = sprite.getEdgeAttachment();
        fillableLine.configureFillableLineForElement(element.getStyle(), camera, element);
        decorable.configureDecorableForElement(bck, camera, element, skel);
        if (element.hasAttribute("ui.size"))
            theSize = camera.getMetrics().lengthToGu(StyleConstants.convertValue(element.getAttribute("ui.size")));
        along = element.getX();
        offset = camera.getMetrics().lengthToGu(element.getY(), sprite.getUnits());
        connectorSkel = (ConnectorSkeleton) edge.getAttribute(Skeleton.attributeName);
    } else {
        connectorSkel = null;
    }
}
Also used : GraphicSprite(org.graphstream.ui.graphicGraph.GraphicSprite) GraphicEdge(org.graphstream.ui.graphicGraph.GraphicEdge)

Example 3 with GraphicSprite

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

the class DefaultCamera method allGraphicElementsIn.

@Override
public Collection<GraphicElement> allGraphicElementsIn(GraphicGraph graph, EnumSet<InteractiveElement> types, double x1, double y1, double x2, double y2) {
    List<GraphicElement> elts = new ArrayList<GraphicElement>();
    Stream nodeStream = null;
    Stream edgeStream = null;
    Stream spriteStream = null;
    if (types.contains(InteractiveElement.NODE)) {
        nodeStream = graph.nodes().filter(n -> isNodeIn((GraphicNode) n, x1, y1, x2, y2));
    } else {
        nodeStream = Stream.empty();
    }
    if (types.contains(InteractiveElement.EDGE)) {
        edgeStream = graph.edges().filter(e -> isEdgeIn((GraphicEdge) e, x1, y1, x2, y2));
    } else {
        edgeStream = Stream.empty();
    }
    if (types.contains(InteractiveElement.SPRITE)) {
        spriteStream = graph.sprites().filter(e -> isSpriteIn((GraphicSprite) e, x1, y1, x2, y2));
    } else {
        spriteStream = Stream.empty();
    }
    Stream<GraphicElement> s = Stream.concat(nodeStream, Stream.concat(edgeStream, spriteStream));
    return s.collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) Affine(javafx.scene.transform.Affine) Point2(org.graphstream.ui.geom.Point2) Point3(org.graphstream.ui.geom.Point3) GraphicElement(org.graphstream.ui.graphicGraph.GraphicElement) Camera(org.graphstream.ui.view.camera.Camera) NonInvertibleTransformException(javafx.scene.transform.NonInvertibleTransformException) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) GraphMetrics(org.graphstream.ui.view.util.GraphMetrics) InteractiveElement(org.graphstream.ui.view.util.InteractiveElement) Point2D(javafx.geometry.Point2D) EnumSet(java.util.EnumSet) GraphicGraph(org.graphstream.ui.graphicGraph.GraphicGraph) GraphicNode(org.graphstream.ui.graphicGraph.GraphicNode) Units(org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.Units) GraphicEdge(org.graphstream.ui.graphicGraph.GraphicEdge) Edge(org.graphstream.graph.Edge) Node(org.graphstream.graph.Node) GraphicsContext(javafx.scene.canvas.GraphicsContext) Collection(java.util.Collection) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) StyleConstants(org.graphstream.ui.graphicGraph.stylesheet.StyleConstants) List(java.util.List) GraphicSprite(org.graphstream.ui.graphicGraph.GraphicSprite) Values(org.graphstream.ui.graphicGraph.stylesheet.Values) Stream(java.util.stream.Stream) Vector2(org.graphstream.ui.geom.Vector2) Optional(java.util.Optional) Selector(org.graphstream.ui.graphicGraph.stylesheet.Selector) Style(org.graphstream.ui.graphicGraph.stylesheet.Style) GraphicElement(org.graphstream.ui.graphicGraph.GraphicElement) ArrayList(java.util.ArrayList) Stream(java.util.stream.Stream)

Example 4 with GraphicSprite

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

the class SpriteRenderer method renderElement.

@Override
public void renderElement(Backend bck, DefaultCamera2D camera, GraphicElement element) {
    GraphicSprite sprite = (GraphicSprite) element;
    AreaSkeleton skel = getOrSetAreaSkeleton(element);
    shape.configureForElement(bck, element, skel, camera);
    shape.render(bck, camera, element, skel);
}
Also used : GraphicSprite(org.graphstream.ui.graphicGraph.GraphicSprite)

Aggregations

GraphicSprite (org.graphstream.ui.graphicGraph.GraphicSprite)4 Point3 (org.graphstream.ui.geom.Point3)2 GraphicEdge (org.graphstream.ui.graphicGraph.GraphicEdge)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Point2D (javafx.geometry.Point2D)1 GraphicsContext (javafx.scene.canvas.GraphicsContext)1 Affine (javafx.scene.transform.Affine)1 NonInvertibleTransformException (javafx.scene.transform.NonInvertibleTransformException)1 Edge (org.graphstream.graph.Edge)1 Node (org.graphstream.graph.Node)1