Examples of CropBounds


Examples of com.lightcrafts.model.CropBounds

        double height = oldCrop.getHeight();
        double angle = oldCrop.getAngle();

        center.setLocation(center.getX() + dx, center.getY() + dy);

        CropBounds newCrop = new CropBounds(center, width, height, angle);
        return newCrop;
    }
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        if ((newCrop == null) || newCrop.isAngleOnly()) {
            double angle = 0;
            if (newCrop != null) {
                angle = newCrop.getAngle();
            }
            newCrop = new CropBounds(underlayRect, angle);
        }
        crop = newCrop;
        repaint();
    }
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

    }

    void setAspectConstraint(AspectConstraint constraint) {
        this.constraint = constraint;
        if (crop != null) {
            CropBounds newCrop = constraint.adjust(crop);
            newCrop = UnderlayConstraints.translateToUnderlay(newCrop, underlayRect);
            // The crop may be null, if the constraints could not be enforced
            // within the bounds of the image.
            setCrop(newCrop);
        }
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        }
        Point p = e.getPoint();

        if (isRotateOnly) {
            if (crop == null) {
                setCrop(new CropBounds(underlayRect));
            }
            isRotating = true;
            rotateAngleStart = crop.getAngle();
            rotateMouseStart = p;
        }
        else {
            if (isOnRect(p)) {
                if (isOnNorth(p)) {
                    adjustingNorth = true;
                }
                if (isOnSouth(p)) {
                    adjustingSouth = true;
                }
                if (isOnEast(p)) {
                    adjustingEast = true;
                }
                if (isOnWest(p)) {
                    adjustingWest = true;
                }
                updateRotateConstraints();
            }
            else if (isInRect(p)) {
                if (hasRotateModifier(e)) {
                    isRotating = true;
                    rotateAngleStart = crop.getAngle();
                    rotateMouseStart = p;
                }
                else {
                    isMoving = true;
                    moveMouseStart = p;
                    moveCenterStart = crop.getCenter();
                }
                updateRotateConstraints();
            }
            else if (crop != null && (! crop.isAngleOnly())) {
                isRotating = true;
                rotateAngleStart = crop.getAngle();
                rotateMouseStart = p;
            }
            else {
                if (hasRotateModifier(e)) {
                    setCrop(new CropBounds(underlayRect));
                    isRotating = true;
                    rotateAngleStart = crop.getAngle();
                    rotateMouseStart = p;
                }
                else {
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        Point p = e.getPoint();

        // Backup the current crop, so we can back out changes if it turns
        // out they exceed the underlay constraint.
        CropBounds oldCrop = crop;

        if ((dragStart != null) &&
            ((Math.abs(dragStart.x - p.x) < MinDragDistance) ||
             (Math.abs(dragStart.y - p.y) < MinDragDistance))) {
            return;
        }
        if (dragStart != null) {
            if (! underlayRect.contains(p)) {
                return;
            }
            double x = Math.min(p.x, dragStart.x);
            double y = Math.min(p.y, dragStart.y);
            double w = Math.abs(p.x - dragStart.x);
            double h = Math.abs(p.y - dragStart.y);
            Rectangle2D rect = new Rectangle2D.Double(x, y, w, h);
            CropBounds newCrop = new CropBounds(rect);
            setCrop(newCrop);
            if (isOnNorth(p)) {
                adjustingNorth = true;
            }
            else {
                adjustingSouth = true;
            }
            if (isOnWest(p)) {
                adjustingWest = true;
            }
            else {
                adjustingEast = true;
            }
            dragStart = null;
        }
        else if (isMoving) {
            int dx = p.x - moveMouseStart.x;
            int dy = p.y - moveMouseStart.y;
            Point2D.Double center = new Point2D.Double(
                moveCenterStart.getX() + dx,
                moveCenterStart.getY() + dy
            );
            double width = crop.getWidth();
            double height = crop.getHeight();
            double angle = crop.getAngle();
            CropBounds newCrop = new CropBounds(center, width, height, angle);
            newCrop = UnderlayConstraints.translateToUnderlay(newCrop, underlayRect);
            if (newCrop != null) {
                setCrop(newCrop);
            }
        }
        else if (isRotating) {
            Point2D center = crop.getCenter();
            Line2D start = new Line2D.Double(center, rotateMouseStart);
            Line2D end = new Line2D.Double(center, p);
            double startAngle = Math.atan2(
                start.getY2() - start.getY1(), start.getX2() - start.getX1()
            );
            double endAngle = Math.atan2(
                end.getY2() - end.getY1(), end.getX2() - end.getX1()
            );
            double angle = rotateAngleStart + endAngle - startAngle;
            CropBounds newCrop = new CropBounds(crop, angle);
            updateRotateConstraints();
            newCrop = UnderlayConstraints.sizeToUnderlay(
                newCrop, underlayRect, rotateWidthLimit, rotateHeightLimit
            );
            if (newCrop != null) {
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        Point2D ul = north.getP1();
        Point2D ur = north.getP2();
        Point2D ll = crop.getLowerLeft();
        Point2D lr = crop.getLowerRight();

        CropBounds newCrop = new CropBounds(ul, ur, ll, lr);
        setCrop(newCrop);
    }
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        Point2D ul = crop.getUpperLeft();
        Point2D ur = crop.getUpperRight();
        Point2D ll = south.getP2();
        Point2D lr = south.getP1();

        CropBounds newCrop = new CropBounds(ul, ur, ll, lr);
        setCrop(newCrop);
    }
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        Point2D ul = crop.getUpperLeft();
        Point2D ur = east.getP1();
        Point2D ll = crop.getLowerLeft();
        Point2D lr = east.getP2();

        CropBounds newCrop = new CropBounds(ul, ur, ll, lr);
        setCrop(newCrop);
    }
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        Point2D ul = west.getP2();
        Point2D ur = crop.getUpperRight();
        Point2D ll = west.getP1();
        Point2D lr = crop.getLowerRight();

        CropBounds newCrop = new CropBounds(ul, ur, ll, lr);
        setCrop(newCrop);
    }
View Full Code Here

Examples of com.lightcrafts.model.CropBounds

        double area = bad.getWidth() * bad.getHeight();
        Point2D center = bad.getCenter();
        double width = Math.sqrt(area / ratio);
        double height = Math.sqrt(area * ratio);
        double angle = bad.getAngle();
        CropBounds good = new CropBounds(
            center, width, height, angle
        );
        return good;
    }
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.