Logo Search packages:      
Sourcecode: javamorph version File versions  Download package

void javamorph::CFrame::scalePoint ( Point  p  )  [inline]

Scale a screen point to a picture point.

Parameters:
p Point in screen resolution units.

Definition at line 163 of file CFrame.java.

References getImageBounds(), and image.

Referenced by javamorph::CPolygonDecorator::mouseDragged(), javamorph::CMeshDecorator::mouseDragged(), javamorph::CPolygonDecorator::mouseMoved(), and javamorph::CMeshDecorator::mouseMoved().

                                   {
        /* Picture area on JComponent. */
        Rectangle bounds = getImageBounds();
        /* Picture's own size. */
        int w = image.getWidth(), h = image.getHeight();
        /* Scale. */
        double x, y;
        x = (p.x - bounds.x) * w / bounds.width;
        y = (p.y - bounds.y) * h / bounds.height;
        x = Math.max(0, Math.min(w, x));
        y = Math.max(0, Math.min(h, y));
        p.x = (int)x;
        p.y = (int)y;
        /* Limit relating the picture's own size. */
        p.x = Math.max(0, Math.min(image.getWidth() - 1, p.x));
        p.y = Math.max(0, Math.min(image.getHeight() - 1, p.y));
    }


Generated by  Doxygen 1.6.0   Back to index