Package java.awt.geom

Examples of java.awt.geom.Line2D


        if (underlayContains(oldCrop, underlay)) {
            return oldCrop;
        }
        Point2D se = oldCrop.getLowerRight();
        Point2D nw = oldCrop.getUpperLeft();
        Line2D diagonal = new Line2D.Double(se, nw);

        double oldDiag = se.distance(nw);
        double newDiag = getMinimumDistance(
            nw, Collections.singleton(diagonal), underlay
        );
        double diagScale = newDiag / oldDiag;

        Point2D ne = oldCrop.getUpperRight();
        Line2D north = getNorthCropLine(oldCrop);

        double oldNorth = nw.distance(ne);
        double newNorth = getMinimumDistance(
            nw, Collections.singleton(north), underlay
        );
        double northScale = newNorth / oldNorth;

        Point2D sw = oldCrop.getLowerLeft();
        Line2D west = getWestCropLine(oldCrop);

        double oldWest = sw.distance(nw);
        double newWest = getMinimumDistance(
            nw, Collections.singleton(west), underlay
        );
View Full Code Here


        if (underlayContains(oldCrop, underlay)) {
            return oldCrop;
        }
        Point2D sw = oldCrop.getLowerLeft();
        Point2D ne = oldCrop.getUpperRight();
        Line2D diagonal = new Line2D.Double(sw, ne);

        double oldDiag = sw.distance(ne);
        double newDiag = getMinimumDistance(
            ne, Collections.singleton(diagonal), underlay
        );
        double diagScale = newDiag / oldDiag;

        Point2D nw = oldCrop.getUpperLeft();
        Line2D north = getNorthCropLine(oldCrop);

        double oldNorth = nw.distance(ne);
        double newNorth = getMinimumDistance(
            ne, Collections.singleton(north), underlay
        );
        double northScale = newNorth / oldNorth;

        Point2D se = oldCrop.getLowerRight();
        Line2D east = getEastCropLine(oldCrop);

        double oldEast = ne.distance(se);
        double newEast = getMinimumDistance(
            ne, Collections.singleton(east), underlay
        );
View Full Code Here

    // intersection between any of the given lines and the underlay rectangle.
    // If none of the lines intersect the underlay, returns -1;
    private static double getMinimumDistance(
        Point2D p, Collection<Line2D> lines, Rectangle2D underlay
    ) {
        Line2D top = getTopUnderlayLine(underlay);
        Line2D left = getLeftUnderlayLine(underlay);
        Line2D bottom = getBottomUnderlayLine(underlay);
        Line2D right = getRightUnderlayLine(underlay);

        LinkedList<Point2D> intersections = new LinkedList<Point2D>();

        for (Line2D line : lines) {
View Full Code Here

        }
        return false;
    }

    private static double getMinimumDistance(Point2D p, Rectangle2D underlay) {
        Line2D top = getTopUnderlayLine(underlay);
        Line2D bottom = getBottomUnderlayLine(underlay);
        Line2D left = getLeftUnderlayLine(underlay);
        Line2D right = getRightUnderlayLine(underlay);

        double dist = top.ptLineDist(p);
        dist = Math.min(dist, bottom.ptLineDist(p));
        dist = Math.min(dist, left.ptLineDist(p));
        dist = Math.min(dist, right.ptLineDist(p));

        return dist;
    }
