Package com.samskivert.swing.util

Examples of com.samskivert.swing.util.ProximityTracker


{
    @Test
    public void runTest ()
    {
        Random rand = new Random();
        ProximityTracker tracker = new ProximityTracker();
        ArrayList<Point> points = new ArrayList<Point>();

        // create 100 random points and add them to the tracker and our
        // comparison list
        for (int i = 0; i < 100; i++) {
            int x = rand.nextInt(MAX_X);
            int y = rand.nextInt(MAX_Y);
            Point p = new Point(x, y);
            tracker.addObject(x, y, p);
            points.add(p);
        }

        // now choose 100 new random points and confirm that the tracker
        // reports the same closest point that our brute force check
        // reports
        for (int i = 0; i < 100; i++) {
            int x = rand.nextInt(MAX_X);
            int y = rand.nextInt(MAX_Y);

            // get the closest point via the tracker
            Point tp = (Point)tracker.findClosestObject(x, y, null);

            // get the closest point via brute force
            Point cp = null;
            int mindist = Integer.MAX_VALUE;
            for (int p = 0; p < points.size(); p++) {
View Full Code Here

TOP

Related Classes of com.samskivert.swing.util.ProximityTracker

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.