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:54:51
* To change this template use Options | File Templates.
*/
class VertAlignAction extends AlignAction {
public VertAlignAction() {
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.x + rect.width / 2;
while (iterator.hasNext()) {
Figure figure = (Figure) iterator.next();
if (!(figure instanceof ConnectionFigure)) {
figure.moveBy(limit - figure.center().x, 0);
}
}
drawingEditor.getCurrentView().repairDamage();
}
}