View Full Code Here

        CropBounds oldCrop, Rectangle2D underlay
    ) {
        if (underlayContains(oldCrop, underlay)) {
            return oldCrop;
        }
        Line2D top = getTopUnderlayLine(underlay);
        Line2D left = getLeftUnderlayLine(underlay);
        Line2D bottom = getBottomUnderlayLine(underlay);
        Line2D right = getRightUnderlayLine(underlay);

        Line2D north = getNorthCropLine(oldCrop);
        Line2D south = getSouthCropLine(oldCrop);
        Line2D east = getEastCropLine(oldCrop);
        Line2D west = getWestCropLine(oldCrop);

        Point2D et = getIntersection(east, top);
        Point2D el = getIntersection(east, left);
        Point2D eb = getIntersection(east, bottom);
        Point2D er = getIntersection(east, right);
View Full Code Here

        CropBounds oldCrop, Rectangle2D underlay
    ) {
        if (underlayContains(oldCrop, underlay)) {
            return oldCrop;
        }
        Line2D top = getTopUnderlayLine(underlay);
        Line2D left = getLeftUnderlayLine(underlay);
        Line2D bottom = getBottomUnderlayLine(underlay);
        Line2D right = getRightUnderlayLine(underlay);

        Line2D north = getNorthCropLine(oldCrop);
        Line2D south = getSouthCropLine(oldCrop);
        Line2D east = getEastCropLine(oldCrop);
        Line2D west = getWestCropLine(oldCrop);

        Point2D et = getIntersection(east, top);
        Point2D el = getIntersection(east, left);
        Point2D eb = getIntersection(east, bottom);
        Point2D er = getIntersection(east, right);
View Full Code Here

        CropBounds oldCrop, Rectangle2D underlay
    ) {
        if (underlayContains(oldCrop, underlay)) {
            return oldCrop;
        }
        Line2D top = getTopUnderlayLine(underlay);
        Line2D left = getLeftUnderlayLine(underlay);
        Line2D bottom = getBottomUnderlayLine(underlay);
        Line2D right = getRightUnderlayLine(underlay);

        Line2D north = getNorthCropLine(oldCrop);
        Line2D south = getSouthCropLine(oldCrop);
        Line2D east = getEastCropLine(oldCrop);
        Line2D west = getWestCropLine(oldCrop);

        Point2D nt = getIntersection(north, top);
        Point2D nl = getIntersection(north, left);
        Point2D nb = getIntersection(north, bottom);
        Point2D nr = getIntersection(north, right);

        Point2D st = getIntersection(south, top);
        Point2D sl = getIntersection(south, left);
        Point2D sb = getIntersection(south, bottom);
        Point2D sr = getIntersection(south, right);

        double width = oldCrop.getWidth();

        if (nt != null) {
            width = minIgnoreNegative(width, west.ptLineDist(nt));
        }
        if (nl != null) {
            width = minIgnoreNegative(width, west.ptLineDist(nl));
        }
        if (nb != null) {
            width = minIgnoreNegative(width, west.ptLineDist(nb));
        }
        if (nr != null) {
            width = minIgnoreNegative(width, west.ptLineDist(nr));
        }
        if (st != null) {
            width = minIgnoreNegative(width, west.ptLineDist(st));
        }
        if (sl != null) {
            width = minIgnoreNegative(width, west.ptLineDist(sl));
        }
        if (sb != null) {
            width = minIgnoreNegative(width, west.ptLineDist(sb));
        }
        if (sr != null) {
            width = minIgnoreNegative(width, west.ptLineDist(sr));
        }
        Point2D oldCenter = oldCrop.getCenter();
        double angle = oldCrop.getAngle();
        double height = oldCrop.getHeight();
        double dw = width - oldCrop.getWidth();
View Full Code Here

            Rectangle2D bounds = new Rectangle2D.Double(0, 0, w, h);
            double midX = w / 2d;
            double midY = h / 2d;

            InfiniteLine line;
            Line2D l;
            double normal = angle + Math.PI / 2;
            double x, y;
            int n;

            n = 0;
View Full Code Here

        GeneralPath path = new GeneralPath();
        for (double t=start; t<=end; t+=inc) {
            double newX = xNum.evaluate(t) / xDen.evaluate(t);
            double newY = yNum.evaluate(t) / yDen.evaluate(t);
            Line2D line = new Line2D.Double(oldX, oldY, newX, newY);
            path.append(line, true);
            oldX = newX;
            oldY = newY;
        }
        return path;
View Full Code Here

    Line2D getSegment(Rectangle2D rect) {
        if (isMoreHorizontal) {
            double x1 = rect.getX();
            double x2 = rect.getX() + rect.getWidth();
            Line2D line = getHorizontalSegment(x1, x2);
            if (rect.intersectsLine(line)) {
                return line;
            }
        }
        else {
            double y1 = rect.getY();
            double y2 = rect.getY() + rect.getHeight();
            Line2D line = getVerticalSegment(y1, y2);
            if (rect.intersectsLine(line)) {
                return line;
            }
        }
        return null;
View Full Code Here

TOP

Related Classes of java.awt.geom.Line2D

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.