Example usage for java.awt.geom AffineTransform getScaleY

List of usage examples for java.awt.geom AffineTransform getScaleY

Introduction

In this page you can find the example usage for java.awt.geom AffineTransform getScaleY.

Prototype

public double getScaleY() 

Source Link

Document

Returns the m11 element of the 3x3 affine transformation matrix.

Usage

From source file:tufts.vue.LWComponent.java

/** @return our shape, full transformed into map coords and ultimate scale when drawn at 100% map zoom
 * this is used for portal clipping, and will be imperfect for some scaled shapes, such as RountRect's
 * This only works for raw shapes that are RectangularShapes -- other Shape types just return the bounding
 * box in map coordinates (e.g., a link shape)
 *///from   www  .  j a  va2  s .  com
public RectangularShape getMapShape() {
    // Will not work for shapes like RoundRect when scaled -- e..g, corner scaling will be off

    final Shape s = getZeroShape();
    //        if (getMapScale() != 1f && s instanceof RectangularShape) { // todo: do if any transform, not just scale
    if (s instanceof RectangularShape) {
        // todo: cache this: only need to updaate if location, size or scale changes
        // (Also, on the scale or location change of any parent!)
        RectangularShape rshape = (RectangularShape) s;
        rshape = (RectangularShape) rshape.clone();
        AffineTransform a = getZeroTransform();
        Point2D.Float loc = new Point2D.Float();
        a.transform(loc, loc);
        rshape.setFrame(loc.x, loc.y, rshape.getWidth() * a.getScaleX(), rshape.getHeight() * a.getScaleY());
        //System.out.println("TRANSFORMED SHAPE: " + rshape + " for " + this);
        return rshape;
    } else {
        return getMapBounds();
    }
}

From source file:uky.article.imageviewer.views.SWTImageCanvas.java

/**
 * Synchronize the scrollbar with the image. If the transform is out
 * of range, it will correct it. This function considers only following
 * factors :<b> transform, image size, client area</b>.
 *///from   w ww  . j a v a 2s.  com
public void syncScrollBars() {
    if (sourceImage == null) {
        redraw();
        return;
    }

    AffineTransform af = transform;
    double sx = af.getScaleX(), sy = af.getScaleY();
    double tx = af.getTranslateX(), ty = af.getTranslateY();
    if (tx > 0)
        tx = 0;
    if (ty > 0)
        ty = 0;

    ScrollBar horizontal = getHorizontalBar();
    horizontal.setIncrement(getClientArea().width / 100);
    horizontal.setPageIncrement(getClientArea().width);
    Rectangle imageBound = sourceImage.getBounds();
    int cw = getClientArea().width, ch = getClientArea().height;
    if (imageBound.width * sx > cw) { /* image is wider than client area */
        horizontal.setMaximum((int) (imageBound.width * sx));
        horizontal.setEnabled(true);
        if (((int) -tx) > horizontal.getMaximum() - cw)
            tx = -horizontal.getMaximum() + cw;
    } else { /* image is narrower than client area */
        horizontal.setEnabled(false);
        tx = (cw - imageBound.width * sx) / 2; //center if too small.
    }
    horizontal.setSelection((int) (-tx));
    horizontal.setThumb((getClientArea().width));

    ScrollBar vertical = getVerticalBar();
    vertical.setIncrement(getClientArea().height / 100);
    vertical.setPageIncrement((getClientArea().height));
    if (imageBound.height * sy > ch) { /* image is higher than client area */
        vertical.setMaximum((int) (imageBound.height * sy));
        vertical.setEnabled(true);
        if (((int) -ty) > vertical.getMaximum() - ch)
            ty = -vertical.getMaximum() + ch;
    } else { /* image is less higher than client area */
        vertical.setEnabled(false);
        ty = (ch - imageBound.height * sy) / 2; //center if too small.
    }
    vertical.setSelection((int) (-ty));
    vertical.setThumb((getClientArea().height));

    /* update transform. */
    af = AffineTransform.getScaleInstance(sx, sy);
    af.preConcatenate(AffineTransform.getTranslateInstance(tx, ty));
    transform = af;

    redraw();
}