use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method moveNode.
private void moveNode(Node<?, ?> nodeDecisionPostfix, int dx, int dy) {
View content = (View) nodeDecisionPostfix.getContent();
Bound ul = content.getBounds().getUpperLeft();
Bound lr = content.getBounds().getLowerRight();
content.setBounds(org.kie.workbench.common.stunner.core.graph.content.Bounds.create(ul.getX() + dx, ul.getY() + dy, lr.getX() + dx, lr.getY() + dy));
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToAbsoluteBoundsWhenChild.
@Test
public void testConvertToAbsoluteBoundsWhenChild() {
final Node<View, Edge> parent = new NodeImpl<>(UUID.uuid());
final View parentView = new ViewImpl<>(new Decision(), Bounds.create(100, 200, 1000, 2000));
parent.setContent(parentView);
final Node<View, Edge> child = new NodeImpl<>(UUID.uuid());
final View childView = new ViewImpl<>(new Decision(), Bounds.create(10, 20, 50, 60));
child.setContent(childView);
final Edge<Child, Node> edge = new EdgeImpl<>(UUID.uuid());
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(child);
parent.getOutEdges().add(edge);
child.getInEdges().add(edge);
PointUtils.convertToAbsoluteBounds(child);
final Bound ulBound = child.getContent().getBounds().getUpperLeft();
final Bound lrBound = child.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(110);
assertThat(ulBound.getY()).isEqualTo(220);
assertThat(lrBound.getX()).isEqualTo(150);
assertThat(lrBound.getY()).isEqualTo(260);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToRelativeBoundsWhenNotChild.
@Test
public void testConvertToRelativeBoundsWhenNotChild() {
final Node<View, ?> node = new NodeImpl<>(UUID.uuid());
final View nodeView = new ViewImpl<>(new Decision(), Bounds.create(10, 20, 50, 60));
node.setContent(nodeView);
PointUtils.convertToRelativeBounds(node);
final Bound ulBound = node.getContent().getBounds().getUpperLeft();
final Bound lrBound = node.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(10);
assertThat(ulBound.getY()).isEqualTo(20);
assertThat(lrBound.getX()).isEqualTo(50);
assertThat(lrBound.getY()).isEqualTo(60);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToRelativeBoundsWhenChild.
@Test
public void testConvertToRelativeBoundsWhenChild() {
final Node<View, Edge> parent = new NodeImpl<>(UUID.uuid());
final View parentView = new ViewImpl<>(new Decision(), Bounds.create(100, 200, 1000, 2000));
parent.setContent(parentView);
final Node<View, Edge> child = new NodeImpl<>(UUID.uuid());
final View childView = new ViewImpl<>(new Decision(), Bounds.create(110, 220, 150, 260));
child.setContent(childView);
final Edge<Child, Node> edge = new EdgeImpl<>(UUID.uuid());
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(child);
parent.getOutEdges().add(edge);
child.getInEdges().add(edge);
PointUtils.convertToRelativeBounds(child);
final Bound ulBound = child.getContent().getBounds().getUpperLeft();
final Bound lrBound = child.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(10);
assertThat(ulBound.getY()).isEqualTo(20);
assertThat(lrBound.getX()).isEqualTo(50);
assertThat(lrBound.getY()).isEqualTo(60);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class DMNMarshallerStandalone method ddExtAugmentStunner.
private void ddExtAugmentStunner(final Optional<org.kie.dmn.model.api.dmndi.DMNDiagram> dmnDDDiagram, Node currentNode) {
if (!dmnDDDiagram.isPresent()) {
return;
}
final Stream<DMNShape> drgShapeStream = dmnDDDiagram.get().getDMNDiagramElement().stream().filter(DMNShape.class::isInstance).map(DMNShape.class::cast);
final View content = (View) currentNode.getContent();
final Bound ulBound = upperLeftBound(content);
final Bound lrBound = lowerRightBound(content);
if (content.getDefinition() instanceof Decision) {
final Decision d = (Decision) content.getDefinition();
internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
} else if (content.getDefinition() instanceof InputData) {
final InputData d = (InputData) content.getDefinition();
internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
} else if (content.getDefinition() instanceof BusinessKnowledgeModel) {
final BusinessKnowledgeModel d = (BusinessKnowledgeModel) content.getDefinition();
internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
} else if (content.getDefinition() instanceof KnowledgeSource) {
final KnowledgeSource d = (KnowledgeSource) content.getDefinition();
internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
} else if (content.getDefinition() instanceof TextAnnotation) {
final TextAnnotation d = (TextAnnotation) content.getDefinition();
internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
} else if (content.getDefinition() instanceof DecisionService) {
final DecisionService d = (DecisionService) content.getDefinition();
internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet(), dividerLineY -> d.setDividerLineY(new DecisionServiceDividerLineY(dividerLineY - ulBound.getY())));
}
}
Aggregations