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:57:38
* To change this template use Options | File Templates.
*/
class TopAlignAction extends AlignAction {
public TopAlignAction() {
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;
while (iterator.hasNext()) {
Figure figure = (Figure) iterator.next();
if (!(figure instanceof ConnectionFigure)) {
figure.moveBy(0, limit - figure.getDisplayBox(r).y);
}
}
drawingEditor.getCurrentView().repairDamage();
}
}