src/jtwod/engine/drawable/Shape.java
private void constrain(Vector min, Vector max)
    {
        if (this.position.getX() < min.getX() - min.getXBuffer()) {
            this.position.setX(min.getX() - min.getXBuffer());
            this.onConstrained(AxisEventType.LeftX);
        }

        if (this.position.getY() < min.getY() - min.getYBuffer()) {
            this.onConstrained(AxisEventType.TopY);
            this.position.setY(min.getY() - min.getYBuffer());
        }

        if (this.position.getX() > max.getX() - max.getXBuffer()) {
            this.position.setX(max.getX() - max.getXBuffer());
            this.onConstrained(AxisEventType.RightX);
        }

        if (this.position.getY() > max.getY() - max.getYBuffer()) {
            this.position.setY(max.getY() - max.getYBuffer());
            this.onConstrained(AxisEventType.BottomY);
        }
    }
/**
     * A custom implementation of the Vector constraint mechanism.
     * This will call back to the {@link Shape#onConstrained(AxisEventType)} function.
     * 
     * We use this instead of {@link Vector#constrain(Vector, Vector)}
     *
     * @param min The minimum constraint to use.
     * @param max The maximum constraint to use.
     */
A custom implementation of the Vector constraint mechanism.
This will call back to the  Shape#onConstrained(AxisEventType) function.



@param min The minimum constraint to use.
@param max The maximum constraint to use.
A custom implementation of the Vector constraint mechanism . This will call back to the Shape#onConstrained ( AxisEventType ) function . @param min The minimum constraint to use . @param max The maximum constraint to use .
private void constrain(Vector min, Vector max)
    {
        if (this.position.getX() < min.getX() - min.getXBuffer()) {
            this.position.setX(min.getX() - min.getXBuffer());
            this.onConstrained(AxisEventType.LeftX);
        }
        if (this.position.getY() < min.getY() - min.getYBuffer()) {
            this.onConstrained(AxisEventType.TopY);
            this.position.setY(min.getY() - min.getYBuffer());
        }
        if (this.position.getX() > max.getX() - max.getXBuffer()) {
            this.position.setX(max.getX() - max.getXBuffer());
            this.onConstrained(AxisEventType.RightX);
        }
        if (this.position.getY() > max.getY() - max.getYBuffer()) {
            this.position.setY(max.getY() - max.getYBuffer());
            this.onConstrained(AxisEventType.BottomY);
        }
    }
private void constrain ( Vector min , Vector max ) { if ( this . position . getX ( ) < min . getX ( ) - min . getXBuffer ( ) ) { this . position . setX ( min . getX ( ) - min . getXBuffer ( ) ) ; this . onConstrained ( AxisEventType . LeftX ) ; } if ( this . position . getY ( ) < min . getY ( ) - min . getYBuffer ( ) ) { this . onConstrained ( AxisEventType . TopY ) ; this . position . setY ( min . getY ( ) - min . getYBuffer ( ) ) ; } if ( this . position . getX ( ) > max . getX ( ) - max . getXBuffer ( ) ) { this . position . setX ( max . getX ( ) - max . getXBuffer ( ) ) ; this . onConstrained ( AxisEventType . RightX ) ; } if ( this . position . getY ( ) > max . getY ( ) - max . getYBuffer ( ) ) { this . position . setY ( max . getY ( ) - max . getYBuffer ( ) ) ; this . onConstrained ( AxisEventType . BottomY ) ; } }
A custom implementation of the Vector constraint mechanism.
A custom implementation of the Vector constraint mechanism .