X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fslipway%2Fgui%2FGuiCell.java;h=ebd3044ae4566b853a9e590b697252fd297a19d3;hb=d04562880cfecf6fdaf5eab0e0da92cab8225e04;hp=10992e9b3ffde1d23695b79c369f41f8ed9f84dd;hpb=d50d9adb6825ca0c4e86cdf1ca529911b97c23a9;p=slipway.git diff --git a/src/edu/berkeley/slipway/gui/GuiCell.java b/src/edu/berkeley/slipway/gui/GuiCell.java index 10992e9..ebd3044 100644 --- a/src/edu/berkeley/slipway/gui/GuiCell.java +++ b/src/edu/berkeley/slipway/gui/GuiCell.java @@ -50,11 +50,15 @@ public class GuiCell { private void drawBody(G g, R r) { if (xgate == null && ygate == null) return; + + int N = 7; + int TSIZE = 10; + double TSQR = TSIZE / Math.sqrt(2.0); + R body = r; g.color(BODY_COLOR); R xgater = null; R ygater = null; - int N = 7; R gateArea = body.plus(12+N, 12+N, -(4+N), -(4+N)); if (xgate==null) ygater = gateArea; else if (ygate==null) xgater = gateArea; @@ -66,36 +70,19 @@ public class GuiCell { R xring = gateArea.plus(-4, -4, 4, 4); R yring = gateArea.plus(-6, -6, 6, 6); - - int rot = 0; - switch (fpslicCell.yi()) { - case NORTH: rot = 2; break; - case SOUTH: rot = 0; break; - case WEST: rot = 3; break; - case EAST: rot = 1; break; - default: rot = 0; - } if (xgate != null) { - xgate.rotation = rot; + xgate.rotation(fpslicCell.yi()); xgate.gateArea = gateArea; xgate.r = xgater; } if (ygate != null) { - ygate.rotation = rot; + ygate.rotation(fpslicCell.yi()); ygate.gateArea = gateArea; ygate.r = ygater; } - int TSIZE = 10; - double TSQR = TSIZE / Math.sqrt(2.0); g.color(XGATE_COLOR); - P p = null; - switch (fpslicCell.xi()) { - case SW: p = new P(r.minx(), r.miny()); break; - case SE: p = new P(r.maxx(), r.miny()); break; - case NW: p = new P(r.minx(), r.maxy()); break; - case NE: p = new P(r.maxx(), r.maxy()); break; - } + P p = r.corner(fpslicCell.xi()); if (p!=null) { if (ygate != null) { g.route(p, xring, ygate.getInput(1)); @@ -107,14 +94,8 @@ public class GuiCell { } } - p = null; + p = r.corner(fpslicCell.yi()); g.color(YGATE_COLOR); - switch (fpslicCell.yi()) { - case NORTH: p = new P(r.cx(), r.maxy()); break; - case SOUTH: p = new P(r.cx(), r.miny()); break; - case WEST: p = new P(r.minx(), r.cy()); break; - case EAST: p = new P(r.maxx(), r.cy()); break; - } if (p!=null) { if (ygate != null) { g.route(p, yring, ygate.getInput(0));