79c986e458903dd31e0689909e2017729536d5c1
[slipway.git] / src / edu / berkeley / slipway / gui / P.java
1 package edu.berkeley.slipway.gui;
2
3 import static com.atmel.fpslic.FpslicConstants.*;
4 import static com.atmel.fpslic.FpslicUtil.*;
5 import edu.berkeley.slipway.*;
6 import java.awt.*;
7 import java.awt.geom.*;
8 import java.awt.event.*;
9 import java.awt.color.*;
10 import org.ibex.util.*;
11 import java.io.*;
12 import java.util.*;
13 import javax.swing.*;
14
15 /** a point, since Java2D's Point2D class sucks rocks */
16 public class P {
17
18     public final double x;
19     public final double y;
20
21     public P(double x, double y) { this.x = x; this.y = y; }
22     public P(Point2D p) { this(p.getX(), p.getY()); }
23     public double getX() { return x; }
24     public double getY() { return y; }
25
26     public P transform(AffineTransform a) {
27         Point2D me = new Point2D.Double(x, y);
28         return new P(a.transform(me, me));
29     }
30     public P inverseTransform(AffineTransform a) {
31         try {
32             Point2D me = new Point2D.Double(x, y);
33             return new P(a.inverseTransform(me, me));
34         } catch (Exception e) {
35             throw new RuntimeException(e);
36         }
37     }
38
39     public P translate(double dx, double dy) {
40         return new P(dx+x, dy+y);
41     }
42
43 }