@Test @SuppressWarnings("unchecked") public void testInitialize() { AbstractCompositeCommand<AbstractCanvasHandler, CanvasViolation> command = tested.initialize(canvasHandler); assertNotNull(command); final List commands = command.getCommands(); assertNotNull(commands); assertEquals(6, commands.size()); assertTrue(commands.get(0) instanceof UpdateElementPropertyCommand); final UpdateElementPropertyCommand wPropertyCommand = (UpdateElementPropertyCommand) commands.get(0); assertEquals(element, wPropertyCommand.getElement()); assertEquals(W_PROPERTY_ID, wPropertyCommand.getField()); assertEquals(boundingBox.getWidth(), wPropertyCommand.getValue()); assertTrue(commands.get(1) instanceof UpdateElementPropertyCommand); final UpdateElementPropertyCommand hPropertyCommand = (UpdateElementPropertyCommand) commands.get(1); assertEquals(element, hPropertyCommand.getElement()); assertEquals(H_PROPERTY_ID, hPropertyCommand.getField()); assertEquals(boundingBox.getHeight(), hPropertyCommand.getValue()); assertTrue(commands.get(2) instanceof UpdateElementPropertyCommand); final UpdateElementPropertyCommand rPropertyCommand = (UpdateElementPropertyCommand) commands.get(2); assertEquals(element, rPropertyCommand.getElement()); assertEquals(R_PROPERTY_ID, rPropertyCommand.getField()); assertEquals(50d, rPropertyCommand.getValue()); verify(magnetLocationProvider, times(1)).apply(eq(shape), eq(0)); verify(magnetLocationProvider, times(1)).apply(eq(shape), eq(1)); }
@Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<AbstractCanvasHandler, CanvasViolation> initialize(final AbstractCanvasHandler context) { super.initialize(context); widthBefore = candidate.getContent().getBounds().getWidth(); heightBefore = candidate.getContent().getBounds().getHeight(); final double w = boundingBox.getMaxX(); final double h = boundingBox.getMaxY(); final List<Command<AbstractCanvasHandler, CanvasViolation>> commands = getResizeCommands(context, w, h); if (null != commands) { final Node<View<?>, Edge> node = (Node<View<?>, Edge>) candidate; commands.forEach(this::addCommand); if (GraphUtils.hasDockedNodes(node)) { updateDockedNodesPosition(context, node); } if (GraphUtils.hasConnections(node)) { updateConnectionsPositions(context, node); } } return this; }
ResizeNodeCommand extends AbstractCanvasCompositeCommand { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<AbstractCanvasHandler, CanvasViolation> initialize(final AbstractCanvasHandler context) { super.initialize(context); widthBefore = candidate.getContent().getBounds().getWidth(); heightBefore = candidate.getContent().getBounds().getHeight(); final double w = boundingBox.getMaxX(); final double h = boundingBox.getMaxY(); final List<Command<AbstractCanvasHandler, CanvasViolation>> commands = getResizeCommands(context, w, h); if (null != commands) { final Node<View<?>, Edge> node = (Node<View<?>, Edge>) candidate; commands.forEach(this::addCommand); if (GraphUtils.hasDockedNodes(node)) { updateDockedNodesPosition(context, node); } if (GraphUtils.hasConnections(node)) { updateConnectionsPositions(context, node); } } return this; } }
ResizeNodeCommand extends AbstractCanvasCompositeCommand { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<AbstractCanvasHandler, CanvasViolation> initialize(final AbstractCanvasHandler context) { super.initialize(context); widthBefore = candidate.getContent().getBounds().getWidth(); heightBefore = candidate.getContent().getBounds().getHeight(); final double w = boundingBox.getMaxX(); final double h = boundingBox.getMaxY(); final List<Command<AbstractCanvasHandler, CanvasViolation>> commands = getResizeCommands(context, w, h); if (null != commands) { final Node<View<?>, Edge> node = (Node<View<?>, Edge>) candidate; commands.forEach(this::addCommand); if (GraphUtils.hasDockedNodes(node)) { updateDockedNodesPosition(context, node); } if (GraphUtils.hasConnections(node)) { updateConnectionsPositions(context, node); } } return this; } 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 { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<AbstractCanvasHandler, CanvasViolation> initialize(final AbstractCanvasHandler context) { super.initialize(context); widthBefore = candidate.getContent().getBounds().getWidth(); heightBefore = candidate.getContent().getBounds().getHeight(); final double w = boundingBox.getMaxX(); final double h = boundingBox.getMaxY(); final List<Command<AbstractCanvasHandler, CanvasViolation>> commands = getResizeCommands(context, w, h); if (null != commands) { final Node<View<?>, Edge> node = (Node<View<?>, Edge>) candidate; commands.forEach(this::addCommand); if (GraphUtils.hasDockedNodes(node)) { updateDockedNodesPosition(context, node); } if (GraphUtils.hasConnections(node)) { updateConnectionsPositions(context, node); } } return this; } 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 { @Override @SuppressWarnings("unchecked") protected AbstractCompositeCommand<AbstractCanvasHandler, CanvasViolation> initialize(final AbstractCanvasHandler context) { super.initialize(context); widthBefore = candidate.getContent().getBounds().getWidth(); heightBefore = candidate.getContent().getBounds().getHeight(); final double w = boundingBox.getMaxX(); final double h = boundingBox.getMaxY(); final List<Command<AbstractCanvasHandler, CanvasViolation>> commands = getResizeCommands(context, w, h); if (null != commands) { final Node<View<?>, Edge> node = (Node<View<?>, Edge>) candidate; commands.forEach(this::addCommand); if (GraphUtils.hasDockedNodes(node)) { updateDockedNodesPosition(context, node); } if (GraphUtils.hasConnections(node)) { updateConnectionsPositions(context, node); } } return this; } 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();  }