comparison 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
comparison
equal deleted inserted replaced
534:e08777967bad 535:017371801479
1 package de.intevation.flys.client.shared;
2
3 import java.io.Serializable;
4
5
6 /**
7 * This object supports a linear transformation to transform xy coordinates into
8 * an other coordinate system based on scale and translation values.
9 *
10 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
11 */
12 public class Transform2D implements Serializable {
13
14 protected double sx;
15 protected double sy;
16
17 protected double tx;
18 protected double ty;
19
20
21 public Transform2D() {
22 }
23
24
25 /**
26 * Creates a new transformation with scale and translation factors.
27 *
28 * @param sx The scale factor for the x axis.
29 * @param sy The scale factor for the y axis.
30 * @param tx The translation factor for the x axis.
31 * @param ty The translation factor for the y axis.
32 */
33 public Transform2D(double sx, double sy, double tx, double ty) {
34 this.sx = sx;
35 this.sy = sy;
36 this.tx = tx;
37 this.ty = ty;
38 }
39
40
41 /**
42 * Transforms the pixel x and y into a new coordinate system based on the
43 * scale and translation values specified in the constructor.
44 */
45 public double[] transform(double x, double y) {
46 double resX = sx * x + tx;
47 double resY = sy * y + ty;
48
49 return new double[] { resX, resY };
50 }
51 }
52 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org