X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fslipway%2Fgui%2FGuiGate.java;h=6392e1a2df4c5ef66ffb36aebbe1bcff7b26e3c6;hb=f6f476bd63c268a2dbcc09c85f79dbc807a74ba3;hp=b12366cf5e128d3dee3482f891a73fbe7979ca96;hpb=ef1ceb0816c8c8a661db6809dc629ceac764ad13;p=slipway.git diff --git a/src/edu/berkeley/slipway/gui/GuiGate.java b/src/edu/berkeley/slipway/gui/GuiGate.java index b12366c..6392e1a 100644 --- a/src/edu/berkeley/slipway/gui/GuiGate.java +++ b/src/edu/berkeley/slipway/gui/GuiGate.java @@ -9,14 +9,15 @@ import static com.atmel.fpslic.FpslicConstants.*; public class GuiGate { + private final GuiCell cell; private GeneralPath gp = new GeneralPath(); int rotation = 1; - R gateArea; R r; boolean disabled = false; - public GuiGate() { + public GuiGate(GuiCell cell) { + this.cell = cell; gp.moveTo(29.141f, 36.301f); gp.lineTo(29.141f, 36.301f-7.161f); gp.curveTo(27.71f, 11.24f, 23.413f, 9.45f, 14.82f, 0.5f); @@ -36,15 +37,15 @@ public class GuiGate { gp.transform(AffineTransform.getScaleInstance(1.0/factor, -1.0/factor)); } - public void draw(G g, int color) { + public void draw(G g, int color, int fill) { if (disabled) return; g.pushTransform(); - g.g.translate(gateArea.cx(), gateArea.cy()); + g.g.translate(cell.gateArea.cx(), cell.gateArea.cy()); g.g.rotate((2 * Math.PI * rotation)/4); - g.g.translate(-1 * gateArea.cx(), -1 * gateArea.cy()); + g.g.translate(-1 * cell.gateArea.cx(), -1 * cell.gateArea.cy()); AffineTransform at = AffineTransform.getTranslateInstance(r.cx(), r.cy()); at.scale(r.getWidth(), r.getHeight()); - g.color(0xffffffff); + g.color(fill); g.g.fill(gp.createTransformedShape(at)); g.color(color); g.g.draw(gp.createTransformedShape(at)); @@ -53,18 +54,18 @@ public class GuiGate { public P getInput(int index) { AffineTransform at = new AffineTransform(); - at.translate(gateArea.cx(), gateArea.cy()); + at.translate(cell.gateArea.cx(), cell.gateArea.cy()); at.rotate((2 * Math.PI * rotation)/4); - at.translate(-1 * gateArea.cx(), -1 * gateArea.cy()); + at.translate(-1 * cell.gateArea.cx(), -1 * cell.gateArea.cy()); return new P(r.minx() + ((index + 1) * r.width()) / 4, r.miny() - 3).transform(at); } public P getInputDest(int index) { AffineTransform at = new AffineTransform(); - at.translate(gateArea.cx(), gateArea.cy()); + at.translate(cell.gateArea.cx(), cell.gateArea.cy()); at.rotate((2 * Math.PI * rotation)/4); - at.translate(-1 * gateArea.cx(), -1 * gateArea.cy()); + at.translate(-1 * cell.gateArea.cx(), -1 * cell.gateArea.cy()); return new P(r.minx() + ((index + 1) * r.width()) / 4, r.miny() + r.height()/2).transform(at); }