Search in sources :

Example 41 with Bounds

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

the class TestSequenceFlowWriter method nodeOf.

PropertyWriter nodeOf(String id, float x, float y, float width, float height) {
    ScriptTask el = bpmn2.createScriptTask();
    el.setId(id);
    Bounds sb = Bounds.create(x, y, x + width, y + height);
    PropertyWriter p = propertyWriter.of(el);
    p.setBounds(sb);
    return p;
}
Also used : ScriptTask(org.eclipse.bpmn2.ScriptTask) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds)

Example 42 with Bounds

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

the class LocationControlImplTest method testEnsureDragConstraints.

@Test
public void testEnsureDragConstraints() throws Exception {
    tested.init(canvasHandler);
    Bounds bounds = Bounds.create(0d, 0d, 600d, 600d);
    when(canvasPanel.getLocationConstraints()).thenReturn(bounds);
    tested.register(element);
    verify(shapeView, times(1)).setDragBounds(eq(bounds));
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Test(org.junit.Test)

Example 43 with Bounds

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

the class BPMNDirectDiagramMarshallerTest method assertCoordinatesProperlyCalculatedAndMarshalled.

@SuppressWarnings("unchecked")
private static void assertCoordinatesProperlyCalculatedAndMarshalled(Diagram<Graph, Metadata> diagram, String marshalledDiagram, String elementId, Boolean isExpandedAttribute) {
    Node<View<? extends Definition>, ?> node = diagram.getGraph().getNode(elementId);
    Bounds nodeAbsoluteBounds = BasePropertyWriter.absoluteBounds(node);
    float expectedX = Double.valueOf(nodeAbsoluteBounds.getX()).floatValue();
    float expectedY = Double.valueOf(nodeAbsoluteBounds.getY()).floatValue();
    float expectedWidth = nodeAbsoluteBounds.getLowerRight().getX().floatValue() - nodeAbsoluteBounds.getUpperLeft().getX().floatValue();
    float expectedHeight = nodeAbsoluteBounds.getLowerRight().getY().floatValue() - nodeAbsoluteBounds.getUpperLeft().getY().floatValue();
    assertContainsShape(marshalledDiagram, elementId, expectedX, expectedY, expectedWidth, expectedHeight, isExpandedAttribute);
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 44 with Bounds

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

the class BasePropertyReaderTest method testBounds.

@Test
public void testBounds() {
    Bounds bounds = tested.getBounds();
    assertTrue(bounds.hasLowerRight());
    assertTrue(bounds.hasUpperLeft());
    assertEquals(0.7150000154972077d, bounds.getUpperLeft().getX(), 0d);
    assertEquals(1.4300000309944154d, bounds.getUpperLeft().getY(), 0d);
    assertEquals(65.71500001549721d, bounds.getLowerRight().getX(), 0d);
    assertEquals(355.9010174870491d, bounds.getLowerRight().getY(), 0d);
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Test(org.junit.Test)

Example 45 with Bounds

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

the class LanePropertyReaderTest method testGetBoundsWithParentLaneShape.

@Test
public void testGetBoundsWithParentLaneShape() {
    LanePropertyReader propertyReader = new LanePropertyReader(lane, diagram, shape, parentLaneShape, RESOLUTION_FACTOR);
    Bounds result = propertyReader.getBounds();
    assertBounds(PARENT_X * RESOLUTION_FACTOR, Y * RESOLUTION_FACTOR, PARENT_X * RESOLUTION_FACTOR + PARENT_WIDTH * RESOLUTION_FACTOR, Y * RESOLUTION_FACTOR + HEIGHT * RESOLUTION_FACTOR, result);
}
Also used : TestUtils.assertBounds(org.kie.workbench.common.stunner.bpmn.backend.converters.TestUtils.assertBounds) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) TestUtils.mockBounds(org.kie.workbench.common.stunner.bpmn.backend.converters.TestUtils.mockBounds) Test(org.junit.Test)

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