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