Search in sources :

Example 11 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 12 with Bounds

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

the class DMNCommonActionsToolboxFactoryTest method testBuildToolboxForBusinessKnowledgeModelType.

@Test
@SuppressWarnings("unchecked")
public void testBuildToolboxForBusinessKnowledgeModelType() {
    final Node<View<BusinessKnowledgeModel>, Edge> bkmNode = new NodeImpl<>("bkmNode1");
    final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<BusinessKnowledgeModel> nodeContent = new ViewImpl<>(bkm, bounds);
    bkmNode.setContent(nodeContent);
    final Optional<Toolbox<?>> _toolbox = tested.build(canvasHandler, bkmNode);
    assertTrue(_toolbox.isPresent());
    Toolbox<?> toolbox = _toolbox.get();
    assertTrue(toolbox instanceof ActionsToolbox);
    final ActionsToolbox actionsToolbox = (ActionsToolbox) toolbox;
    assertEquals("bkmNode1", actionsToolbox.getElementUUID());
    assertEquals(2, actionsToolbox.size());
    final Iterator<ToolboxAction> actionsIt = actionsToolbox.iterator();
    assertEquals(deleteNodeAction, actionsIt.next());
    assertEquals(editBusinessKnowledgeModelToolboxAction, actionsIt.next());
    assertFalse(actionsIt.hasNext());
    verify(view, times(1)).init(eq(actionsToolbox));
    verify(view, times(2)).addButton(any(Glyph.class), anyString(), any(Consumer.class));
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ActionsToolboxView(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolboxView) Consumer(java.util.function.Consumer) ToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ToolboxAction) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Toolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.Toolbox) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 13 with Bounds

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

the class DMNEditBusinessKnowledgeModelToolboxActionTest method setup.

@Before
public void setup() throws Exception {
    bkmNode = new NodeImpl<>(E_UUID);
    bkm = new BusinessKnowledgeModel();
    bkmFunction = new FunctionDefinition();
    bkm.setEncapsulatedLogic(bkmFunction);
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<BusinessKnowledgeModel> nodeContent = new ViewImpl<>(bkm, bounds);
    bkmNode.setContent(nodeContent);
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(graphIndex.get(eq(E_UUID))).thenReturn(bkmNode);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    this.tested = new DMNEditBusinessKnowledgeModelToolboxAction(sessionManager, translationService, editExpressionEvent);
}
Also used : BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.v1_1.FunctionDefinition) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Before(org.junit.Before)

Example 14 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 15 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)

Aggregations

Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)34 View (org.kie.workbench.common.stunner.core.graph.content.view.View)18 Test (org.junit.Test)16 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)13 Node (org.kie.workbench.common.stunner.core.graph.Node)13 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 Graph (org.kie.workbench.common.stunner.core.graph.Graph)7 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)6 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)6 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)5 Ignore (org.junit.Ignore)4 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)4 RuleEvaluationContext (org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext)4 Consumer (java.util.function.Consumer)2 Before (org.junit.Before)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel)2 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)2 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)2