Package research.align

Source Code of research.align.HoriAlignAction

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();
    }
}
TOP

Related Classes of research.align.HoriAlignAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.