Back to index

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

Constrains a point such that it falls on a grid. More...

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

List of all members.

Public Member Functions

 GridConstrainer (int x, int y)
Point constrainPoint (Point p)
 Constrains the given point.
int getStepX ()
 Gets the x offset to move an object.
int getStepY ()
 Gets the y offset to move an object.

Private Attributes

int fGridX
int fGridY

Detailed Description

Constrains a point such that it falls on a grid.

See also:
DrawingView

Definition at line 20 of file GridConstrainer.java.


Constructor & Destructor Documentation

Definition at line 25 of file GridConstrainer.java.

                                         {
        fGridX = Math.max(1, x);
        fGridY = Math.max(1, y);
    }

Member Function Documentation

Constrains the given point.

Returns:
constrained point.

Implements CH.ifa.draw.framework.PointConstrainer.

Definition at line 34 of file GridConstrainer.java.

                                         {
        p.x = ((p.x+fGridX/2) / fGridX) * fGridX;
        p.y = ((p.y+fGridY/2) / fGridY) * fGridY;
        return p;
    }

Gets the x offset to move an object.

Implements CH.ifa.draw.framework.PointConstrainer.

Definition at line 43 of file GridConstrainer.java.

                          {
        return fGridX;
    }

Gets the y offset to move an object.

Implements CH.ifa.draw.framework.PointConstrainer.

Definition at line 50 of file GridConstrainer.java.

                          {
        return fGridY;
    }

Member Data Documentation

Definition at line 22 of file GridConstrainer.java.

Definition at line 23 of file GridConstrainer.java.


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