Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/shared/Transform2D.java @ 535:017371801479
Added a chart info service to fetch the info document for a specific chart from artifact server.
flys-client/trunk@2033 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 01 Jun 2011 08:15:58 +0000 |
parents | |
children | ea2191b1299d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/Transform2D.java Wed Jun 01 08:15:58 2011 +0000 @@ -0,0 +1,52 @@ +package de.intevation.flys.client.shared; + +import java.io.Serializable; + + +/** + * This object supports a linear transformation to transform xy coordinates into + * an other coordinate system based on scale and translation values. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class Transform2D implements Serializable { + + protected double sx; + protected double sy; + + protected double tx; + protected double ty; + + + public Transform2D() { + } + + + /** + * Creates a new transformation with scale and translation factors. + * + * @param sx The scale factor for the x axis. + * @param sy The scale factor for the y axis. + * @param tx The translation factor for the x axis. + * @param ty The translation factor for the y axis. + */ + public Transform2D(double sx, double sy, double tx, double ty) { + this.sx = sx; + this.sy = sy; + this.tx = tx; + this.ty = ty; + } + + + /** + * Transforms the pixel x and y into a new coordinate system based on the + * scale and translation values specified in the constructor. + */ + public double[] transform(double x, double y) { + double resX = sx * x + tx; + double resY = sy * y + ty; + + return new double[] { resX, resY }; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :