當前位置: 首頁>>代碼示例>>Java>>正文


Java AffineTransform.inverseTransform方法代碼示例

本文整理匯總了Java中java.awt.geom.AffineTransform.inverseTransform方法的典型用法代碼示例。如果您正苦於以下問題:Java AffineTransform.inverseTransform方法的具體用法?Java AffineTransform.inverseTransform怎麽用?Java AffineTransform.inverseTransform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.AffineTransform的用法示例。


在下文中一共展示了AffineTransform.inverseTransform方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createImageProjected

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
 * Modify the GeometricLayer so the layer coordinate system matches the image coordinate system ("pixel" projection).
 */
public static GeometryImage createImageProjected(GeometryImage layer, AffineTransform geoTransform) {
    for(Geometry geom:layer.geoms){
        for(Coordinate pos:geom.getCoordinates()){
            Point2D.Double temp=new Point2D.Double();
            try {
	geoTransform.inverseTransform(new Point2D.Double(pos.x, pos.y),temp);
} catch (NoninvertibleTransformException e) {
	e.printStackTrace();
}
            pos.x=temp.x;
            pos.y=temp.y;
        }
    }
    return layer;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:19,代碼來源:GeometryImage.java

示例2: pixellate

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
 * !!! not used currently, but might be by getPixelbounds?
 */
public void pixellate(FontRenderContext renderFRC, Point2D loc, Point pxResult) {
    if (renderFRC == null) {
        renderFRC = frc;
    }

    // it is a total pain that you have to copy the transform.

    AffineTransform at = renderFRC.getTransform();
    at.transform(loc, loc);
    pxResult.x = (int)loc.getX(); // but must not behave oddly around zero
    pxResult.y = (int)loc.getY();
    loc.setLocation(pxResult.x, pxResult.y);
    try {
        at.inverseTransform(loc, loc);
    }
    catch (NoninvertibleTransformException e) {
        throw new IllegalArgumentException("must be able to invert frc transform");
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:StandardGlyphVector.java

示例3: doZoom

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
 	Zoom by factor and center on point p.
 	@param p point to center on.
 	@param factor Factor to zoom by.
 */
public void doZoom( Point2D p, double factor ) {
	AffineTransform ATrans = new AffineTransform();
	ATrans.scale( zoom, zoom );
	Insets insets = getInsets();
	Rectangle rect = getVisibleRect();
	Dimension dim = getParent().getSize();
	if( dim.width>rect.width) rect.width = dim.width;
	if( dim.height>rect.height) rect.height = dim.height;
	rect.width -= insets.left + insets.right;
	rect.height -= insets.top + insets.bottom;
	double nX = (p.getX() - insets.left - (rect.width/(2.*factor)));
	double nY = ( p.getY() - insets.top - rect.height/(2.*factor));
	Point2D newP = null;
	try {
		newP = ATrans.inverseTransform( new Point2D.Double(nX, nY), null );
	} catch (Exception ex ) {
		return;
	}
	ATrans.scale( factor, factor );
	zoom *= factor;
	newP = ATrans.transform( newP, null );
	int newX = (int)newP.getX(); // + insets.left;
	int newY = (int)newP.getY(); // + insets.top;
	invalidate();
	scrollPane.validate();
	JScrollBar sb = scrollPane.getHorizontalScrollBar();
	sb.setValue(newX);
	sb = scrollPane.getVerticalScrollBar();
	sb.setValue(newY);
	revalidate();

	//If this is MapApp Auto Focus
	if (app instanceof MapApp) {
		((MapApp) app).autoFocus();
	}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:42,代碼來源:XMap.java

示例4: getImageRegion

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
 * Returns a rectangle in image coordinates that may be required
 * in order to draw the given image into the given clipping region
 * through a pair of AffineTransforms.  In addition, horizontal and
 * vertical padding factors for antialising and interpolation may
 * be used.
 */
private static Rectangle getImageRegion(RenderedImage img,
                                        Region compClip,
                                        AffineTransform transform,
                                        AffineTransform xform,
                                        int padX, int padY) {
    Rectangle imageRect =
        new Rectangle(img.getMinX(), img.getMinY(),
                      img.getWidth(), img.getHeight());

    Rectangle result = null;
    try {
        double p[] = new double[8];
        p[0] = p[2] = compClip.getLoX();
        p[4] = p[6] = compClip.getHiX();
        p[1] = p[5] = compClip.getLoY();
        p[3] = p[7] = compClip.getHiY();

        // Inverse transform the output bounding rect
        transform.inverseTransform(p, 0, p, 0, 4);
        xform.inverseTransform(p, 0, p, 0, 4);

        // Determine a bounding box for the inverse transformed region
        double x0,x1,y0,y1;
        x0 = x1 = p[0];
        y0 = y1 = p[1];

        for (int i = 2; i < 8; ) {
            double pt = p[i++];
            if (pt < x0)  {
                x0 = pt;
            } else if (pt > x1) {
                x1 = pt;
            }
            pt = p[i++];
            if (pt < y0)  {
                y0 = pt;
            } else if (pt > y1) {
                y1 = pt;
            }
        }

        // This is padding for anti-aliasing and such.  It may
        // be more than is needed.
        int x = (int)x0 - padX;
        int w = (int)(x1 - x0 + 2*padX);
        int y = (int)y0 - padY;
        int h = (int)(y1 - y0 + 2*padY);

        Rectangle clipRect = new Rectangle(x,y,w,h);
        result = clipRect.intersection(imageRect);
    } catch (NoninvertibleTransformException nte) {
        // Worst case bounds are the bounds of the image.
        result = imageRect;
    }

    return result;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:65,代碼來源:SunGraphics2D.java


注:本文中的java.awt.geom.AffineTransform.inverseTransform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。