{
return;
}
Arrays.sort(reportElements, new ElementPositionComparator());
final MassElementStyleUndoEntryBuilder builder = new MassElementStyleUndoEntryBuilder(reportElements);
final Element[] carrier = new Element[1];
final int lastElementIdx = reportElements.length - 1;
final Element lastElement = reportElements[lastElementIdx];
final Element firstElement = reportElements[0];
final CachedLayoutData firstLayoutData = ModelUtility.getCachedLayoutData(firstElement);
final CachedLayoutData lastLayoutData = ModelUtility.getCachedLayoutData(lastElement);
final long height = (lastLayoutData.getX() + lastLayoutData.getWidth() / 2) -
(firstLayoutData.getX() + firstLayoutData.getWidth() / 2);
final long incr = height / lastElementIdx;
long currentY = firstLayoutData.getX() + firstLayoutData.getWidth() / 2;
currentY += incr;//start from second element
for (int i = 1; i < lastElementIdx; i++)
{
final Element reportElement = reportElements[i];
final CachedLayoutData layoutData = ModelUtility.getCachedLayoutData(reportElement);
final long delta = currentY - layoutData.getWidth() / 2;
if (delta == 0)
{
continue;
}
carrier[0] = reportElement;
final Point2D.Double originPoint = new Point2D.Double(StrictGeomUtility.toExternalValue(layoutData.getX()), 0);
final MoveDragOperation mop = new MoveDragOperation
(carrier, originPoint, EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE);
mop.update(new Point2D.Double(StrictGeomUtility.toExternalValue(delta), 0), 1);
mop.finish();
currentY += incr;
}
final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish();
getActiveContext().getUndo().addChange(ActionMessages.getString("DistributeCenterAction.UndoName"), massElementStyleUndoEntry);
}