use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class PointUtils method convertBounds.
@SuppressWarnings("unchecked")
private static void convertBounds(final Node<?, ?> targetNode, final BiFunction<Double, Double, Double> convertor) {
if (targetNode.getContent() instanceof View<?>) {
final View<?> targetNodeView = (View<?>) targetNode.getContent();
double boundsX = xOfBound(upperLeftBound(targetNodeView));
double boundsY = yOfBound(upperLeftBound(targetNodeView));
final double boundsWidth = xOfBound(lowerRightBound(targetNodeView)) - boundsX;
final double boundsHeight = yOfBound(lowerRightBound(targetNodeView)) - boundsY;
final List<Edge<?, ?>> inEdges = (List<Edge<?, ?>>) targetNode.getInEdges();
for (Edge<?, ?> e : inEdges) {
if (e.getContent() instanceof Child) {
final Node<?, ?> sourceNode = e.getSourceNode();
final View<?> sourceView = (View<?>) sourceNode.getContent();
final Bound sourceViewULBound = sourceView.getBounds().getUpperLeft();
final double dx = sourceViewULBound.getX();
final double dy = sourceViewULBound.getY();
boundsX = convertor.apply(boundsX, dx);
boundsY = convertor.apply(boundsY, dy);
targetNodeView.setBounds(Bounds.create(boundsX, boundsY, boundsX + boundsWidth, boundsY + boundsHeight));
break;
}
}
}
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class DomainObjectAwareLienzoMultipleSelectionControlTest method testIsClickedOnShapeWhenShapeIsClicked.
@Test
public void testIsClickedOnShapeWhenShapeIsClicked() {
final DomainObjectAwareLienzoMultipleSelectionControl partiallyMockedControl = mock(DomainObjectAwareLienzoMultipleSelectionControl.class);
final View view = mock(View.class);
when(partiallyMockedControl.getSelectedNodesStream(canvasHandler)).thenReturn(Stream.of(element));
when(element.getContent()).thenReturn(view);
when(view.getBounds()).thenReturn(new Bounds(new Bound(10d, 5d), new Bound(30d, 20d)));
when(partiallyMockedControl.isClickedOnShape(canvasHandler, 25, 15)).thenCallRealMethod();
assertThat(partiallyMockedControl.isClickedOnShape(canvasHandler, 25, 15)).isTrue();
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class DRDContextMenuServiceTest method mockNodes.
private Collection<Node<? extends Definition<?>, Edge>> mockNodes() {
final Node node = mock(Node.class);
final Node clonedNode = mock(Node.class);
final View content = mock(View.class);
final View clonedContent = mock(View.class);
final Bounds bounds = mock(Bounds.class);
final Bound upperLeft = mock(Bound.class);
final Bound lowerRight = mock(Bound.class);
final InputData inputData = spy(new InputData());
final InputData clonedInputData = spy(new InputData());
final Collection<Node<? extends Definition<?>, Edge>> nodes = new ArrayList<>();
when(node.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(inputData);
when(content.getBounds()).thenReturn(bounds);
when(bounds.getUpperLeft()).thenReturn(upperLeft);
when(bounds.getLowerRight()).thenReturn(lowerRight);
when(factoryManager.newElement(Mockito.<String>any(), Mockito.<String>any())).thenReturn(clonedNode);
when(clonedNode.asNode()).thenReturn(clonedNode);
when(clonedNode.getContent()).thenReturn(clonedContent);
when(clonedContent.getDefinition()).thenReturn(clonedInputData);
when(dmnDeepCloneProcess.clone(eq(inputData))).thenReturn(clonedInputData);
nodes.add(node);
return nodes;
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class DRDContextMenuService method cloneBounds.
private Bounds cloneBounds(final Bounds bounds) {
final Bound ul = bounds.getUpperLeft();
final Bound lr = bounds.getLowerRight();
return Bounds.create(ul.getX(), ul.getY(), lr.getX(), lr.getY());
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class DMNMarshallerStandalone method internalAugment.
@SuppressWarnings("unchecked")
private void internalAugment(final Stream<DMNShape> drgShapeStream, final Id id, final Bound ulBound, final RectangleDimensionsSet dimensionsSet, final Bound lrBound, final StylingSet stylingSet, final DoubleConsumer decisionServiceDividerLineYSetter) {
final Optional<DMNShape> drgShapeOpt = drgShapeStream.filter(shape -> shape.getDmnElementRef().getLocalPart().endsWith(id.getValue())).findFirst();
if (!drgShapeOpt.isPresent()) {
return;
}
final DMNShape drgShape = drgShapeOpt.get();
if (ulBound != null) {
ulBound.setX(xOfShape(drgShape));
ulBound.setY(yOfShape(drgShape));
}
dimensionsSet.setWidth(new Width(widthOfShape(drgShape)));
dimensionsSet.setHeight(new Height(heightOfShape(drgShape)));
if (lrBound != null) {
lrBound.setX(xOfShape(drgShape) + widthOfShape(drgShape));
lrBound.setY(yOfShape(drgShape) + heightOfShape(drgShape));
}
final DMNStyle dmnStyleOfDrgShape = drgShape.getStyle() instanceof DMNStyle ? (DMNStyle) drgShape.getStyle() : null;
if (dmnStyleOfDrgShape != null) {
if (null != dmnStyleOfDrgShape.getFillColor()) {
stylingSet.setBgColour(new BgColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getFillColor())));
}
if (null != dmnStyleOfDrgShape.getStrokeColor()) {
stylingSet.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getStrokeColor())));
}
}
final StylingSet fontSet = new StylingSet();
if (dmnStyleOfDrgShape != null) {
mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN(dmnStyleOfDrgShape));
}
if (drgShape.getDMNLabel() != null && drgShape.getDMNLabel().getSharedStyle() instanceof DMNStyle) {
mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN((DMNStyle) drgShape.getDMNLabel().getSharedStyle()));
}
if (drgShape.getDMNLabel() != null && drgShape.getDMNLabel().getStyle() instanceof DMNStyle) {
mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN((DMNStyle) drgShape.getDMNLabel().getStyle()));
}
mergeFontSet(stylingSet, fontSet);
if (drgShape.getDMNDecisionServiceDividerLine() != null) {
decisionServiceDividerLineYSetter.accept(drgShape.getDMNDecisionServiceDividerLine().getWaypoint().get(0).getY());
}
}
Aggregations