Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes | Private Attributes
CH.ifa.draw.standard.AlignCommand Class Reference

Align a selection of figures relative to each other. More...

Inheritance diagram for CH.ifa.draw.standard.AlignCommand:
Inheritance graph
[legend]
Collaboration diagram for CH.ifa.draw.standard.AlignCommand:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AlignCommand (String name, DrawingView view, int op)
 Constructs an alignment command.
boolean isExecutable ()
 Tests if the command can be executed.
void execute ()
 Executes the command.
String name ()
 Gets the command name.

Static Public Attributes

static final int LEFTS = 0
 align left sides
static final int CENTERS = 1
 align centers (horizontally)
static final int RIGHTS = 2
 align right sides
static final int TOPS = 3
 align tops
static final int MIDDLES = 4
 align middles (vertically)
static final int BOTTOMS = 5
 align bottoms

Private Attributes

DrawingView fView
int fOp

Detailed Description

Align a selection of figures relative to each other.

Definition at line 17 of file AlignCommand.java.


Constructor & Destructor Documentation

CH.ifa.draw.standard.AlignCommand.AlignCommand ( String  name,
DrawingView  view,
int  op 
) [inline]

Constructs an alignment command.

Parameters:
namethe command name
viewthe target view
opthe alignment operation (LEFTS, CENTERS, RIGHTS, etc.)

Definition at line 54 of file AlignCommand.java.

                                                               {
        super(name);
        fView = view;
        fOp = op;
    }

Member Function Documentation

void CH.ifa.draw.standard.AlignCommand.execute ( ) [inline, virtual]

Executes the command.

Implements CH.ifa.draw.util.Command.

Definition at line 64 of file AlignCommand.java.

                          {
        FigureEnumeration selection = fView.selectionElements();
        Figure anchorFigure = selection.nextFigure();
        Rectangle r = anchorFigure.displayBox();

        while (selection.hasMoreElements()) {
            Figure f = selection.nextFigure();
            Rectangle rr = f.displayBox();
            switch (fOp) {
            case LEFTS:
                f.moveBy(r.x-rr.x, 0);
                break;
            case CENTERS:
                f.moveBy((r.x+r.width/2) - (rr.x+rr.width/2), 0);
                break;
            case RIGHTS:
                f.moveBy((r.x+r.width) - (rr.x+rr.width), 0);
                break;
            case TOPS:
                f.moveBy(0, r.y-rr.y);
                break;
            case MIDDLES:
                f.moveBy(0, (r.y+r.height/2) - (rr.y+rr.height/2));
                break;
            case BOTTOMS:
                f.moveBy(0, (r.y+r.height) - (rr.y+rr.height));
                break;
            }
        }
        fView.checkDamage();
    }

Here is the caller graph for this function:

Tests if the command can be executed.

Reimplemented from CH.ifa.draw.util.Command.

Definition at line 60 of file AlignCommand.java.

                                  {
        return fView.selectionCount() > 1;
    }
String CH.ifa.draw.util.Command.name ( ) [inline, inherited]

Gets the command name.

Definition at line 53 of file Command.java.

                         {
        return fName;
    }

Here is the caller graph for this function:


Member Data Documentation

align bottoms

Definition at line 45 of file AlignCommand.java.

align centers (horizontally)

Definition at line 29 of file AlignCommand.java.

Definition at line 20 of file AlignCommand.java.

Definition at line 19 of file AlignCommand.java.

align left sides

Definition at line 25 of file AlignCommand.java.

align middles (vertically)

Definition at line 41 of file AlignCommand.java.

align right sides

Definition at line 33 of file AlignCommand.java.

align tops

Definition at line 37 of file AlignCommand.java.


The documentation for this class was generated from the following file: