1 package edu.berkeley.slipway.gui;
3 import com.atmel.fpslic.*;
5 import java.awt.geom.*;
6 import java.awt.event.*;
7 import java.awt.color.*;
11 private GeneralPath gp = new GeneralPath();
14 gp.moveTo(29.141f, 36.301f);
15 gp.lineTo(29.141f, 36.301f-7.161f);
16 gp.curveTo(27.71f, 11.24f, 23.413f, 9.45f, 14.82f, 0.5f);
17 gp.curveTo(6.229f, 9.45f, 1.932f, 11.24f, 0.5f, 29.141f);
18 gp.lineTo(0.5f, 29.141f+7.161f);
20 float y = 29.141f+7.161f;
21 gp.curveTo(5.729f+x, -1.789f+y, 6.444f+x, -2.686f+y, 14.32f+x, -3.58f+y);
22 gp.curveTo(22.697f, 33.616f, 23.413f, 34.512f, 29.141f, 36.301f);
23 double minx = gp.getBounds2D().getMinX();
24 double miny = gp.getBounds2D().getMinY();
25 gp.transform(AffineTransform.getTranslateInstance(-minx, -miny));
26 double width = gp.getBounds2D().getWidth();
27 double height = gp.getBounds2D().getHeight();
28 double factor = Math.max(width, height);
29 gp.transform(AffineTransform.getTranslateInstance(-width/2, -height/2));
30 gp.transform(AffineTransform.getScaleInstance(1.0/factor, -1.0/factor));
37 public void draw(G g, int color) {
39 g.g.translate(gateArea.cx(), gateArea.cy());
40 g.g.rotate((2 * Math.PI * rotation)/4);
41 g.g.translate(-1 * gateArea.cx(), -1 * gateArea.cy());
42 AffineTransform at = AffineTransform.getTranslateInstance(r.cx(), r.cy());
43 at.scale(r.getWidth(), r.getHeight());
45 g.g.fill(gp.createTransformedShape(at));
47 g.g.draw(gp.createTransformedShape(at));
51 public P getInput(int index) {
52 AffineTransform at = new AffineTransform();
53 at.translate(gateArea.cx(), gateArea.cy());
54 at.rotate((2 * Math.PI * rotation)/4);
55 at.translate(-1 * gateArea.cx(), -1 * gateArea.cy());
56 return new P(r.minx() + ((index + 1) * r.width()) / 4,
57 r.miny() - 3).transform(at);
60 public P getInputDest(int index) {
61 AffineTransform at = new AffineTransform();
62 at.translate(gateArea.cx(), gateArea.cy());
63 at.rotate((2 * Math.PI * rotation)/4);
64 at.translate(-1 * gateArea.cx(), -1 * gateArea.cy());
65 return new P(r.minx() + ((index + 1) * r.width()) / 4,
66 r.miny() + r.height()/2).transform(at);