Search in sources :

Example 1 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class LocationControlImpl method getLocationBounds.

@SuppressWarnings("unchecked")
private double[] getLocationBounds() {
    final Graph<DefinitionSet, ? extends Node> graph = canvasHandler.getDiagram().getGraph();
    final Bounds bounds = graph.getContent().getBounds();
    return new double[] { bounds.getUpperLeft().getX(), bounds.getUpperLeft().getY(), bounds.getLowerRight().getX(), bounds.getLowerRight().getY() };
}
Also used : HasDragBounds(org.kie.workbench.common.stunner.core.client.shape.view.HasDragBounds) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)

Example 2 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class AbstractNodeBuilder method setBounds.

protected void setBounds(BuilderContext context, T node) {
    if (null != boundUL && null != boundLR) {
        Bounds bounds = new BoundsImpl(new BoundImpl(boundUL[0], boundUL[1]), new BoundImpl(boundLR[0], boundLR[1]));
        node.getContent().setBounds(bounds);
        setSize(context, node);
    }
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)

Example 3 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class CommandTestUtils method makeNode.

public static Node<View<?>, Edge> makeNode(final String uuid, final String content, final double x, final double y, final double w, final double h) {
    final Bounds bounds = new BoundsImpl(new BoundImpl(x, y), new BoundImpl(x + w, y + h));
    final Node<View<?>, Edge> node = new NodeImpl<>(uuid);
    node.setContent(new ViewImpl<>(content, bounds));
    return node;
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 4 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class MigrationDiagramMarshallerTest method assertNodeEquals.

private void assertNodeEquals(Diagram<Graph, Metadata> oldDiagram, Diagram<Graph, Metadata> newDiagram, String fileName) {
    Map<String, Node<View, ?>> oldNodes = asNodeMap(oldDiagram.getGraph().nodes());
    Map<String, Node<View, ?>> newNodes = asNodeMap(newDiagram.getGraph().nodes());
    assertEquals(fileName + ": Number of nodes should match", oldNodes.size(), newNodes.size());
    for (Node<View, ?> o : oldNodes.values()) {
        Node<View, ?> n = newNodes.get(o.getUUID());
        View oldContent = o.getContent();
        View newContent = n.getContent();
        Bounds oldBounds = oldContent.getBounds();
        Bounds newBounds = newContent.getBounds();
        assertEquals(fileName + ": Bounds should match for " + o.getUUID(), oldBounds, newBounds);
        Object oldDefinition = oldContent.getDefinition();
        Object newDefinition = newContent.getDefinition();
        assertEquals(fileName + ": Definitions should match for " + o.getUUID(), oldDefinition, newDefinition);
    }
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Matchers.anyString(org.mockito.Matchers.anyString) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 5 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerBase method assertNodeEquals.

private void assertNodeEquals(Diagram<Graph, Metadata> oldDiagram, Diagram<Graph, Metadata> newDiagram, String fileName) {
    Map<String, Node<View, ?>> oldNodes = asNodeMap(oldDiagram.getGraph().nodes());
    Map<String, Node<View, ?>> newNodes = asNodeMap(newDiagram.getGraph().nodes());
    assertEquals(fileName + ": Number of nodes should match", oldNodes.size(), newNodes.size());
    for (Node<View, ?> o : oldNodes.values()) {
        Node<View, ?> n = newNodes.get(o.getUUID());
        View oldContent = o.getContent();
        View newContent = n.getContent();
        Bounds oldBounds = oldContent.getBounds();
        Bounds newBounds = newContent.getBounds();
        assertEquals(fileName + ": Bounds should match for " + o.getUUID(), oldBounds, newBounds);
        Object oldDefinition = oldContent.getDefinition();
        Object newDefinition = newContent.getDefinition();
        assertEquals(fileName + ": Definitions should match for " + o.getUUID(), oldDefinition, newDefinition);
    }
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Matchers.anyString(org.mockito.Matchers.anyString) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Aggregations

Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)95 Test (org.junit.Test)42 View (org.kie.workbench.common.stunner.core.graph.content.view.View)34 Bound (org.kie.workbench.common.stunner.core.graph.content.Bound)26 Node (org.kie.workbench.common.stunner.core.graph.Node)24 Edge (org.kie.workbench.common.stunner.core.graph.Edge)20 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)20 Graph (org.kie.workbench.common.stunner.core.graph.Graph)9 ArrayList (java.util.ArrayList)8 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)7 HasBounds (org.kie.workbench.common.stunner.core.graph.content.HasBounds)7 Connection (org.kie.workbench.common.stunner.core.graph.content.view.Connection)7 Dock (org.kie.workbench.common.stunner.core.graph.content.relationship.Dock)6 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)6 Before (org.junit.Before)5 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)5 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)5 List (java.util.List)4 Ignore (org.junit.Ignore)4 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)4