/** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {
    final ReportSelectionModel model = getSelectionModel();
    if (model == null) {
      return;
    }
    final Element[] visualElements = model.getSelectedVisualElements();
    if (visualElements.length <= 1) {
      return;
    }
    final Element[] carrier = new Element[1];
    final Element[] objects = ModelUtility.filterParents(visualElements);
    final MassElementStyleUndoEntryBuilder builder = new MassElementStyleUndoEntryBuilder(objects);

    long minY = Long.MAX_VALUE;
    long maxY = Long.MIN_VALUE;
    for (int j = 0; j < objects.length; j++) {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long y1 = data.getY();
      final long y2 = y1 + data.getHeight();
      if (y2 > maxY) {
        maxY = y2;
      }
      if (y1 < minY) {
        minY = y1;
      }
    }

    final long centerPoint = minY + (maxY - minY) / 2;

    for (int j = 0; j < objects.length; j++) {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long elementCenter = data.getY() + data.getHeight() / 2;

      final long delta = centerPoint - elementCenter;
      if (delta == 0) {
        continue;
      }

      carrier[0] = object;
      final MoveDragOperation mop =
          new MoveDragOperation(
              carrier, ORIGIN_POINT, EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE);
      mop.update(new Point2D.Double(0, StrictGeomUtility.toExternalValue(delta)), 1);
      mop.finish();
    }
    final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish();
    getActiveContext()
        .getUndo()
        .addChange(
            ActionMessages.getString("AlignMiddleAction.UndoName"), massElementStyleUndoEntry);
  }
  /** Invoked when an action occurs. */
  public void actionPerformed(final ActionEvent e) {
    final Element[] visualElements = getSelectionModel().getSelectedVisualElements();
    if (visualElements.length == 0) {
      return;
    }

    final MassElementStyleUndoEntryBuilder builder =
        new MassElementStyleUndoEntryBuilder(visualElements);
    final MoveDragOperation mop =
        new MoveDragOperation(
            visualElements, new Point(), EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE);
    mop.update(new Point(1, 0), 1);
    mop.finish();

    final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish();
    getActiveContext()
        .getUndo()
        .addChange(
            ActionMessages.getString("MoveRightOneAction.UndoName"), massElementStyleUndoEntry);
  }
 private void registerChanges() {
   final MassElementStyleUndoEntry massElementStyleUndoEntry = builder.finish();
   context
       .getUndo()
       .addChange(Messages.getString("AlignmentUtilities.Undo"), massElementStyleUndoEntry);
 }