@Override public Group setX(final double x) { updateChildrenLocations(x - getX(), 0); return super.setX(x); }
@Override public Group setY(final double y) { updateChildrenLocations(0, y - getY()); return super.setY(y); }
public WiresBaseDynamicContainer() { //Record the start location of Children when the Container is dragged. These are //used to calculate the new positions of Children as the Container is dragged addNodeDragStartHandler(new NodeDragStartHandler() { @Override public void onNodeDragStart(final NodeDragStartEvent nodeDragStartEvent) { dragStartLocations.clear(); for (WiresBaseShape shape : children) { dragStartLocations.add(new Pair<WiresBaseShape, Point2D>(shape, new Point2D(shape.getLocation().getX(), shape.getLocation().getY()))); } } }); //As the Container is dragged update the location of the Children, //using their start location and the DragContext DX, DY addNodeDragMoveHandler(new NodeDragMoveHandler() { @Override public void onNodeDragMove(final NodeDragMoveEvent nodeDragMoveEvent) { final double deltaX = nodeDragMoveEvent.getDragContext().getDx(); final double deltaY = nodeDragMoveEvent.getDragContext().getDy(); final Point2D delta = new Point2D(deltaX, deltaY); for (Pair<WiresBaseShape, Point2D> dragStartLocation : dragStartLocations) { dragStartLocation.getK1().setLocation(dragStartLocation.getK2().add(delta)); } getLayer().batch(); } }); }
@Override public void onNodeDragMove(final NodeDragMoveEvent nodeDragMoveEvent) { final double deltaX = nodeDragMoveEvent.getDragContext().getDx(); final double deltaY = nodeDragMoveEvent.getDragContext().getDy(); final Point2D delta = new Point2D(deltaX, deltaY); for (Pair<WiresBaseShape, Point2D> dragStartLocation : dragStartLocations) { dragStartLocation.getK1().setLocation(dragStartLocation.getK2().add(delta)); } getLayer().batch(); } });
public WiresBaseDynamicContainer() { //Record the start location of Children when the Container is dragged. These are //used to calculate the new positions of Children as the Container is dragged addNodeDragStartHandler(new NodeDragStartHandler() { @Override public void onNodeDragStart(final NodeDragStartEvent nodeDragStartEvent) { dragStartLocations.clear(); for (WiresBaseShape shape : children) { dragStartLocations.add(new Pair<WiresBaseShape, Point2D>(shape, new Point2D(shape.getLocation().getX(), shape.getLocation().getY()))); } } }); //As the Container is dragged update the location of the Children, //using their start location and the DragContext DX, DY addNodeDragMoveHandler(new NodeDragMoveHandler() { @Override public void onNodeDragMove(final NodeDragMoveEvent nodeDragMoveEvent) { final double deltaX = nodeDragMoveEvent.getDragContext().getDx(); final double deltaY = nodeDragMoveEvent.getDragContext().getDy(); final Point2D delta = new Point2D(deltaX, deltaY); for (Pair<WiresBaseShape, Point2D> dragStartLocation : dragStartLocations) { dragStartLocation.getK1().setLocation(dragStartLocation.getK2().add(delta)); } getLayer().batch(); } }); }
@Override public void onNodeDragMove(final NodeDragMoveEvent nodeDragMoveEvent) { final double deltaX = nodeDragMoveEvent.getDragContext().getDx(); final double deltaY = nodeDragMoveEvent.getDragContext().getDy(); final Point2D delta = new Point2D(deltaX, deltaY); for (Pair<WiresBaseShape, Point2D> dragStartLocation : dragStartLocations) { dragStartLocation.getK1().setLocation(dragStartLocation.getK2().add(delta)); } getLayer().batch(); } });
@Override public Group setY(final double y) { updateChildrenLocations(0, y - getY()); return super.setY(y); }
@Override public Group setX(final double x) { updateChildrenLocations(x - getX(), 0); return super.setX(x); }