package research.align;
import research.Figure;
import research.ConnectionFigure;
import research.DrawingEditor;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.util.Vector;
import java.util.Iterator;
/**
* Created by IntelliJ IDEA.
* User: saturn
* Date: 2003-10-15
* Time: 18:58:56
* To change this template use Options | File Templates.
*/
class HoriAlignAction extends AlignAction {
public HoriAlignAction() {
this.putValue(Action.NAME, "ˮƽ����");
}
public void actionPerformed(ActionEvent e) {
if (!isEnabled()) return;
caculateAffectedArea();
DrawingEditor drawingEditor = (DrawingEditor)getValue(ConstantDefinition.DRAWING_EDITOR);
Vector selection = drawingEditor.getCurrentView().getSelection();
Iterator iterator = selection.iterator();
Rectangle r = new Rectangle();
int limit = rect.y + rect.height / 2;
while (iterator.hasNext()) {
Figure figure = (Figure) iterator.next();
if (!(figure instanceof ConnectionFigure)) {
figure.moveBy(0, limit - figure.center().y);
}
}
drawingEditor.getCurrentView().repairDamage();
}
}