@Test @SuppressWarnings("unchecked") public void testSetAbsoluteBounds() { Node<View, Edge> node = (Node<View, Edge>) super.createNode(); Node<View, ?> dockSourceParentNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(PARENT_ABSOLUTE_X1, PARENT_ABSOLUTE_Y1, PARENT_ABSOLUTE_X2, PARENT_ABSOLUTE_Y2)); double dockSourceRelativeX1 = 15d; double dockSourceRelativeY1 = 20d; double dockSourceRelativeX2 = 50d; double dockSourceAbsoluteY2 = 45d; Node<View, ?> dockSourceNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(dockSourceRelativeX1, dockSourceRelativeY1, dockSourceRelativeX2, dockSourceAbsoluteY2), dockSourceParentNode); Edge dockEdge = mock(Edge.class); when(dockEdge.getSourceNode()).thenReturn(dockSourceNode); Dock dock = mock(Dock.class); when(dockEdge.getContent()).thenReturn(dock); node.getInEdges().clear(); node.getInEdges().add(dockEdge); propertyWriter.setAbsoluteBounds(node); Bounds shapeBounds = propertyWriter.getShape().getBounds(); org.kie.workbench.common.stunner.core.graph.content.Bounds relativeBounds = node.getContent().getBounds(); double dockSourceAbsoluteX = PARENT_ABSOLUTE_X1 + dockSourceRelativeX1; double dockSourceAbsoluteY = PARENT_ABSOLUTE_Y1 + dockSourceRelativeY1; assertEquals(dockSourceAbsoluteX + relativeBounds.getX(), shapeBounds.getX(), 0); assertEquals(dockSourceAbsoluteY + relativeBounds.getY(), shapeBounds.getY(), 0); assertEquals(relativeBounds.getWidth(), shapeBounds.getWidth(), 0); assertEquals(relativeBounds.getHeight(), shapeBounds.getHeight(), 0); verifyDockerInfoWasSet(relativeBounds); }
@Override public void setAbsoluteBounds(Node<? extends View, ?> node) { Bound ul = node.getContent().getBounds().getUpperLeft(); setDockerInfo(Point2D.create(ul.getX(), ul.getY())); Optional<Node<View, Edge>> dockSourceNode = getDockSourceNode(node); if (dockSourceNode.isPresent()) { Bounds dockSourceNodeBounds = absoluteBounds(dockSourceNode.get()); Bounds nodeBounds = node.getContent().getBounds(); double x = dockSourceNodeBounds.getX() + nodeBounds.getUpperLeft().getX(); double y = dockSourceNodeBounds.getY() + nodeBounds.getUpperLeft().getY(); super.setBounds(Bounds.create(x, y, x + nodeBounds.getWidth(), y + nodeBounds.getHeight())); } else { super.setAbsoluteBounds(node); } }
BoundaryEventPropertyWriter extends CatchEventPropertyWriter { @Override public void setAbsoluteBounds(Node<? extends View, ?> node) { Bound ul = node.getContent().getBounds().getUpperLeft(); setDockerInfo(Point2D.create(ul.getX(), ul.getY())); Optional<Node<View, Edge>> dockSourceNode = getDockSourceNode(node); if (dockSourceNode.isPresent()) { Bounds dockSourceNodeBounds = absoluteBounds(dockSourceNode.get()); Bounds nodeBounds = node.getContent().getBounds(); double x = dockSourceNodeBounds.getX() + nodeBounds.getUpperLeft().getX(); double y = dockSourceNodeBounds.getY() + nodeBounds.getUpperLeft().getY(); super.setBounds(Bounds.create(x, y, x + nodeBounds.getWidth(), y + nodeBounds.getHeight())); } else { super.setAbsoluteBounds(node); } } }
BoundaryEventPropertyWriter extends CatchEventPropertyWriter { @Override public void setAbsoluteBounds(Node<? extends View, ?> node) { Bound ul = node.getContent().getBounds().getUpperLeft(); setDockerInfo(Point2D.create(ul.getX(), ul.getY())); Optional<Node<View, Edge>> dockSourceNode = getDockSourceNode(node); if (dockSourceNode.isPresent()) { Bounds dockSourceNodeBounds = absoluteBounds(dockSourceNode.get()); Bounds nodeBounds = node.getContent().getBounds(); double x = dockSourceNodeBounds.getX() + nodeBounds.getUpperLeft().getX(); double y = dockSourceNodeBounds.getY() + nodeBounds.getUpperLeft().getY(); super.setBounds(Bounds.create(x, y, x + nodeBounds.getWidth(), y + nodeBounds.getHeight())); } else { super.setAbsoluteBounds(node); } } BoundaryEventPropertyWriter(BoundaryEvent event, VariableScope variableScope, Set<DataObject> dataObjects); }
BoundaryEventPropertyWriter extends CatchEventPropertyWriter { @Override public void setAbsoluteBounds(Node<? extends View, ?> node) { Bound ul = node.getContent().getBounds().getUpperLeft(); setDockerInfo(Point2D.create(ul.getX(), ul.getY())); Optional<Node<View, Edge>> dockSourceNode = getDockSourceNode(node); if (dockSourceNode.isPresent()) { Bounds dockSourceNodeBounds = absoluteBounds(dockSourceNode.get()); Bounds nodeBounds = node.getContent().getBounds(); double x = dockSourceNodeBounds.getX() + nodeBounds.getUpperLeft().getX(); double y = dockSourceNodeBounds.getY() + nodeBounds.getUpperLeft().getY(); super.setBounds(Bounds.create(x, y, x + nodeBounds.getWidth(), y + nodeBounds.getHeight())); } else { super.setAbsoluteBounds(node); } } BoundaryEventPropertyWriter(BoundaryEvent event, VariableScope variableScope, Set<DataObject> dataObjects); @Override void setCancelActivity(Boolean value); void setParentActivity(ActivityPropertyWriter parent); @Override void addEventDefinition(EventDefinition eventDefinition); @Override void setAbsoluteBounds(Node<? extends View, ?> node); }
BoundaryEventPropertyWriter extends CatchEventPropertyWriter { @Override public void setAbsoluteBounds(Node<? extends View, ?> node) { Bound ul = node.getContent().getBounds().getUpperLeft(); setDockerInfo(Point2D.create(ul.getX(), ul.getY())); Optional<Node<View, Edge>> dockSourceNode = getDockSourceNode(node); if (dockSourceNode.isPresent()) { Bounds dockSourceNodeBounds = absoluteBounds(dockSourceNode.get()); Bounds nodeBounds = node.getContent().getBounds(); double x = dockSourceNodeBounds.getX() + nodeBounds.getUpperLeft().getX(); double y = dockSourceNodeBounds.getY() + nodeBounds.getUpperLeft().getY(); super.setBounds(Bounds.create(x, y, x + nodeBounds.getWidth(), y + nodeBounds.getHeight())); } else { super.setAbsoluteBounds(node); } } BoundaryEventPropertyWriter(BoundaryEvent event, VariableScope variableScope, Set<DataObject> dataObjects); @Override void setCancelActivity(Boolean value); void setParentActivity(ActivityPropertyWriter parent); @Override void addEventDefinition(EventDefinition eventDefinition); @Override void setAbsoluteBounds(Node<? extends View, ?> node);  }