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() };
}
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));
}
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);
}
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);
}
}
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;
}
Aggregations