1 package de.fzi.wim.guibase.graphview.lens;
2
3 import java.awt.geom.Point2D;
4
5 /***
6 * An implementation of the lens that allows transaltion.
7 */
8 public class TranslateLens extends AbstractLens {
9 /*** The translation along X axis. */
10 protected double m_translateX;
11 /*** The translation along Y axis. */
12 protected double m_translateY;
13
14 /***
15 * Creates a lens for zooming.
16 */
17 public TranslateLens() {
18 setTranslate(0,0);
19 }
20 /***
21 * Returns the translation along X axis.
22 *
23 * @return the translation along X axis
24 */
25 public double getTranslateX() {
26 return m_translateX;
27 }
28 /***
29 * Returns the translation along Y axis.
30 *
31 * @return the translation along Y axis
32 */
33 public double getTranslateY() {
34 return m_translateY;
35 }
36 /***
37 * Sets the new translation factory.
38 *
39 * @param translateX translation along X axis
40 * @param translateY translation along Y axis
41 */
42 public void setTranslate(double translateX,double translateY) {
43 m_translateX=translateX;
44 m_translateY=translateY;
45 fireLensUpdated();
46 }
47 /***
48 * Applies the lens to the point and modifies it according to the lens equations.
49 *
50 * @param point the point that will be modified
51 */
52 public void applyLens(Point2D point) {
53 point.setLocation(point.getX()+m_translateX,point.getY()+m_translateY);
54 }
55 /***
56 * Undoes the lens effect on the point.
57 *
58 * @param point the point that will be modified
59 */
60 public void undoLens(Point2D point) {
61 point.setLocation(point.getX()-m_translateX,point.getY()-m_translateY);
62 }
63 }