updates that were lying around but never got checked in; includes reorg of gui
[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 edu.berkeley.slipway.*;
5 import java.awt.*;
6 import java.awt.geom.*;
7 import java.awt.event.*;
8 import java.awt.color.*;
9 import org.ibex.util.*;
10 import java.io.*;
11 import java.util.*;
12 import javax.swing.*;
13
14 /** a point, since Java2D's Point2D class sucks rocks */
15 public class P {
16
17     public final double x;
18     public final double y;
19
20     public P(double x, double y) { this.x = x; this.y = y; }
21     public P(Point2D p) { this(p.getX(), p.getY()); }
22     public double getX() { return x; }
23     public double getY() { return y; }
24
25     public P transform(AffineTransform a) {
26         Point2D me = new Point2D.Double(x, y);
27         return new P(a.transform(me, me));
28     }
29     public P inverseTransform(AffineTransform a) {
30         try {
31             Point2D me = new Point2D.Double(x, y);
32             return new P(a.inverseTransform(me, me));
33         } catch (Exception e) {
34             throw new RuntimeException(e);
35         }
36     }
37
38     public P translate(double dx, double dy) {
39         return new P(dx+x, dy+y);
40     }
41
42     public P scale(double factor) {
43         return new P(x*factor, y*factor);
44     }
45 }