@Test @SuppressWarnings("unchecked") public void testPostOperation() { CommandResult<CanvasViolation> result = CanvasCommandResultBuilder.SUCCESS; CommandResult<CanvasViolation> cascasded = tested.postOperation(canvasHandler, result, 100, 200); assertEquals(result, cascasded); verify(onResize, times(1)).accept(eq(shape)); ArgumentCaptor<Bounds> boundsArgumentCaptor = ArgumentCaptor.forClass(Bounds.class); verify(elementContent, times(1)).setBounds(boundsArgumentCaptor.capture()); assertEquals(Bounds.create(10, 20, 110, 220), boundsArgumentCaptor.getValue()); }
CommandResult<CanvasViolation> postOperation(final AbstractCanvasHandler context, final CommandResult<CanvasViolation> result, final double width, final double height) { if (!CommandUtils.isError(result)) { final Point2D current = GraphUtils.getPosition(candidate.getContent()); final Bounds newBounds = Bounds.create(current.getX(), current.getY(), current.getX() + width, current.getY() + height); candidate.getContent().setBounds(newBounds); final ShapeView shapeView = getShape(context, candidate.getUUID()).getShapeView(); ShapeUtils.setSizeFromBoundingBox(shapeView, width, height); onResize.accept(getShape(context, candidate.getUUID())); } return result; }
ResizeNodeCommand extends AbstractCanvasCompositeCommand { CommandResult<CanvasViolation> postOperation(final AbstractCanvasHandler context, final CommandResult<CanvasViolation> result, final double width, final double height) { if (!CommandUtils.isError(result)) { final Point2D current = GraphUtils.getPosition(candidate.getContent()); final Bounds newBounds = Bounds.create(current.getX(), current.getY(), current.getX() + width, current.getY() + height); candidate.getContent().setBounds(newBounds); final ShapeView shapeView = getShape(context, candidate.getUUID()).getShapeView(); ShapeUtils.setSizeFromBoundingBox(shapeView, width, height); onResize.accept(getShape(context, candidate.getUUID())); } return result; } }
ResizeNodeCommand extends AbstractCanvasCompositeCommand { CommandResult<CanvasViolation> postOperation(final AbstractCanvasHandler context, final CommandResult<CanvasViolation> result, final double width, final double height) { if (!CommandUtils.isError(result)) { final Point2D current = GraphUtils.getPosition(candidate.getContent()); final Bounds newBounds = Bounds.create(current.getX(), current.getY(), current.getX() + width, current.getY() + height); candidate.getContent().setBounds(newBounds); final ShapeView shapeView = getShape(context, candidate.getUUID()).getShapeView(); ShapeUtils.setSizeFromBoundingBox(shapeView, width, height); onResize.accept(getShape(context, candidate.getUUID())); } return result; } ResizeNodeCommand(final Element<? extends View> candidate,
                             final BoundingBox boundingBox,
                             final BiFunction<Shape, Integer, Point2D> magnetLocationProvider);  ResizeNodeCommand(final Element<? extends View> candidate,
                             final BoundingBox boundingBox,
                             final BiFunction<Shape, Integer, Point2D> magnetLocationProvider,
                             final Consumer<Shape> onResize); }
ResizeNodeCommand extends AbstractCanvasCompositeCommand { CommandResult<CanvasViolation> postOperation(final AbstractCanvasHandler context, final CommandResult<CanvasViolation> result, final double width, final double height) { if (!CommandUtils.isError(result)) { final Point2D current = GraphUtils.getPosition(candidate.getContent()); final Bounds newBounds = Bounds.create(current.getX(), current.getY(), current.getX() + width, current.getY() + height); candidate.getContent().setBounds(newBounds); final ShapeView shapeView = getShape(context, candidate.getUUID()).getShapeView(); ShapeUtils.setSizeFromBoundingBox(shapeView, width, height); onResize.accept(getShape(context, candidate.getUUID())); } return result; } ResizeNodeCommand(final Element<? extends View> candidate,
                             final BoundingBox boundingBox,
                             final BiFunction<Shape, Integer, Point2D> magnetLocationProvider);  ResizeNodeCommand(final Element<? extends View> candidate,
                             final BoundingBox boundingBox,
                             final BiFunction<Shape, Integer, Point2D> magnetLocationProvider,
                             final Consumer<Shape> onResize); @Override CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(AbstractCanvasHandler context); Element<? extends View> getCandidate(); BoundingBox getBoundingBox(); BiFunction<Shape, Integer, Point2D> getMagnetLocationProvider(); Consumer<Shape> getOnResize(); @Override String toString(); }
ResizeNodeCommand extends AbstractCanvasCompositeCommand { CommandResult<CanvasViolation> postOperation(final AbstractCanvasHandler context, final CommandResult<CanvasViolation> result, final double width, final double height) { if (!CommandUtils.isError(result)) { final Point2D current = GraphUtils.getPosition(candidate.getContent()); final Bounds newBounds = Bounds.create(current.getX(), current.getY(), current.getX() + width, current.getY() + height); candidate.getContent().setBounds(newBounds); final ShapeView shapeView = getShape(context, candidate.getUUID()).getShapeView(); ShapeUtils.setSizeFromBoundingBox(shapeView, width, height); onResize.accept(getShape(context, candidate.getUUID())); } return result; } ResizeNodeCommand(final Element<? extends View> candidate,
                             final BoundingBox boundingBox,
                             final BiFunction<Shape, Integer, Point2D> magnetLocationProvider);  ResizeNodeCommand(final Element<? extends View> candidate,
                             final BoundingBox boundingBox,
                             final BiFunction<Shape, Integer, Point2D> magnetLocationProvider,
                             final Consumer<Shape> onResize); @Override CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context); @Override CommandResult<CanvasViolation> undo(AbstractCanvasHandler context); Element<? extends View> getCandidate(); BoundingBox getBoundingBox(); BiFunction<Shape, Integer, Point2D> getMagnetLocationProvider(); Consumer<Shape> getOnResize(); @Override String toString();  }