Package graphics.common

Examples of graphics.common.Box


        drawTreeRecursive( g, node.mTopLeft );
        drawTreeRecursive( g, node.mTopRight );
        drawTreeRecursive( g, node.mBottomLeft );
        drawTreeRecursive( g, node.mBottomRight );

        Box loc = node.mNodeLoc;
        //top
        g.drawLine( loc.getX(), loc.getY(),
                loc.getX() + loc.getWidth(), loc.getY() );
        //bottom
        g.drawLine( loc.getX(), loc.getY() + loc.getHeight(),
                loc.getX() + loc.getWidth(), loc.getY() + loc.getHeight() );
        //left
        g.drawLine( loc.getX(), loc.getY(), loc.getX(),
                loc.getY() + loc.getHeight() );
        //right
        g.drawLine( loc.getX() + loc.getWidth(), loc.getY(),
                loc.getX() + loc.getWidth(), loc.getY() + loc.getHeight() );
        loc = null;
    }
View Full Code Here


        insertRecursive( thing, mHead, 0 );
    }

    private void insertRecursive( T thing, Node< T > node, int depth ) {
        if( node.mTopLeft != null ) {
            Box thingBox = thing.getBox()[ 0 ];
            if( thingBox.intersectingWith( node.mTopLeft.mNodeLoc ) )
                insertRecursive( thing, node.mTopLeft, depth + 1 );
            if( thingBox.intersectingWith( node.mTopRight.mNodeLoc ) )
                insertRecursive( thing, node.mTopRight, depth + 1 );
            if( thingBox.intersectingWith( node.mBottomLeft.mNodeLoc ) )
                insertRecursive( thing, node.mBottomLeft, depth + 1 );
            if( thingBox.intersectingWith( node.mBottomRight.mNodeLoc ) )
                insertRecursive( thing, node.mBottomRight, depth + 1 );
        }
        else {
            node.mStoredItems.add( thing );
            if( node.mStoredItems.size() >= mItemsToSplit && depth < mMaxDepth ) {
View Full Code Here

    }

    private void removeRecursive( T thing, Node< T > node ) {
        if( node == null )
            return;
        Box thingBox = thing.getBox()[ 0 ];
        if( thingBox.intersectingWith( node.mNodeLoc ) ) {
            if( node.mTopLeft == null ) {
                node.mStoredItems.remove( thing );
            }
            else {
                removeRecursive( thing, node.mTopLeft );
View Full Code Here

            return true;
       
        //if( node.mStoredItems.contains( thing ) )
        //    return true;
       
        Box thingBox = thing.getBox()[ 0 ];
        boolean found = false;
        if( thingBox.intersectingWith( node.mNodeLoc ) ) {
            found = updateRecursive( thing, node.mTopLeft, depth + 1 ) || found ? true : false;
            found = updateRecursive( thing, node.mTopRight, depth + 1 ) || found ? true : false;
            found = updateRecursive( thing, node.mBottomLeft, depth + 1 ) || found ? true : false;
            found = updateRecursive( thing, node.mBottomRight, depth + 1 ) || found ? true : false;
        }
View Full Code Here

        return false;
    }

    private boolean nodeContains( Node< T > node, T thing ) {
        Box thingBox = thing.getBox()[ 0 ];
        Box nodeLoc = node.mNodeLoc;
        if( thingBox.getRealX() < nodeLoc.getRealX() ||
                thingBox.getRealX() > nodeLoc.getRealX() + nodeLoc.getRealWidth() )
            return false;
        if( thingBox.getRealX() + thingBox.getRealWidth() < nodeLoc.getRealX() ||
                thingBox.getRealX() + thingBox.getRealWidth() > nodeLoc.getRealX() + nodeLoc.getRealWidth() )
            return false;
        if( thingBox.getRealY() < nodeLoc.getRealY() ||
                thingBox.getRealY() > nodeLoc.getRealY() + nodeLoc.getRealHeight() )
            return false;
        if( thingBox.getRealY() + thingBox.getRealHeight() < nodeLoc.getRealY() ||
                thingBox.getRealY() + thingBox.getRealHeight() > nodeLoc.getRealY() + nodeLoc.getRealHeight() )
            return false;

        return true;
    }
View Full Code Here

            if( thingBox.intersectingWith( node.mBottomRight.mNodeLoc ) )
                findCollidingRecursive( thingBox, node.mBottomRight, list );
        }
        else {
            for( T storedThing : node.mStoredItems ) {
                Box otherBox = storedThing.getBox()[ 0 ];
                if( thingBox.intersectingWith( otherBox ) ) {
                    list.add( storedThing );
                }
            }
        }
View Full Code Here

    }

    @Override
    public List< T > findCollidingBetween( T thing1, T thing2 ) {
        List< T > theList = new LinkedList< T >();
        Box box1 = thing1.getBox()[ 0 ];
        Box box2 = thing2.getBox()[ 0 ];
        Box totalBox = null;
        if( box1.getRealY() < box2.getRealY() ) {
            if( box1.getRealX() < box2.getRealX() ) {
                totalBox = Boxes.get( box1.getRealX(), box1.getRealY(), 0,
                        box2.getRealX() + box2.getRealWidth() - box1.getRealX(),
                        box2.getRealY() + box2.getRealHeight() - box1.getRealY(),
View Full Code Here

TOP

Related Classes of graphics.common.Box

Copyright © 2018 www.massapicom. 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.