void setPoints() { super.setPoints(); int dir = 0; if (abs(dx) > abs(dy)) { dir = -sign(dx) * sign(dy); point2.y = point1.y; } else { dir = sign(dy) * sign(dx); point2.x = point1.x; } if (dir == 0) dir = 1; calcLeads(16); cathode = newPointArray(2); Point pa[] = newPointArray(2); interpPoint2(lead1, lead2, pa[0], pa[1], 0, hs); interpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs); poly = createPolygon(pa[0], pa[1], lead2); gate = newPointArray(2); double leadlen = (dn - 16) / 2; int gatelen = sim.gridSize; gatelen += leadlen % sim.gridSize; if (leadlen < gatelen) { x2 = x; y2 = y; return; } interpPoint(lead2, point2, gate[0], gatelen / leadlen, gatelen * dir); interpPoint(lead2, point2, gate[1], gatelen / leadlen, sim.gridSize * 2 * dir); }