Package com.lightcrafts.model

Examples of com.lightcrafts.model.CropBounds


    // When crop mode starts, or when the user asks to reset the current crop,
    // use these CropBounds.  They are angle-only bounds, set to the nearest
    // multiple of 90 degrees.
    private CropBounds getUncroppedBounds() {
        if (bounds == null) {
            return new CropBounds();
        }
        double angle = bounds.getAngle();
        angle = (Math.PI / 2) * Math.round(angle / (Math.PI / 2));
        return new CropBounds(angle);
    }
View Full Code Here


                lr = new Point2D.Double(x, y);
            }
            catch (NumberFormatException e) {
                throw new XMLException("Invalid crop coordinates", e);
            }
            bounds = new CropBounds(ul, ur, ll, lr);
        }
        catch (XMLException e1) {
            try {
                double angle = Double.parseDouble(node.getAttribute(AngleTag));

                Dimension size = engine.getNaturalSize();
                Rectangle2D imageBounds = new Rectangle2D.Double(0, 0, size.width, size.height);

                bounds = new CropBounds(imageBounds, angle);
                // bounds = new CropBounds(angle);
            }
            catch (XMLException e2) {
                throw new XMLException(
                    "No valid crop or rotate data: " +
View Full Code Here

            transform.preConcatenate(AffineTransform.getTranslateInstance(-bounds.getMinX(), -bounds.getMinY()));
        }

        // Crop
        if (!cropBounds.isAngleOnly()) {
            CropBounds actualCropBounds = CropBounds.transform(transform, cropBounds);

            Point2D cropUpperLeft = actualCropBounds.getUpperLeft();

            transform.preConcatenate(AffineTransform.getTranslateInstance(-cropUpperLeft.getX(),
                                                                          -cropUpperLeft.getY()));
        }
View Full Code Here

            } else
                xformedSourceImage = image;
        }

        if (!cropBounds.isAngleOnly()) {
            CropBounds actualCropBounds = CropBounds.transform(completeInputTransform, cropBounds);

            Rectangle bounds = new Rectangle(xformedSourceImage.getMinX(), xformedSourceImage.getMinY(),
                                             xformedSourceImage.getWidth(), xformedSourceImage.getHeight());
            Rectangle finalBounds = bounds.intersection(new Rectangle(0, 0,
                                                                      (int) actualCropBounds.getWidth(),
                                                                      (int) actualCropBounds.getHeight()));
            if (finalBounds.width > 0 && finalBounds.height > 0)
                xformedSourceImage = Functions.crop(xformedSourceImage,
                                                    finalBounds.x, finalBounds.y,
                                                    finalBounds.width, finalBounds.height, null);
        }
View Full Code Here

        LocalCropListener( String s ) {
            m_opName = s;
        }

        public void cropCommitted(CropBounds crop) {
            CropBounds newBounds = (crop != null) ? crop : new CropBounds();
            // Don't allow rotations past 45 degrees through the crop mode.
            newBounds = limitRotation(newBounds);
            engine.setCropBounds(newBounds);
            double angle = newBounds.getAngle();
            // Note this sign change:
            hiddenRotorMode.setAngle(- angle);
            // The rotate package applies the convention that positive angles
            // are positive in screen coordinates, meaning clockwise on the
            // screen, which is the opposite of the convention in CropBounds.
View Full Code Here

            xform.update();
            postEdit(newBounds, LOCALE.get( m_opName + "EditName"), true );
        }

        public void unCrop() {
            CropBounds newBounds = getUncroppedBounds();
            engine.setCropBounds(newBounds);
            xform.update();
            // This method gets called when crop and rotate modes are entered,
            // to reveal the whole image.  We used to post an insignificant
            // undoable edit at this time, but it's not necessary for undo
View Full Code Here

     */
    static CropBounds translateToUnderlay(
        CropBounds oldCrop, Rectangle2D underlay
    ) {
        Rectangle2D oldRect = getCropAsShape(oldCrop).getBounds2D();
        CropBounds newCrop = oldCrop;
        if (oldRect.getX() < underlay.getMinX()) {
            double dx = - (oldRect.getX() - underlay.getMinX());
            double dy = 0;
            newCrop = translateCrop(newCrop, dx, dy);
        }
View Full Code Here

    public static CropBounds sizeToUnderlay(
        CropBounds oldCrop,
        Rectangle2D underlay,
        double limitW, double limitH
    ) {
        CropBounds newCrop = new CropBounds(
            oldCrop.getCenter(), limitW, limitH, oldCrop.getAngle()
        );
        if (underlayContains(newCrop, underlay)) {
            return newCrop;
        }
        double ult = ultHeight(oldCrop, underlay);
        double ull = ullHeight(oldCrop, underlay);
        double ulb = ulbHeight(oldCrop, underlay);
        double ulr = ulrHeight(oldCrop, underlay);

        double urt = urtHeight(oldCrop, underlay);
        double url = urlHeight(oldCrop, underlay);
        double urb = urbHeight(oldCrop, underlay);
        double urr = urrHeight(oldCrop, underlay);

        double llt = lltHeight(oldCrop, underlay);
        double lll = lllHeight(oldCrop, underlay);
        double llb = llbHeight(oldCrop, underlay);
        double llr = llrHeight(oldCrop, underlay);

        double lrt = lrtHeight(oldCrop, underlay);
        double lrl = lrlHeight(oldCrop, underlay);
        double lrb = lrbHeight(oldCrop, underlay);
        double lrr = lrrHeight(oldCrop, underlay);

        double aspect = oldCrop.getWidth() / oldCrop.getHeight();

        double h = limitH;

        h = minIgnoreNegative(h, ult);
        h = minIgnoreNegative(h, ull);
        h = minIgnoreNegative(h, ulb);
        h = minIgnoreNegative(h, ulr);
        h = minIgnoreNegative(h, urt);
        h = minIgnoreNegative(h, url);
        h = minIgnoreNegative(h, urb);
        h = minIgnoreNegative(h, urr);
        h = minIgnoreNegative(h, llt);
        h = minIgnoreNegative(h, lll);
        h = minIgnoreNegative(h, llb);
        h = minIgnoreNegative(h, llr);
        h = minIgnoreNegative(h, lrt);
        h = minIgnoreNegative(h, lrl);
        h = minIgnoreNegative(h, lrb);
        h = minIgnoreNegative(h, lrr);

        double w = h * aspect;

        newCrop = new CropBounds(
            oldCrop.getCenter(), w, h, oldCrop.getAngle()
        );
        return newCrop;
    }
View Full Code Here

        Point2D newCenter = new Point2D.Double(
            oldCenter.getX() + (dh / 2) * Math.sin(angle),
            oldCenter.getY() - (dh / 2) * Math.cos(angle)
        );
        CropBounds newCrop = new CropBounds(newCenter, width, height, angle);

        return newCrop;
    }
View Full Code Here

        Point2D newCenter = new Point2D.Double(
            oldCenter.getX() - (dh / 2) * Math.sin(angle),
            oldCenter.getY() + (dh / 2) * Math.cos(angle)
        );
        CropBounds newCrop = new CropBounds(newCenter, width, height, angle);

        return newCrop;
    }
View Full Code Here

TOP

Related Classes of com.lightcrafts.model.CropBounds

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.