Package java.awt.geom

Examples of java.awt.geom.Point2D


        SoftReference<PlanarImage> softBlender = new SoftReference<PlanarImage>(null);
        SoftReference<PlanarImage> softResult = new SoftReference<PlanarImage>(null);

        int[] pointToPixel(Point2D p) {
            if (p != null) {
                Point2D pp = rendering.getTransform().transform(p, null);

                int x = (int) pp.getX();
                int y = (int) pp.getY();

                if (rendering.getScaleFactor() > 1) {
                    x /= rendering.getScaleFactor();
                    y /= rendering.getScaleFactor();
                }
View Full Code Here


    // closer angle and maybe transposed.
    private CropBounds limitRotation(CropBounds crop) {
        double oldAngle = (bounds != null) ? bounds.getAngle() : 0;
        double newAngle = (crop != null) ? crop.getAngle() : 0;
        while (newAngle - oldAngle > Math.PI / 4) {
            Point2D center = crop.getCenter();
            double width = crop.getWidth();
            double height = crop.getHeight();
            double angle = crop.getAngle();
            crop = new CropBounds(center, height, width, angle - Math.PI / 2);
            newAngle = crop.getAngle();
        }
        while (newAngle - oldAngle < - Math.PI / 4) {
            Point2D center = crop.getCenter();
            double width = crop.getWidth();
            double height = crop.getHeight();
            double angle = crop.getAngle();
            crop = new CropBounds(center, height, width, angle + Math.PI / 2);
            newAngle = crop.getAngle();
View Full Code Here

            double angle = bounds.getAngle();
            node.setAttribute(AngleTag, Double.toString(angle));
        }
        else {
            XmlNode ulNode = node.addChild(ULtag);
            Point2D ul = bounds.getUpperLeft();
            ulNode.setAttribute(Xtag, Double.toString(ul.getX()));
            ulNode.setAttribute(Ytag, Double.toString(ul.getY()));

            XmlNode urNode = node.addChild(URtag);
            Point2D ur = bounds.getUpperRight();
            urNode.setAttribute(Xtag, Double.toString(ur.getX()));
            urNode.setAttribute(Ytag, Double.toString(ur.getY()));

            XmlNode llNode = node.addChild(LLtag);
            Point2D ll = bounds.getLowerLeft();
            llNode.setAttribute(Xtag, Double.toString(ll.getX()));
            llNode.setAttribute(Ytag, Double.toString(ll.getY()));

            XmlNode lrNode = node.addChild(LRtag);
            Point2D lr = bounds.getLowerRight();
            lrNode.setAttribute(Xtag, Double.toString(lr.getX()));
            lrNode.setAttribute(Ytag, Double.toString(lr.getY()));
        }
    }
View Full Code Here

        if (cropBounds.isAngleOnly()) {
            // NOTE: we must clone PlanarImage.getBounds() since it returns a reference to an object
            Rectangle sourceBounds = new Rectangle(sourceImage.getBounds());

            if (cropBounds.getAngle() != 0) {
                Point2D center = new Point2D.Double(sourceBounds.getCenterX(), sourceBounds.getCenterY());

                sourceBounds = AffineTransform.getRotateInstance(-cropBounds.getAngle(),
                                                                 center.getX(),
                                                                 center.getY()).createTransformedShape(sourceBounds).getBounds();
            }

            return new Dimension(sourceBounds.width,
                                 sourceBounds.height);
        } else
View Full Code Here

        // Rotate
        if (cropBounds.getAngle() != 0) {
            Rectangle2D bounds = transform.createTransformedShape(sourceBounds).getBounds2D();

            Point2D center = new Point2D.Double(bounds.getCenterX(), bounds.getCenterY());

            transform.preConcatenate(AffineTransform.getRotateInstance(-cropBounds.getAngle(),
                                                                       center.getX(),
                                                                       center.getY()));

            bounds = transform.createTransformedShape(sourceBounds).getBounds2D();
            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()));
        }

        return transform;
    }
View Full Code Here

        AffineTransform completeInputTransform = inputTransform;

        if (!completeInputTransform.isIdentity()) {
            AffineTransform transform = completeInputTransform;

            Point2D zero = transform.transform(new Point2D.Double(0, 0), null);
            Point2D one = transform.transform(new Point2D.Double(1, 1), null);

            double dx = one.getX() - zero.getX();
            double dy = one.getY() - zero.getY();
            double scale = Math.sqrt(dx*dx + dy*dy)/Math.sqrt(2.0);

            if (!cheapScale && scale <= 0.5) {
                int level = 0;
                while(scale <= 1/(double) MIP_SCALE_RATIO) {
View Full Code Here

    CropBounds adjustWidth(CropBounds bad) {
        if (isNoConstraint()) {
            return bad;
        }
        double ratio = getAspectRatio();
        Point2D center = bad.getCenter();
        double height = bad.getHeight();
        double width = height / ratio;
        double angle = bad.getAngle();
        CropBounds good = new CropBounds(
            center, width, height, angle
View Full Code Here

    CropBounds adjustHeight(CropBounds bad) {
        if (isNoConstraint()) {
            return bad;
        }
        double ratio = getAspectRatio();
        Point2D center = bad.getCenter();
        double width = bad.getWidth();
        double height = width * ratio;
        double angle = bad.getAngle();
        CropBounds good = new CropBounds(
            center, width, height, angle
View Full Code Here

    private Dimension getInferredImageSize() {
        Dimension size = overlay.getUnderlayBounds().getSize();
        if (xform == null) {
            return size;
        }
        Point2D ul = new Point(0, 0);
        Point2D ll = new Point(0, size.height);
        Point2D ur = new Point(size.width, 0);
        try {
            ul = xform.inverseTransform(ul, null);
            ll = xform.inverseTransform(ll, null);
            ur = xform.inverseTransform(ur, null);
        }
        catch (NoninvertibleTransformException e) {
            return size;
        }
        double width = Math.sqrt(
            (ur.getX() - ul.getX()) * (ur.getX() - ul.getX()) +
            (ur.getY() - ul.getY()) * (ur.getY() - ul.getY())
        );
        double height = Math.sqrt(
            (ll.getX() - ul.getX()) * (ll.getX() - ul.getX()) +
            (ll.getY() - ul.getY()) * (ll.getY() - ul.getY())
        );
View Full Code Here

            CloneContour cloneContour = (CloneContour) c;

            // This is the mask for the clone operation:
            final Contour contour = cloneContour;
            final Point2D translation = contour.getTranslation();

            // And this is the extra point that says where to clone from:
            final Point2D clonePoint = cloneContour.getClonePoint();

            Point2D source = new Point2D.Double(clonePoint.getX() + (translation != null ? translation.getX() : 0),
                                                clonePoint.getY() + (translation != null ? translation.getY() : 0));

            source = rendering.getInputTransform().transform(source, null);

            final Rectangle bounds = contour.getOuterShape().getBounds();
            Point2D target = new Point2D.Double(bounds.getCenterX() + (translation != null ? translation.getX() : 0),
                                                bounds.getCenterY() + (translation != null ? translation.getY() : 0));
            target = rendering.getInputTransform().transform(target, null);

            int dx = (int) (target.getX() - source.getX());
            int dy = (int) (target.getY() - source.getY());

            ParameterBlock pb = new ParameterBlock();
            pb.addSource(back);
            pb.add((float) dx);
            pb.add((float) dy);
View Full Code Here

TOP

Related Classes of java.awt.geom.Point2D

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.