checkpoint
[slipway.git] / src / edu / berkeley / slipway / gui / GuiCell.java
index 7f31383..c4273f9 100644 (file)
@@ -11,7 +11,8 @@ public class GuiCell {
     public static final int LOCAL_WIRE_COLOR  = 0x000FF000;
     public static final int XGATE_COLOR       = 0x00800000;
     public static final int YGATE_COLOR       = 0x00000080;
-    double MAIN_AREA = 0.75;
+
+    private static final int LOCAL_ROUTING_CHANNEL_WIDTH = 7;
 
     private final Fpslic.Cell fpslicCell;
     private GuiGate xgate = new GuiGate();
@@ -49,44 +50,46 @@ 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);
+        if (xgate.disabled && ygate.disabled) return;
 
-        R body = r;
-        g.color(BODY_COLOR);
+        R gateArea =
+            xgate.gateArea = 
+            ygate.gateArea = 
+            r.plus(12+LOCAL_ROUTING_CHANNEL_WIDTH,
+                   12+LOCAL_ROUTING_CHANNEL_WIDTH,
+                   -(4+LOCAL_ROUTING_CHANNEL_WIDTH),
+                   -(4+LOCAL_ROUTING_CHANNEL_WIDTH));
 
-        R gateArea = body.plus(12+N, 12+N, -(4+N), -(4+N));
         double factor = gateArea.width()/2;
-        R ygater = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(0, 0, -factor, -factor);
-        R xgater = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(factor, 0, 0, -factor);
+        xgate.r = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(factor, 0, 0, -factor);
+        ygate.r = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(0, 0, -factor, -factor);
 
+        P xip   = r.corner(fpslicCell.xi());
+        P yip   = r.corner(fpslicCell.yi());
         R xring = gateArea.plus(-4, -4, 4, 4);
         R yring = gateArea.plus(-6, -6, 6, 6);
-        P xip = r.corner(fpslicCell.xi());
-        P yip = r.corner(fpslicCell.yi());
-
         xgate.rotation(fpslicCell.yi());
-        xgate.gateArea = gateArea;
-        xgate.r = xgater;
+        ygate.rotation(fpslicCell.yi());
         if (xip != null) xgate.route(g, xip, xring, 0, XGATE_COLOR);
         if (yip != null) xgate.route(g, yip, yring, 2, YGATE_COLOR);
-
-        ygate.rotation(fpslicCell.yi());
-        ygate.gateArea = gateArea;
-        ygate.r = ygater;
         if (xip != null) ygate.route(g, xip, xring, 2, XGATE_COLOR);
         if (yip != null) ygate.route(g, yip, yring, 0, YGATE_COLOR);
 
+        drawWin(g, r);
+        drawGates(g);
+    }
+
+    private void drawWin(G g, R r) {
         int layer = fpslicCell.wi() - L0;
-        P p2 = r.corner(SW).translate(2*(layer+1), 2*(layer+1));
-        R r2 = r.plus(2*(layer+1), 2*(layer+1), -2*(layer+1), -2*(layer+1));
-        ygate.route(g, p2, r2, 1, LOCAL_WIRE_COLOR);
-        xgate.route(g, p2, r2, 1, LOCAL_WIRE_COLOR);
+        P   wip   = r.corner(SW).translate(2*(layer+1), 2*(layer+1));
+        R   wring = r.plus(2*(layer+1), 2*(layer+1), -2*(layer+1), -2*(layer+1));
+        ygate.route(g, wip, wring, 1, LOCAL_WIRE_COLOR);
+        xgate.route(g, wip, wring, 1, LOCAL_WIRE_COLOR);
+    }
 
+    private void drawGates(G g) {
         xgate.draw(g, XGATE_COLOR);
         ygate.draw(g, YGATE_COLOR);
     }
+
 }
\ No newline at end of file