Examples of FreedomPoint


Examples of it.freedomotic.model.geometry.FreedomPoint

    //Helper class to transform from a FreedomPolygon to a Path
    public static Path2D freedomPolygonToPath(FreedomPolygon fp) {
        Path2D mP = new Path2D.Double();
        for (int j = 0; j < fp.getPoints().size(); j++) {
            FreedomPoint point = fp.getPoints().get(j);
            if (j == 0) {
                mP.moveTo(point.getX(), point.getY());
            } else {
                mP.lineTo(point.getX(), point.getY());
            }
        }
        //closing the path
        mP.closePath();
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

        point.setY(y);
        handle.setBounds(x - 13, y - 13, 26, 26);
    }

    public FreedomPoint addAdiacent() {
        FreedomPoint added = zone.getPojo().getShape().insert(point);

        return added;
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

        return output;
    }

    public static FreedomPolygon rotate(FreedomPolygon input, int degrees) {
        FreedomPoint pivot = input.getPoints().get(0); //getRectangleCenter(getBoundingBox(input));
        FreedomPolygon output = new FreedomPolygon();

        for (FreedomPoint point : input.getPoints()) {
            output.append(rotatePoint(point, pivot, degrees));
        }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

        return poly;
    }

    private static FreedomPoint getRectangleCenter(FreedomPolygon input) {
        FreedomPoint min = input.getPoints().get(0);
        FreedomPoint max = input.getPoints().get(2);
        int x = ((max.getX() - min.getX()) / 2) + min.getX();
        int y = ((max.getY() - (min.getY() / 2)) + min.getY());

        return new FreedomPoint(x, y);
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

        int y =
                (int) Math.round(pivot.getY()
                + (double) (((pt.getX() - pivot.getX()) * sinAngle)
                + ((pt.getY() - pivot.getY()) * cosAngle)));

        return new FreedomPoint(x, y);
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

    @Test
    public void testTranslate() {
        System.out.println("Translate a polygon");

        FreedomPolygon input = new FreedomPolygon();
        input.append(new FreedomPoint(0, 0));
        input.append(new FreedomPoint(100, 0));
        input.append(new FreedomPoint(100, 100));
        input.append(new FreedomPoint(0, 100));

        int xoffset = 50;
        int yoffset = 50;
        FreedomPolygon expResult = new FreedomPolygon();
        expResult.append(new FreedomPoint(50, 50));
        expResult.append(new FreedomPoint(150, 50));
        expResult.append(new FreedomPoint(150, 150));
        expResult.append(new FreedomPoint(50, 150));

        FreedomPolygon result = TopologyUtils.translate(input, xoffset, yoffset);
        assertEquals(expResult.toString(),
                result.toString());
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

    @Test
    public void testRotate() {
        System.out.println("Rotate a polygon");

        FreedomPolygon input = new FreedomPolygon();
        input.append(new FreedomPoint(0, 0));
        input.append(new FreedomPoint(100, 0));
        input.append(new FreedomPoint(100, 50));
        input.append(new FreedomPoint(0, 50));

        int degrees = 90;
        FreedomPolygon expResult = new FreedomPolygon();
        expResult.append(new FreedomPoint(0, 0));
        expResult.append(new FreedomPoint(0, 100));
        expResult.append(new FreedomPoint(-50, 100));
        expResult.append(new FreedomPoint(-50, 0));

        FreedomPolygon result = TopologyUtils.rotate(input, degrees);
        assertEquals(expResult.toString(),
                result.toString());
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

    @Test
    public void testIntersects() {
        System.out.println("Intersects a copy of itself (expected true)");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPolygon target = new FreedomPolygon();
        target.append(new FreedomPoint(0, 0));
        target.append(new FreedomPoint(100, 0));
        target.append(new FreedomPoint(100, 50));
        target.append(new FreedomPoint(0, 50));

        boolean expResult = true;
        boolean result = TopologyUtils.intersects(source, target);
        assertEquals(expResult, result);
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

    @Test
    public void testIntersects2() {
        System.out.println("Intersects with a rotated copy (90°) of itself (expected true)");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPolygon target = new FreedomPolygon();
        target.append(new FreedomPoint(0, 0));
        target.append(new FreedomPoint(0, 100));
        target.append(new FreedomPoint(-50, 100));
        target.append(new FreedomPoint(-50, 0));

        boolean expResult = true;
        boolean result = TopologyUtils.intersects(source, target);
        assertEquals(expResult, result);
    }
View Full Code Here

Examples of it.freedomotic.model.geometry.FreedomPoint

    @Test
    public void testIntersects3() {
        System.out.println("Intersects overlapping polygins with no edge collision (expected true)");

        FreedomPolygon source = new FreedomPolygon();
        source.append(new FreedomPoint(0, 0));
        source.append(new FreedomPoint(100, 0));
        source.append(new FreedomPoint(100, 50));
        source.append(new FreedomPoint(0, 50));

        FreedomPolygon target = new FreedomPolygon();
        target.append(new FreedomPoint(50, -25));
        target.append(new FreedomPoint(75, -25));
        target.append(new FreedomPoint(75, 75));
        target.append(new FreedomPoint(50, 75));

        boolean expResult = true;
        boolean result = TopologyUtils.intersects(source, target);

        //TODO: THIS FAILS MUST BE SOLVED
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.