[
  {
    "path": ".gitignore",
    "content": "src/*.class\n"
  },
  {
    "path": "README.md",
    "content": "circuit-simulator\n=================\n\nThis is a version of Paul Falstad's circuit simulator (original available at <http://www.falstad.com/circuit/>) with the following improvements:\n\n* fixed import/export when running as an applet\n* it is now possible to save/load to/from a file when running as an application\n* the circuits that appear in the \"Circuit\" menu may now be bundled with the jar file.\n* many interface improvements: double click to edit, Delete key to delete a component, cursor changes to crosshairs when in place mode, Esc goes back to move/interact mode, ...\n* separated keyboard shortcuts from dump types (this makes it easier to configure shortcuts without changing the file format)\n* WireElm is now a subclass of ResistorElm (without this change, whenever you use two switches in parallel, you get the error \"voltage source/wire loop with no resistance\")\n* some cosmetic improvements (like starting with a white background as default)\n\ncompiling and building\n----------------------\n\nIf you have make installed, just `cd` to the *src* directory and run `make`, followed by a `make jar`\n\nIf not, compile with `javac *.java` and build the jar file with `jar cfm circuit.jar Manifest.txt *.class *.txt circuits/`\n\nrunning\n-------\n\nAs an application: `java -jar circuit.jar`\n\nIf you want to use the circuit simulator as an applet, create an html file and load the applet with:\n\n    <applet code=Circuit.class archive=circuit.jar width=600 height=50>\n        Sorry, you need a Java-enabled browser to see the simulation.\n        <param name=pause value=20>\n    </applet>\n\nIf you want to enable import/export of circuit files, you must define two javascript helper functions in the same page:\n\n* `exportCircuit(dump)`, whose first parameter is a string describing the circuit in the same format used for the circuit file.\n\n*  `importCircuit()`, which must return a string describing the circuit in the same format used for the circuit file.\n\nThe definition of those functions is up to you (for instance, you may copy the string to/from a textarea).\n\nterms and conditions\n--------------------\n\nThe terms and conditions for the original code still apply. Check <http://www.falstad.com/licensing.html> before redistributing or modifying the code. You must always consult the original licensing information but, in case the link is unavailable, here is a copy of the original license (as of 2013-05-08):\n\n    You have permission to use these applets in a classroom setting or take\n    screenshots as long as the applets are unmodified. Modification or\n    redistribution for non-commercial purposes is allowed, as long as you\n    credit me (Paul Falstad) and provide a link to my page (the page you\n    found the applet(s) on, or http://www.falstad.com/mathphysics.html).\n\n    Contact me for any other uses. The source code for each applet is\n    generally available on that applet's web page, but some of the applets\n    use third-party source code that has restrictions.\n\n    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED\n    WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF\n    MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\n\nRodrigo Hausen's changes are in the public domain (but it would be nice if you credited me alongside Paul if you use this version).\n"
  },
  {
    "path": "src/ACRailElm.java",
    "content": "    class ACRailElm extends RailElm {\n\tpublic ACRailElm(int xx, int yy) { super(xx, yy, WF_AC); }\n\tClass getDumpClass() { return RailElm.class; }\n\tint getShortcut() { return 0; }\n    }\n"
  },
  {
    "path": "src/ACVoltageElm.java",
    "content": "    class ACVoltageElm extends VoltageElm {\n\tpublic ACVoltageElm(int xx, int yy) { super(xx, yy, WF_AC); }\n\tClass getDumpClass() { return VoltageElm.class; }\n    }\n"
  },
  {
    "path": "src/ADCElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass ADCElm extends ChipElm {\n    public ADCElm(int xx, int yy) { super(xx, yy); }\n    public ADCElm(int xa, int ya, int xb, int yb, int f,\n\t\t  StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n    }\n    String getChipName() { return \"ADC\"; }\n    boolean needsBits() { return true; }\n    void setupPins() {\n\tsizeX = 2;\n\tsizeY = bits > 2 ? bits : 2;\n\tpins = new Pin[getPostCount()];\n\tint i;\n\tfor (i = 0; i != bits; i++) {\n\t    pins[i] = new Pin(bits-1-i, SIDE_E, \"D\" + i);\n\t    pins[i].output = true;\n\t}\n\tpins[bits]   = new Pin(0, SIDE_W, \"In\");\n\tpins[bits+1] = new Pin(sizeY-1, SIDE_W, \"V+\");\n\tallocNodes();\n    }\n    void execute() {\n\tint imax = (1<<bits)-1;\n\t// if we round, the half-flash doesn't work\n\tdouble val = imax*volts[bits]/volts[bits+1]; // + .5;\n\tint ival = (int) val;\n\tival = min(imax, max(0, ival));\n\tint i;\n\tfor (i = 0; i != bits; i++)\n\t    pins[i].value = ((ival & (1<<i)) != 0);\n    }\n    int getVoltageSourceCount() { return bits; }\n    int getPostCount() { return bits+2; }\n    int getDumpType() { return 167; }\n}\n    \n"
  },
  {
    "path": "src/AnalogSwitch2Elm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass AnalogSwitch2Elm extends AnalogSwitchElm {\n    public AnalogSwitch2Elm(int xx, int yy) {\n\tsuper(xx, yy);\n    }\n    public AnalogSwitch2Elm(int xa, int ya, int xb, int yb, int f,\n\t\t\t    StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n    }\n\n    final int openhs = 16;\n    Point swposts[], swpoles[], ctlPoint;\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(32);\n\tswposts = newPointArray(2);\n\tswpoles = newPointArray(2);\n\tinterpPoint2(lead1,  lead2,  swpoles[0], swpoles[1], 1, openhs);\n\tinterpPoint2(point1, point2, swposts[0], swposts[1], 1, openhs);\n\tctlPoint = interpPoint(point1, point2, .5, openhs);\n    }\n    int getPostCount() { return 4; }\n\n    void draw(Graphics g) {\n\tsetBbox(point1, point2, openhs);\n\n\t// draw first lead\n\tsetVoltageColor(g, volts[0]);\n\tdrawThickLine(g, point1, lead1);\n\n\t// draw second lead\n\tsetVoltageColor(g, volts[1]);\n\tdrawThickLine(g, swpoles[0], swposts[0]);\n\t    \n\t// draw third lead\n\tsetVoltageColor(g, volts[2]);\n\tdrawThickLine(g, swpoles[1], swposts[1]);\n\n\t// draw switch\n\tg.setColor(lightGrayColor);\n\tint position = (open) ? 1 : 0;\n\tdrawThickLine(g, lead1, swpoles[position]);\n\t    \n\tupdateDotCount();\n\tdrawDots(g, point1, lead1, curcount);\n\tdrawDots(g, swpoles[position], swposts[position], curcount);\n\tdrawPosts(g);\n    }\n\t\n    Point getPost(int n) {\n\treturn (n == 0) ? point1 : (n == 3) ? ctlPoint : swposts[n-1];\n    }\n    int getDumpType() { return 160; }\n\n    void calculateCurrent() {\n\tif (open)\n\t    current = (volts[0]-volts[2])/r_on;\n\telse\n\t    current = (volts[0]-volts[1])/r_on;\n    }\n\t\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n\tsim.stampNonLinear(nodes[2]);\n    }\n    void doStep() {\n\topen = (volts[3] < 2.5);\n\tif ((flags & FLAG_INVERT) != 0)\n\t    open = !open;\n\tif (open) {\n\t    sim.stampResistor(nodes[0], nodes[2], r_on);\n\t    sim.stampResistor(nodes[0], nodes[1], r_off);\n\t} else {\n\t    sim.stampResistor(nodes[0], nodes[1], r_on);\n\t    sim.stampResistor(nodes[0], nodes[2], r_off);\n\t}\n    }\n\t\n    boolean getConnection(int n1, int n2) {\n\tif (n1 == 3 || n2 == 3)\n\t    return false;\n\treturn true;\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"analog switch (SPDT)\";\n\tarr[1] = \"I = \" + getCurrentDText(getCurrent());\n    }\n}\n\n"
  },
  {
    "path": "src/AnalogSwitchElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass AnalogSwitchElm extends CircuitElm {\n    final int FLAG_INVERT = 1;\n    double resistance, r_on, r_off;\n    public AnalogSwitchElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tr_on = 20;\n\tr_off = 1e10;\n    }\n    public AnalogSwitchElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t   StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tr_on = 20;\n\tr_off = 1e10;\n\ttry {\n\t    r_on = new Double(st.nextToken()).doubleValue();\n\t    r_off = new Double(st.nextToken()).doubleValue();\n\t} catch (Exception e) { }\n\t\n    }\n    String dump() {\n\treturn super.dump() + \" \" + r_on + \" \" + r_off;\n    }\n    \n    int getDumpType() { return 159; }\n    boolean open;\n\t\n    Point ps, point3, lead3;\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(32);\n\tps = new Point();\n\tint openhs = 16;\n\tpoint3 = interpPoint(point1, point2, .5, -openhs);\n\tlead3  = interpPoint(point1, point2, .5, -openhs/2);\n    }\n\t\n    void draw(Graphics g) {\n\tint openhs = 16;\n\tint hs = (open) ? openhs : 0;\n\tsetBbox(point1, point2, openhs);\n\n\tdraw2Leads(g);\n\t    \n\tg.setColor(lightGrayColor);\n\tinterpPoint(lead1, lead2, ps, 1, hs);\n\tdrawThickLine(g, lead1, ps);\n\n\tsetVoltageColor(g, volts[2]);\n\tdrawThickLine(g, point3, lead3);\n\t    \n\tif (!open)\n\t    doDots(g);\n\tdrawPosts(g);\n    }\n    void calculateCurrent() {\n\tcurrent = (volts[0]-volts[1])/resistance;\n    }\n\t\n    // we need this to be able to change the matrix for each step\n    boolean nonLinear() { return true; }\n\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    void doStep() {\n\topen = (volts[2] < 2.5);\n\tif ((flags & FLAG_INVERT) != 0)\n\t    open = !open;\n\tresistance = (open) ? r_off : r_on;\n\tsim.stampResistor(nodes[0], nodes[1], resistance);\n    }\n    void drag(int xx, int yy) {\n\txx = sim.snapGrid(xx);\n\tyy = sim.snapGrid(yy);\n\tif (abs(x-xx) < abs(y-yy))\n\t    xx = x;\n\telse\n\t    yy = y;\n\tint q1 = abs(x-xx)+abs(y-yy);\n\tint q2 = (q1/2) % sim.gridSize;\n\tif (q2 != 0)\n\t    return;\n\tx2 = xx; y2 = yy;\n\tsetPoints();\n    }\n    int getPostCount() { return 3; }\n    Point getPost(int n) {\n\treturn (n == 0) ? point1 : (n == 1) ? point2 : point3;\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"analog switch\";\n\tarr[1] = open ? \"open\" : \"closed\";\n\tarr[2] = \"Vd = \" + getVoltageDText(getVoltageDiff());\n\tarr[3] = \"I = \" + getCurrentDText(getCurrent());\n\tarr[4] = \"Vc = \" + getVoltageText(volts[2]);\n    }\n    // we have to just assume current will flow either way, even though that\n    // might cause singular matrix errors\n    boolean getConnection(int n1, int n2) {\n\tif (n1 == 2 || n2 == 2)\n\t    return false;\n\treturn true;\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0) {\n\t    EditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t    ei.checkbox = new Checkbox(\"Normally closed\",\n\t\t\t\t       (flags & FLAG_INVERT) != 0);\n\t    return ei;\n\t}\n\tif (n == 1)\n\t    return new EditInfo(\"On Resistance (ohms)\", r_on, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Off Resistance (ohms)\", r_off, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0)\n\t    flags = (ei.checkbox.getState()) ?\n\t\t(flags | FLAG_INVERT) :\n\t\t(flags & ~FLAG_INVERT);\n\tif (n == 1 && ei.value > 0)\n\t    r_on = ei.value;\n\tif (n == 2 && ei.value > 0)\n\t    r_off = ei.value;\n    }\n}\n\n"
  },
  {
    "path": "src/AndGateElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class AndGateElm extends GateElm {\n\tpublic AndGateElm(int xx, int yy) { super(xx, yy); }\n\tpublic AndGateElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t  StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    \n\t    // 0=topleft, 1-10 = top curve, 11 = right, 12-21=bottom curve,\n\t    // 22 = bottom left\n\t    Point triPoints[] = newPointArray(23);\n\t    interpPoint2(lead1, lead2, triPoints[0], triPoints[22], 0, hs2);\n\t    int i;\n\t    for (i = 0; i != 10; i++) {\n\t\tdouble a = i*.1;\n\t\tdouble b = Math.sqrt(1-a*a);\n\t\tinterpPoint2(lead1, lead2,\n\t\t\t     triPoints[i+1], triPoints[21-i],\n\t\t\t     .5+a/2, b*hs2);\n\t    }\n\t    triPoints[11] = new Point(lead2);\n\t    if (isInverting()) {\n\t\tpcircle = interpPoint(point1, point2, .5+(ww+4)/dn);\n\t\tlead2 = interpPoint(point1, point2, .5+(ww+8)/dn);\n\t    }\n\t    gatePoly = createPolygon(triPoints);\n\t}\n\tString getGateName() { return \"AND gate\"; }\n\tboolean calcFunction() {\n\t    int i;\n\t    boolean f = true;\n\t    for (i = 0; i != inputCount; i++)\n\t\tf &= getInput(i);\n\t    return f;\n\t}\n\tint getDumpType() { return 150; }\n\tint getShortcut() { return '2'; }\n    }\n"
  },
  {
    "path": "src/AntennaElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class AntennaElm extends RailElm {\n\tpublic AntennaElm(int xx, int yy) { super(xx, yy, WF_DC); }\n\tpublic AntennaElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    waveform = WF_DC;\n\t}\n\tdouble fmphase;\n\tvoid stamp() {\n\t    sim.stampVoltageSource(0, nodes[0], voltSource);\n\t}\n\tvoid doStep() {\n\t    sim.updateVoltageSource(0, nodes[0], voltSource, getVoltage());\n\t}\n\tdouble getVoltage() {\n\t    fmphase += 2*pi*(2200+Math.sin(2*pi*sim.t*13)*100)*sim.timeStep;\n\t    double fm = 3*Math.sin(fmphase);\n\t    return Math.sin(2*pi*sim.t*3000)*(1.3+Math.sin(2*pi*sim.t*12))*3 +\n\t           Math.sin(2*pi*sim.t*2710)*(1.3+Math.sin(2*pi*sim.t*13))*3 +\n\t\t   Math.sin(2*pi*sim.t*2433)*(1.3+Math.sin(2*pi*sim.t*14))*3 + fm;\n\t}\n\tint getDumpType() { return 'A'; }\n\tint getShortcut() { return 0; }\n    }\n"
  },
  {
    "path": "src/BoxElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\nimport java.util.Vector;\n\nclass BoxElm extends GraphicElm {\n\n    public BoxElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tx2 = xx + 16;\n\ty2 = yy + 16;\n\tsetBbox(x, y, x2, y2);\n    }\n\n    public BoxElm(int xa, int ya, int xb, int yb, int f,\n\t\t   StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tx2 = xb;\n\ty2 = yb;\n/*\tif ( st.hasMoreTokens() )\n\t\tx = new Integer(st.nextToken()).intValue();\n\tif ( st.hasMoreTokens() )\n\t\ty = new Integer(st.nextToken()).intValue();\n\tif ( st.hasMoreTokens() )\n\t\tx2 = new Integer(st.nextToken()).intValue();\n\tif ( st.hasMoreTokens() )\n\t\ty2 = new Integer(st.nextToken()).intValue();*/\n\tsetBbox(x, y, x2, y2);\n    }\n\n    String dump() {\n\treturn super.dump();\n    }\n\n    int getDumpType() { return 'b'; }\n\n    void drag(int xx, int yy) {\n\tx = xx;\n\ty = yy;\n    }\n\n    void draw(Graphics g) {\n\t//g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\tg.setColor(needsHighlight() ? selectColor : Color.GRAY);\n\tsetBbox(x, y, x2, y2);\n\tif ( x < x2 && y < y2 )\n\t\tg.fillRect(x,y, x2-x, y2-y);\n\telse if ( x > x2 && y < y2 )\n\t\tg.fillRect(x2,y, x-x2, y2-y);\n\telse if ( x < x2 && y > y2 )\n\t\tg.fillRect(x, y2, x2-x, y-y2);\n\telse\n\t\tg.fillRect(x2, y2, x-x2, y-y2);\n    }\n\n    public EditInfo getEditInfo(int n) {\n\treturn null;\n    }\n\n    public void setEditValue(int n, EditInfo ei) {\n    }\n\n    void getInfo(String arr[]) {\n    }\n\n    @Override\n    int getShortcut() { return 0; }\n}\n\n"
  },
  {
    "path": "src/CC2Elm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class CC2Elm extends ChipElm {\n\tdouble gain;\n\tpublic CC2Elm(int xx, int yy) { super(xx, yy); gain = 1; }\n\tpublic CC2Elm(int xx, int yy, int g) { super(xx, yy); gain = g; }\n\tpublic CC2Elm(int xa, int ya, int xb, int yb, int f,\n\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    gain = new Double(st.nextToken()).doubleValue();\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + gain;\n\t}\n\tString getChipName() { return \"CC2\"; }\n\tvoid setupPins() {\n\t    sizeX = 2;\n\t    sizeY = 3;\n\t    pins = new Pin[3];\n\t    pins[0] = new Pin(0, SIDE_W, \"X\");\n\t    pins[0].output = true;\n\t    pins[1] = new Pin(2, SIDE_W, \"Y\");\n\t    pins[2] = new Pin(1, SIDE_E, \"Z\");\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = (gain == 1) ? \"CCII+\" : \"CCII-\";\n\t    arr[1] = \"X,Y = \" + getVoltageText(volts[0]);\n\t    arr[2] = \"Z = \" + getVoltageText(volts[2]);\n\t    arr[3] = \"I = \" + getCurrentText(pins[0].current);\n\t}\n\t//boolean nonLinear() { return true; }\n\tvoid stamp() {\n\t    // X voltage = Y voltage\n\t    sim.stampVoltageSource(0, nodes[0], pins[0].voltSource);\n\t    sim.stampVCVS(0, nodes[1], 1, pins[0].voltSource);\n\t    // Z current = gain * X current\n\t    sim.stampCCCS(0, nodes[2], pins[0].voltSource, gain);\n\t}\n\tvoid draw(Graphics g) {\n\t    pins[2].current = pins[0].current * gain;\n\t    drawChip(g);\n\t}\n\tint getPostCount() { return 3; }\n\tint getVoltageSourceCount() { return 1; }\n\tint getDumpType() { return 179; }\n    }\n\nclass CC2NegElm extends CC2Elm {\n    public CC2NegElm(int xx, int yy) { super(xx, yy, -1); }\n    Class getDumpClass() { return CC2Elm.class; }\n}\n"
  },
  {
    "path": "src/CapacitorElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class CapacitorElm extends CircuitElm {\n\tdouble capacitance;\n\tdouble compResistance, voltdiff;\n\tPoint plate1[], plate2[];\n\tpublic static final int FLAG_BACK_EULER = 2;\n\tpublic CapacitorElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    capacitance = 1e-5;\n\t}\n\tpublic CapacitorElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    capacitance = new Double(st.nextToken()).doubleValue();\n\t    voltdiff = new Double(st.nextToken()).doubleValue();\n\t}\n\tboolean isTrapezoidal() { return (flags & FLAG_BACK_EULER) == 0; }\n\tvoid setNodeVoltage(int n, double c) {\n\t    super.setNodeVoltage(n, c);\n\t    voltdiff = volts[0]-volts[1];\n\t}\n\tvoid reset() {\n\t    current = curcount = 0;\n\t    // put small charge on caps when reset to start oscillators\n\t    voltdiff = 1e-3;\n\t}\n\tint getDumpType() { return 'c'; }\n\tString dump() {\n\t    return super.dump() + \" \" + capacitance + \" \" + voltdiff;\n\t}\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    double f = (dn/2-4)/dn;\n\t    // calc leads\n\t    lead1 = interpPoint(point1, point2, f);\n\t    lead2 = interpPoint(point1, point2, 1-f);\n\t    // calc plates\n\t    plate1 = newPointArray(2);\n\t    plate2 = newPointArray(2);\n\t    interpPoint2(point1, point2, plate1[0], plate1[1], f, 12);\n\t    interpPoint2(point1, point2, plate2[0], plate2[1], 1-f, 12);\n\t}\n\t\n\tvoid draw(Graphics g) {\n\t    int hs = 12;\n\t    setBbox(point1, point2, hs);\n\t    \n\t    // draw first lead and plate\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, lead1);\n\t    setPowerColor(g, false);\n\t    drawThickLine(g, plate1[0], plate1[1]);\n\t    if (sim.powerCheckItem.getState())\n\t\tg.setColor(Color.gray);\n\n\t    // draw second lead and plate\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, point2, lead2);\n\t    setPowerColor(g, false);\n\t    drawThickLine(g, plate2[0], plate2[1]);\n\t    \n\t    updateDotCount();\n\t    if (sim.dragElm != this) {\n\t\tdrawDots(g, point1, lead1, curcount);\n\t\tdrawDots(g, point2, lead2, -curcount);\n\t    }\n\t    drawPosts(g);\n\t    if (sim.showValuesCheckItem.getState()) {\n\t\tString s = getShortUnitText(capacitance, \"F\");\n\t\tdrawValues(g, s, hs);\n\t    }\n\t}\n\tvoid stamp() {\n\t    // capacitor companion model using trapezoidal approximation\n\t    // (Norton equivalent) consists of a current source in\n\t    // parallel with a resistor.  Trapezoidal is more accurate\n\t    // than backward euler but can cause oscillatory behavior\n\t    // if RC is small relative to the timestep.\n\t    if (isTrapezoidal())\n\t\tcompResistance = sim.timeStep/(2*capacitance);\n\t    else\n\t\tcompResistance = sim.timeStep/capacitance;\n\t    sim.stampResistor(nodes[0], nodes[1], compResistance);\n\t    sim.stampRightSide(nodes[0]);\n\t    sim.stampRightSide(nodes[1]);\n\t}\n\tvoid startIteration() {\n\t    if (isTrapezoidal())\n\t\tcurSourceValue = -voltdiff/compResistance-current;\n\t    else\n\t\tcurSourceValue = -voltdiff/compResistance;\n\t    //System.out.println(\"cap \" + compResistance + \" \" + curSourceValue + \" \" + current + \" \" + voltdiff);\n\t}\n\tvoid calculateCurrent() {\n\t    double voltdiff = volts[0] - volts[1];\n\t    // we check compResistance because this might get called\n\t    // before stamp(), which sets compResistance, causing\n\t    // infinite current\n\t    if (compResistance > 0)\n\t\tcurrent = voltdiff/compResistance + curSourceValue;\n\t}\n\tdouble curSourceValue;\n\tvoid doStep() {\n\t    sim.stampCurrentSource(nodes[0], nodes[1], curSourceValue);\n \t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"capacitor\";\n\t    getBasicInfo(arr);\n\t    arr[3] = \"C = \" + getUnitText(capacitance, \"F\");\n\t    arr[4] = \"P = \" + getUnitText(getPower(), \"W\");\n\t    //double v = getVoltageDiff();\n\t    //arr[4] = \"U = \" + getUnitText(.5*capacitance*v*v, \"J\");\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Capacitance (F)\", capacitance, 0, 0);\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Trapezoidal Approximation\", isTrapezoidal());\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0 && ei.value > 0)\n\t\tcapacitance = ei.value;\n\t    if (n == 1) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags &= ~FLAG_BACK_EULER;\n\t\telse\n\t\t    flags |= FLAG_BACK_EULER;\n\t    }\n\t}\n\tint getShortcut() { return 'c'; }\n    }\n"
  },
  {
    "path": "src/ChipElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    abstract class ChipElm extends CircuitElm {\n\tint csize, cspc, cspc2;\n\tint bits;\n\tfinal int FLAG_SMALL = 1;\n\tfinal int FLAG_FLIP_X = 1024;\n\tfinal int FLAG_FLIP_Y = 2048;\n\tpublic ChipElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    if (needsBits())\n\t\tbits = (this instanceof DecadeElm) ? 10 : 4;\n\t    noDiagonal = true;\n\t    setupPins();\n\t    setSize(sim.smallGridCheckItem.getState() ? 1 : 2);\n\t}\n\tpublic ChipElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    if (needsBits())\n\t\tbits = new Integer(st.nextToken()).intValue();\n\t    noDiagonal = true;\n\t    setupPins();\n\t    setSize((f & FLAG_SMALL) != 0 ? 1 : 2);\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tif (pins[i].state) {\n\t\t    volts[i] = new Double(st.nextToken()).doubleValue();\n\t\t    pins[i].value = volts[i] > 2.5;\n\t\t}\n\t    }\n\t}\n\tboolean needsBits() { return false; }\n\tvoid setSize(int s) {\n\t    csize = s;\n\t    cspc = 8*s;\n\t    cspc2 = cspc*2;\n\t    flags &= ~FLAG_SMALL;\n\t    flags |= (s == 1) ? FLAG_SMALL : 0;\n\t}\n\tabstract void setupPins();\n\tvoid draw(Graphics g) {\n\t    drawChip(g);\n\t}\n\tvoid drawChip(Graphics g) {\n\t    int i;\n\t    Font f = new Font(\"SansSerif\", 0, 10*csize);\n\t    g.setFont(f);\n\t    FontMetrics fm = g.getFontMetrics();\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tPin p = pins[i];\n\t\tsetVoltageColor(g, volts[i]);\n\t\tPoint a = p.post;\n\t\tPoint b = p.stub;\n\t\tdrawThickLine(g, a, b);\n\t\tp.curcount = updateDotCount(p.current, p.curcount);\n\t\tdrawDots(g, b, a, p.curcount);\n\t\tif (p.bubble) {\n\t\t    g.setColor(sim.printableCheckItem.getState() ?\n\t\t\t       Color.white : Color.black);\n\t\t    drawThickCircle(g, p.bubbleX, p.bubbleY, 1);\n\t\t    g.setColor(lightGrayColor);\n\t\t    drawThickCircle(g, p.bubbleX, p.bubbleY, 3);\n\t\t}\n\t\tg.setColor(whiteColor);\n\t\tint sw = fm.stringWidth(p.text);\n\t\tg.drawString(p.text, p.textloc.x-sw/2,\n\t\t\t     p.textloc.y+fm.getAscent()/2);\n\t\tif (p.lineOver) {\n\t\t    int ya = p.textloc.y-fm.getAscent()/2;\n\t\t    g.drawLine(p.textloc.x-sw/2, ya, p.textloc.x+sw/2, ya);\n\t\t}\n\t    }\n\t    g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\t    drawThickPolygon(g, rectPointsX, rectPointsY, 4);\n\t    if (clockPointsX != null)\n\t\tg.drawPolyline(clockPointsX, clockPointsY, 3);\n\t    for (i = 0; i != getPostCount(); i++)\n\t\tdrawPost(g, pins[i].post.x, pins[i].post.y, nodes[i]);\n\t}\n\tint rectPointsX[], rectPointsY[];\n\tint clockPointsX[], clockPointsY[];\n\tPin pins[];\n\tint sizeX, sizeY;\n\tboolean lastClock;\n\tvoid drag(int xx, int yy) {\n\t    yy = sim.snapGrid(yy);\n\t    if (xx < x) {\n\t\txx = x; yy = y;\n\t    } else {\n\t\ty = y2 = yy;\n\t\tx2 = sim.snapGrid(xx);\n\t    }\n\t    setPoints();\n\t}\n\tvoid setPoints() {\n\t    if (x2-x > sizeX*cspc2 && this == sim.dragElm)\n\t\tsetSize(2);\n\t    int hs = cspc;\n\t    int x0 = x+cspc2; int y0 = y;\n\t    int xr = x0-cspc;\n\t    int yr = y0-cspc;\n\t    int xs = sizeX*cspc2;\n\t    int ys = sizeY*cspc2;\n\t    rectPointsX = new int[] { xr, xr+xs, xr+xs, xr };\n\t    rectPointsY = new int[] { yr, yr, yr+ys, yr+ys };\n\t    setBbox(xr, yr, rectPointsX[2], rectPointsY[2]);\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tPin p = pins[i];\n\t\tswitch (p.side) {\n\t\tcase SIDE_N: p.setPoint(x0, y0, 1, 0, 0, -1, 0, 0); break;\n\t\tcase SIDE_S: p.setPoint(x0, y0, 1, 0, 0,  1, 0, ys-cspc2);break;\n\t\tcase SIDE_W: p.setPoint(x0, y0, 0, 1, -1, 0, 0, 0); break;\n\t\tcase SIDE_E: p.setPoint(x0, y0, 0, 1,  1, 0, xs-cspc2, 0);break;\n\t\t}\n\t    }\n\t}\n\tPoint getPost(int n) {\n\t    return pins[n].post;\n\t}\n\tabstract int getVoltageSourceCount(); // output count\n\tvoid setVoltageSource(int j, int vs) {\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tPin p = pins[i];\n\t\tif (p.output && j-- == 0) {\n\t\t    p.voltSource = vs;\n\t\t    return;\n\t\t}\n\t    }\n\t    System.out.println(\"setVoltageSource failed for \" + this);\n\t}\n\tvoid stamp() {\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tPin p = pins[i];\n\t\tif (p.output)\n\t\t    sim.stampVoltageSource(0, nodes[i], p.voltSource);\n\t    }\n\t}\n\tvoid execute() {}\n\tvoid doStep() {\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tPin p = pins[i];\n\t\tif (!p.output)\n\t\t    p.value = volts[i] > 2.5;\n\t    }\n\t    execute();\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tPin p = pins[i];\n\t\tif (p.output)\n\t\t    sim.updateVoltageSource(0, nodes[i], p.voltSource,\n\t\t\t\t\tp.value ? 5 : 0);\n\t    }\n\t}\n\tvoid reset() {\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tpins[i].value = false;\n\t\tpins[i].curcount = 0;\n\t\tvolts[i] = 0;\n\t    }\n\t    lastClock = false;\n\t}\n\t\n\tString dump() {\n\t    int t = getDumpType();\n\t    String s = super.dump();\n\t    if (needsBits())\n\t\ts += \" \" + bits;\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tif (pins[i].state)\n\t\t    s += \" \" + volts[i];\n\t    }\n\t    return s;\n\t}\n\t\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = getChipName();\n\t    int i, a = 1;\n\t    for (i = 0; i != getPostCount(); i++) {\n\t\tPin p = pins[i];\n\t\tif (arr[a] != null)\n\t\t    arr[a] += \"; \";\n\t\telse\n\t\t    arr[a] = \"\";\n\t\tString t = p.text;\n\t\tif (p.lineOver)\n\t\t    t += '\\'';\n\t\tif (p.clock)\n\t\t    t = \"Clk\";\n\t\tarr[a] += t + \" = \" + getVoltageText(volts[i]);\n\t\tif (i % 2 == 1)\n\t\t    a++;\n\t    }\n\t}\n\tvoid setCurrent(int x, double c) {\n\t    int i;\n\t    for (i = 0; i != getPostCount(); i++)\n\t\tif (pins[i].output && pins[i].voltSource == x)\n\t\t    pins[i].current = c;\n\t}\n\tString getChipName() { return \"chip\"; }\n\tboolean getConnection(int n1, int n2) { return false; }\n\tboolean hasGroundConnection(int n1) {\n\t    return pins[n1].output;\n\t}\n\t\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Flip X\", (flags & FLAG_FLIP_X) != 0);\n\t\treturn ei;\n\t    }\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Flip Y\", (flags & FLAG_FLIP_Y) != 0);\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags |= FLAG_FLIP_X;\n\t\telse\n\t\t    flags &= ~FLAG_FLIP_X;\n\t\tsetPoints();\n\t    }\n\t    if (n == 1) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags |= FLAG_FLIP_Y;\n\t\telse\n\t\t    flags &= ~FLAG_FLIP_Y;\n\t\tsetPoints();\n\t    }\n\t}\n\n\tfinal int SIDE_N = 0;\n\tfinal int SIDE_S = 1;\n\tfinal int SIDE_W = 2;\n\tfinal int SIDE_E = 3;\n\tclass Pin {\n\t    Pin(int p, int s, String t) {\n\t\tpos = p; side = s; text = t;\n\t    }\n\t    Point post, stub;\n\t    Point textloc;\n\t    int pos, side, voltSource, bubbleX, bubbleY;\n\t    String text;\n\t    boolean lineOver, bubble, clock, output, value, state;\n\t    double curcount, current;\n\t    void setPoint(int px, int py, int dx, int dy, int dax, int day,\n\t\t\t  int sx, int sy) {\n\t\tif ((flags & FLAG_FLIP_X) != 0) {\n\t\t    dx = -dx;\n\t\t    dax = -dax;\n\t\t    px += cspc2*(sizeX-1);\n\t\t    sx = -sx;\n\t\t}\n\t\tif ((flags & FLAG_FLIP_Y) != 0) {\n\t\t    dy = -dy;\n\t\t    day = -day;\n\t\t    py += cspc2*(sizeY-1);\n\t\t    sy = -sy;\n\t\t}\n\t\tint xa = px+cspc2*dx*pos+sx;\n\t\tint ya = py+cspc2*dy*pos+sy;\n\t\tpost    = new Point(xa+dax*cspc2, ya+day*cspc2);\n\t\tstub    = new Point(xa+dax*cspc , ya+day*cspc );\n\t\ttextloc = new Point(xa       , ya       );\n\t\tif (bubble) {\n\t\t    bubbleX = xa+dax*10*csize;\n\t\t    bubbleY = ya+day*10*csize;\n\t\t}\n\t\tif (clock) {\n\t\t    clockPointsX = new int[3];\n\t\t    clockPointsY = new int[3];\n\t\t    clockPointsX[0] = xa+dax*cspc-dx*cspc/2;\n\t\t    clockPointsY[0] = ya+day*cspc-dy*cspc/2;\n\t\t    clockPointsX[1] = xa;\n\t\t    clockPointsY[1] = ya;\n\t\t    clockPointsX[2] = xa+dax*cspc+dx*cspc/2;\n\t\t    clockPointsY[2] = ya+day*cspc+dy*cspc/2;\n\t\t}\n\t    }\n\t}\n    }\n\n"
  },
  {
    "path": "src/CirSim.java",
    "content": "// CirSim.java (c) 2010 by Paul Falstad\n\n// For information about the theory behind this, see Electronic Circuit & System Simulation Methods by Pillage\n\nimport java.io.InputStream;\nimport java.awt.*;\nimport java.awt.image.*;\nimport java.applet.Applet;\nimport java.util.Vector;\nimport java.io.File;\nimport java.util.Random;\nimport java.util.Arrays;\nimport java.lang.Math;\nimport java.net.URL;\nimport java.awt.event.*;\nimport java.io.FilterInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.util.StringTokenizer;\nimport java.text.DecimalFormat;\nimport java.text.NumberFormat;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\nimport java.net.URLDecoder;\nimport java.net.URLEncoder;\n\npublic class CirSim extends Frame\n  implements ComponentListener, ActionListener, AdjustmentListener,\n  MouseMotionListener, MouseListener, ItemListener, KeyListener {\n    \n    Thread engine = null;\n\n    Dimension winSize;\n    Image dbimage;\n    \n    Random random;\n    public static final int sourceRadius = 7;\n    public static final double freqMult = 3.14159265*2*4;\n    \n    public String getAppletInfo() {\n\treturn \"Circuit by Paul Falstad\";\n    }\n\n    static Container main;\n    Label titleLabel;\n    Button resetButton;\n    Button dumpMatrixButton;\n    MenuItem exportItem, exportLinkItem, importItem, exitItem, undoItem, redoItem,\n\tcutItem, copyItem, pasteItem, selectAllItem, optionsItem;\n    Menu optionsMenu;\n    Checkbox stoppedCheck;\n    CheckboxMenuItem dotsCheckItem;\n    CheckboxMenuItem voltsCheckItem;\n    CheckboxMenuItem powerCheckItem;\n    CheckboxMenuItem smallGridCheckItem;\n    CheckboxMenuItem showValuesCheckItem;\n    CheckboxMenuItem conductanceCheckItem;\n    CheckboxMenuItem euroResistorCheckItem;\n    CheckboxMenuItem printableCheckItem;\n    CheckboxMenuItem conventionCheckItem;\n    CheckboxMenuItem idealWireCheckItem;\n    Scrollbar speedBar;\n    Scrollbar currentBar;\n    Label powerLabel;\n    Scrollbar powerBar;\n    PopupMenu elmMenu;\n    MenuItem elmEditMenuItem;\n    MenuItem elmCutMenuItem;\n    MenuItem elmCopyMenuItem;\n    MenuItem elmDeleteMenuItem;\n    MenuItem elmScopeMenuItem;\n    PopupMenu scopeMenu;\n    PopupMenu transScopeMenu;\n    PopupMenu mainMenu;\n    CheckboxMenuItem scopeVMenuItem;\n    CheckboxMenuItem scopeIMenuItem;\n    CheckboxMenuItem scopeMaxMenuItem;\n    CheckboxMenuItem scopeMinMenuItem;\n    CheckboxMenuItem scopeFreqMenuItem;\n    CheckboxMenuItem scopePowerMenuItem;\n    CheckboxMenuItem scopeIbMenuItem;\n    CheckboxMenuItem scopeIcMenuItem;\n    CheckboxMenuItem scopeIeMenuItem;\n    CheckboxMenuItem scopeVbeMenuItem;\n    CheckboxMenuItem scopeVbcMenuItem;\n    CheckboxMenuItem scopeVceMenuItem;\n    CheckboxMenuItem scopeVIMenuItem;\n    CheckboxMenuItem scopeXYMenuItem;\n    CheckboxMenuItem scopeResistMenuItem;\n    CheckboxMenuItem scopeVceIcMenuItem;\n    MenuItem scopeSelectYMenuItem;\n    Class addingClass;\n    int mouseMode = MODE_SELECT;\n    int tempMouseMode = MODE_SELECT;\n    String mouseModeStr = \"Select\";\n    static final double pi = 3.14159265358979323846;\n    static final int MODE_ADD_ELM = 0;\n    static final int MODE_DRAG_ALL = 1;\n    static final int MODE_DRAG_ROW = 2;\n    static final int MODE_DRAG_COLUMN = 3;\n    static final int MODE_DRAG_SELECTED = 4;\n    static final int MODE_DRAG_POST = 5;\n    static final int MODE_SELECT = 6;\n    static final int infoWidth = 120;\n    int dragX, dragY, initDragX, initDragY;\n    int selectedSource;\n    Rectangle selectedArea;\n    int gridSize, gridMask, gridRound;\n    boolean dragging;\n    boolean analyzeFlag;\n    boolean dumpMatrix;\n    boolean useBufferedImage;\n    boolean isMac;\n    String ctrlMetaKey;\n    double t;\n    int pause = 10;\n    int scopeSelected = -1;\n    int menuScope = -1;\n    int hintType = -1, hintItem1, hintItem2;\n    String stopMessage;\n    double timeStep;\n    static final int HINT_LC = 1;\n    static final int HINT_RC = 2;\n    static final int HINT_3DB_C = 3;\n    static final int HINT_TWINT = 4;\n    static final int HINT_3DB_L = 5;\n    Vector<CircuitElm> elmList;\n//    Vector setupList;\n    CircuitElm dragElm, menuElm, mouseElm, stopElm;\n    boolean didSwitch = false;\n    int mousePost = -1;\n    CircuitElm plotXElm, plotYElm;\n    int draggingPost;\n    SwitchElm heldSwitchElm;\n    double circuitMatrix[][], circuitRightSide[],\n\torigRightSide[], origMatrix[][];\n    RowInfo circuitRowInfo[];\n    int circuitPermute[];\n    boolean circuitNonLinear;\n    int voltageSourceCount;\n    int circuitMatrixSize, circuitMatrixFullSize;\n    boolean circuitNeedsMap;\n    public boolean useFrame;\n    int scopeCount;\n    Scope scopes[];\n    int scopeColCount[];\n    static EditDialog editDialog;\n    static ImportExportDialog impDialog, expDialog;\n    Class dumpTypes[], shortcuts[];\n    static String muString = \"u\";\n    static String ohmString = \"ohm\";\n    String clipboard;\n    Rectangle circuitArea;\n    int circuitBottom;\n    Vector<String> undoStack, redoStack;\n\n    int getrand(int x) {\n\tint q = random.nextInt();\n\tif (q < 0) q = -q;\n\treturn q % x;\n    }\n    CircuitCanvas cv;\n    Circuit applet;\n\n    CirSim(Circuit a) {\n\tsuper(\"Circuit Simulator v1.6.1a\");\n\tapplet = a;\n\tuseFrame = false;\n    }\n\n    String startCircuit = null;\n    String startLabel = null;\n    String startCircuitText = null;\n    String baseURL = \"http://www.falstad.com/circuit/\";\n    \n    public void init() {\n\tString euroResistor = null;\n\tString useFrameStr = null;\n\tboolean printable = true; // hausen: changed from false to true\n\tboolean convention = true;\n\n\tCircuitElm.initClass(this);\n\n\ttry {\n\t    baseURL = applet.getDocumentBase().getFile();\n\t    // look for circuit embedded in URL\n\t    String doc = applet.getDocumentBase().toString();\n\t    int in = doc.indexOf('#');\n\t    if (in > 0) {\n\t\tString x = null;\n\t\ttry {\n\t\t    x = doc.substring(in+1);\n\t\t    x = URLDecoder.decode(x);\n\t\t    startCircuitText = x;\n\t\t} catch (Exception e) {\n\t\t    System.out.println(\"can't decode \" + x);\n\t\t    e.printStackTrace();\n\t\t}\n\t    }\n\t    in = doc.lastIndexOf('/');\n\t    if (in > 0)\n\t\tbaseURL = doc.substring(0, in+1);\n\t    \n\t    String param = applet.getParameter(\"PAUSE\");\n\t    if (param != null)\n\t\tpause = Integer.parseInt(param);\n\t    startCircuit = applet.getParameter(\"startCircuit\");\n\t    startLabel   = applet.getParameter(\"startLabel\");\n\t    euroResistor = applet.getParameter(\"euroResistors\");\n\t    useFrameStr  = applet.getParameter(\"useFrame\");\n\t    String x = applet.getParameter(\"whiteBackground\");\n\t    if (x != null && x.equalsIgnoreCase(\"true\"))\n\t\tprintable = true;\n\t    x = applet.getParameter(\"conventionalCurrent\");\n\t    if (x != null && x.equalsIgnoreCase(\"true\"))\n\t\tconvention = false;\n\t} catch (Exception e) { }\n\t\n\tboolean euro = (euroResistor != null && euroResistor.equalsIgnoreCase(\"true\"));\n\tuseFrame = (useFrameStr == null || !useFrameStr.equalsIgnoreCase(\"false\"));\n\tif (useFrame)\n\t    main = this;\n\telse\n\t    main = applet;\n\t\n\tString os = System.getProperty(\"os.name\");\n\tisMac = (os.indexOf(\"Mac \") == 0);\n\tctrlMetaKey = (isMac) ? \"\\u2318\" : \"Ctrl\";\n\tString jv = System.getProperty(\"java.class.version\");\n\tdouble jvf = new Double(jv).doubleValue();\n\tif (jvf >= 48) {\n\t    muString = \"\\u03bc\";\n\t    ohmString = \"\\u03a9\";\n\t    useBufferedImage = true;\n\t}\n\t\n\tdumpTypes = new Class[300];\n\tshortcuts = new Class[127];\n\n\t// these characters are reserved\n\tdumpTypes[(int)'o'] = Scope.class;\n\tdumpTypes[(int)'h'] = Scope.class;\n\tdumpTypes[(int)'$'] = Scope.class;\n\tdumpTypes[(int)'%'] = Scope.class;\n\tdumpTypes[(int)'?'] = Scope.class;\n\tdumpTypes[(int)'B'] = Scope.class;\n\n\tmain.setLayout(new CircuitLayout());\n\tcv = new CircuitCanvas(this);\n\tcv.addComponentListener(this);\n\tcv.addMouseMotionListener(this);\n\tcv.addMouseListener(this);\n\tcv.addKeyListener(this);\n\tmain.add(cv);\n\n\tmainMenu = new PopupMenu();\n\tMenuBar mb = null;\n\tif (useFrame)\n\t    mb = new MenuBar();\n\tMenu m = new Menu(\"File\");\n\tif (useFrame)\n\t    mb.add(m);\n\telse\n\t    mainMenu.add(m);\n\tm.add(importItem = getMenuItem(\"Import\"));\n\tm.add(exportItem = getMenuItem(\"Export\"));\n//\tm.add(exportLinkItem = getMenuItem(\"Export Link\"));\n\tm.addSeparator();\n\tm.add(exitItem   = getMenuItem(\"Exit\"));\n\n\tm = new Menu(\"Edit\");\n\tm.add(undoItem = getMenuItem(\"Undo\"));\n\tundoItem.setShortcut(new MenuShortcut(KeyEvent.VK_Z));\n\tm.add(redoItem = getMenuItem(\"Redo\"));\n\tredoItem.setShortcut(new MenuShortcut(KeyEvent.VK_Z, true));\n\tm.addSeparator();\n\tm.add(cutItem = getMenuItem(\"Cut\"));\n\tcutItem.setShortcut(new MenuShortcut(KeyEvent.VK_X));\n\tm.add(copyItem = getMenuItem(\"Copy\"));\n\tcopyItem.setShortcut(new MenuShortcut(KeyEvent.VK_C));\n\tm.add(pasteItem = getMenuItem(\"Paste\"));\n\tpasteItem.setShortcut(new MenuShortcut(KeyEvent.VK_V));\n\tpasteItem.setEnabled(false);\n\tm.add(selectAllItem = getMenuItem(\"Select All\"));\n\tselectAllItem.setShortcut(new MenuShortcut(KeyEvent.VK_A));\n\tif (useFrame)\n\t    mb.add(m);\n\telse\n\t    mainMenu.add(m);\n\n\tm = new Menu(\"Scope\");\n\tif (useFrame)\n\t    mb.add(m);\n\telse\n\t    mainMenu.add(m);\n\tm.add(getMenuItem(\"Stack All\", \"stackAll\"));\n\tm.add(getMenuItem(\"Unstack All\", \"unstackAll\"));\n\n\toptionsMenu = m = new Menu(\"Options\");\n\tif (useFrame)\n\t    mb.add(m);\n\telse\n\t    mainMenu.add(m);\n\tm.add(dotsCheckItem = getCheckItem(\"Show Current\"));\n\tdotsCheckItem.setState(false); // hausen: changed from true to false\n\tm.add(voltsCheckItem = getCheckItem(\"Show Voltage\"));\n\tvoltsCheckItem.setState(true);\n\tm.add(powerCheckItem = getCheckItem(\"Show Power\"));\n\tm.add(showValuesCheckItem = getCheckItem(\"Show Values\"));\n\tshowValuesCheckItem.setState(true);\n\t//m.add(conductanceCheckItem = getCheckItem(\"Show Conductance\"));\n\tm.add(smallGridCheckItem = getCheckItem(\"Small Grid\"));\n\tm.add(euroResistorCheckItem = getCheckItem(\"European Resistors\"));\n\teuroResistorCheckItem.setState(euro);\n\tm.add(printableCheckItem = getCheckItem(\"White Background\"));\n\tprintableCheckItem.setState(printable);\n\tm.add(conventionCheckItem = getCheckItem(\"Conventional Current Motion\"));\n\tconventionCheckItem.setState(convention);\n\tm.add(idealWireCheckItem = getCheckItem(\"Ideal Wires\"));\n\tidealWireCheckItem.setState(WireElm.ideal);\n\tidealWireCheckItem.addItemListener(\n\t\tnew ItemListener() {\n\t\t\t@Override\n\t\t\tpublic void itemStateChanged(ItemEvent e) {\n\t\t\t\tif (e.getStateChange() == ItemEvent.SELECTED) {\n\t\t\t\t\tWireElm.ideal = true;\n\t\t\t\t} else {\n\t\t\t\t\tWireElm.ideal = false;\n\t\t\t\t}\n\t\t\t\tSystem.err.println(\"ideal wires: \" + WireElm.ideal);\n\t\t\t}\n\t\t}\n\t);\n\n\tm.add(optionsItem = getMenuItem(\"Other Options...\"));\n\t\n\tMenu circuitsMenu = new Menu(\"Circuits\");\n\tif (useFrame)\n\t    mb.add(circuitsMenu);\n\telse\n\t    mainMenu.add(circuitsMenu);\n\n\tmainMenu.add(getClassCheckItem(\"Add Wire\", \"WireElm\"));\n\tmainMenu.add(getClassCheckItem(\"Add Resistor\", \"ResistorElm\"));\n\t\n\tMenu passMenu = new Menu(\"Passive Components\");\n\tmainMenu.add(passMenu);\n\tpassMenu.add(getClassCheckItem(\"Add Capacitor\", \"CapacitorElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Inductor\", \"InductorElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Switch\", \"SwitchElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Push Switch\", \"PushSwitchElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add SPDT Switch\", \"Switch2Elm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Potentiometer\", \"PotElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Transformer\", \"TransformerElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Tapped Transformer\",\n\t\t\t\t       \"TappedTransformerElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Transmission Line\", \"TransLineElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Relay\", \"RelayElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Memristor\", \"MemristorElm\"));\n\tpassMenu.add(getClassCheckItem(\"Add Spark Gap\", \"SparkGapElm\"));\n\t\n\tMenu inputMenu = new Menu(\"Inputs/Outputs\");\n\tmainMenu.add(inputMenu);\n\tinputMenu.add(getClassCheckItem(\"Add Ground\", \"GroundElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Voltage Source (2-terminal)\", \"DCVoltageElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add A/C Source (2-terminal)\", \"ACVoltageElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Voltage Source (1-terminal)\", \"RailElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add A/C Source (1-terminal)\", \"ACRailElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Square Wave (1-terminal)\", \"SquareRailElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Analog Output\", \"OutputElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Logic Input\", \"LogicInputElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Logic Output\", \"LogicOutputElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Clock\", \"ClockElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add A/C Sweep\", \"SweepElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Var. Voltage\", \"VarRailElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Antenna\", \"AntennaElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Current Source\", \"CurrentElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add LED\", \"LEDElm\"));\n\tinputMenu.add(getClassCheckItem(\"Add Lamp (beta)\", \"LampElm\"));\n\t\n\tMenu activeMenu = new Menu(\"Active Components\");\n\tmainMenu.add(activeMenu);\n\tactiveMenu.add(getClassCheckItem(\"Add Diode\", \"DiodeElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Zener Diode\", \"ZenerElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Transistor (bipolar, NPN)\",\n\t\t\t\t    \"NTransistorElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Transistor (bipolar, PNP)\",\n\t\t\t\t    \"PTransistorElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Op Amp (- on top)\", \"OpAmpElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Op Amp (+ on top)\",\n\t\t\t\t    \"OpAmpSwapElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add MOSFET (n-channel)\",\n\t\t\t\t    \"NMosfetElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add MOSFET (p-channel)\",\n\t\t\t\t    \"PMosfetElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add JFET (n-channel)\",\n\t\t\t\t\t \"NJfetElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add JFET (p-channel)\",\n\t\t\t\t\t \"PJfetElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Analog Switch (SPST)\", \"AnalogSwitchElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Analog Switch (SPDT)\", \"AnalogSwitch2Elm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add SCR\", \"SCRElm\"));\n\t//activeMenu.add(getClassCheckItem(\"Add Varactor/Varicap\", \"VaractorElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Tunnel Diode\", \"TunnelDiodeElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add Triode\", \"TriodeElm\"));\n\t//activeMenu.add(getClassCheckItem(\"Add Diac\", \"DiacElm\"));\n\t//activeMenu.add(getClassCheckItem(\"Add Triac\", \"TriacElm\"));\n\t//activeMenu.add(getClassCheckItem(\"Add Photoresistor\", \"PhotoResistorElm\"));\n\t//activeMenu.add(getClassCheckItem(\"Add Thermistor\", \"ThermistorElm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add CCII+\", \"CC2Elm\"));\n\tactiveMenu.add(getClassCheckItem(\"Add CCII-\", \"CC2NegElm\"));\n\n\tMenu gateMenu = new Menu(\"Logic Gates\");\n\tmainMenu.add(gateMenu);\n\tgateMenu.add(getClassCheckItem(\"Add Inverter\", \"InverterElm\"));\n\tgateMenu.add(getClassCheckItem(\"Add NAND Gate\", \"NandGateElm\"));\n\tgateMenu.add(getClassCheckItem(\"Add NOR Gate\", \"NorGateElm\"));\n\tgateMenu.add(getClassCheckItem(\"Add AND Gate\", \"AndGateElm\"));\n\tgateMenu.add(getClassCheckItem(\"Add OR Gate\", \"OrGateElm\"));\n\tgateMenu.add(getClassCheckItem(\"Add XOR Gate\", \"XorGateElm\"));\n\n\tMenu chipMenu = new Menu(\"Chips\");\n\tmainMenu.add(chipMenu);\n\tchipMenu.add(getClassCheckItem(\"Add D Flip-Flop\", \"DFlipFlopElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add JK Flip-Flop\", \"JKFlipFlopElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add 7 Segment LED\", \"SevenSegElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add VCO\", \"VCOElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add Phase Comparator\", \"PhaseCompElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add Counter\", \"CounterElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add Decade Counter\", \"DecadeElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add 555 Timer\", \"TimerElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add DAC\", \"DACElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add ADC\", \"ADCElm\"));\n\tchipMenu.add(getClassCheckItem(\"Add Latch\", \"LatchElm\"));\n\t\n\tMenu otherMenu = new Menu(\"Other\");\n\tmainMenu.add(otherMenu);\n\totherMenu.add(getClassCheckItem(\"Add Text\", \"TextElm\"));\n\totherMenu.add(getClassCheckItem(\"Add Box\", \"BoxElm\"));\n\totherMenu.add(getClassCheckItem(\"Add Scope Probe\", \"ProbeElm\"));\n\totherMenu.add(getCheckItem(\"Drag All (Alt-drag)\", \"DragAll\"));\n\totherMenu.add(getCheckItem(\n\t\t\t  isMac ? \"Drag Row (Alt-S-drag, S-right)\" :\n\t\t\t  \"Drag Row (S-right)\",\n\t\t\t  \"DragRow\"));\n\totherMenu.add(getCheckItem(\n\t\t\t  isMac ? \"Drag Column (Alt-\\u2318-drag, \\u2318-right)\" :\n\t\t\t  \"Drag Column (C-right)\",\n\t\t\t  \"DragColumn\"));\n\totherMenu.add(getCheckItem(\"Drag Selected\", \"DragSelected\"));\n\totherMenu.add(getCheckItem(\"Drag Post (\" + ctrlMetaKey + \"-drag)\",\n\t\t\t\t   \"DragPost\"));\n\n\tmainMenu.add(getCheckItem(\"Select/Drag Selected (space or Shift-drag)\", \"Select\"));\n\tmain.add(mainMenu);\n\n\tmain.add(resetButton = new Button(\"Reset\"));\n\tresetButton.addActionListener(this);\n\tdumpMatrixButton = new Button(\"Dump Matrix\");\n\t//main.add(dumpMatrixButton);\n\tdumpMatrixButton.addActionListener(this);\n\tstoppedCheck = new Checkbox(\"Stopped\");\n\tstoppedCheck.addItemListener(this);\n\tmain.add(stoppedCheck);\n\t\n\tmain.add(new Label(\"Simulation Speed\", Label.CENTER));\n\n\t// was max of 140\n\tmain.add(speedBar = new Scrollbar(Scrollbar.HORIZONTAL, 3, 1, 0, 260));\n\tspeedBar.addAdjustmentListener(this);\n\n\tmain.add(new Label(\"Current Speed\", Label.CENTER));\n\tcurrentBar = new Scrollbar(Scrollbar.HORIZONTAL,\n\t\t\t\t   50, 1, 1, 100);\n\tcurrentBar.addAdjustmentListener(this);\n\tmain.add(currentBar);\n\n\tmain.add(powerLabel = new Label(\"Power Brightness\", Label.CENTER));\n\tmain.add(powerBar = new Scrollbar(Scrollbar.HORIZONTAL,\n\t\t\t\t    50, 1, 1, 100));\n\tpowerBar.addAdjustmentListener(this);\n\tpowerBar.disable();\n\tpowerLabel.disable();\n\n\tmain.add(new Label(\"www.falstad.com\"));\n\n\tif (useFrame)\n\t    main.add(new Label(\"\"));\n\tFont f = new Font(\"SansSerif\", 0, 10);\n\tLabel l;\n\tl = new Label(\"Current Circuit:\");\n\tl.setFont(f);\n\ttitleLabel = new Label(\"Label\");\n\ttitleLabel.setFont(f);\n\tif (useFrame) {\n\t    main.add(l);\n\t    main.add(titleLabel);\n\t}\n\n\tsetGrid();\n\telmList = new Vector<CircuitElm>();\n//\tsetupList = new Vector();\n\tundoStack = new Vector<String>();\n\tredoStack = new Vector<String>();\n\n\tscopes = new Scope[20];\n\tscopeColCount = new int[20];\n\tscopeCount = 0;\n\t\n\trandom = new Random();\n\tcv.setBackground(Color.black);\n\tcv.setForeground(Color.lightGray);\n\t\n\telmMenu = new PopupMenu();\n\telmMenu.add(elmEditMenuItem = getMenuItem(\"Edit\"));\n\telmMenu.add(elmScopeMenuItem = getMenuItem(\"View in Scope\"));\n\telmMenu.add(elmCutMenuItem = getMenuItem(\"Cut\"));\n\telmMenu.add(elmCopyMenuItem = getMenuItem(\"Copy\"));\n\telmMenu.add(elmDeleteMenuItem = getMenuItem(\"Delete\"));\n\tmain.add(elmMenu);\n\t\n\tscopeMenu = buildScopeMenu(false);\n\ttransScopeMenu = buildScopeMenu(true);\n\n\tgetSetupList(circuitsMenu, false);\n\tif (useFrame)\n\t    setMenuBar(mb);\n\tif (startCircuitText != null)\n\t    readSetup(startCircuitText);\n\telse if (stopMessage == null && startCircuit != null)\n\t    readSetupFile(startCircuit, startLabel);\n\telse\n\t    readSetup(null, 0, false);\n\n\tif (useFrame) {\n\t    Dimension screen = getToolkit().getScreenSize();\n\t    resize(860, 640);\n\t    handleResize();\n\t    Dimension x = getSize();\n\t    setLocation((screen.width  - x.width)/2,\n\t\t\t(screen.height - x.height)/2);\n\t    show();\n\t} else {\n\t    if (!powerCheckItem.getState()) {\n\t\tmain.remove(powerBar);\n\t\tmain.remove(powerLabel);\n\t\tmain.validate();\n\t    }\n\t    hide();\n\t    handleResize();\n\t    applet.validate();\n\t}\n\trequestFocus();\n\n\taddWindowListener(new WindowAdapter()\n\t\t{\n\t\t\tpublic void windowClosing(WindowEvent we)\n\t\t\t{\n\t\t\t\tdestroyFrame();\n\t\t\t}\n\t\t}\n\t);\n    }\n\n    boolean shown = false;\n    \n    public void triggerShow() {\n\tif (!shown)\n\t    show();\n\tshown = true;\n    }\n\n    public void requestFocus()\n    {\n\tsuper.requestFocus();\n\tcv.requestFocus();\n    }\n    \n    PopupMenu buildScopeMenu(boolean t) {\n\tPopupMenu m = new PopupMenu();\n\tm.add(getMenuItem(\"Remove\", \"remove\"));\n\tm.add(getMenuItem(\"Speed 2x\", \"speed2\"));\n\tm.add(getMenuItem(\"Speed 1/2x\", \"speed1/2\"));\n\tm.add(getMenuItem(\"Scale 2x\", \"scale\"));\n\tm.add(getMenuItem(\"Max Scale\", \"maxscale\"));\n\tm.add(getMenuItem(\"Stack\", \"stack\"));\n\tm.add(getMenuItem(\"Unstack\", \"unstack\"));\n\tm.add(getMenuItem(\"Reset\", \"reset\"));\n\tif (t) {\n\t    m.add(scopeIbMenuItem = getCheckItem(\"Show Ib\"));\n\t    m.add(scopeIcMenuItem = getCheckItem(\"Show Ic\"));\n\t    m.add(scopeIeMenuItem = getCheckItem(\"Show Ie\"));\n\t    m.add(scopeVbeMenuItem = getCheckItem(\"Show Vbe\"));\n\t    m.add(scopeVbcMenuItem = getCheckItem(\"Show Vbc\"));\n\t    m.add(scopeVceMenuItem = getCheckItem(\"Show Vce\"));\n\t    m.add(scopeVceIcMenuItem = getCheckItem(\"Show Vce vs Ic\"));\n\t} else {\n\t    m.add(scopeVMenuItem = getCheckItem(\"Show Voltage\"));\n\t    m.add(scopeIMenuItem = getCheckItem(\"Show Current\"));\n\t    m.add(scopePowerMenuItem = getCheckItem(\"Show Power Consumed\"));\n\t    m.add(scopeMaxMenuItem = getCheckItem(\"Show Peak Value\"));\n\t    m.add(scopeMinMenuItem = getCheckItem(\"Show Negative Peak Value\"));\n\t    m.add(scopeFreqMenuItem = getCheckItem(\"Show Frequency\"));\n\t    m.add(scopeVIMenuItem = getCheckItem(\"Show V vs I\"));\n\t    m.add(scopeXYMenuItem = getCheckItem(\"Plot X/Y\"));\n\t    m.add(scopeSelectYMenuItem = getMenuItem(\"Select Y\", \"selecty\"));\n\t    m.add(scopeResistMenuItem = getCheckItem(\"Show Resistance\"));\n\t}\n\tmain.add(m);\n\treturn m;\n    }\n    \n    MenuItem getMenuItem(String s) {\n\tMenuItem mi = new MenuItem(s);\n\tmi.addActionListener(this);\n\treturn mi;\n    }\n\n    MenuItem getMenuItem(String s, String ac) {\n\tMenuItem mi = new MenuItem(s);\n\tmi.setActionCommand(ac);\n\tmi.addActionListener(this);\n\treturn mi;\n    }\n\n    CheckboxMenuItem getCheckItem(String s) {\n\tCheckboxMenuItem mi = new CheckboxMenuItem(s);\n\tmi.addItemListener(this);\n\tmi.setActionCommand(\"\");\n\treturn mi;\n    }\n\n    CheckboxMenuItem getClassCheckItem(String s, String t) {\n\ttry {\n\t    Class c = Class.forName(t);\n\t    CircuitElm elm = constructElement(c, 0, 0);\n\t    register(c, elm);\n\t    if ( elm.needsShortcut() ) {\n\t\ts += \" (\" + (char)elm.getShortcut() + \")\";\n\t    }\n\t    elm.delete();\n\t} catch (Exception ee) {\n\t    ee.printStackTrace();\n\t}\n\treturn getCheckItem(s, t);\n    }\n    \n    CheckboxMenuItem getCheckItem(String s, String t) {\n\tCheckboxMenuItem mi = new CheckboxMenuItem(s);\n\tmi.addItemListener(this);\n\tmi.setActionCommand(t);\n\treturn mi;\n    }\n\n    void register(Class c, CircuitElm elm) {\n\tint t = elm.getDumpType();\n\tif (t == 0) {\n\t    System.out.println(\"no dump type: \" + c);\n\t    return;\n\t}\n\n\tint s = elm.getShortcut();\n\tif ( elm.needsShortcut() && s == 0 )\n\t{\n\t    if ( s == 0 )\n\t    {\n\t\tSystem.err.println(\"no shortcut \" + c + \" for \" + c);\n\t\treturn;\n\t    }\n\t    else if ( s <= ' ' || s >= 127 )\n\t    {\n\t\tSystem.err.println(\"invalid shortcut \" + c + \" for \" + c);\n\t\treturn;\n\t    }\n\t}\n\n\tClass dclass = elm.getDumpClass();\n\n\tif ( dumpTypes[t] != null && dumpTypes[t] != dclass ) {\n\t    System.out.println(\"dump type conflict: \" + c + \" \" +\n\t\t\t       dumpTypes[t]);\n\t    return;\n\t}\n\tdumpTypes[t] = dclass;\n\n\tClass sclass = elm.getClass();\n\n\tif ( elm.needsShortcut() && shortcuts[s] != null &&\n\t     shortcuts[s] != sclass )\n\t{\n\t    System.err.println(\"shortcut conflict: \" + c +\n\t \t\t       \" (previously assigned to \" +\n\t\t\t       shortcuts[s] + \")\");\n\t}\n\telse\n\t{\n\t    shortcuts[s] = sclass;\n\t}\n    }\n    \n    void handleResize() {\n        winSize = cv.getSize();\n\tif (winSize.width == 0)\n\t    return;\n\tdbimage = main.createImage(winSize.width, winSize.height);\n\tint h = winSize.height / 5;\n\t/*if (h < 128 && winSize.height > 300)\n\t  h = 128;*/\n\tcircuitArea = new Rectangle(0, 0, winSize.width, winSize.height-h);\n\tint i;\n\tint minx = 1000, maxx = 0, miny = 1000, maxy = 0;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    // centered text causes problems when trying to center the circuit,\n\t    // so we special-case it here\n\t    if (!ce.isCenteredText()) {\n\t\tminx = min(ce.x, min(ce.x2, minx));\n\t\tmaxx = max(ce.x, max(ce.x2, maxx));\n\t    }\n\t    miny = min(ce.y, min(ce.y2, miny));\n\t    maxy = max(ce.y, max(ce.y2, maxy));\n\t}\n\t// center circuit; we don't use snapGrid() because that rounds\n\tint dx = gridMask & ((circuitArea.width -(maxx-minx))/2-minx);\n\tint dy = gridMask & ((circuitArea.height-(maxy-miny))/2-miny);\n\tif (dx+minx < 0)\n\t    dx = gridMask & (-minx);\n\tif (dy+miny < 0)\n\t    dy = gridMask & (-miny);\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.move(dx, dy);\n\t}\n\t// after moving elements, need this to avoid singular matrix probs\n\tneedAnalyze();\n\tcircuitBottom = 0;\n    }\n\n    void destroyFrame() {\n\tif (applet == null)\n\t{\n\t    dispose();\n\t    System.exit(0);\n\t}\n\telse\n\t{\n\t    applet.destroyFrame();\n\t}\n    }\n    \n    public boolean handleEvent(Event ev) {\n        if (ev.id == Event.WINDOW_DESTROY) {\n\t    destroyFrame();\n            return true;\n        }\n        return super.handleEvent(ev);\n    }\n    \n    public void paint(Graphics g) {\n\tcv.repaint();\n    }\n\n    static final int resct = 6;\n    long lastTime = 0, lastFrameTime, lastIterTime, secTime = 0;\n    int frames = 0;\n    int steps = 0;\n    int framerate = 0, steprate = 0;\n\n    public void updateCircuit(Graphics realg) {\n\tCircuitElm realMouseElm;\n\tif (winSize == null || winSize.width == 0)\n\t    return;\n\tif (analyzeFlag) {\n\t    analyzeCircuit();\n\t    analyzeFlag = false;\n\t}\n\tif (editDialog != null && editDialog.elm instanceof CircuitElm)\n\t    mouseElm = (CircuitElm) (editDialog.elm);\n\trealMouseElm = mouseElm;\n\tif (mouseElm == null)\n\t    mouseElm = stopElm;\n\tsetupScopes();\n        Graphics2D g = null; // hausen: changed to Graphics2D\n\tg = (Graphics2D)dbimage.getGraphics();\n\tg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\n\t\tRenderingHints.VALUE_ANTIALIAS_ON);\n\tCircuitElm.selectColor = Color.cyan;\n\tif (printableCheckItem.getState()) {\n  \t    CircuitElm.whiteColor = Color.black;\n  \t    CircuitElm.lightGrayColor = Color.black;\n  \t    g.setColor(Color.white);\n\t} else {\n\t    CircuitElm.whiteColor = Color.white;\n\t    CircuitElm.lightGrayColor = Color.lightGray;\n\t    g.setColor(Color.black);\n\t}\n\tg.fillRect(0, 0, winSize.width, winSize.height);\n\tif (!stoppedCheck.getState()) {\n\t    try {\n\t\trunCircuit();\n\t    } catch (Exception e) {\n\t\te.printStackTrace();\n\t\tanalyzeFlag = true;\n\t\tcv.repaint();\n\t\treturn;\n\t    }\n\t}\n\tif (!stoppedCheck.getState()) {\n\t    long sysTime = System.currentTimeMillis();\n\t    if (lastTime != 0) {\n\t\tint inc = (int) (sysTime-lastTime);\n\t\tdouble c = currentBar.getValue();\n\t\tc = java.lang.Math.exp(c/3.5-14.2);\n\t\tCircuitElm.currentMult = 1.7 * inc * c;\n\t\tif (!conventionCheckItem.getState())\n\t\t    CircuitElm.currentMult = -CircuitElm.currentMult;\n\t    }\n\t    if (sysTime-secTime >= 1000) {\n\t\tframerate = frames; steprate = steps;\n\t\tframes = 0; steps = 0;\n\t\tsecTime = sysTime;\n\t    }\n\t    lastTime = sysTime;\n\t} else\n\t    lastTime = 0;\n\tCircuitElm.powerMult = Math.exp(powerBar.getValue()/4.762-7);\n\t\n\tint i;\n\tFont oldfont = g.getFont();\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    if (powerCheckItem.getState())\n\t\tg.setColor(Color.gray);\n\t    /*else if (conductanceCheckItem.getState())\n\t      g.setColor(Color.white);*/\n\t    getElm(i).draw(g);\n\t}\n\tif (tempMouseMode == MODE_DRAG_ROW || tempMouseMode == MODE_DRAG_COLUMN ||\n\t    tempMouseMode == MODE_DRAG_POST || tempMouseMode == MODE_DRAG_SELECTED)\n\t    for (i = 0; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\tce.drawPost(g, ce.x , ce.y );\n\t\tce.drawPost(g, ce.x2, ce.y2);\n\t    }\n\tint badnodes = 0;\n\t// find bad connections, nodes not connected to other elements which\n\t// intersect other elements' bounding boxes\n\t// debugged by hausen: nullPointerException\n\tif ( nodeList != null )\n\tfor (i = 0; i != nodeList.size(); i++) {\n\t    CircuitNode cn = getCircuitNode(i);\n\t    if (!cn.internal && cn.links.size() == 1) {\n\t\tint bb = 0, j;\n\t\tCircuitNodeLink cnl = cn.links.elementAt(0);\n\t\tfor (j = 0; j != elmList.size(); j++)\n\t\t{ // TODO: (hausen) see if this change does not break stuff\n\t\t    CircuitElm ce = getElm(j);\n\t\t    if ( ce instanceof GraphicElm )\n\t\t\tcontinue;\n\t\t    if (cnl.elm != ce &&\n\t\t\tgetElm(j).boundingBox.contains(cn.x, cn.y))\n\t\t\tbb++;\n\t\t}\n\t\tif (bb > 0) {\n\t\t    g.setColor(Color.red);\n\t\t    g.fillOval(cn.x-3, cn.y-3, 7, 7);\n\t\t    badnodes++;\n\t\t}\n\t    }\n\t}\n\t/*if (mouseElm != null) {\n\t    g.setFont(oldfont);\n\t    g.drawString(\"+\", mouseElm.x+10, mouseElm.y);\n\t    }*/\n\tif (dragElm != null &&\n\t      (dragElm.x != dragElm.x2 || dragElm.y != dragElm.y2))\n\t    dragElm.draw(g);\n\tg.setFont(oldfont);\n\tint ct = scopeCount;\n\tif (stopMessage != null)\n\t    ct = 0;\n\tfor (i = 0; i != ct; i++)\n\t    scopes[i].draw(g);\n\tg.setColor(CircuitElm.whiteColor);\n\tif (stopMessage != null) {\n\t    g.drawString(stopMessage, 10, circuitArea.height);\n\t} else {\n\t    if (circuitBottom == 0)\n\t\tcalcCircuitBottom();\n\t    String info[] = new String[10];\n\t    if (mouseElm != null) {\n\t\tif (mousePost == -1)\n\t\t    mouseElm.getInfo(info);\n\t\telse\n\t\t    info[0] = \"V = \" +\n\t\t\tCircuitElm.getUnitText(mouseElm.getPostVoltage(mousePost), \"V\");\n\t\t/* //shownodes\n\t\tfor (i = 0; i != mouseElm.getPostCount(); i++)\n\t\t    info[0] += \" \" + mouseElm.nodes[i];\n\t\tif (mouseElm.getVoltageSourceCount() > 0)\n\t\t    info[0] += \";\" + (mouseElm.getVoltageSource()+nodeList.size());\n\t\t*/\n\t\t\n\t    } else {\n\t\tCircuitElm.showFormat.setMinimumFractionDigits(2);\n\t\tinfo[0] = \"t = \" + CircuitElm.getUnitText(t, \"s\");\n\t\tCircuitElm.showFormat.setMinimumFractionDigits(0);\n\t    }\n\t    if (hintType != -1) {\n\t\tfor (i = 0; info[i] != null; i++)\n\t\t    ;\n\t\tString s = getHint();\n\t\tif (s == null)\n\t\t    hintType = -1;\n\t\telse\n\t\t    info[i] = s;\n\t    }\n\t    int x = 0;\n\t    if (ct != 0)\n\t\tx = scopes[ct-1].rightEdge() + 20;\n\t    x = max(x, winSize.width*2/3);\n\t    \n\t    // count lines of data\n\t    for (i = 0; info[i] != null; i++)\n\t\t;\n\t    if (badnodes > 0)\n\t\tinfo[i++] = badnodes + ((badnodes == 1) ?\n\t\t\t\t\t\" bad connection\" : \" bad connections\");\n\t    \n\t    // find where to show data; below circuit, not too high unless we need it\n\t    int ybase = winSize.height-15*i-5;\n\t    ybase = min(ybase, circuitArea.height);\n\t    ybase = max(ybase, circuitBottom);\n\t    for (i = 0; info[i] != null; i++)\n\t\tg.drawString(info[i], x,\n\t\t\t     ybase+15*(i+1));\n\t}\n\tif (selectedArea != null) {\n\t    g.setColor(CircuitElm.selectColor);\n\t    g.drawRect(selectedArea.x, selectedArea.y, selectedArea.width, selectedArea.height);\n\t}\n\tmouseElm = realMouseElm;\n\tframes++;\n\t/*\n\tg.setColor(Color.white);\n\tg.drawString(\"Framerate: \" + framerate, 10, 10);\n\tg.drawString(\"Steprate: \" + steprate,  10, 30);\n\tg.drawString(\"Steprate/iter: \" + (steprate/getIterCount()),  10, 50);\n\tg.drawString(\"iterc: \" + (getIterCount()),  10, 70);\n\t*/\n\n\trealg.drawImage(dbimage, 0, 0, this);\n\tif (!stoppedCheck.getState() && circuitMatrix != null) {\n\t    // Limit to 50 fps (thanks to Jurgen Klotzer for this)\n\t    long delay = 1000/50 - (System.currentTimeMillis() - lastFrameTime);\n\t    //realg.drawString(\"delay: \" + delay,  10, 90);\n\t    if (delay > 0) {\n\t\ttry {\n\t\t    Thread.sleep(delay);\n\t\t} catch (InterruptedException e) {\n\t\t}\n\t    }\n\t    \n\t    cv.repaint(0);\n\t}\n\tlastFrameTime = lastTime;\n    }\n\n    void setupScopes() {\n\tint i;\n\t\n\t// check scopes to make sure the elements still exist, and remove\n\t// unused scopes/columns\n\tint pos = -1;\n\tfor (i = 0; i < scopeCount; i++) {\n\t    if (locateElm(scopes[i].elm) < 0)\n\t\tscopes[i].setElm(null);\n\t    if (scopes[i].elm == null) {\n\t\tint j;\n\t\tfor (j = i; j != scopeCount; j++)\n\t\t    scopes[j] = scopes[j+1];\n\t\tscopeCount--;\n\t\ti--;\n\t\tcontinue;\n\t    }\n\t    if (scopes[i].position > pos+1)\n\t\tscopes[i].position = pos+1;\n\t    pos = scopes[i].position;\n\t}\n\twhile (scopeCount > 0 && scopes[scopeCount-1].elm == null)\n\t    scopeCount--;\n\tint h = winSize.height - circuitArea.height;\n\tpos = 0;\n\tfor (i = 0; i != scopeCount; i++)\n\t    scopeColCount[i] = 0;\n\tfor (i = 0; i != scopeCount; i++) {\n\t    pos = max(scopes[i].position, pos);\n\t    scopeColCount[scopes[i].position]++;\n\t}\n\tint colct = pos+1;\n\tint iw = infoWidth;\n\tif (colct <= 2)\n\t    iw = iw*3/2;\n\tint w = (winSize.width-iw) / colct;\n\tint marg = 10;\n\tif (w < marg*2)\n\t    w = marg*2;\n\tpos = -1;\n\tint colh = 0;\n\tint row = 0;\n\tint speed = 0;\n\tfor (i = 0; i != scopeCount; i++) {\n\t    Scope s = scopes[i];\n\t    if (s.position > pos) {\n\t\tpos = s.position;\n\t\tcolh = h / scopeColCount[pos];\n\t\trow = 0;\n\t\tspeed = s.speed;\n\t    }\n\t    if (s.speed != speed) {\n\t\ts.speed = speed;\n\t\ts.resetGraph();\n\t    }\n\t    Rectangle r = new Rectangle(pos*w, winSize.height-h+colh*row,\n\t\t\t\t\tw-marg, colh);\n\t    row++;\n\t    if (!r.equals(s.rect))\n\t\ts.setRect(r);\n\t}\n    }\n    \n    String getHint() {\n\tCircuitElm c1 = getElm(hintItem1);\n\tCircuitElm c2 = getElm(hintItem2);\n\tif (c1 == null || c2 == null)\n\t    return null;\n\tif (hintType == HINT_LC) {\n\t    if (!(c1 instanceof InductorElm))\n\t\treturn null;\n\t    if (!(c2 instanceof CapacitorElm))\n\t\treturn null;\n\t    InductorElm ie = (InductorElm) c1;\n\t    CapacitorElm ce = (CapacitorElm) c2;\n\t    return \"res.f = \" + CircuitElm.getUnitText(1/(2*pi*Math.sqrt(ie.inductance*\n\t\t\t\t\t\t    ce.capacitance)), \"Hz\");\n\t}\n\tif (hintType == HINT_RC) {\n\t    if (!(c1 instanceof ResistorElm))\n\t\treturn null;\n\t    if (!(c2 instanceof CapacitorElm))\n\t\treturn null;\n\t    ResistorElm re = (ResistorElm) c1;\n\t    CapacitorElm ce = (CapacitorElm) c2;\n\t    return \"RC = \" + CircuitElm.getUnitText(re.resistance*ce.capacitance,\n\t\t\t\t\t \"s\");\n\t}\n\tif (hintType == HINT_3DB_C) {\n\t    if (!(c1 instanceof ResistorElm))\n\t\treturn null;\n\t    if (!(c2 instanceof CapacitorElm))\n\t\treturn null;\n\t    ResistorElm re = (ResistorElm) c1;\n\t    CapacitorElm ce = (CapacitorElm) c2;\n\t    return \"f.3db = \" +\n\t\tCircuitElm.getUnitText(1/(2*pi*re.resistance*ce.capacitance), \"Hz\");\n\t}\n\tif (hintType == HINT_3DB_L) {\n\t    if (!(c1 instanceof ResistorElm))\n\t\treturn null;\n\t    if (!(c2 instanceof InductorElm))\n\t\treturn null;\n\t    ResistorElm re = (ResistorElm) c1;\n\t    InductorElm ie = (InductorElm) c2;\n\t    return \"f.3db = \" +\n\t\tCircuitElm.getUnitText(re.resistance/(2*pi*ie.inductance), \"Hz\");\n\t}\n\tif (hintType == HINT_TWINT) {\n\t    if (!(c1 instanceof ResistorElm))\n\t\treturn null;\n\t    if (!(c2 instanceof CapacitorElm))\n\t\treturn null;\n\t    ResistorElm re = (ResistorElm) c1;\n\t    CapacitorElm ce = (CapacitorElm) c2;\n\t    return \"fc = \" +\n\t\tCircuitElm.getUnitText(1/(2*pi*re.resistance*ce.capacitance), \"Hz\");\n\t}\n\treturn null;\n    }\n\n    public void toggleSwitch(int n) {\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce instanceof SwitchElm) {\n\t\tn--;\n\t\tif (n == 0) {\n\t\t    ((SwitchElm) ce).toggle();\n\t\t    analyzeFlag = true;\n\t\t    cv.repaint();\n\t\t    return;\n\t\t}\n\t    }\n\t}\n    }\n    \n    void needAnalyze() {\n\tanalyzeFlag = true;\n\tcv.repaint();\n    }\n    \n    Vector<CircuitNode> nodeList;\n    CircuitElm voltageSources[];\n\n    public CircuitNode getCircuitNode(int n) {\n\tif (n >= nodeList.size())\n\t    return null;\n\treturn nodeList.elementAt(n);\n    }\n\n    public CircuitElm getElm(int n) {\n\tif (n >= elmList.size())\n\t    return null;\n\treturn elmList.elementAt(n);\n    }\n    \n    void analyzeCircuit() {\n\tcalcCircuitBottom();\n\tif (elmList.isEmpty())\n\t    return;\n\tstopMessage = null;\n\tstopElm = null;\n\tint i, j;\n\tint vscount = 0;\n\tnodeList = new Vector<CircuitNode>();\n\tboolean gotGround = false;\n\tboolean gotRail = false;\n\tCircuitElm volt = null;\n\n\t//System.out.println(\"ac1\");\n\t// look for voltage or ground element\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce instanceof GroundElm) {\n\t\tgotGround = true;\n\t\tbreak;\n\t    }\n\t    if (ce instanceof RailElm)\n\t\tgotRail = true;\n\t    if (volt == null && ce instanceof VoltageElm)\n\t\tvolt = ce;\n\t}\n\n\t// if no ground, and no rails, then the voltage elm's first terminal\n\t// is ground\n\tif (!gotGround && volt != null && !gotRail) {\n\t    CircuitNode cn = new CircuitNode();\n\t    Point pt = volt.getPost(0);\n\t    cn.x = pt.x;\n\t    cn.y = pt.y;\n\t    nodeList.addElement(cn);\n\t} else {\n\t    // otherwise allocate extra node for ground\n\t    CircuitNode cn = new CircuitNode();\n\t    cn.x = cn.y = -1;\n\t    nodeList.addElement(cn);\n\t}\n\t//System.out.println(\"ac2\");\n\n\t// allocate nodes and voltage sources\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    int inodes = ce.getInternalNodeCount();\n\t    int ivs = ce.getVoltageSourceCount();\n\t    int posts = ce.getPostCount();\n\t    \n\t    // allocate a node for each post and match posts to nodes\n\t    for (j = 0; j != posts; j++) {\n\t\tPoint pt = ce.getPost(j);\n\t\tint k;\n\t\tfor (k = 0; k != nodeList.size(); k++) {\n\t\t    CircuitNode cn = getCircuitNode(k);\n\t\t    if (pt.x == cn.x && pt.y == cn.y)\n\t\t\tbreak;\n\t\t}\n\t\tif (k == nodeList.size()) {\n\t\t    CircuitNode cn = new CircuitNode();\n\t\t    cn.x = pt.x;\n\t\t    cn.y = pt.y;\n\t\t    CircuitNodeLink cnl = new CircuitNodeLink();\n\t\t    cnl.num = j;\n\t\t    cnl.elm = ce;\n\t\t    cn.links.addElement(cnl);\n\t\t    ce.setNode(j, nodeList.size());\n\t\t    nodeList.addElement(cn);\n\t\t} else {\n\t\t    CircuitNodeLink cnl = new CircuitNodeLink();\n\t\t    cnl.num = j;\n\t\t    cnl.elm = ce;\n\t\t    getCircuitNode(k).links.addElement(cnl);\n\t\t    ce.setNode(j, k);\n\t\t    // if it's the ground node, make sure the node voltage is 0,\n\t\t    // cause it may not get set later\n\t\t    if (k == 0)\n\t\t\tce.setNodeVoltage(j, 0);\n\t\t}\n\t    }\n\t    for (j = 0; j != inodes; j++) {\n\t\tCircuitNode cn = new CircuitNode();\n\t\tcn.x = cn.y = -1;\n\t\tcn.internal = true;\n\t\tCircuitNodeLink cnl = new CircuitNodeLink();\n\t\tcnl.num = j+posts;\n\t\tcnl.elm = ce;\n\t\tcn.links.addElement(cnl);\n\t\tce.setNode(cnl.num, nodeList.size());\n\t\tnodeList.addElement(cn);\n\t    }\n\t    vscount += ivs;\n\t}\n\tvoltageSources = new CircuitElm[vscount];\n\tvscount = 0;\n\tcircuitNonLinear = false;\n\t//System.out.println(\"ac3\");\n\n\t// determine if circuit is nonlinear\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.nonLinear())\n\t\tcircuitNonLinear = true;\n\t    int ivs = ce.getVoltageSourceCount();\n\t    for (j = 0; j != ivs; j++) {\n\t\tvoltageSources[vscount] = ce;\n\t\tce.setVoltageSource(j, vscount++);\n\t    }\n\t}\n\tvoltageSourceCount = vscount;\n\n\tint matrixSize = nodeList.size()-1 + vscount;\n\tcircuitMatrix = new double[matrixSize][matrixSize];\n\tcircuitRightSide = new double[matrixSize];\n\torigMatrix = new double[matrixSize][matrixSize];\n\torigRightSide = new double[matrixSize];\n\tcircuitMatrixSize = circuitMatrixFullSize = matrixSize;\n\tcircuitRowInfo = new RowInfo[matrixSize];\n\tcircuitPermute = new int[matrixSize];\n\tint vs = 0;\n\tfor (i = 0; i != matrixSize; i++)\n\t    circuitRowInfo[i] = new RowInfo();\n\tcircuitNeedsMap = false;\n\t\n\t// stamp linear circuit elements\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.stamp();\n\t}\n\t//System.out.println(\"ac4\");\n\n\t// determine nodes that are unconnected\n\tboolean closure[] = new boolean[nodeList.size()];\n\tboolean tempclosure[] = new boolean[nodeList.size()];\n\tboolean changed = true;\n\tclosure[0] = true;\n\twhile (changed) {\n\t    changed = false;\n\t    for (i = 0; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\t// loop through all ce's nodes to see if they are connected\n\t\t// to other nodes not in closure\n\t\tfor (j = 0; j < ce.getPostCount(); j++) {\n\t\t    if (!closure[ce.getNode(j)]) {\n\t\t\tif (ce.hasGroundConnection(j))\n\t\t\t    closure[ce.getNode(j)] = changed = true;\n\t\t\tcontinue;\n\t\t    }\n\t\t    int k;\n\t\t    for (k = 0; k != ce.getPostCount(); k++) {\n\t\t\tif (j == k)\n\t\t\t    continue;\n\t\t\tint kn = ce.getNode(k);\n\t\t\tif (ce.getConnection(j, k) && !closure[kn]) {\n\t\t\t    closure[kn] = true;\n\t\t\t    changed = true;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    if (changed)\n\t\tcontinue;\n\n\t    // connect unconnected nodes\n\t    for (i = 0; i != nodeList.size(); i++)\n\t\tif (!closure[i] && !getCircuitNode(i).internal) {\n\t\t    System.out.println(\"node \" + i + \" unconnected\");\n\t\t    stampResistor(0, i, 1e8);\n\t\t    closure[i] = true;\n\t\t    changed = true;\n\t\t    break;\n\t\t}\n\t}\n\t//System.out.println(\"ac5\");\n\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    // look for inductors with no current path\n\t    if (ce instanceof InductorElm) {\n\t\tFindPathInfo fpi = new FindPathInfo(FindPathInfo.INDUCT, ce,\n\t\t\t\t\t\t    ce.getNode(1));\n\t\t// first try findPath with maximum depth of 5, to avoid slowdowns\n\t\tif (!fpi.findPath(ce.getNode(0), 5) &&\n\t\t    !fpi.findPath(ce.getNode(0))) {\n\t\t    System.out.println(ce + \" no path\");\n\t\t    ce.reset();\n\t\t}\n\t    }\n\t    // look for current sources with no current path\n\t    if (ce instanceof CurrentElm) {\n\t\tFindPathInfo fpi = new FindPathInfo(FindPathInfo.INDUCT, ce,\n\t\t\t\t\t\t    ce.getNode(1));\n\t\tif (!fpi.findPath(ce.getNode(0))) {\n\t\t    stop(\"No path for current source!\", ce);\n\t\t    return;\n\t\t}\n\t    }\n\t    // look for voltage source loops\n\t    if ((ce instanceof VoltageElm && ce.getPostCount() == 2) ||\n\t\tce instanceof WireElm) {\n\t\tFindPathInfo fpi = new FindPathInfo(FindPathInfo.VOLTAGE, ce,\n\t\t\t\t\t\t    ce.getNode(1));\n\t\tif (fpi.findPath(ce.getNode(0))) {\n\t\t    stop(\"Voltage source/wire loop with no resistance!\", ce);\n\t\t    return;\n\t\t}\n\t    }\n\t    // look for shorted caps, or caps w/ voltage but no R\n\t    if (ce instanceof CapacitorElm) {\n\t\tFindPathInfo fpi = new FindPathInfo(FindPathInfo.SHORT, ce,\n\t\t\t\t\t\t    ce.getNode(1));\n\t\tif (fpi.findPath(ce.getNode(0))) {\n\t\t    System.out.println(ce + \" shorted\");\n\t\t    ce.reset();\n\t\t} else {\n\t\t    fpi = new FindPathInfo(FindPathInfo.CAP_V, ce, ce.getNode(1));\n\t\t    if (fpi.findPath(ce.getNode(0))) {\n\t\t\tstop(\"Capacitor loop with no resistance!\", ce);\n\t\t\treturn;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\t//System.out.println(\"ac6\");\n\n\t// simplify the matrix; this speeds things up quite a bit\n\tfor (i = 0; i != matrixSize; i++) {\n\t    int qm = -1, qp = -1;\n\t    double qv = 0;\n\t    RowInfo re = circuitRowInfo[i];\n\t    /*System.out.println(\"row \" + i + \" \" + re.lsChanges + \" \" + re.rsChanges + \" \" +\n\t\t\t       re.dropRow);*/\n\t    if (re.lsChanges || re.dropRow || re.rsChanges)\n\t\tcontinue;\n\t    double rsadd = 0;\n\n\t    // look for rows that can be removed\n\t    for (j = 0; j != matrixSize; j++) {\n\t\tdouble q = circuitMatrix[i][j];\n\t\tif (circuitRowInfo[j].type == RowInfo.ROW_CONST) {\n\t\t    // keep a running total of const values that have been\n\t\t    // removed already\n\t\t    rsadd -= circuitRowInfo[j].value*q;\n\t\t    continue;\n\t\t}\n\t\tif (q == 0)\n\t\t    continue;\n\t\tif (qp == -1) {\n\t\t    qp = j;\n\t\t    qv = q;\n\t\t    continue;\n\t\t}\n\t\tif (qm == -1 && q == -qv) {\n\t\t    qm = j;\n\t\t    continue;\n\t\t}\n\t\tbreak;\n\t    }\n\t    //System.out.println(\"line \" + i + \" \" + qp + \" \" + qm + \" \" + j);\n\t    /*if (qp != -1 && circuitRowInfo[qp].lsChanges) {\n\t\tSystem.out.println(\"lschanges\");\n\t\tcontinue;\n\t    }\n\t    if (qm != -1 && circuitRowInfo[qm].lsChanges) {\n\t\tSystem.out.println(\"lschanges\");\n\t\tcontinue;\n\t\t}*/\n\t    if (j == matrixSize) {\n\t\tif (qp == -1) {\n\t\t    stop(\"Matrix error\", null);\n\t\t    return;\n\t\t}\n\t\tRowInfo elt = circuitRowInfo[qp];\n\t\tif (qm == -1) {\n\t\t    // we found a row with only one nonzero entry; that value\n\t\t    // is a constant\n\t\t    int k;\n\t\t    for (k = 0; elt.type == RowInfo.ROW_EQUAL && k < 100; k++) {\n\t\t\t// follow the chain\n\t\t\t/*System.out.println(\"following equal chain from \" +\n\t\t\t\t\t   i + \" \" + qp + \" to \" + elt.nodeEq);*/\n\t\t\tqp = elt.nodeEq;\n\t\t\telt = circuitRowInfo[qp];\n\t\t    }\n\t\t    if (elt.type == RowInfo.ROW_EQUAL) {\n\t\t\t// break equal chains\n\t\t\t//System.out.println(\"Break equal chain\");\n\t\t\telt.type = RowInfo.ROW_NORMAL;\n\t\t\tcontinue;\n\t\t    }\n\t\t    if (elt.type != RowInfo.ROW_NORMAL) {\n\t\t\tSystem.out.println(\"type already \" + elt.type + \" for \" + qp + \"!\");\n\t\t\tcontinue;\n\t\t    }\n\t\t    elt.type = RowInfo.ROW_CONST;\n\t\t    elt.value = (circuitRightSide[i]+rsadd)/qv;\n\t\t    circuitRowInfo[i].dropRow = true;\n\t\t    //System.out.println(qp + \" * \" + qv + \" = const \" + elt.value);\n\t\t    i = -1; // start over from scratch\n\t\t} else if (circuitRightSide[i]+rsadd == 0) {\n\t\t    // we found a row with only two nonzero entries, and one\n\t\t    // is the negative of the other; the values are equal\n\t\t    if (elt.type != RowInfo.ROW_NORMAL) {\n\t\t\t//System.out.println(\"swapping\");\n\t\t\tint qq = qm;\n\t\t\tqm = qp; qp = qq;\n\t\t\telt = circuitRowInfo[qp];\n\t\t\tif (elt.type != RowInfo.ROW_NORMAL) {\n\t\t\t    // we should follow the chain here, but this\n\t\t\t    // hardly ever happens so it's not worth worrying\n\t\t\t    // about\n\t\t\t    System.out.println(\"swap failed\");\n\t\t\t    continue;\n\t\t\t}\n\t\t    }\n\t\t    elt.type = RowInfo.ROW_EQUAL;\n\t\t    elt.nodeEq = qm;\n\t\t    circuitRowInfo[i].dropRow = true;\n\t\t    //System.out.println(qp + \" = \" + qm);\n\t\t}\n\t    }\n\t}\n\t//System.out.println(\"ac7\");\n\n\t// find size of new matrix\n\tint nn = 0;\n\tfor (i = 0; i != matrixSize; i++) {\n\t    RowInfo elt = circuitRowInfo[i];\n\t    if (elt.type == RowInfo.ROW_NORMAL) {\n\t\telt.mapCol = nn++;\n\t\t//System.out.println(\"col \" + i + \" maps to \" + elt.mapCol);\n\t\tcontinue;\n\t    }\n\t    if (elt.type == RowInfo.ROW_EQUAL) {\n\t\tRowInfo e2 = null;\n\t\t// resolve chains of equality; 100 max steps to avoid loops\n\t\tfor (j = 0; j != 100; j++) {\n\t\t    e2 = circuitRowInfo[elt.nodeEq];\n\t\t    if (e2.type != RowInfo.ROW_EQUAL)\n\t\t\tbreak;\n\t\t    if (i == e2.nodeEq)\n\t\t\tbreak;\n\t\t    elt.nodeEq = e2.nodeEq;\n\t\t}\n\t    }\n\t    if (elt.type == RowInfo.ROW_CONST)\n\t\telt.mapCol = -1;\n\t}\n\tfor (i = 0; i != matrixSize; i++) {\n\t    RowInfo elt = circuitRowInfo[i];\n\t    if (elt.type == RowInfo.ROW_EQUAL) {\n\t\tRowInfo e2 = circuitRowInfo[elt.nodeEq];\n\t\tif (e2.type == RowInfo.ROW_CONST) {\n\t\t    // if something is equal to a const, it's a const\n\t\t    elt.type = e2.type;\n\t\t    elt.value = e2.value;\n\t\t    elt.mapCol = -1;\n\t\t    //System.out.println(i + \" = [late]const \" + elt.value);\n\t\t} else {\n\t\t    elt.mapCol = e2.mapCol;\n\t\t    //System.out.println(i + \" maps to: \" + e2.mapCol);\n\t\t}\n\t    }\n\t}\n\t//System.out.println(\"ac8\");\n\n\t/*System.out.println(\"matrixSize = \" + matrixSize);\n\t\n\tfor (j = 0; j != circuitMatrixSize; j++) {\n\t    System.out.println(j + \": \");\n\t    for (i = 0; i != circuitMatrixSize; i++)\n\t\tSystem.out.print(circuitMatrix[j][i] + \" \");\n\t    System.out.print(\"  \" + circuitRightSide[j] + \"\\n\");\n\t}\n\tSystem.out.print(\"\\n\");*/\n\t\n\n\t// make the new, simplified matrix\n\tint newsize = nn;\n\tdouble newmatx[][] = new double[newsize][newsize];\n\tdouble newrs  []   = new double[newsize];\n\tint ii = 0;\n\tfor (i = 0; i != matrixSize; i++) {\n\t    RowInfo rri = circuitRowInfo[i];\n\t    if (rri.dropRow) {\n\t\trri.mapRow = -1;\n\t\tcontinue;\n\t    }\n\t    newrs[ii] = circuitRightSide[i];\n\t    rri.mapRow = ii;\n\t    //System.out.println(\"Row \" + i + \" maps to \" + ii);\n\t    for (j = 0; j != matrixSize; j++) {\n\t\tRowInfo ri = circuitRowInfo[j];\n\t\tif (ri.type == RowInfo.ROW_CONST)\n\t\t    newrs[ii] -= ri.value*circuitMatrix[i][j];\n\t\telse\n\t\t    newmatx[ii][ri.mapCol] += circuitMatrix[i][j];\n\t    }\n\t    ii++;\n\t}\n\n\tcircuitMatrix = newmatx;\n\tcircuitRightSide = newrs;\n\tmatrixSize = circuitMatrixSize = newsize;\n\tfor (i = 0; i != matrixSize; i++)\n\t    origRightSide[i] = circuitRightSide[i];\n\tfor (i = 0; i != matrixSize; i++)\n\t    for (j = 0; j != matrixSize; j++)\n\t\torigMatrix[i][j] = circuitMatrix[i][j];\n\tcircuitNeedsMap = true;\n\n\t/*\n\tSystem.out.println(\"matrixSize = \" + matrixSize + \" \" + circuitNonLinear);\n\tfor (j = 0; j != circuitMatrixSize; j++) {\n\t    for (i = 0; i != circuitMatrixSize; i++)\n\t\tSystem.out.print(circuitMatrix[j][i] + \" \");\n\t    System.out.print(\"  \" + circuitRightSide[j] + \"\\n\");\n\t}\n\tSystem.out.print(\"\\n\");*/\n\n\t// if a matrix is linear, we can do the lu_factor here instead of\n\t// needing to do it every frame\n\tif (!circuitNonLinear) {\n\t    if (!lu_factor(circuitMatrix, circuitMatrixSize, circuitPermute)) {\n\t\tstop(\"Singular matrix!\", null);\n\t\treturn;\n\t    }\n\t}\n    }\n\n    void calcCircuitBottom() {\n\tint i;\n\tcircuitBottom = 0;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    Rectangle rect = getElm(i).boundingBox;\n\t    int bottom = rect.height + rect.y;\n\t    if (bottom > circuitBottom)\n\t\tcircuitBottom = bottom;\n\t}\n    }\n    \n    class FindPathInfo {\n\tstatic final int INDUCT  = 1;\n\tstatic final int VOLTAGE = 2;\n\tstatic final int SHORT   = 3;\n\tstatic final int CAP_V   = 4;\n\tboolean used[];\n\tint dest;\n\tCircuitElm firstElm;\n\tint type;\n\tFindPathInfo(int t, CircuitElm e, int d) {\n\t    dest = d;\n\t    type = t;\n\t    firstElm = e;\n\t    used = new boolean[nodeList.size()];\n\t}\n\tboolean findPath(int n1) { return findPath(n1, -1); }\n\tboolean findPath(int n1, int depth) {\n\t    if (n1 == dest)\n\t\treturn true;\n\t    if (depth-- == 0)\n\t\treturn false;\n\t    if (used[n1]) {\n\t\t//System.out.println(\"used \" + n1);\n\t\treturn false;\n\t    }\n\t    used[n1] = true;\n\t    int i;\n\t    for (i = 0; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\tif (ce == firstElm)\n\t\t    continue;\n\t\tif (type == INDUCT) {\n\t\t    if (ce instanceof CurrentElm)\n\t\t\tcontinue;\n\t\t}\n\t\tif (type == VOLTAGE) {\n\t\t    if (!(ce.isWire() || ce instanceof VoltageElm))\n\t\t\tcontinue;\n\t\t}\n\t\tif (type == SHORT && !ce.isWire())\n\t\t    continue;\n\t\tif (type == CAP_V) {\n\t\t    if (!(ce.isWire() || ce instanceof CapacitorElm ||\n\t\t\t  ce instanceof VoltageElm))\n\t\t\tcontinue;\n\t\t}\n\t\tif (n1 == 0) {\n\t\t    // look for posts which have a ground connection;\n\t\t    // our path can go through ground\n\t\t    int j;\n\t\t    for (j = 0; j != ce.getPostCount(); j++)\n\t\t\tif (ce.hasGroundConnection(j) &&\n\t\t\t    findPath(ce.getNode(j), depth)) {\n\t\t\t    used[n1] = false;\n\t\t\t    return true;\n\t\t\t}\n\t\t}\n\t\tint j;\n\t\tfor (j = 0; j != ce.getPostCount(); j++) {\n\t\t    //System.out.println(ce + \" \" + ce.getNode(j));\n\t\t    if (ce.getNode(j) == n1)\n\t\t\tbreak;\n\t\t}\n\t\tif (j == ce.getPostCount())\n\t\t    continue;\n\t\tif (ce.hasGroundConnection(j) && findPath(0, depth)) {\n\t\t    //System.out.println(ce + \" has ground\");\n\t\t    used[n1] = false;\n\t\t    return true;\n\t\t}\n\t\tif (type == INDUCT && ce instanceof InductorElm) {\n\t\t    double c = ce.getCurrent();\n\t\t    if (j == 0)\n\t\t\tc = -c;\n\t\t    //System.out.println(\"matching \" + c + \" to \" + firstElm.getCurrent());\n\t\t    //System.out.println(ce + \" \" + firstElm);\n\t\t    if (Math.abs(c-firstElm.getCurrent()) > 1e-10)\n\t\t\tcontinue;\n\t\t}\n\t\tint k;\n\t\tfor (k = 0; k != ce.getPostCount(); k++) {\n\t\t    if (j == k)\n\t\t\tcontinue;\n\t\t    //System.out.println(ce + \" \" + ce.getNode(j) + \"-\" + ce.getNode(k));\n\t\t    if (ce.getConnection(j, k) && findPath(ce.getNode(k), depth)) {\n\t\t\t//System.out.println(\"got findpath \" + n1);\n\t\t\tused[n1] = false;\n\t\t\treturn true;\n\t\t    }\n\t\t    //System.out.println(\"back on findpath \" + n1);\n\t\t}\n\t    }\n\t    used[n1] = false;\n\t    //System.out.println(n1 + \" failed\");\n\t    return false;\n\t}\n    }\n\n    void stop(String s, CircuitElm ce) {\n\tstopMessage = s;\n\tcircuitMatrix = null;\n\tstopElm = ce;\n\tstoppedCheck.setState(true);\n\tanalyzeFlag = false;\n\tcv.repaint();\n    }\n    \n    // control voltage source vs with voltage from n1 to n2 (must\n    // also call stampVoltageSource())\n    void stampVCVS(int n1, int n2, double coef, int vs) {\n\tint vn = nodeList.size()+vs;\n\tstampMatrix(vn, n1, coef);\n\tstampMatrix(vn, n2, -coef);\n    }\n    \n    // stamp independent voltage source #vs, from n1 to n2, amount v\n    void stampVoltageSource(int n1, int n2, int vs, double v) {\n\tint vn = nodeList.size()+vs;\n\tstampMatrix(vn, n1, -1);\n\tstampMatrix(vn, n2, 1);\n\tstampRightSide(vn, v);\n\tstampMatrix(n1, vn, 1);\n\tstampMatrix(n2, vn, -1);\n    }\n\n    // use this if the amount of voltage is going to be updated in doStep()\n    void stampVoltageSource(int n1, int n2, int vs) {\n\tint vn = nodeList.size()+vs;\n\tstampMatrix(vn, n1, -1);\n\tstampMatrix(vn, n2, 1);\n\tstampRightSide(vn);\n\tstampMatrix(n1, vn, 1);\n\tstampMatrix(n2, vn, -1);\n    }\n    \n    void updateVoltageSource(int n1, int n2, int vs, double v) {\n\tint vn = nodeList.size()+vs;\n\tstampRightSide(vn, v);\n    }\n    \n    void stampResistor(int n1, int n2, double r) {\n\tdouble r0 = 1/r;\n\tif (Double.isNaN(r0) || Double.isInfinite(r0)) {\n\t    System.out.print(\"bad resistance \" + r + \" \" + r0 + \"\\n\");\n\t    int a = 0;\n\t    a /= a;\n\t}\n\tstampMatrix(n1, n1, r0);\n\tstampMatrix(n2, n2, r0);\n\tstampMatrix(n1, n2, -r0);\n\tstampMatrix(n2, n1, -r0);\n    }\n\n    void stampConductance(int n1, int n2, double r0) {\n\tstampMatrix(n1, n1, r0);\n\tstampMatrix(n2, n2, r0);\n\tstampMatrix(n1, n2, -r0);\n\tstampMatrix(n2, n1, -r0);\n    }\n\n    // current from cn1 to cn2 is equal to voltage from vn1 to 2, divided by g\n    void stampVCCurrentSource(int cn1, int cn2, int vn1, int vn2, double g) {\n\tstampMatrix(cn1, vn1, g);\n\tstampMatrix(cn2, vn2, g);\n\tstampMatrix(cn1, vn2, -g);\n\tstampMatrix(cn2, vn1, -g);\n    }\n\n    void stampCurrentSource(int n1, int n2, double i) {\n\tstampRightSide(n1, -i);\n\tstampRightSide(n2, i);\n    }\n\n    // stamp a current source from n1 to n2 depending on current through vs\n    void stampCCCS(int n1, int n2, int vs, double gain) {\n\tint vn = nodeList.size()+vs;\n\tstampMatrix(n1, vn, gain);\n\tstampMatrix(n2, vn, -gain);\n    }\n\n    // stamp value x in row i, column j, meaning that a voltage change\n    // of dv in node j will increase the current into node i by x dv.\n    // (Unless i or j is a voltage source node.)\n    void stampMatrix(int i, int j, double x) {\n\tif (i > 0 && j > 0) {\n\t    if (circuitNeedsMap) {\n\t\ti = circuitRowInfo[i-1].mapRow;\n\t\tRowInfo ri = circuitRowInfo[j-1];\n\t\tif (ri.type == RowInfo.ROW_CONST) {\n\t\t    //System.out.println(\"Stamping constant \" + i + \" \" + j + \" \" + x);\n\t\t    circuitRightSide[i] -= x*ri.value;\n\t\t    return;\n\t\t}\n\t\tj = ri.mapCol;\n\t\t//System.out.println(\"stamping \" + i + \" \" + j + \" \" + x);\n\t    } else {\n\t\ti--;\n\t\tj--;\n\t    }\n\t    circuitMatrix[i][j] += x;\n\t}\n    }\n\n    // stamp value x on the right side of row i, representing an\n    // independent current source flowing into node i\n    void stampRightSide(int i, double x) {\n\tif (i > 0) {\n\t    if (circuitNeedsMap) {\n\t\ti = circuitRowInfo[i-1].mapRow;\n\t\t//System.out.println(\"stamping \" + i + \" \" + x);\n\t    } else\n\t\ti--;\n\t    circuitRightSide[i] += x;\n\t}\n    }\n\n    // indicate that the value on the right side of row i changes in doStep()\n    void stampRightSide(int i) {\n\t//System.out.println(\"rschanges true \" + (i-1));\n\tif (i > 0)\n\t    circuitRowInfo[i-1].rsChanges = true;\n    }\n    \n    // indicate that the values on the left side of row i change in doStep()\n    void stampNonLinear(int i) {\n\tif (i > 0)\n\t    circuitRowInfo[i-1].lsChanges = true;\n    }\n\n    double getIterCount() {\n\tif (speedBar.getValue() == 0)\n\t    return 0;\n\t//return (Math.exp((speedBar.getValue()-1)/24.) + .5);\n\treturn .1*Math.exp((speedBar.getValue()-61)/24.);\n    }\n    \n    boolean converged;\n    int subIterations;\n    void runCircuit() {\n\tif (circuitMatrix == null || elmList.size() == 0) {\n\t    circuitMatrix = null;\n\t    return;\n\t}\n\tint iter;\n\t//int maxIter = getIterCount();\n\tboolean debugprint = dumpMatrix;\n\tdumpMatrix = false;\n\tlong steprate = (long) (160*getIterCount());\n\tlong tm = System.currentTimeMillis();\n\tlong lit = lastIterTime;\n\tif (1000 >= steprate*(tm-lastIterTime))\n\t    return;\n\tfor (iter = 1; ; iter++) {\n\t    int i, j, k, subiter;\n\t    for (i = 0; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\tce.startIteration();\n\t    }\n\t    steps++;\n\t    final int subiterCount = 5000;\n\t    for (subiter = 0; subiter != subiterCount; subiter++) {\n\t\tconverged = true;\n\t\tsubIterations = subiter;\n\t\tfor (i = 0; i != circuitMatrixSize; i++)\n\t\t    circuitRightSide[i] = origRightSide[i];\n\t\tif (circuitNonLinear) {\n\t\t    for (i = 0; i != circuitMatrixSize; i++)\n\t\t\tfor (j = 0; j != circuitMatrixSize; j++)\n\t\t\t    circuitMatrix[i][j] = origMatrix[i][j];\n\t\t}\n\t\tfor (i = 0; i != elmList.size(); i++) {\n\t\t    CircuitElm ce = getElm(i);\n\t\t    ce.doStep();\n\t\t}\n\t\tif (stopMessage != null)\n\t\t    return;\n\t\tboolean printit = debugprint;\n\t\tdebugprint = false;\n\t\tfor (j = 0; j != circuitMatrixSize; j++) {\n\t\t    for (i = 0; i != circuitMatrixSize; i++) {\n\t\t\tdouble x = circuitMatrix[i][j];\n\t\t\tif (Double.isNaN(x) || Double.isInfinite(x)) {\n\t\t\t    stop(\"nan/infinite matrix!\", null);\n\t\t\t    return;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tif (printit) {\n\t\t    for (j = 0; j != circuitMatrixSize; j++) {\n\t\t\tfor (i = 0; i != circuitMatrixSize; i++)\n\t\t\t    System.out.print(circuitMatrix[j][i] + \",\");\n\t\t\tSystem.out.print(\"  \" + circuitRightSide[j] + \"\\n\");\n\t\t    }\n\t\t    System.out.print(\"\\n\");\n\t\t}\n\t\tif (circuitNonLinear) {\n\t\t    if (converged && subiter > 0)\n\t\t\tbreak;\n\t\t    if (!lu_factor(circuitMatrix, circuitMatrixSize,\n\t\t\t\t  circuitPermute)) {\n\t\t\tstop(\"Singular matrix!\", null);\n\t\t\treturn;\n\t\t    }\n\t\t}\n\t\tlu_solve(circuitMatrix, circuitMatrixSize, circuitPermute,\n\t\t\t circuitRightSide);\n\t\t\n\t\tfor (j = 0; j != circuitMatrixFullSize; j++) {\n\t\t    RowInfo ri = circuitRowInfo[j];\n\t\t    double res = 0;\n\t\t    if (ri.type == RowInfo.ROW_CONST)\n\t\t\tres = ri.value;\n\t\t    else\n\t\t\tres = circuitRightSide[ri.mapCol];\n\t\t    /*System.out.println(j + \" \" + res + \" \" +\n\t\t      ri.type + \" \" + ri.mapCol);*/\n\t\t    if (Double.isNaN(res)) {\n\t\t\tconverged = false;\n\t\t\t//debugprint = true;\n\t\t\tbreak;\n\t\t    }\n\t\t    if (j < nodeList.size()-1) {\n\t\t\tCircuitNode cn = getCircuitNode(j+1);\n\t\t\tfor (k = 0; k != cn.links.size(); k++) {\n\t\t\t    CircuitNodeLink cnl = (CircuitNodeLink)\n\t\t\t\tcn.links.elementAt(k);\n\t\t\t    cnl.elm.setNodeVoltage(cnl.num, res);\n\t\t\t}\n\t\t    } else {\n\t\t\tint ji = j-(nodeList.size()-1);\n\t\t\t//System.out.println(\"setting vsrc \" + ji + \" to \" + res);\n\t\t\tvoltageSources[ji].setCurrent(ji, res);\n\t\t    }\n\t\t}\n\t\tif (!circuitNonLinear)\n\t\t    break;\n\t    }\n\t    if (subiter > 5)\n\t\tSystem.out.print(\"converged after \" + subiter + \" iterations\\n\");\n\t    if (subiter == subiterCount) {\n\t\tstop(\"Convergence failed!\", null);\n\t\tbreak;\n\t    }\n\t    t += timeStep;\n\t    for (i = 0; i != scopeCount; i++)\n\t\tscopes[i].timeStep();\n\t    tm = System.currentTimeMillis();\n\t    lit = tm;\n\t    if (iter*1000 >= steprate*(tm-lastIterTime) ||\n\t\t(tm-lastFrameTime > 500))\n\t\tbreak;\n\t}\n\tlastIterTime = lit;\n\t//System.out.println((System.currentTimeMillis()-lastFrameTime)/(double) iter);\n    }\n\n    int min(int a, int b) { return (a < b) ? a : b; }\n    int max(int a, int b) { return (a > b) ? a : b; }\n\n    void editFuncPoint(int x, int y) {\n\t// XXX\n\tcv.repaint(pause);\n    }\n\n    public void componentHidden(ComponentEvent e){}\n    public void componentMoved(ComponentEvent e){}\n    public void componentShown(ComponentEvent e) {\n\tcv.repaint();\n    }\n\n    public void componentResized(ComponentEvent e) {\n\thandleResize();\n\tcv.repaint(100);\n    }\n    public void actionPerformed(ActionEvent e) {\n\tString ac = e.getActionCommand();\n\tif (e.getSource() == resetButton) {\n\t    int i;\n\t    \n\t    // on IE, drawImage() stops working inexplicably every once in\n\t    // a while.  Recreating it fixes the problem, so we do that here.\n\t    dbimage = main.createImage(winSize.width, winSize.height);\n\t    \n\t    for (i = 0; i != elmList.size(); i++)\n\t\tgetElm(i).reset();\n\t    for (i = 0; i != scopeCount; i++)\n\t\tscopes[i].resetGraph();\n\t    analyzeFlag = true;\n\t    t = 0;\n\t    stoppedCheck.setState(false);\n\t    cv.repaint();\n\t}\n\tif (e.getSource() == dumpMatrixButton)\n\t    dumpMatrix = true;\n\tif (e.getSource() == exportItem)\n\t    doExport(false);\n\tif (e.getSource() == optionsItem)\n\t    doEdit(new EditOptions(this));\n\tif (e.getSource() == importItem)\n\t    doImport();\n\tif (e.getSource() == exportLinkItem)\n\t    doExport(true);\n\tif (e.getSource() == undoItem)\n\t    doUndo();\n\tif (e.getSource() == redoItem)\n\t    doRedo();\n\tif (ac.compareTo(\"Cut\") == 0) {\n\t    if (e.getSource() != elmCutMenuItem)\n\t\tmenuElm = null;\n\t    doCut();\n\t}\n\tif (ac.compareTo(\"Copy\") == 0) {\n\t    if (e.getSource() != elmCopyMenuItem)\n\t\tmenuElm = null;\n\t    doCopy();\n\t}\n\tif (ac.compareTo(\"Paste\") == 0)\n\t    doPaste();\n\tif (e.getSource() == selectAllItem)\n\t    doSelectAll();\n\tif (e.getSource() == exitItem) {\n\t    destroyFrame();\n\t    return;\n\t}\n\tif (ac.compareTo(\"stackAll\") == 0)\n\t    stackAll();\n\tif (ac.compareTo(\"unstackAll\") == 0)\n\t    unstackAll();\n\tif (e.getSource() == elmEditMenuItem)\n\t    doEdit(menuElm);\n\tif (ac.compareTo(\"Delete\") == 0) {\n\t    if (e.getSource() != elmDeleteMenuItem)\n\t\tmenuElm = null;\n\t    doDelete();\n\t}\n\tif (e.getSource() == elmScopeMenuItem && menuElm != null) {\n\t    int i;\n\t    for (i = 0; i != scopeCount; i++)\n\t\tif (scopes[i].elm == null)\n\t\t    break;\n\t    if (i == scopeCount) {\n\t\tif (scopeCount == scopes.length)\n\t\t    return;\n\t\tscopeCount++;\n\t\tscopes[i] = new Scope(this);\n\t\tscopes[i].position = i;\n\t\thandleResize();\n\t    }\n\t    scopes[i].setElm(menuElm);\n\t}\n\tif (menuScope != -1) {\n\t    if (ac.compareTo(\"remove\") == 0)\n\t\tscopes[menuScope].setElm(null);\n\t    if (ac.compareTo(\"speed2\") == 0)\n\t\tscopes[menuScope].speedUp();\n\t    if (ac.compareTo(\"speed1/2\") == 0)\n\t\tscopes[menuScope].slowDown();\n\t    if (ac.compareTo(\"scale\") == 0)\n\t\tscopes[menuScope].adjustScale(.5);\n\t    if (ac.compareTo(\"maxscale\") == 0)\n\t\tscopes[menuScope].adjustScale(1e-50);\n\t    if (ac.compareTo(\"stack\") == 0)\n\t\tstackScope(menuScope);\n\t    if (ac.compareTo(\"unstack\") == 0)\n\t\tunstackScope(menuScope);\n\t    if (ac.compareTo(\"selecty\") == 0)\n\t\tscopes[menuScope].selectY();\n\t    if (ac.compareTo(\"reset\") == 0)\n\t\tscopes[menuScope].resetGraph();\n\t    cv.repaint();\n\t}\n\tif (ac.indexOf(\"setup \") == 0) {\n\t    pushUndo();\n\t    readSetupFile(ac.substring(6),\n\t\t\t  ((MenuItem) e.getSource()).getLabel());\n\t}\n    }\n\n    void stackScope(int s) {\n\tif (s == 0) {\n\t    if (scopeCount < 2)\n\t\treturn;\n\t    s = 1;\n\t}\n\tif (scopes[s].position == scopes[s-1].position)\n\t    return;\n\tscopes[s].position = scopes[s-1].position;\n\tfor (s++; s < scopeCount; s++)\n\t    scopes[s].position--;\n    }\n    \n    void unstackScope(int s) {\n\tif (s == 0) {\n\t    if (scopeCount < 2)\n\t\treturn;\n\t    s = 1;\n\t}\n\tif (scopes[s].position != scopes[s-1].position)\n\t    return;\n\tfor (; s < scopeCount; s++)\n\t    scopes[s].position++;\n    }\n\n    void stackAll() {\n\tint i;\n\tfor (i = 0; i != scopeCount; i++) {\n\t    scopes[i].position = 0;\n\t    scopes[i].showMax = scopes[i].showMin = false;\n\t}\n    }\n\n    void unstackAll() {\n\tint i;\n\tfor (i = 0; i != scopeCount; i++) {\n\t    scopes[i].position = i;\n\t    scopes[i].showMax = true;\n\t}\n    }\n    \n    void doEdit(Editable eable) {\n\tclearSelection();\n\tpushUndo();\n\tif (editDialog != null) {\n\t    requestFocus();\n\t    editDialog.setVisible(false);\n\t    editDialog = null;\n\t}\n\teditDialog = new EditDialog(eable, this);\n\teditDialog.show();\n    }\n\n    void doImport() {\n\tif (impDialog == null)\n\t    impDialog = ImportExportDialogFactory.Create(this,\n\t\tImportExportDialog.Action.IMPORT);\n//\t    impDialog = new ImportExportClipboardDialog(this,\n//\t\tImportExportDialog.Action.IMPORT);\n\tpushUndo();\n\timpDialog.execute();\n    }\n\n    void doExport(boolean url)\n    {\n    \tString dump = dumpCircuit();\n\tif (url)\n\t    dump = baseURL + \"#\" + URLEncoder.encode(dump);\n\tif (expDialog == null) {\n\t    expDialog = ImportExportDialogFactory.Create(this,\n\t\t ImportExportDialog.Action.EXPORT);\n//\t    expDialog = new ImportExportClipboardDialog(this,\n//\t\t ImportExportDialog.Action.EXPORT);\n\t}\n        expDialog.setDump(dump);\n\texpDialog.execute();\n    }\n    \n    String dumpCircuit() {\n\tint i;\n\tint f = (dotsCheckItem.getState()) ? 1 : 0;\n\tf |= (smallGridCheckItem.getState()) ? 2 : 0;\n\tf |= (voltsCheckItem.getState()) ? 0 : 4;\n\tf |= (powerCheckItem.getState()) ? 8 : 0;\n\tf |= (showValuesCheckItem.getState()) ? 0 : 16;\n\t// 32 = linear scale in afilter\n\tString dump = \"$ \" + f + \" \" +\n\t    timeStep + \" \" + getIterCount() + \" \" +\n\t    currentBar.getValue() + \" \" + CircuitElm.voltageRange + \" \" +\n\t    powerBar.getValue() + \"\\n\";\n\tfor (i = 0; i != elmList.size(); i++)\n\t    dump += getElm(i).dump() + \"\\n\";\n\tfor (i = 0; i != scopeCount; i++) {\n\t    String d = scopes[i].dump();\n\t    if (d != null)\n\t\tdump += d + \"\\n\";\n\t}\n\tif (hintType != -1)\n\t    dump += \"h \" + hintType + \" \" + hintItem1 + \" \" +\n\t\thintItem2 + \"\\n\";\n\treturn dump;\n    }\n    \n    public void adjustmentValueChanged(AdjustmentEvent e) {\n\tSystem.out.print(((Scrollbar) e.getSource()).getValue() + \"\\n\");\n    }\n\n    ByteArrayOutputStream readUrlData(URL url) throws java.io.IOException {\n\tObject o = url.getContent();\n\tFilterInputStream fis = (FilterInputStream) o;\n\tByteArrayOutputStream ba = new ByteArrayOutputStream(fis.available());\n\tint blen = 1024;\n\tbyte b[] = new byte[blen];\n\twhile (true) {\n\t    int len = fis.read(b);\n\t    if (len <= 0)\n\t\tbreak;\n\t    ba.write(b, 0, len);\n\t}\n\treturn ba;\n    }\n\n    URL getCodeBase() {\n\ttry {\n\t    if (applet != null)\n\t\treturn applet.getCodeBase();\n\t    File f = new File(\".\");\n\t    return new URL(\"file:\" + f.getCanonicalPath() + \"/\");\n\t} catch (Exception e) {\n\t    e.printStackTrace();\n\t    return null;\n\t}\n    }\n    \n    void getSetupList(Menu menu, boolean retry) {\n\tMenu stack[] = new Menu[6];\n\tint stackptr = 0;\n\tstack[stackptr++] = menu;\n\ttry {\n\t    // hausen: if setuplist.txt does not exist in the same\n\t    // directory, try reading from the jar file\n\t    ByteArrayOutputStream ba = null;\n\t    try {\n\t\tURL url = new URL(getCodeBase() + \"setuplist.txt\");\n\t\tba = readUrlData(url);\n\t    } catch (Exception e) {\n\t\tURL url = getClass().getClassLoader().getResource(\"setuplist.txt\");\n\t\tba = readUrlData(url);\n\t    }\n\t    // /hausen\n\n\t    byte b[] = ba.toByteArray();\n\t    int len = ba.size();\n\t    int p;\n\t    if (len == 0 || b[0] != '#') {\n\t\t// got a redirect, try again\n\t\tgetSetupList(menu, true);\n\t\treturn;\n\t    }\n\t    for (p = 0; p < len; ) {\n\t\tint l;\n\t\tfor (l = 0; l != len-p; l++)\n\t\t    if (b[l+p] == '\\n') {\n\t\t\tl++;\n\t\t\tbreak;\n\t\t    }\n\t\tString line = new String(b, p, l-1);\n\t\tif (line.charAt(0) == '#')\n\t\t    ;\n\t\telse if (line.charAt(0) == '+') {\n\t\t    Menu n = new Menu(line.substring(1));\n\t\t    menu.add(n);\n\t\t    menu = stack[stackptr++] = n;\n\t\t} else if (line.charAt(0) == '-') {\n\t\t    menu = stack[--stackptr-1];\n\t\t} else {\n\t\t    int i = line.indexOf(' ');\n\t\t    if (i > 0) {\n\t\t\tString title = line.substring(i+1);\n\t\t\tboolean first = false;\n\t\t\tif (line.charAt(0) == '>')\n\t\t\t    first = true;\n\t\t\tString file = line.substring(first ? 1 : 0, i);\n\t\t\tmenu.add(getMenuItem(title, \"setup \" + file));\n\t\t\tif (first && startCircuit == null) {\n\t\t\t    startCircuit = file;\n\t\t\t    startLabel = title;\n\t\t\t}\n\t\t    }\n\t\t}\n\t\tp += l;\n\t    }\n\t} catch (Exception e) {\n\t    e.printStackTrace();\n\t    stop(\"Can't read setuplist.txt!\", null);\n\t}\n    }\n\n    void readSetup(String text) {\n\treadSetup(text, false);\n    }\n    \n    void readSetup(String text, boolean retain) {\n\treadSetup(text.getBytes(), text.length(), retain);\n\ttitleLabel.setText(\"untitled\");\n    }\n\n    void readSetupFile(String str, String title) {\n\tt = 0;\n\tSystem.out.println(str);\n\ttry {\n\t    URL url = new URL(getCodeBase() + \"circuits/\" + str);\n\t    ByteArrayOutputStream ba = readUrlData(url);\n\t    readSetup(ba.toByteArray(), ba.size(), false);\n\t} catch (Exception e1) {\n\t    try {\n\t\tURL url = getClass().getClassLoader().getResource(\"circuits/\" + str);\n\t\tByteArrayOutputStream ba = readUrlData(url);\n\t\treadSetup(ba.toByteArray(), ba.size(), false);\n\t    } catch (Exception e) {\n\t\te.printStackTrace();\n\t\tstop(\"Unable to read \" + str + \"!\", null);\n\t    }\n\t}\n\ttitleLabel.setText(title);\n    }\n\n    void readSetup(byte b[], int len, boolean retain) {\n\tint i;\n\tif (!retain) {\n\t    for (i = 0; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\tce.delete();\n\t    }\n\t    elmList.removeAllElements();\n\t    hintType = -1;\n\t    timeStep = 5e-6;\n\t    dotsCheckItem.setState(false); // hausen: changed from true to false\n\t    smallGridCheckItem.setState(false);\n\t    powerCheckItem.setState(false);\n\t    voltsCheckItem.setState(true);\n\t    showValuesCheckItem.setState(true);\n\t    setGrid();\n\t    speedBar.setValue(117); // 57\n\t    currentBar.setValue(50);\n\t    powerBar.setValue(50);\n\t    CircuitElm.voltageRange = 5;\n\t    scopeCount = 0;\n\t}\n\tcv.repaint();\n\tint p;\n\tfor (p = 0; p < len; ) {\n\t    int l;\n\t    int linelen = 0;\n\t    for (l = 0; l != len-p; l++)\n\t\tif (b[l+p] == '\\n' || b[l+p] == '\\r') {\n\t\t    linelen = l++;\n\t\t    if (l+p < b.length && b[l+p] == '\\n')\n\t\t\tl++;\n\t\t    break;\n\t\t}\n\t    String line = new String(b, p, linelen);\n\t    StringTokenizer st = new StringTokenizer(line);\n\t    while (st.hasMoreTokens()) {\n\t\tString type = st.nextToken();\n\t\tint tint = type.charAt(0);\n\t\ttry {\n\t\t    if (tint == 'o') {\n\t\t\tScope sc = new Scope(this);\n\t\t\tsc.position = scopeCount;\n\t\t\tsc.undump(st);\n\t\t\tscopes[scopeCount++] = sc;\n\t\t\tbreak;\n\t\t    }\n\t\t    if (tint == 'h') {\n\t\t\treadHint(st);\n\t\t\tbreak;\n\t\t    }\n\t\t    if (tint == '$') {\n\t\t\treadOptions(st);\n\t\t\tbreak;\n\t\t    }\n\t\t    if (tint == '%' || tint == '?' || tint == 'B') {\n\t\t\t// ignore afilter-specific stuff\n\t\t\tbreak;\n\t\t    }\n\t\t    if (tint >= '0' && tint <= '9')\n\t\t\ttint = new Integer(type).intValue();\n\t\t    int x1 = new Integer(st.nextToken()).intValue();\n\t\t    int y1 = new Integer(st.nextToken()).intValue();\n\t\t    int x2 = new Integer(st.nextToken()).intValue();\n\t\t    int y2 = new Integer(st.nextToken()).intValue();\n\t\t    int f  = new Integer(st.nextToken()).intValue();\n\t\t    CircuitElm ce = null;\n\t\t    Class cls = dumpTypes[tint];\n\t\t    if (cls == null) {\n\t\t\tSystem.out.println(\"unrecognized dump type: \" + type);\n\t\t\tbreak;\n\t\t    }\n\t\t    // find element class\n\t\t    Class carr[] = new Class[6];\n\t\t    //carr[0] = getClass();\n\t\t    carr[0] = carr[1] = carr[2] = carr[3] = carr[4] =\n\t\t\tint.class;\n\t\t    carr[5] = StringTokenizer.class;\n\t\t    Constructor cstr = null;\n\t\t    cstr = cls.getConstructor(carr);\n\t\t\n\t\t    // invoke constructor with starting coordinates\n\t\t    Object oarr[] = new Object[6];\n\t\t    //oarr[0] = this;\n\t\t    oarr[0] = new Integer(x1);\n\t\t    oarr[1] = new Integer(y1);\n\t\t    oarr[2] = new Integer(x2);\n\t\t    oarr[3] = new Integer(y2);\n\t\t    oarr[4] = new Integer(f );\n\t\t    oarr[5] = st;\n\t\t    ce = (CircuitElm) cstr.newInstance(oarr);\n\t\t    ce.setPoints();\n\t\t    elmList.addElement(ce);\n\t\t} catch (java.lang.reflect.InvocationTargetException ee) {\n\t\t    ee.getTargetException().printStackTrace();\n\t\t    break;\n\t\t} catch (Exception ee) {\n\t\t    ee.printStackTrace();\n\t\t    break;\n\t\t}\n\t\tbreak;\n\t    }\n\t    p += l;\n\t    \n\t}\n\tenableItems();\n\tif (!retain)\n\t    handleResize(); // for scopes\n\tneedAnalyze();\n    }\n\n    void readHint(StringTokenizer st) {\n\thintType  = new Integer(st.nextToken()).intValue();\n\thintItem1 = new Integer(st.nextToken()).intValue();\n\thintItem2 = new Integer(st.nextToken()).intValue();\n    }\n\n    void readOptions(StringTokenizer st) {\n\tint flags = new Integer(st.nextToken()).intValue();\n\tdotsCheckItem.setState((flags & 1) != 0);\n\tsmallGridCheckItem.setState((flags & 2) != 0);\n\tvoltsCheckItem.setState((flags & 4) == 0);\n\tpowerCheckItem.setState((flags & 8) == 8);\n\tshowValuesCheckItem.setState((flags & 16) == 0);\n\ttimeStep = new Double (st.nextToken()).doubleValue();\n\tdouble sp = new Double(st.nextToken()).doubleValue();\n\tint sp2 = (int) (Math.log(10*sp)*24+61.5);\n\t//int sp2 = (int) (Math.log(sp)*24+1.5);\n\tspeedBar.setValue(sp2);\n\tcurrentBar.setValue(new Integer(st.nextToken()).intValue());\n\tCircuitElm.voltageRange = new Double (st.nextToken()).doubleValue();\n\ttry {\n\t    powerBar.setValue(new Integer(st.nextToken()).intValue());\n\t} catch (Exception e) {\n\t}\n\tsetGrid();\n    }\n    \n    int snapGrid(int x) {\n\treturn (x+gridRound) & gridMask;\n    }\n\n    boolean doSwitch(int x, int y) {\n\tif (mouseElm == null || !(mouseElm instanceof SwitchElm))\n\t    return false;\n\tSwitchElm se = (SwitchElm) mouseElm;\n\tse.toggle();\n\tif (se.momentary)\n\t    heldSwitchElm = se;\n\tneedAnalyze();\n\treturn true;\n    }\n\n    int locateElm(CircuitElm elm) {\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++)\n\t    if (elm == elmList.elementAt(i))\n\t\treturn i;\n\treturn -1;\n    }\n    \n    public void mouseDragged(MouseEvent e) {\n\t// ignore right mouse button with no modifiers (needed on PC)\n\tif ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {\n\t    int ex = e.getModifiersEx();\n\t    if ((ex & (MouseEvent.META_DOWN_MASK|\n\t\t       MouseEvent.SHIFT_DOWN_MASK|\n\t\t       MouseEvent.CTRL_DOWN_MASK|\n\t\t       MouseEvent.ALT_DOWN_MASK)) == 0)\n\t\treturn;\n\t}\n\tif (!circuitArea.contains(e.getX(), e.getY()))\n\t    return;\n\tif (dragElm != null)\n\t    dragElm.drag(e.getX(), e.getY());\n\tboolean success = true;\n\tswitch (tempMouseMode) {\n\tcase MODE_DRAG_ALL:\n\t    dragAll(snapGrid(e.getX()), snapGrid(e.getY()));\n\t    break;\n\tcase MODE_DRAG_ROW:\n\t    dragRow(snapGrid(e.getX()), snapGrid(e.getY()));\n\t    break;\n\tcase MODE_DRAG_COLUMN:\n\t    dragColumn(snapGrid(e.getX()), snapGrid(e.getY()));\n\t    break;\n\tcase MODE_DRAG_POST:\n\t    if (mouseElm != null)\n\t\tdragPost(snapGrid(e.getX()), snapGrid(e.getY()));\n\t    break;\n\tcase MODE_SELECT:\n\t    if (mouseElm == null)\n\t\tselectArea(e.getX(), e.getY());\n\t    else {\n\t\ttempMouseMode = MODE_DRAG_SELECTED;\n\t\tsuccess = dragSelected(e.getX(), e.getY());\n\t    }\n\t    break;\n\tcase MODE_DRAG_SELECTED:\n\t    success = dragSelected(e.getX(), e.getY());\n\t    break;\n\t}\n\tdragging = true;\n\tif (success) {\n\t    if (tempMouseMode == MODE_DRAG_SELECTED && mouseElm instanceof GraphicElm ) {\n\t\tdragX = e.getX(); dragY = e.getY();\n\t    } else {\n\t\tdragX = snapGrid(e.getX()); dragY = snapGrid(e.getY());\n\t    }\n\t}\n\tcv.repaint(pause);\n    }\n\n    void dragAll(int x, int y) {\n\tint dx = x-dragX;\n\tint dy = y-dragY;\n\tif (dx == 0 && dy == 0)\n\t    return;\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.move(dx, dy);\n\t}\n\tremoveZeroLengthElements();\n    }\n\n    void dragRow(int x, int y) {\n\tint dy = y-dragY;\n\tif (dy == 0)\n\t    return;\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.y  == dragY)\n\t\tce.movePoint(0, 0, dy);\n\t    if (ce.y2 == dragY)\n\t\tce.movePoint(1, 0, dy);\n\t}\n\tremoveZeroLengthElements();\n    }\n    \n    void dragColumn(int x, int y) {\n\tint dx = x-dragX;\n\tif (dx == 0)\n\t    return;\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.x  == dragX)\n\t\tce.movePoint(0, dx, 0);\n\t    if (ce.x2 == dragX)\n\t\tce.movePoint(1, dx, 0);\n\t}\n\tremoveZeroLengthElements();\n    }\n\n    boolean dragSelected(int x, int y) {\n\tboolean me = false;\n\tif (mouseElm != null && !mouseElm.isSelected())\n\t    mouseElm.setSelected(me = true);\n\n\t// snap grid, unless we're only dragging text elements\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if ( ce.isSelected() && !(ce instanceof GraphicElm) )\n\t\tbreak;\n\t}\n\tif (i != elmList.size()) {\n\t    x = snapGrid(x);\n\t    y = snapGrid(y);\n\t}\n\t\n\tint dx = x-dragX;\n\tint dy = y-dragY;\n\tif (dx == 0 && dy == 0) {\n\t    // don't leave mouseElm selected if we selected it above\n\t    if (me)\n\t\tmouseElm.setSelected(false);\n\t    return false;\n\t}\n\tboolean allowed = true;\n\n\t// check if moves are allowed\n\tfor (i = 0; allowed && i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.isSelected() && !ce.allowMove(dx, dy))\n\t\tallowed = false;\n\t}\n\n\tif (allowed) {\n\t    for (i = 0; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\tif (ce.isSelected())\n\t\t    ce.move(dx, dy);\n\t    }\n\t    needAnalyze();\n\t}\n\t\n\t// don't leave mouseElm selected if we selected it above\n\tif (me)\n\t    mouseElm.setSelected(false);\n\t\n\treturn allowed;\n    }\n\n    void dragPost(int x, int y) {\n\tif (draggingPost == -1) {\n\t    draggingPost =\n\t\t(distanceSq(mouseElm.x , mouseElm.y , x, y) >\n\t\t distanceSq(mouseElm.x2, mouseElm.y2, x, y)) ? 1 : 0;\n\t}\n\tint dx = x-dragX;\n\tint dy = y-dragY;\n\tif (dx == 0 && dy == 0)\n\t    return;\n\tmouseElm.movePoint(draggingPost, dx, dy);\n\tneedAnalyze();\n    }\n\n    void selectArea(int x, int y) {\n\tint x1 = min(x, initDragX);\n\tint x2 = max(x, initDragX);\n\tint y1 = min(y, initDragY);\n\tint y2 = max(y, initDragY);\n\tselectedArea = new Rectangle(x1, y1, x2-x1, y2-y1);\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.selectRect(selectedArea);\n\t}\n    }\n\n    void setSelectedElm(CircuitElm cs) {\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.setSelected(ce == cs);\n\t}\n\tmouseElm = cs;\n    }\n    \n    void removeZeroLengthElements() {\n\tint i;\n\tboolean changed = false;\n\tfor (i = elmList.size()-1; i >= 0; i--) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.x == ce.x2 && ce.y == ce.y2) {\n\t\telmList.removeElementAt(i);\n\t\tce.delete();\n\t\tchanged = true;\n\t    }\n\t}\n\tneedAnalyze();\n    }\n\n    public void mouseMoved(MouseEvent e) {\n\tif ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0)\n\t    return;\n\tint x = e.getX();\n\tint y = e.getY();\n\tdragX = snapGrid(x); dragY = snapGrid(y);\n\tdraggingPost = -1;\n\tint i;\n\tCircuitElm origMouse = mouseElm;\n\tmouseElm = null;\n\tmousePost = -1;\n\tplotXElm = plotYElm = null;\n\tint bestDist = 100000;\n\tint bestArea = 100000;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.boundingBox.contains(x, y)) {\n\t\tint j;\n\t\tint area = ce.boundingBox.width * ce.boundingBox.height;\n\t\tint jn = ce.getPostCount();\n\t\tif (jn > 2)\n\t\t    jn = 2;\n\t\tfor (j = 0; j != jn; j++) {\n\t\t    Point pt = ce.getPost(j);\n\t\t    int dist = distanceSq(x, y, pt.x, pt.y);\n\n\t\t    // if multiple elements have overlapping bounding boxes,\n\t\t    // we prefer selecting elements that have posts close\n\t\t    // to the mouse pointer and that have a small bounding\n\t\t    // box area.\n\t\t    if (dist <= bestDist && area <= bestArea) {\n\t\t\tbestDist = dist;\n\t\t\tbestArea = area;\n\t\t\tmouseElm = ce;\n\t\t    }\n\t\t}\n\t\tif (ce.getPostCount() == 0)\n\t\t    mouseElm = ce;\n\t    }\n\t}\n\tscopeSelected = -1;\n\tif (mouseElm == null) {\n\t    for (i = 0; i != scopeCount; i++) {\n\t\tScope s = scopes[i];\n\t\tif (s.rect.contains(x, y)) {\n\t\t    s.select();\n\t\t    scopeSelected = i;\n\t\t}\n\t    }\n\t    // the mouse pointer was not in any of the bounding boxes, but we\n\t    // might still be close to a post\n\t    for (i = 0; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\tint j;\n\t\tint jn = ce.getPostCount();\n\t\tfor (j = 0; j != jn; j++) {\n\t\t    Point pt = ce.getPost(j);\n\t\t    int dist = distanceSq(x, y, pt.x, pt.y);\n\t\t    if (distanceSq(pt.x, pt.y, x, y) < 26) {\n\t\t\tmouseElm = ce;\n\t\t\tmousePost = j;\n\t\t\tbreak;\n\t\t    }\n\t\t}\n\t    }\n\t} else {\n\t    mousePost = -1;\n\t    // look for post close to the mouse pointer\n\t    for (i = 0; i != mouseElm.getPostCount(); i++) {\n\t\tPoint pt = mouseElm.getPost(i);\n\t\tif (distanceSq(pt.x, pt.y, x, y) < 26)\n\t\t    mousePost = i;\n\t    }\n\t}\n\tif (mouseElm != origMouse)\n\t    cv.repaint();\n    }\n\n    int distanceSq(int x1, int y1, int x2, int y2) {\n\tx2 -= x1;\n\ty2 -= y1;\n\treturn x2*x2+y2*y2;\n    }\n\n    public void mouseClicked(MouseEvent e) {\n\tif ( e.getClickCount() == 2 && !didSwitch )\n\t    doEditMenu(e);\n\tif ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {\n\t    if (mouseMode == MODE_SELECT || mouseMode == MODE_DRAG_SELECTED)\n\t\tclearSelection();\n\t}\n    }\n    public void mouseEntered(MouseEvent e) {\n    }\n    public void mouseExited(MouseEvent e) {\n\tscopeSelected = -1;\n\tmouseElm = plotXElm = plotYElm = null;\n\tcv.repaint();\n    }\n    \n    public void mousePressed(MouseEvent e) {\n\tdidSwitch = false;\n\n\tSystem.out.println(e.getModifiers());\n\tint ex = e.getModifiersEx();\n\tif ((ex & (MouseEvent.META_DOWN_MASK|\n\t\t   MouseEvent.SHIFT_DOWN_MASK)) == 0 && e.isPopupTrigger()) {\n\t    doPopupMenu(e);\n\t    return;\n\t}\n\tif ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {\n\t    // left mouse\n\t    tempMouseMode = mouseMode;\n\t    if ((ex & MouseEvent.ALT_DOWN_MASK) != 0 &&\n\t\t(ex & MouseEvent.META_DOWN_MASK) != 0)\n\t\ttempMouseMode = MODE_DRAG_COLUMN;\n\t    else if ((ex & MouseEvent.ALT_DOWN_MASK) != 0 &&\n\t\t     (ex & MouseEvent.SHIFT_DOWN_MASK) != 0)\n\t\ttempMouseMode = MODE_DRAG_ROW;\n\t    else if ((ex & MouseEvent.SHIFT_DOWN_MASK) != 0)\n\t\ttempMouseMode = MODE_SELECT;\n\t    else if ((ex & MouseEvent.ALT_DOWN_MASK) != 0)\n\t\ttempMouseMode = MODE_DRAG_ALL;\n\t    else if ((ex & (MouseEvent.CTRL_DOWN_MASK|\n\t\t\t    MouseEvent.META_DOWN_MASK)) != 0)\n\t\ttempMouseMode = MODE_DRAG_POST;\n\t} else if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {\n\t    // right mouse\n\t    if ((ex & MouseEvent.SHIFT_DOWN_MASK) != 0)\n\t\ttempMouseMode = MODE_DRAG_ROW;\n\t    else if ((ex & (MouseEvent.CTRL_DOWN_MASK|\n\t\t\t    MouseEvent.META_DOWN_MASK)) != 0)\n\t\ttempMouseMode = MODE_DRAG_COLUMN;\n\t    else\n\t\treturn;\n\t}\n\t\n\tif (tempMouseMode != MODE_SELECT && tempMouseMode != MODE_DRAG_SELECTED)\n\t    clearSelection();\n\tif (mouseMode == MODE_SELECT && doSwitch(e.getX(), e.getY()))\n\t{\n            didSwitch = true;\n\t    return;\n\t}\n\n\tpushUndo();\n\tinitDragX = e.getX();\n\tinitDragY = e.getY();\n\tdragging = true;\n\tif (tempMouseMode != MODE_ADD_ELM || addingClass == null)\n\t    return;\n\t\n\tint x0 = snapGrid(e.getX());\n\tint y0 = snapGrid(e.getY());\n\tif (!circuitArea.contains(x0, y0))\n\t    return;\n\n\tdragElm = constructElement(addingClass, x0, y0);\n    }\n\n    CircuitElm constructElement(Class c, int x0, int y0) {\n\t// find element class\n\tClass carr[] = new Class[2];\n\t//carr[0] = getClass();\n\tcarr[0] = carr[1] = int.class;\n\tConstructor cstr = null;\n\ttry {\n\t    cstr = c.getConstructor(carr);\n\t} catch (NoSuchMethodException ee) {\n\t    System.out.println(\"caught NoSuchMethodException \" + c);\n\t    return null;\n\t} catch (Exception ee) {\n\t    ee.printStackTrace();\n\t    return null;\n\t}\n\n\t// invoke constructor with starting coordinates\n\tObject oarr[] = new Object[2];\n\toarr[0] = new Integer(x0);\n\toarr[1] = new Integer(y0);\n\ttry {\n\t    return (CircuitElm) cstr.newInstance(oarr);\n\t} catch (Exception ee) { ee.printStackTrace(); }\n\treturn null;\n    }\n\n    // hausen: add doEditMenu\n    void doEditMenu(MouseEvent e) {\n\tif( mouseElm != null )\n\t    doEdit(mouseElm);\n    }\n\n    void doPopupMenu(MouseEvent e) {\n\tmenuElm = mouseElm;\n\tmenuScope = -1;\n\tif (scopeSelected != -1) {\n\t    PopupMenu m = scopes[scopeSelected].getMenu();\n\t    menuScope = scopeSelected;\n\t    if (m != null)\n\t\tm.show(e.getComponent(), e.getX(), e.getY());\n\t} else if (mouseElm != null) {\n\t    elmEditMenuItem .setEnabled(mouseElm.getEditInfo(0) != null);\n\t    elmScopeMenuItem.setEnabled(mouseElm.canViewInScope());\n\t    elmMenu.show(e.getComponent(), e.getX(), e.getY());\n\t} else {\n\t    doMainMenuChecks(mainMenu);\n\t    mainMenu.show(e.getComponent(), e.getX(), e.getY());\n\t}\n    }\n\n    void doMainMenuChecks(Menu m) {\n\tint i;\n\tif (m == optionsMenu)\n\t    return;\n\tfor (i = 0; i != m.getItemCount(); i++) {\n\t    MenuItem mc = m.getItem(i);\n\t    if (mc instanceof Menu)\n\t\tdoMainMenuChecks((Menu) mc);\n\t    if (mc instanceof CheckboxMenuItem) {\n\t\tCheckboxMenuItem cmi = (CheckboxMenuItem) mc;\n\t\tcmi.setState(\n\t\t      mouseModeStr.compareTo(cmi.getActionCommand()) == 0);\n\t    }\n\t}\n    }\n    \n    public void mouseReleased(MouseEvent e) {\n\tint ex = e.getModifiersEx();\n\tif ((ex & (MouseEvent.SHIFT_DOWN_MASK|MouseEvent.CTRL_DOWN_MASK|\n\t\t   MouseEvent.META_DOWN_MASK)) == 0 && e.isPopupTrigger()) {\n\t    doPopupMenu(e);\n\t    return;\n\t}\n\ttempMouseMode = mouseMode;\n\tselectedArea = null;\n\tdragging = false;\n\tboolean circuitChanged = false;\n\tif (heldSwitchElm != null) {\n\t    heldSwitchElm.mouseUp();\n\t    heldSwitchElm = null;\n\t    circuitChanged = true;\n\t}\n\tif (dragElm != null) {\n\t    // if the element is zero size then don't create it\n\t    if (dragElm.x == dragElm.x2 && dragElm.y == dragElm.y2)\n\t\tdragElm.delete();\n\t    else {\n\t\telmList.addElement(dragElm);\n\t\tcircuitChanged = true;\n\t    }\n\t    dragElm = null;\n\t}\n\tif (circuitChanged)\n\t    needAnalyze();\n\tif (dragElm != null)\n\t    dragElm.delete();\n\tdragElm = null;\n\tcv.repaint();\n    }\n\n    void enableItems() {\n\tif (powerCheckItem.getState()) {\n\t    powerBar.enable();\n\t    powerLabel.enable();\n\t} else {\n\t    powerBar.disable();\n\t    powerLabel.disable();\n\t}\n\tenableUndoRedo();\n    }\n    \n    public void itemStateChanged(ItemEvent e) {\n\tcv.repaint(pause);\n\tObject mi = e.getItemSelectable();\n\tif (mi == stoppedCheck)\n\t    return;\n\tif (mi == smallGridCheckItem)\n\t    setGrid();\n\tif (mi == powerCheckItem) {\n\t    if (powerCheckItem.getState())\n\t\tvoltsCheckItem.setState(false);\n\t    else\n\t\tvoltsCheckItem.setState(true);\n\t}\n\tif (mi == voltsCheckItem && voltsCheckItem.getState())\n\t    powerCheckItem.setState(false);\n\tenableItems();\n\tif (menuScope != -1) {\n\t    Scope sc = scopes[menuScope];\n\t    sc.handleMenu(e, mi);\n\t}\n\tif (mi instanceof CheckboxMenuItem) {\n\t    MenuItem mmi = (MenuItem) mi;\n\t    int prevMouseMode = mouseMode;\n\t    setMouseMode(MODE_ADD_ELM);\n\t    String s = mmi.getActionCommand();\n\t    if (s.length() > 0)\n\t\tmouseModeStr = s;\n\t    if (s.compareTo(\"DragAll\") == 0)\n\t\tsetMouseMode(MODE_DRAG_ALL);\n\t    else if (s.compareTo(\"DragRow\") == 0)\n\t\tsetMouseMode(MODE_DRAG_ROW);\n\t    else if (s.compareTo(\"DragColumn\") == 0)\n\t\tsetMouseMode(MODE_DRAG_COLUMN);\n\t    else if (s.compareTo(\"DragSelected\") == 0)\n\t\tsetMouseMode(MODE_DRAG_SELECTED);\n\t    else if (s.compareTo(\"DragPost\") == 0)\n\t\tsetMouseMode(MODE_DRAG_POST);\n\t    else if (s.compareTo(\"Select\") == 0)\n\t\tsetMouseMode(MODE_SELECT);\n\t    else if (s.length() > 0) {\n\t\ttry {\n\t\t    addingClass = Class.forName(s);\n\t\t} catch (Exception ee) {\n\t\t    ee.printStackTrace();\n\t\t}\n\t    }\n\t    else\n\t    \tsetMouseMode(prevMouseMode);\n\t    tempMouseMode = mouseMode;\n\t}\n    }\n\n    void setGrid() {\n\tgridSize = (smallGridCheckItem.getState()) ? 8 : 16;\n\tgridMask = ~(gridSize-1);\n\tgridRound = gridSize/2-1;\n    }\n\n    void pushUndo() {\n\tredoStack.removeAllElements();\n\tString s = dumpCircuit();\n\tif (undoStack.size() > 0 &&\n\t\ts.compareTo(undoStack.lastElement()) == 0)\n\t    return;\n\tundoStack.add(s);\n\tenableUndoRedo();\n    }\n\n    void doUndo() {\n\tif (undoStack.size() == 0)\n\t    return;\n\tredoStack.add(dumpCircuit());\n\tString s = undoStack.remove(undoStack.size()-1);\n\treadSetup(s);\n\tenableUndoRedo();\n    }\n\n    void doRedo() {\n\tif (redoStack.size() == 0)\n\t    return;\n\tundoStack.add(dumpCircuit());\n\tString s = redoStack.remove(redoStack.size()-1);\n\treadSetup(s);\n\tenableUndoRedo();\n    }\n\n    void enableUndoRedo() {\n\tredoItem.setEnabled(redoStack.size() > 0);\n\tundoItem.setEnabled(undoStack.size() > 0);\n    }\n\n    void setMouseMode(int mode)\n    {\n\tmouseMode = mode;\n\tif ( mode == MODE_ADD_ELM )\n\t    cv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));\n\telse\n\t    cv.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));\n    }\n\n    void setMenuSelection() {\n\tif (menuElm != null) {\n\t    if (menuElm.selected)\n\t\treturn;\n\t    clearSelection();\n\t    menuElm.setSelected(true);\n\t}\n    }\n    \n    void doCut() {\n\tint i;\n\tpushUndo();\n\tsetMenuSelection();\n\tclipboard = \"\";\n\tfor (i = elmList.size()-1; i >= 0; i--) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.isSelected()) {\n\t\tclipboard += ce.dump() + \"\\n\";\n\t\tce.delete();\n\t\telmList.removeElementAt(i);\n\t    }\n\t}\n\tenablePaste();\n\tneedAnalyze();\n    }\n\n    void doDelete() {\n\tint i;\n\tpushUndo();\n\tsetMenuSelection();\n\tboolean hasDeleted = false;\n\n\tfor (i = elmList.size()-1; i >= 0; i--) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.isSelected()) {\n\t\tce.delete();\n\t\telmList.removeElementAt(i);\n\t\thasDeleted = true;\n\t    }\n\t}\n\n\tif ( !hasDeleted )\n\t{\n\t    for (i = elmList.size()-1; i >= 0; i--) {\n\t\tCircuitElm ce = getElm(i);\n\t\tif (ce == mouseElm) {\n\t\t    ce.delete();\n\t\t    elmList.removeElementAt(i);\n\t\t    hasDeleted = true;\n\t\t    mouseElm = null;\n\t\t    break;\n\t\t}\n\t    }\n\t}\n\n\tif ( hasDeleted )\n\t    needAnalyze();\n    }\n\n    void doCopy() {\n\tint i;\n\tclipboard = \"\";\n\tsetMenuSelection();\n\tfor (i = elmList.size()-1; i >= 0; i--) {\n\t    CircuitElm ce = getElm(i);\n\t    if (ce.isSelected())\n\t\tclipboard += ce.dump() + \"\\n\";\n\t}\n\tenablePaste();\n    }\n\n    void enablePaste() {\n\tpasteItem.setEnabled(clipboard.length() > 0);\n    }\n    \n    void doPaste() {\n\tpushUndo();\n\tclearSelection();\n\tint i;\n\tRectangle oldbb = null;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    Rectangle bb = ce.getBoundingBox();\n\t    if (oldbb != null)\n\t\toldbb = oldbb.union(bb);\n\t    else\n\t\toldbb = bb;\n\t}\n\tint oldsz = elmList.size();\n\treadSetup(clipboard, true);\n\t\n\t// select new items\n\tRectangle newbb = null;\n\tfor (i = oldsz; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.setSelected(true);\n\t    Rectangle bb = ce.getBoundingBox();\n\t    if (newbb != null)\n\t\tnewbb = newbb.union(bb);\n\t    else\n\t\tnewbb = bb;\n\t}\n\tif (oldbb != null && newbb != null && oldbb.intersects(newbb)) {\n\t    // find a place for new items\n\t    int dx = 0, dy = 0;\n\t    int spacew = circuitArea.width - oldbb.width - newbb.width;\n\t    int spaceh = circuitArea.height - oldbb.height - newbb.height;\n\t    if (spacew > spaceh)\n\t\tdx = snapGrid(oldbb.x + oldbb.width  - newbb.x + gridSize);\n\t    else\n\t\tdy = snapGrid(oldbb.y + oldbb.height - newbb.y + gridSize);\n\t    for (i = oldsz; i != elmList.size(); i++) {\n\t\tCircuitElm ce = getElm(i);\n\t\tce.move(dx, dy);\n\t    }\n\t    // center circuit\n\t    handleResize();\n\t}\n\tneedAnalyze();\n    }\n\n    void clearSelection() {\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.setSelected(false);\n\t}\n    }\n    \n    void doSelectAll() {\n\tint i;\n\tfor (i = 0; i != elmList.size(); i++) {\n\t    CircuitElm ce = getElm(i);\n\t    ce.setSelected(true);\n\t}\n    }\n\n    public void keyPressed(KeyEvent e) {}\n    public void keyReleased(KeyEvent e) {}\n    \n    public void keyTyped(KeyEvent e) {\n\tif (e.getKeyChar() == 127)\n\t{\n\t    doDelete();\n\t    return;\n\t}\n\tif (e.getKeyChar() > ' ' && e.getKeyChar() < 127) {\n\t    Class c = shortcuts[e.getKeyChar()];\n\t    if (c == null)\n\t\treturn;\n\t    CircuitElm elm = null;\n\t    elm = constructElement(c, 0, 0);\n\t    if (elm == null)\n\t\treturn;\n\t    setMouseMode(MODE_ADD_ELM);\n\t    mouseModeStr = c.getName();\n\t    addingClass = c;\n\t}\n\tif (e.getKeyChar() == ' ' || e.getKeyChar() == KeyEvent.VK_ESCAPE) {\n\t    setMouseMode(MODE_SELECT);\n\t    mouseModeStr = \"Select\";\n\t}\n\ttempMouseMode = mouseMode;\n    }\n\n    // factors a matrix into upper and lower triangular matrices by\n    // gaussian elimination.  On entry, a[0..n-1][0..n-1] is the\n    // matrix to be factored.  ipvt[] returns an integer vector of pivot\n    // indices, used in the lu_solve() routine.\n    boolean lu_factor(double a[][], int n, int ipvt[]) {\n\tdouble scaleFactors[];\n\tint i,j,k;\n\n\tscaleFactors = new double[n];\n\t\n        // divide each row by its largest element, keeping track of the\n\t// scaling factors\n\tfor (i = 0; i != n; i++) { \n\t    double largest = 0;\n\t    for (j = 0; j != n; j++) {\n\t\tdouble x = Math.abs(a[i][j]);\n\t\tif (x > largest)\n\t\t    largest = x;\n\t    }\n\t    // if all zeros, it's a singular matrix\n\t    if (largest == 0)\n\t\treturn false;\n\t    scaleFactors[i] = 1.0/largest;\n\t}\n\t\n        // use Crout's method; loop through the columns\n\tfor (j = 0; j != n; j++) {\n\t    \n\t    // calculate upper triangular elements for this column\n\t    for (i = 0; i != j; i++) {\n\t\tdouble q = a[i][j];\n\t\tfor (k = 0; k != i; k++)\n\t\t    q -= a[i][k]*a[k][j];\n\t\ta[i][j] = q;\n\t    }\n\n\t    // calculate lower triangular elements for this column\n\t    double largest = 0;\n\t    int largestRow = -1;\n\t    for (i = j; i != n; i++) {\n\t\tdouble q = a[i][j];\n\t\tfor (k = 0; k != j; k++)\n\t\t    q -= a[i][k]*a[k][j];\n\t\ta[i][j] = q;\n\t\tdouble x = Math.abs(q);\n\t\tif (x >= largest) {\n\t\t    largest = x;\n\t\t    largestRow = i;\n\t\t}\n\t    }\n\t    \n\t    // pivoting\n\t    if (j != largestRow) {\n\t\tdouble x;\n\t\tfor (k = 0; k != n; k++) {\n\t\t    x = a[largestRow][k];\n\t\t    a[largestRow][k] = a[j][k];\n\t\t    a[j][k] = x;\n\t\t}\n\t\tscaleFactors[largestRow] = scaleFactors[j];\n\t    }\n\n\t    // keep track of row interchanges\n\t    ipvt[j] = largestRow;\n\n\t    // avoid zeros\n\t    if (a[j][j] == 0.0) {\n\t\tSystem.out.println(\"avoided zero\");\n\t\ta[j][j]=1e-18;\n\t    }\n\n\t    if (j != n-1) {\n\t\tdouble mult = 1.0/a[j][j];\n\t\tfor (i = j+1; i != n; i++)\n\t\t    a[i][j] *= mult;\n\t    }\n\t}\n\treturn true;\n    }\n\n    // Solves the set of n linear equations using a LU factorization\n    // previously performed by lu_factor.  On input, b[0..n-1] is the right\n    // hand side of the equations, and on output, contains the solution.\n    void lu_solve(double a[][], int n, int ipvt[], double b[]) {\n\tint i;\n\n\t// find first nonzero b element\n\tfor (i = 0; i != n; i++) {\n\t    int row = ipvt[i];\n\n\t    double swap = b[row];\n\t    b[row] = b[i];\n\t    b[i] = swap;\n\t    if (swap != 0)\n\t\tbreak;\n\t}\n\t\n\tint bi = i++;\n\tfor (; i < n; i++) {\n\t    int row = ipvt[i];\n\t    int j;\n\t    double tot = b[row];\n\t    \n\t    b[row] = b[i];\n\t    // forward substitution using the lower triangular matrix\n\t    for (j = bi; j < i; j++)\n\t\ttot -= a[i][j]*b[j];\n\t    b[i] = tot;\n\t}\n\tfor (i = n-1; i >= 0; i--) {\n\t    double tot = b[i];\n\t    \n\t    // back-substitution using the upper triangular matrix\n\t    int j;\n\t    for (j = i+1; j != n; j++)\n\t\ttot -= a[i][j]*b[j];\n\t    b[i] = tot/a[i][i];\n\t}\n    }\n\n}\n"
  },
  {
    "path": "src/Circuit.java",
    "content": "// Circuit.java (c) 2005,2008 by Paul Falstad, www.falstad.com\n\nimport java.io.InputStream;\nimport java.awt.*;\nimport java.awt.image.*;\nimport java.applet.Applet;\nimport java.util.Vector;\nimport java.io.File;\nimport java.util.Random;\nimport java.util.Arrays;\nimport java.lang.Math;\nimport java.net.URL;\nimport java.awt.event.*;\nimport java.io.FilterInputStream;\nimport java.io.ByteArrayOutputStream;\nimport java.util.StringTokenizer;\nimport java.text.DecimalFormat;\nimport java.text.NumberFormat;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\n\npublic class Circuit extends Applet implements ComponentListener {\n    static CirSim ogf;\n    boolean finished = false;\n\n    void destroyFrame() {\n\tif (ogf != null)\n\t    ogf.dispose();\n\togf = null;\n\trepaint();\n\tfinished = true;\n    }\n    boolean started = false;\n    public void init() {\n\taddComponentListener(this);\n    }\n\n    public static void main(String args[]) {\n\togf = new CirSim(null);\n\togf.init();\n    }\n    \n    public void showFrame() {\n\tif ( finished )\n\t{\n\t    repaint();\n\t    return;\n\t}\n\tif (ogf == null) {\n\t    started = true;\n\t    ogf = new CirSim(this);\n\t    ogf.init();\n\t}\n\togf.setVisible(true);\n\trepaint();\n    }\n\n    public void hideFrame() {\n\tif ( finished )\n\t    return;\n\togf.setVisible(false);\n\trepaint();\n    }\n\n    public void toggleSwitch(int x) { ogf.toggleSwitch(x); }\n    \n    public void paint(Graphics g) {\n\tString s = \"Applet is open in a separate window.\";\n\tif ( ogf != null && !ogf.isVisible() )\n\t    s = \"Applet window is hidden.\";\n\tif (!started)\n\t    s = \"Applet is starting.\";\n\telse if (ogf == null || finished)\n\t    s = \"Applet is finished.\";\n\telse if (ogf != null && ogf.useFrame)\n\t    ogf.triggerShow();\n\tg.drawString(s, 10, 30);\n    }\n    \n    public void componentHidden(ComponentEvent e){}\n    public void componentMoved(ComponentEvent e){}\n    public void componentShown(ComponentEvent e) { showFrame(); }\n    public void componentResized(ComponentEvent e) {\n\tif (ogf != null)\n\t    ogf.componentResized(e);\n    }\n    \n    public void destroy() {\n\tif (ogf != null)\n\t    ogf.dispose();\n\togf = null;\n\trepaint();\n    }\n};\n\n"
  },
  {
    "path": "src/CircuitCanvas.java",
    "content": "import java.awt.*;\n\nclass CircuitCanvas extends Canvas {\n    CirSim pg;\n    CircuitCanvas(CirSim p) {\n\tpg = p;\n    }\n    public Dimension getPreferredSize() {\n\treturn new Dimension(300,400);\n    }\n    public void update(Graphics g) {\n\tpg.updateCircuit(g);\n    }\n    public void paint(Graphics g) {\n\tpg.updateCircuit(g);\n    }\n};\n"
  },
  {
    "path": "src/CircuitElm.java",
    "content": "import java.awt.*;\nimport java.text.DecimalFormat;\nimport java.text.NumberFormat;\n\npublic abstract class CircuitElm implements Editable {\n    static double voltageRange = 5;\n    static int colorScaleCount = 32;\n    static Color colorScale[];\n    static double currentMult, powerMult;\n    static Point ps1, ps2;\n    static CirSim sim;\n    static Color whiteColor, selectColor, lightGrayColor;\n    static Font unitsFont;\n\n    public static NumberFormat showFormat, shortFormat, noCommaFormat;\n    static final double pi = 3.14159265358979323846;\n\n    int x, y, x2, y2, flags, nodes[], voltSource;\n    int dx, dy, dsign;\n    double dn, dpx1, dpy1;\n    Point point1, point2, lead1, lead2;\n    double volts[];\n    double current, curcount;\n    Rectangle boundingBox;\n    boolean noDiagonal;\n    public boolean selected;\n    int getDumpType() { return 0; }\n    Class getDumpClass() { return getClass(); }\n    int getDefaultFlags() { return 0; }\n\n    static void initClass(CirSim s) {\n\tunitsFont = new Font(\"SansSerif\", 0, 10);\n\tsim = s;\n\t\n\tcolorScale = new Color[colorScaleCount];\n\tint i;\n\tfor (i = 0; i != colorScaleCount; i++) {\n\t    double v = i*2./colorScaleCount - 1;\n\t    if (v < 0) {\n\t\tint n1 = (int) (128*-v)+127;\n\t\tint n2 = (int) (127*(1+v));\n\t\tcolorScale[i] = new Color(n1, n2, n2);\n\t    } else {\n\t\tint n1 = (int) (128*v)+127;\n\t\tint n2 = (int) (127*(1-v));\n\t\tcolorScale[i] = new Color(n2, n1, n2);\n\t    }\n\t}\n\t\n\tps1 = new Point();\n\tps2 = new Point();\n\n\tshowFormat = DecimalFormat.getInstance();\n\tshowFormat.setMaximumFractionDigits(2);\n\tshortFormat = DecimalFormat.getInstance();\n\tshortFormat.setMaximumFractionDigits(1);\n\tnoCommaFormat = DecimalFormat.getInstance();\n\tnoCommaFormat.setMaximumFractionDigits(10);\n\tnoCommaFormat.setGroupingUsed(false);\n    }\n    \n    CircuitElm(int xx, int yy) {\n\tx = x2 = xx;\n\ty = y2 = yy;\n\tflags = getDefaultFlags();\n\tallocNodes();\n\tinitBoundingBox();\n    }\n    CircuitElm(int xa, int ya, int xb, int yb, int f) {\n\tx = xa; y = ya; x2 = xb; y2 = yb; flags = f;\n\tallocNodes();\n\tinitBoundingBox();\n    }\n    \n    void initBoundingBox() {\n\tboundingBox = new Rectangle();\n\tboundingBox.setBounds(min(x, x2), min(y, y2),\n\t\t\t      abs(x2-x)+1, abs(y2-y)+1);\n    }\n    \n    void allocNodes() {\n\tnodes = new int[getPostCount()+getInternalNodeCount()];\n\tvolts = new double[getPostCount()+getInternalNodeCount()];\n    }\n    String dump() {\n\tint t = getDumpType();\n\treturn (t < 127 ? ((char)t)+\" \" : t+\" \") + x + \" \" + y + \" \" +\n\t    x2 + \" \" + y2 + \" \" + flags;\n    }\n    void reset() {\n\tint i;\n\tfor (i = 0; i != getPostCount()+getInternalNodeCount(); i++)\n\t    volts[i] = 0;\n\tcurcount = 0;\n    }\n    void draw(Graphics g) {}\n    void setCurrent(int x, double c) { current = c; }\n    double getCurrent() { return current; }\n    void doStep() {}\n    void delete() {}\n    void startIteration() {}\n    double getPostVoltage(int x) { return volts[x]; }\n    void setNodeVoltage(int n, double c) {\n\tvolts[n] = c;\n\tcalculateCurrent();\n    }\n    void calculateCurrent() {}\n    void setPoints() {\n\tdx = x2-x; dy = y2-y;\n\tdn = Math.sqrt(dx*dx+dy*dy);\n\tdpx1 = dy/dn;\n\tdpy1 = -dx/dn;\n\tdsign = (dy == 0) ? sign(dx) : sign(dy);\n\tpoint1 = new Point(x , y );\n\tpoint2 = new Point(x2, y2);\n    }\n    void calcLeads(int len) {\n\tif (dn < len || len == 0) {\n\t    lead1 = point1;\n\t    lead2 = point2;\n\t    return;\n\t}\n\tlead1 = interpPoint(point1, point2, (dn-len)/(2*dn));\n\tlead2 = interpPoint(point1, point2, (dn+len)/(2*dn));\n    }\n    Point interpPoint(Point a, Point b, double f) {\n\tPoint p = new Point();\n\tinterpPoint(a, b, p, f);\n\treturn p;\n    }\n    void interpPoint(Point a, Point b, Point c, double f) {\n\tint xpd = b.x-a.x;\n\tint ypd = b.y-a.y;\n\t/*double q = (a.x*(1-f)+b.x*f+.48);\n\t  System.out.println(q + \" \" + (int) q);*/\n\tc.x = (int) Math.floor(a.x*(1-f)+b.x*f+.48);\n\tc.y = (int) Math.floor(a.y*(1-f)+b.y*f+.48);\n    }\n    void interpPoint(Point a, Point b, Point c, double f, double g) {\n\tint xpd = b.x-a.x;\n\tint ypd = b.y-a.y;\n\tint gx = b.y-a.y;\n\tint gy = a.x-b.x;\n\tg /= Math.sqrt(gx*gx+gy*gy);\n\tc.x = (int) Math.floor(a.x*(1-f)+b.x*f+g*gx+.48);\n\tc.y = (int) Math.floor(a.y*(1-f)+b.y*f+g*gy+.48);\n    }\n    Point interpPoint(Point a, Point b, double f, double g) {\n\tPoint p = new Point();\n\tinterpPoint(a, b, p, f, g);\n\treturn p;\n    }\n    void interpPoint2(Point a, Point b, Point c, Point d, double f, double g) {\n\tint xpd = b.x-a.x;\n\tint ypd = b.y-a.y;\n\tint gx = b.y-a.y;\n\tint gy = a.x-b.x;\n\tg /= Math.sqrt(gx*gx+gy*gy);\n\tc.x = (int) Math.floor(a.x*(1-f)+b.x*f+g*gx+.48);\n\tc.y = (int) Math.floor(a.y*(1-f)+b.y*f+g*gy+.48);\n\td.x = (int) Math.floor(a.x*(1-f)+b.x*f-g*gx+.48);\n\td.y = (int) Math.floor(a.y*(1-f)+b.y*f-g*gy+.48);\n    }\n    void draw2Leads(Graphics g) {\n\t// draw first lead\n\tsetVoltageColor(g, volts[0]);\n\tdrawThickLine(g, point1, lead1);\n\n\t// draw second lead\n\tsetVoltageColor(g, volts[1]);\n\tdrawThickLine(g, lead2, point2);\n    }\n    Point [] newPointArray(int n) {\n\tPoint a[] = new Point[n];\n\twhile (n > 0)\n\t    a[--n] = new Point();\n\treturn a;\n    }\n\t\n    void drawDots(Graphics g, Point pa, Point pb, double pos) {\n\tif (sim.stoppedCheck.getState() || pos == 0 || !sim.dotsCheckItem.getState())\n\t    return;\n\tint dx = pb.x-pa.x;\n\tint dy = pb.y-pa.y;\n\tdouble dn = Math.sqrt(dx*dx+dy*dy);\n\tg.setColor(Color.yellow);\n\tint ds = 16;\n\tpos %= ds;\n\tif (pos < 0)\n\t    pos += ds;\n\tdouble di = 0;\n\tfor (di = pos; di < dn; di += ds) {\n\t    int x0 = (int) (pa.x+di*dx/dn);\n\t    int y0 = (int) (pa.y+di*dy/dn);\n\t    g.fillRect(x0-1, y0-1, 4, 4);\n\t}\n    }\n\n    Polygon calcArrow(Point a, Point b, double al, double aw) {\n\tPolygon poly = new Polygon();\n\tPoint p1 = new Point();\n\tPoint p2 = new Point();\n\tint adx = b.x-a.x;\n\tint ady = b.y-a.y;\n\tdouble l = Math.sqrt(adx*adx+ady*ady);\n\tpoly.addPoint(b.x, b.y);\n\tinterpPoint2(a, b, p1, p2, 1-al/l, aw);\n\tpoly.addPoint(p1.x, p1.y);\n\tpoly.addPoint(p2.x, p2.y);\n\treturn poly;\n    }\n\n    Polygon calcArrowReverse(Point a, Point b, double al, double aw) {\n    \tPolygon poly = new Polygon();\n\tPoint p1 = new Point();\n\tPoint p2 = new Point();\n\tdouble adx = b.x-a.x;\n\tdouble ady = b.y-a.y;\n\tdouble l = Math.sqrt(adx*adx+ady*ady);\n\tif (l > 0)\n\t{\n\t    adx /= l;\n\t    ady /= l;\n\t    double bdx = -ady; // orthogonal unit vector\n\t    double bdy = adx;  //\n\t    poly.addPoint((int)Math.round(b.x+1 - adx*al),\n\t                  (int)Math.round(b.y+1 - ady*al));\n\t    poly.addPoint((int)Math.round(b.x+1 - bdx*al),\n\t                  (int)Math.round(b.y+1 - bdy*aw));\n\t    poly.addPoint((int)Math.round(b.x+1 + bdx*al),\n\t                  (int)Math.round(b.y+1 + bdy*aw));\n\t}\n\treturn poly;\n    }\n\n    Polygon createPolygon(Point a, Point b, Point c) {\n\tPolygon p = new Polygon();\n\tp.addPoint(a.x, a.y);\n\tp.addPoint(b.x, b.y);\n\tp.addPoint(c.x, c.y);\n\treturn p;\n    }\n    Polygon createPolygon(Point a, Point b, Point c, Point d) {\n\tPolygon p = new Polygon();\n\tp.addPoint(a.x, a.y);\n\tp.addPoint(b.x, b.y);\n\tp.addPoint(c.x, c.y);\n\tp.addPoint(d.x, d.y);\n\treturn p;\n    }\n    Polygon createPolygon(Point a[]) {\n\tPolygon p = new Polygon();\n\tint i;\n\tfor (i = 0; i != a.length; i++)\n\t    p.addPoint(a[i].x, a[i].y);\n\treturn p;\n    }\n    void drag(int xx, int yy) {\n\txx = sim.snapGrid(xx);\n\tyy = sim.snapGrid(yy);\n\tif (noDiagonal) {\n\t    if (Math.abs(x-xx) < Math.abs(y-yy)) {\n\t\txx = x;\n\t    } else {\n\t\tyy = y;\n\t    }\n\t}\n\tx2 = xx; y2 = yy;\n\tsetPoints();\n    }\n    void move(int dx, int dy) {\n\tx += dx; y += dy; x2 += dx; y2 += dy;\n\tboundingBox.move(dx, dy);\n\tsetPoints();\n    }\n\n    // determine if moving this element by (dx,dy) will put it on top of another element\n    boolean allowMove(int dx, int dy) {\n\tint nx = x+dx;\n\tint ny = y+dy;\n\tint nx2 = x2+dx;\n\tint ny2 = y2+dy;\n\tint i;\n\tfor (i = 0; i != sim.elmList.size(); i++) {\n\t    CircuitElm ce = sim.getElm(i);\n\t    if (ce.x == nx && ce.y == ny && ce.x2 == nx2 && ce.y2 == ny2)\n\t\treturn false;\n\t    if (ce.x == nx2 && ce.y == ny2 && ce.x2 == nx && ce.y2 == ny)\n\t\treturn false;\n\t}\n\treturn true;\n    }\n    \n    void movePoint(int n, int dx, int dy) {\n\tif (n == 0) {\n\t    x += dx; y += dy;\n\t} else {\n\t    x2 += dx; y2 += dy;\n\t}\n\tsetPoints();\n    }\n    void drawPosts(Graphics g) {\n\tint i;\n\tfor (i = 0; i != getPostCount(); i++) {\n\t    Point p = getPost(i);\n\t    drawPost(g, p.x, p.y, nodes[i]);\n\t}\n    }\n    void stamp() {}\n    int getVoltageSourceCount() { return 0; }\n    int getInternalNodeCount() { return 0; }\n    void setNode(int p, int n) { nodes[p] = n; }\n    void setVoltageSource(int n, int v) { voltSource = v; }\n    int getVoltageSource() { return voltSource; }\n    double getVoltageDiff() {\n\treturn volts[0] - volts[1];\n    }\n    boolean nonLinear() { return false; }\n    int getPostCount() { return 2; }\n    int getNode(int n) { return nodes[n]; }\n    Point getPost(int n) {\n\treturn (n == 0) ? point1 : (n == 1) ? point2 : null;\n    }\n    void drawPost(Graphics g, int x0, int y0, int n) {\n\tif (sim.dragElm == null && !needsHighlight() &&\n\t    sim.getCircuitNode(n).links.size() == 2)\n\t    return;\n\tif (sim.mouseMode == CirSim.MODE_DRAG_ROW ||\n\t    sim.mouseMode == CirSim.MODE_DRAG_COLUMN)\n\t    return;\n\tdrawPost(g, x0, y0);\n    }\n    void drawPost(Graphics g, int x0, int y0) {\n\tg.setColor(whiteColor);\n\tg.fillOval(x0-3, y0-3, 7, 7);\n    }\n    void setBbox(int x1, int y1, int x2, int y2) {\n\tif (x1 > x2) { int q = x1; x1 = x2; x2 = q; }\n\tif (y1 > y2) { int q = y1; y1 = y2; y2 = q; }\n\tboundingBox.setBounds(x1, y1, x2-x1+1, y2-y1+1);\n    }\n    void setBbox(Point p1, Point p2, double w) {\n\tsetBbox(p1.x, p1.y, p2.x, p2.y);\n\tint gx = p2.y-p1.y;\n\tint gy = p1.x-p2.x;\n\tint dpx = (int) (dpx1*w);\n\tint dpy = (int) (dpy1*w);\n\tadjustBbox(p1.x+dpx, p1.y+dpy, p1.x-dpx, p1.y-dpy);\n    }\n    void adjustBbox(int x1, int y1, int x2, int y2) {\n\tif (x1 > x2) { int q = x1; x1 = x2; x2 = q; }\n\tif (y1 > y2) { int q = y1; y1 = y2; y2 = q; }\n\tx1 = min(boundingBox.x, x1);\n\ty1 = min(boundingBox.y, y1);\n\tx2 = max(boundingBox.x+boundingBox.width-1,  x2);\n\ty2 = max(boundingBox.y+boundingBox.height-1, y2);\n\tboundingBox.setBounds(x1, y1, x2-x1, y2-y1);\n    }\n    void adjustBbox(Point p1, Point p2) {\n\tadjustBbox(p1.x, p1.y, p2.x, p2.y);\n    }\n    boolean isCenteredText() { return false; }\n\t\n    void drawCenteredText(Graphics g, String s, int x, int y, boolean cx) {\n\tFontMetrics fm = g.getFontMetrics();\n\tint w = fm.stringWidth(s);\n\tif (cx)\n\t    x -= w/2;\n\tg.drawString(s, x, y+fm.getAscent()/2);\n\tadjustBbox(x, y-fm.getAscent()/2,\n\t\t   x+w, y+fm.getAscent()/2+fm.getDescent());\n    }\n    \n    void drawValues(Graphics g, String s, double hs) {\n\tif (s == null)\n\t    return;\n\tg.setFont(unitsFont);\n\tFontMetrics fm = g.getFontMetrics();\n\tint w = fm.stringWidth(s);\n\tg.setColor(whiteColor);\n\tint ya = fm.getAscent()/2;\n\tint xc, yc;\n\tif (this instanceof RailElm || this instanceof SweepElm) {\n\t    xc = x2;\n\t    yc = y2;\n\t} else {\n\t    xc = (x2+x)/2;\n\t    yc = (y2+y)/2;\n\t}\n\tint dpx = (int) (dpx1*hs);\n\tint dpy = (int) (dpy1*hs);\n\tif (dpx == 0) {\n\t    g.drawString(s, xc-w/2, yc-abs(dpy)-2);\n\t} else {\n\t    int xx = xc+abs(dpx)+2;\n\t    if (this instanceof VoltageElm || (x < x2 && y > y2))\n\t\txx = xc-(w+abs(dpx)+2);\n\t    g.drawString(s, xx, yc+dpy+ya);\n\t}\n    }\n    void drawCoil(Graphics g, int hs, Point p1, Point p2,\n\t\t  double v1, double v2) {\n\tdouble len = distance(p1, p2);\n\tint segments = 30; // 10*(int) (len/10);\n\tint i;\n\tdouble segf = 1./segments;\n\t    \n\tps1.setLocation(p1);\n\tfor (i = 0; i != segments; i++) {\n\t    double cx = (((i+1)*6.*segf) % 2)-1;\n\t    double hsx = Math.sqrt(1-cx*cx);\n\t    if (hsx < 0)\n\t\thsx = -hsx;\n\t    interpPoint(p1, p2, ps2, i*segf, hsx*hs);\n\t    double v = v1+(v2-v1)*i/segments;\n\t    setVoltageColor(g, v);\n\t    drawThickLine(g, ps1, ps2);\n\t    ps1.setLocation(ps2);\n\t}\n    }\n    static void drawThickLine(Graphics g, int x, int y, int x2, int y2) {\n\tg.drawLine(x, y, x2, y2);\n\tg.drawLine(x+1, y, x2+1, y2);\n\tg.drawLine(x, y+1, x2, y2+1);\n\tg.drawLine(x+1, y+1, x2+1, y2+1);\n    }\n\n    static void drawThickLine(Graphics g, Point pa, Point pb) {\n\tg.drawLine(pa.x, pa.y, pb.x, pb.y);\n\tg.drawLine(pa.x+1, pa.y, pb.x+1, pb.y);\n\tg.drawLine(pa.x, pa.y+1, pb.x, pb.y+1);\n\tg.drawLine(pa.x+1, pa.y+1, pb.x+1, pb.y+1);\n    }\n\n    static void drawThickPolygon(Graphics g, int xs[], int ys[], int c) {\n\tint i;\n\tfor (i = 0; i != c-1; i++)\n\t    drawThickLine(g, xs[i], ys[i], xs[i+1], ys[i+1]);\n\tdrawThickLine(g, xs[i], ys[i], xs[0], ys[0]);\n    }\n    \n    static void drawThickPolygon(Graphics g, Polygon p) {\n\tdrawThickPolygon(g, p.xpoints, p.ypoints, p.npoints);\n    }\n    \n    static void drawThickCircle(Graphics g, int cx, int cy, int ri) {\n\tint a;\n\tdouble m = pi/180;\n\tdouble r = ri*.98;\n\tfor (a = 0; a != 360; a += 20) {\n\t    double ax = Math.cos(a*m)*r + cx;\n\t    double ay = Math.sin(a*m)*r + cy;\n\t    double bx = Math.cos((a+20)*m)*r + cx;\n\t    double by = Math.sin((a+20)*m)*r + cy;\n\t    drawThickLine(g, (int) ax, (int) ay, (int) bx, (int) by);\n\t}\n    }\n    \n    static String getVoltageDText(double v) {\n\treturn getUnitText(Math.abs(v), \"V\");\n    }\n    static String getVoltageText(double v) {\n\treturn getUnitText(v, \"V\");\n    }\n    static String getUnitText(double v, String u) {\n\tdouble va = Math.abs(v);\n\tif (va < 1e-14)\n\t    return \"0 \" + u;\n\tif (va < 1e-9)\n\t    return showFormat.format(v*1e12) + \" p\" + u;\n\tif (va < 1e-6)\n\t    return showFormat.format(v*1e9) + \" n\" + u;\n\tif (va < 1e-3)\n\t    return showFormat.format(v*1e6) + \" \" + CirSim.muString + u;\n\tif (va < 1)\n\t    return showFormat.format(v*1e3) + \" m\" + u;\n\tif (va < 1e3)\n\t    return showFormat.format(v) + \" \" + u;\n\tif (va < 1e6)\n\t    return showFormat.format(v*1e-3) + \" k\" + u;\n\tif (va < 1e9)\n\t    return showFormat.format(v*1e-6) + \" M\" + u;\n\treturn showFormat.format(v*1e-9) + \" G\" + u;\n    }\n    static String getShortUnitText(double v, String u) {\n\tdouble va = Math.abs(v);\n\tif (va < 1e-13)\n\t    return null;\n\tif (va < 1e-9)\n\t    return shortFormat.format(v*1e12) + \"p\" + u;\n\tif (va < 1e-6)\n\t    return shortFormat.format(v*1e9) + \"n\" + u;\n\tif (va < 1e-3)\n\t    return shortFormat.format(v*1e6) + CirSim.muString + u;\n\tif (va < 1)\n\t    return shortFormat.format(v*1e3) + \"m\" + u;\n\tif (va < 1e3)\n\t    return shortFormat.format(v) + u;\n\tif (va < 1e6)\n\t    return shortFormat.format(v*1e-3) + \"k\" + u;\n\tif (va < 1e9)\n\t    return shortFormat.format(v*1e-6) + \"M\" + u;\n\treturn shortFormat.format(v*1e-9) + \"G\" + u;\n    }\n    static String getCurrentText(double i) {\n\treturn getUnitText(i, \"A\");\n    }\n    static String getCurrentDText(double i) {\n\treturn getUnitText(Math.abs(i), \"A\");\n    }\n\n    void updateDotCount() {\n\tcurcount = updateDotCount(current, curcount);\n    }\n    double updateDotCount(double cur, double cc) {\n\tif (sim.stoppedCheck.getState())\n\t    return cc;\n\tdouble cadd = cur*currentMult;\n\t/*if (cur != 0 && cadd <= .05 && cadd >= -.05)\n\t  cadd = (cadd < 0) ? -.05 : .05;*/\n\tcadd %= 8;\n\t/*if (cadd > 8)\n\t  cadd = 8;\n\t  if (cadd < -8)\n\t  cadd = -8;*/\n\treturn cc + cadd;\n    }\n    void doDots(Graphics g) {\n\tupdateDotCount();\n\tif (sim.dragElm != this)\n\t    drawDots(g, point1, point2, curcount);\n    }\n    void doAdjust() {}\n    void setupAdjust() {}\n    void getInfo(String arr[]) {\n    }\n    int getBasicInfo(String arr[]) {\n\tarr[1] = \"I = \" + getCurrentDText(getCurrent());\n\tarr[2] = \"Vd = \" + getVoltageDText(getVoltageDiff());\n\treturn 3;\n    }\n    void setVoltageColor(Graphics g, double volts) {\n\tif (needsHighlight()) {\n\t    g.setColor(selectColor);\n\t    return;\n\t}\n\tif (!sim.voltsCheckItem.getState()) {\n\t    if (!sim.powerCheckItem.getState()) // && !conductanceCheckItem.getState())\n\t\tg.setColor(whiteColor);\n\t    return;\n\t}\n\tint c = (int) ((volts+voltageRange)*(colorScaleCount-1)/\n\t\t       (voltageRange*2));\n\tif (c < 0)\n\t    c = 0;\n\tif (c >= colorScaleCount)\n\t    c = colorScaleCount-1;\n\tg.setColor(colorScale[c]);\n    }\n    void setPowerColor(Graphics g, boolean yellow) {\n\t/*if (conductanceCheckItem.getState()) {\n\t  setConductanceColor(g, current/getVoltageDiff());\n\t  return;\n\t  }*/\n\tif (!sim.powerCheckItem.getState())\n\t    return;\n\tsetPowerColor(g, getPower());\n    }\n    void setPowerColor(Graphics g, double w0) {\n\tw0 *= powerMult;\n\t//System.out.println(w);\n\tdouble w = (w0 < 0) ? -w0 : w0;\n\tif (w > 1)\n\t    w = 1;\n\tint rg = 128+(int) (w*127);\n\tint b  = (int) (128*(1-w));\n\t/*if (yellow)\n\t  g.setColor(new Color(rg, rg, b));\n\t  else */\n\tif (w0 > 0)\n\t    g.setColor(new Color(rg, b, b));\n\telse\n\t    g.setColor(new Color(b, rg, b));\n    }\n    void setConductanceColor(Graphics g, double w0) {\n\tw0 *= powerMult;\n\t//System.out.println(w);\n\tdouble w = (w0 < 0) ? -w0 : w0;\n\tif (w > 1)\n\t    w = 1;\n\tint rg = (int) (w*255);\n\tg.setColor(new Color(rg, rg, rg));\n    }\n    double getPower() { return getVoltageDiff()*current; }\n    double getScopeValue(int x) {\n\treturn (x == 1) ? getPower() : getVoltageDiff();\n    }\n    String getScopeUnits(int x) {\n\treturn (x == 1) ? \"W\" : \"V\";\n    }\n    public EditInfo getEditInfo(int n) { return null; }\n    public void setEditValue(int n, EditInfo ei) {}\n    boolean getConnection(int n1, int n2) { return true; }\n    boolean hasGroundConnection(int n1) { return false; }\n    boolean isWire() { return false; }\n    boolean canViewInScope() { return getPostCount() <= 2; }\n    boolean comparePair(int x1, int x2, int y1, int y2) {\n\treturn ((x1 == y1 && x2 == y2) || (x1 == y2 && x2 == y1));\n    }\n    boolean needsHighlight() { return sim.mouseElm == this || selected; }\n    boolean isSelected() { return selected; }\n    void setSelected(boolean x) { selected = x; }\n    void selectRect(Rectangle r) {\n\tselected = r.intersects(boundingBox);\n    }\n    static int abs(int x) { return x < 0 ? -x : x; }\n    static int sign(int x) { return (x < 0) ? -1 : (x == 0) ? 0 : 1; }\n    static int min(int a, int b) { return (a < b) ? a : b; }\n    static int max(int a, int b) { return (a > b) ? a : b; }\n    static double distance(Point p1, Point p2) {\n\tdouble x = p1.x-p2.x;\n\tdouble y = p1.y-p2.y;\n\treturn Math.sqrt(x*x+y*y);\n    }\n    Rectangle getBoundingBox() { return boundingBox; }\n    boolean needsShortcut() { return getShortcut() > 0; }\n    int getShortcut() { return 0; }\n\n    boolean isGraphicElmt() { return false; }\n}\n"
  },
  {
    "path": "src/CircuitLayout.java",
    "content": "import java.awt.*;\n\nclass CircuitLayout implements LayoutManager {\n    public CircuitLayout() {}\n    public void addLayoutComponent(String name, Component c) {}\n    public void removeLayoutComponent(Component c) {}\n    public Dimension preferredLayoutSize(Container target) {\n\treturn new Dimension(500, 500);\n    }\n    public Dimension minimumLayoutSize(Container target) {\n\treturn new Dimension(100,100);\n    }\n    public void layoutContainer(Container target) {\n\tInsets insets = target.insets();\n\tint targetw = target.size().width - insets.left - insets.right;\n\tint cw = targetw* 8/10;\n\tint targeth = target.size().height - (insets.top+insets.bottom);\n\ttarget.getComponent(0).move(insets.left, insets.top);\n\ttarget.getComponent(0).resize(cw, targeth);\n\tint barwidth = targetw - cw;\n\tcw += insets.left;\n\tint i;\n\tint h = insets.top;\n\tfor (i = 1; i < target.getComponentCount(); i++) {\n\t    Component m = target.getComponent(i);\n\t    if (m.isVisible()) {\n\t\tDimension d = m.getPreferredSize();\n\t\tif (m instanceof Scrollbar)\n\t\t    d.width = barwidth;\n\t\tif (m instanceof Choice && d.width > barwidth)\n\t\t    d.width = barwidth;\n\t\tif (m instanceof Label) {\n\t\t    h += d.height/5;\n\t\t    d.width = barwidth;\n\t\t}\n\t\tm.move(cw, h);\n\t\tm.resize(d.width, d.height);\n\t\th += d.height;\n\t    }\n\t}\n    }\n};\n"
  },
  {
    "path": "src/CircuitNode.java",
    "content": "import java.util.Vector;\n\nclass CircuitNode {\n    int x, y;\n    Vector<CircuitNodeLink> links;\n    boolean internal;\n    CircuitNode() { links = new Vector<CircuitNodeLink>(); }\n}\n"
  },
  {
    "path": "src/CircuitNodeLink.java",
    "content": "    class CircuitNodeLink {\n\tint num;\n\tCircuitElm elm;\n    }\n"
  },
  {
    "path": "src/ClockElm.java",
    "content": "    class ClockElm extends RailElm {\n\tpublic ClockElm(int xx, int yy) {\n\t    super(xx, yy, WF_SQUARE);\n\t    maxVoltage = 2.5;\n\t    bias = 2.5;\n\t    frequency = 100;\n\t    flags |= FLAG_CLOCK;\n\t}\n\tClass getDumpClass() { return RailElm.class; }\n\tint getShortcut() { return 0; }\n    }\n"
  },
  {
    "path": "src/CounterElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class CounterElm extends ChipElm {\n\tfinal int FLAG_ENABLE = 2;\n\tpublic CounterElm(int xx, int yy) { super(xx, yy); }\n\tpublic CounterElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tboolean needsBits() { return true; }\n\tString getChipName() { return \"Counter\"; }\n\tvoid setupPins() {\n\t    sizeX = 2;\n\t    sizeY = bits > 2 ? bits : 2;\n\t    pins = new Pin[getPostCount()];\n\t    pins[0] = new Pin(0, SIDE_W, \"\");\n\t    pins[0].clock = true;\n\t    pins[1] = new Pin(sizeY-1, SIDE_W, \"R\");\n\t    pins[1].bubble = true;\n\t    int i;\n\t    for (i = 0; i != bits; i++) {\n\t\tint ii = i+2;\n\t\tpins[ii] = new Pin(i, SIDE_E, \"Q\" + (bits-i-1));\n\t\tpins[ii].output = pins[ii].state = true;\n\t    }\n\t    if (hasEnable())\n\t\tpins[bits+2] = new Pin(sizeY-2, SIDE_W, \"En\");\n\t    allocNodes();\n\t}\n\tint getPostCount() {\n\t    if (hasEnable())\n\t\treturn bits+3;\n\t    return bits+2;\n\t}\n\tboolean hasEnable() { return (flags & FLAG_ENABLE) != 0; }\n\tint getVoltageSourceCount() { return bits; }\n\tvoid execute() {\n\t    boolean en = true;\n\t    if (hasEnable())\n\t\ten = pins[bits+2].value;\n\t    if (pins[0].value && !lastClock && en) {\n\t\tint i;\n\t\tfor (i = bits-1; i >= 0; i--) {\n\t\t    int ii = i+2;\n\t\t    if (!pins[ii].value) {\n\t\t\tpins[ii].value = true;\n\t\t\tbreak;\n\t\t    }\n\t\t    pins[ii].value = false;\n\t\t}\n\t    }\n\t    if (!pins[1].value) {\n\t\tint i;\n\t\tfor (i = 0; i != bits; i++)\n\t\t    pins[i+2].value = false;\n\t    }\n\t    lastClock = pins[0].value;\n\t}\n\tint getDumpType() { return 164; }\n    }\n"
  },
  {
    "path": "src/CurrentElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class CurrentElm extends CircuitElm {\n\tdouble currentValue;\n\tpublic CurrentElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    currentValue = .01;\n\t}\n\tpublic CurrentElm(int xa, int ya, int xb, int yb, int f,\n\t\t   StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    try {\n\t\tcurrentValue = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) {\n\t\tcurrentValue = .01;\n\t    }\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + currentValue;\n\t}\n\tint getDumpType() { return 'i'; }\n\t\n\tPolygon arrow;\n\tPoint ashaft1, ashaft2, center;\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    calcLeads(26);\n\t    ashaft1 = interpPoint(lead1, lead2, .25);\n\t    ashaft2 = interpPoint(lead1, lead2, .6);\n\t    center = interpPoint(lead1, lead2, .5);\n\t    Point p2 = interpPoint(lead1, lead2, .75);\n\t    arrow = calcArrow(center, p2, 4, 4);\n\t}\n\tvoid draw(Graphics g) {\n\t    int cr = 12;\n\t    draw2Leads(g);\n\t    setVoltageColor(g, (volts[0]+volts[1])/2);\n\t    setPowerColor(g, false);\n\t    \n\t    drawThickCircle(g, center.x, center.y, cr);\n\t    drawThickLine(g, ashaft1, ashaft2);\n\n\t    g.fillPolygon(arrow);\n\t    setBbox(point1, point2, cr);\n\t    doDots(g);\n\t    if (sim.showValuesCheckItem.getState()) {\n\t\tString s = getShortUnitText(currentValue, \"A\");\n\t\tif (dx == 0 || dy == 0)\n\t\t    drawValues(g, s, cr);\n\t    }\n\t    drawPosts(g);\n\t}\n\tvoid stamp() {\n\t    current = currentValue;\n\t    sim.stampCurrentSource(nodes[0], nodes[1], current);\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Current (A)\", currentValue, 0, .1);\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    currentValue = ei.value;\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"current source\";\n\t    getBasicInfo(arr);\n\t}\n\tdouble getVoltageDiff() {\n\t    return volts[1] - volts[0];\n\t}\n    }\n"
  },
  {
    "path": "src/DACElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass DACElm extends ChipElm {\n    public DACElm(int xx, int yy) { super(xx, yy); }\n    public DACElm(int xa, int ya, int xb, int yb, int f,\n\t\t  StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n    }\n    String getChipName() { return \"DAC\"; }\n    boolean needsBits() { return true; }\n    void setupPins() {\n\tsizeX = 2;\n\tsizeY = bits > 2 ? bits : 2;\n\tpins = new Pin[getPostCount()];\n\tint i;\n\tfor (i = 0; i != bits; i++)\n\t    pins[i] = new Pin(bits-1-i, SIDE_W, \"D\" + i);\n\tpins[bits]   = new Pin(0, SIDE_E, \"O\");\n\tpins[bits].output = true;\n\tpins[bits+1] = new Pin(sizeY-1, SIDE_E, \"V+\");\n\tallocNodes();\n    }\n    void doStep() {\n\tint ival = 0;\n\tint i;\n\tfor (i = 0; i != bits; i++)\n\t    if (volts[i] > 2.5)\n\t\tival |= 1<<i;\n\tint ivalmax = (1<<bits)-1;\n\tdouble v = ival*volts[bits+1]/ivalmax;\n\tsim.updateVoltageSource(0, nodes[bits], pins[bits].voltSource, v);\n    }\n    int getVoltageSourceCount() { return 1; }\n    int getPostCount() { return bits+2; }\n    int getDumpType() { return 166; }\n}\n    \n"
  },
  {
    "path": "src/DCVoltageElm.java",
    "content": "    class DCVoltageElm extends VoltageElm {\n\tpublic DCVoltageElm(int xx, int yy) { super(xx, yy, WF_DC); }\n\tClass getDumpClass() { return VoltageElm.class; }\n\tint getShortcut() { return 'v'; }\n    }\n"
  },
  {
    "path": "src/DFlipFlopElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class DFlipFlopElm extends ChipElm {\n\tfinal int FLAG_RESET = 2;\n\tboolean hasReset() { return (flags & FLAG_RESET) != 0; }\n\tpublic DFlipFlopElm(int xx, int yy) { super(xx, yy); }\n\tpublic DFlipFlopElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    pins[2].value = !pins[1].value;\n\t}\n\tString getChipName() { return \"D flip-flop\"; }\n\tvoid setupPins() {\n\t    sizeX = 2;\n\t    sizeY = 3;\n\t    pins = new Pin[getPostCount()];\n\t    pins[0] = new Pin(0, SIDE_W, \"D\");\n\t    pins[1] = new Pin(0, SIDE_E, \"Q\");\n\t    pins[1].output = pins[1].state = true;\n\t    pins[2] = new Pin(2, SIDE_E, \"Q\");\n\t    pins[2].output = true;\n\t    pins[2].lineOver = true;\n\t    pins[3] = new Pin(1, SIDE_W, \"\");\n\t    pins[3].clock = true;\n\t    if (hasReset())\n\t\tpins[4] = new Pin(2, SIDE_W, \"R\");\n\t}\n\tint getPostCount() {\n\t    return hasReset() ? 5 : 4;\n\t}\n\tint getVoltageSourceCount() { return 2; }\n\tvoid execute() {\n\t    if (pins[3].value && !lastClock) {\n\t\tpins[1].value =  pins[0].value;\n\t\tpins[2].value = !pins[0].value;\n\t    }\n\t    if (pins.length > 4 && pins[4].value) {\n\t\tpins[1].value = false;\n\t\tpins[2].value = true;\n\t    }\n\t    lastClock = pins[3].value;\n\t}\n\tint getDumpType() { return 155; }\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 2) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Reset Pin\", hasReset());\n\t\treturn ei;\n\t    }\n\t    return super.getEditInfo(n);\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 2) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags |= FLAG_RESET;\n\t\telse\n\t\t    flags &= ~FLAG_RESET;\n\t\tsetupPins();\n\t\tallocNodes();\n\t\tsetPoints();\n\t    }\n\t    super.setEditValue(n, ei);\n\t}\n    }\n"
  },
  {
    "path": "src/DecadeElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class DecadeElm extends ChipElm {\n\tpublic DecadeElm(int xx, int yy) { super(xx, yy); }\n\tpublic DecadeElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tString getChipName() { return \"decade counter\"; }\n\tboolean needsBits() { return true; }\n\tvoid setupPins() {\n\t    sizeX = bits > 2 ? bits : 2;\n\t    sizeY = 2;\n\t    pins = new Pin[getPostCount()];\n\t    pins[0] = new Pin(1, SIDE_W, \"\");\n\t    pins[0].clock = true;\n\t    pins[1] = new Pin(sizeX-1, SIDE_S, \"R\");\n\t    pins[1].bubble = true;\n\t    int i;\n\t    for (i = 0; i != bits; i++) {\n\t\tint ii = i+2;\n\t\tpins[ii] = new Pin(i, SIDE_N, \"Q\" + i);\n\t\tpins[ii].output = pins[ii].state = true;\n\t    }\n\t    allocNodes();\n\t}\n\tint getPostCount() { return bits+2; }\n\tint getVoltageSourceCount() { return bits; }\n\tvoid execute() {\n\t    int i;\n\t    if (pins[0].value && !lastClock) {\n\t\tfor (i = 0; i != bits; i++)\n\t\t    if (pins[i+2].value)\n\t\t\tbreak;\n\t\tif (i < bits)\n\t\t    pins[i++ +2].value = false;\n\t\ti %= bits;\n\t\tpins[i+2].value = true;\n\t    }\n\t    if (!pins[1].value) {\n\t\tfor (i = 1; i != bits; i++)\n\t\t    pins[i+2].value = false;\n\t\tpins[2].value = true;\n\t    }\n\t    lastClock = pins[0].value;\n\t}\n\tint getDumpType() { return 163; }\n    }\n"
  },
  {
    "path": "src/DiacElm.java",
    "content": "// stub implementation of DiacElm, based on SparkGapElm\n// FIXME need to add DiacElm.java to srclist\n// FIXME need to uncomment DiacElm line from CirSim.java\n\nimport java.awt.*;\nimport java.util.StringTokenizer;\n\nclass DiacElm extends CircuitElm {\n    double onresistance, offresistance, breakdown, holdcurrent;\n    boolean state;\n    public DiacElm(int xx, int yy) {\n\tsuper(xx, yy);\n\t// FIXME need to adjust defaults to make sense for diac\n\toffresistance = 1e9;\n\tonresistance = 1e3;\n\tbreakdown = 1e3;\n\tholdcurrent = 0.001;\n\tstate = false;\n    }\n    public DiacElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tonresistance = new Double(st.nextToken()).doubleValue();\n\toffresistance = new Double(st.nextToken()).doubleValue();\n\tbreakdown = new Double(st.nextToken()).doubleValue();\n\tholdcurrent = new Double(st.nextToken()).doubleValue();\n    }\n    boolean nonLinear() {return true;}\n    int getDumpType() { return 185; }\n    String dump() {\n\treturn super.dump() + \" \" + onresistance + \" \" + offresistance + \" \"\n\t    + breakdown + \" \" + holdcurrent;\n    }\n    Point ps3, ps4;\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(32);\n\tps3 = new Point();\n\tps4 = new Point();\n    }\n    \n    void draw(Graphics g) {\n\t// FIXME need to draw Diac\n\tint i;\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\tsetBbox(point1, point2, 6);\n\tdraw2Leads(g);\n\tsetPowerColor(g, true);\n\tdoDots(g);\n\tdrawPosts(g);\n    }\n    \n    void calculateCurrent() {\n\tdouble vd = volts[0] - volts[1];\n\tif(state)\n\t    current = vd/onresistance;\n\telse\n\t    current = vd/offresistance;\n    }\n    void startIteration() {\n\tdouble vd = volts[0] - volts[1];\n\tif(Math.abs(current) < holdcurrent) state = false;\n\tif(Math.abs(vd) > breakdown) state = true;\n\t//System.out.print(this + \" res current set to \" + current + \"\\n\");\n    }\n    void doStep() {\n\tif(state)\n\t    sim.stampResistor(nodes[0], nodes[1], onresistance);\n\telse\n\t    sim.stampResistor(nodes[0], nodes[1], offresistance);\n    }\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    void getInfo(String arr[]) {\n\t// FIXME\n\tarr[0] = \"spark gap\";\n\tgetBasicInfo(arr);\n\tarr[3] = state ? \"on\" : \"off\";\n\tarr[4] = \"Ron = \" + getUnitText(onresistance, sim.ohmString);\n\tarr[5] = \"Roff = \" + getUnitText(offresistance, sim.ohmString);\n\tarr[6] = \"Vbrkdn = \" + getUnitText(breakdown, \"V\");\n\tarr[7] = \"Ihold = \" + getUnitText(holdcurrent, \"A\");\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"On resistance (ohms)\", onresistance, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Off resistance (ohms)\", offresistance, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Breakdown voltage (volts)\", breakdown, 0, 0);\n\tif (n == 3)\n\t    return new EditInfo(\"Hold current (amps)\", holdcurrent, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (ei.value > 0 && n == 0)\n\t    onresistance = ei.value;\n\tif (ei.value > 0 && n == 1)\n\t    offresistance = ei.value;\n\tif (ei.value > 0 && n == 2)\n\t    breakdown = ei.value;\n\tif (ei.value > 0 && n == 3)\n\t    holdcurrent = ei.value;\n    }\n}\n\n"
  },
  {
    "path": "src/Diode.java",
    "content": "class Diode {\n    int nodes[];\n    CirSim sim;\n\n    \n    Diode(CirSim s) {\n\tsim = s;\n\tnodes = new int[2];\n    }\n    void setup(double fw, double zv) {\n\tfwdrop = fw;\n\tzvoltage = zv;\n\tvdcoef = Math.log(1/leakage + 1)/fwdrop;\n\tvt = 1/vdcoef;\n\t// critical voltage for limiting; current is vt/sqrt(2) at\n\t// this voltage\n\tvcrit = vt * Math.log(vt/(Math.sqrt(2)*leakage));\n\tif (zvoltage == 0)\n\t    zoffset = 0;\n\telse {\n\t    // calculate offset which will give us 5mA at zvoltage\n\t    double i = -.005;\n\t    zoffset = zvoltage-Math.log(-(1+i/leakage))/vdcoef;\n\t}\n    }\n\t\n    void reset() {\n\tlastvoltdiff = 0;\n    }\n\t\n    public double leakage = 1e-14; // was 1e-9;\n    double vt, vdcoef, fwdrop, zvoltage, zoffset;\n    double lastvoltdiff;\n    double vcrit;\n    \n    double limitStep(double vnew, double vold) {\n\tdouble arg;\n\tdouble oo = vnew;\n\n\t// check new voltage; has current changed by factor of e^2?\n\tif (vnew > vcrit && Math.abs(vnew - vold) > (vt + vt)) {\n\t    if(vold > 0) {\n\t\targ = 1 + (vnew - vold) / vt;\n\t\tif(arg > 0) {\n\t\t    // adjust vnew so that the current is the same\n\t\t    // as in linearized model from previous iteration.\n\t\t    // current at vnew = old current * arg\n\t\t    vnew = vold + vt * Math.log(arg);\n\t\t    // current at v0 = 1uA\n\t\t    double v0 = Math.log(1e-6/leakage)*vt;\n\t\t    vnew = Math.max(v0, vnew);\n\t\t} else {\n\t\t    vnew = vcrit;\n\t\t}\n\t    } else {\n\t\t// adjust vnew so that the current is the same\n\t\t// as in linearized model from previous iteration.\n\t\t// (1/vt = slope of load line)\n\t\tvnew = vt *Math.log(vnew/vt);\n\t    }\n\t    sim.converged = false;\n\t    //System.out.println(vnew + \" \" + oo + \" \" + vold);\n\t} else if (vnew < 0 && zoffset != 0) {\n\t    // for Zener breakdown, use the same logic but translate the values\n\t    vnew = -vnew - zoffset;\n\t    vold = -vold - zoffset;\n\t    \n\t    if (vnew > vcrit && Math.abs(vnew - vold) > (vt + vt)) {\n\t\tif(vold > 0) {\n\t\t    arg = 1 + (vnew - vold) / vt;\n\t\t    if(arg > 0) {\n\t\t\tvnew = vold + vt * Math.log(arg);\n\t\t\tdouble v0 = Math.log(1e-6/leakage)*vt;\n\t\t\tvnew = Math.max(v0, vnew);\n\t\t\t//System.out.println(oo + \" \" + vnew);\n\t\t    } else {\n\t\t\tvnew = vcrit;\n\t\t    }\n\t\t} else {\n\t\t    vnew = vt *Math.log(vnew/vt);\n\t\t}\n\t\tsim.converged = false;\n\t    }\n\t    vnew = -(vnew+zoffset);\n\t}\n\treturn vnew;\n    }\n    \n    void stamp(int n0, int n1) {\n\tnodes[0] = n0;\n\tnodes[1] = n1;\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    \n    void doStep(double voltdiff) {\n\t// used to have .1 here, but needed .01 for peak detector\n\tif (Math.abs(voltdiff-lastvoltdiff) > .01)\n\t    sim.converged = false;\n\tvoltdiff = limitStep(voltdiff, lastvoltdiff);\n\tlastvoltdiff = voltdiff;\n\n\tif (voltdiff >= 0 || zvoltage == 0) {\n\t    // regular diode or forward-biased zener\n\t    double eval = Math.exp(voltdiff*vdcoef);\n\t    // make diode linear with negative voltages; aids convergence\n\t    if (voltdiff < 0)\n\t\teval = 1;\n\t    double geq = vdcoef*leakage*eval;\n\t    double nc = (eval-1)*leakage - geq*voltdiff;\n\t    sim.stampConductance(nodes[0], nodes[1], geq);\n\t    sim.stampCurrentSource(nodes[0], nodes[1], nc);\n\t} else {\n\t    // Zener diode\n\t    \n\t    /* \n\t     * I(Vd) = Is * (exp[Vd*C] - exp[(-Vd-Vz)*C] - 1 )\n\t     *\n\t     * geq is I'(Vd)\n\t     * nc is I(Vd) + I'(Vd)*(-Vd)\n\t     */\n\n\t    double geq = leakage*vdcoef* ( \n\t\tMath.exp(voltdiff*vdcoef) + Math.exp((-voltdiff-zoffset)*vdcoef)\n\t\t);\n\n\t    double nc = leakage* (\n\t\tMath.exp(voltdiff*vdcoef) \n\t\t- Math.exp((-voltdiff-zoffset)*vdcoef) \n\t\t- 1\n\t\t) + geq*(-voltdiff);\n\n\t    sim.stampConductance(nodes[0], nodes[1], geq);\n\t    sim.stampCurrentSource(nodes[0], nodes[1],  nc);\n\t}\n    }\n    \n    double calculateCurrent(double voltdiff) {\n\tif (voltdiff >= 0 || zvoltage == 0)\n\t    return leakage*(Math.exp(voltdiff*vdcoef)-1);\n\treturn leakage* (\n\t    Math.exp(voltdiff*vdcoef)  \n\t    - Math.exp((-voltdiff-zoffset)*vdcoef)  \n\t    - 1\n\t    );\n    }\n}\n"
  },
  {
    "path": "src/DiodeElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass DiodeElm extends CircuitElm {\n    Diode diode;\n    static final int FLAG_FWDROP = 1;\n    final double defaultdrop = .805904783;\n    double fwdrop, zvoltage;\n    \n    public DiodeElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tdiode = new Diode(sim);\n\tfwdrop = defaultdrop;\n\tzvoltage = 0;\n\tsetup();\n    }\n    public DiodeElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tdiode = new Diode(sim);\n\tfwdrop = defaultdrop;\n\tzvoltage = 0;\n\tif ((f & FLAG_FWDROP) > 0) {\n\t    try {\n\t\tfwdrop = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) {\n\t    }\n\t}\n\tsetup();\n    }\n    boolean nonLinear() { return true; }\n    \n    void setup() {\n\tdiode.setup(fwdrop, zvoltage);\n    }\n    \n    int getDumpType() { return 'd'; }\n    String dump() {\n\tflags |= FLAG_FWDROP;\n\treturn super.dump() + \" \" + fwdrop;\n    }\n    \n\n    final int hs = 8;\n    Polygon poly;\n    Point cathode[];\n\t\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(16);\n\tcathode = newPointArray(2);\n\tPoint pa[] = newPointArray(2);\n\tinterpPoint2(lead1, lead2, pa[0], pa[1], 0, hs);\n\tinterpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs);\n\tpoly = createPolygon(pa[0], pa[1], lead2);\n    }\n\t\n    void draw(Graphics g) {\n\tdrawDiode(g);\n\tdoDots(g);\n\tdrawPosts(g);\n    }\n\t\n    void reset() {\n\tdiode.reset();\n\tvolts[0] = volts[1] = curcount = 0;\n    }\n\t\n    void drawDiode(Graphics g) {\n\tsetBbox(point1, point2, hs);\n\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\n\tdraw2Leads(g);\n\n\t// draw arrow thingy\n\tsetPowerColor(g, true);\n\tsetVoltageColor(g, v1);\n\tg.fillPolygon(poly);\n\n\t// draw thing arrow is pointing to\n\tsetVoltageColor(g, v2);\n\tdrawThickLine(g, cathode[0], cathode[1]);\n    }\n\t\n    void stamp() { diode.stamp(nodes[0], nodes[1]); }\n    void doStep() {\n\tdiode.doStep(volts[0]-volts[1]);\n    }\n    void calculateCurrent() {\n\tcurrent = diode.calculateCurrent(volts[0]-volts[1]);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"diode\";\n\tarr[1] = \"I = \" + getCurrentText(getCurrent());\n\tarr[2] = \"Vd = \" + getVoltageText(getVoltageDiff());\n\tarr[3] = \"P = \" + getUnitText(getPower(), \"W\");\n\tarr[4] = \"Vf = \" + getVoltageText(fwdrop);\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"Fwd Voltage @ 1A\", fwdrop, 10, 1000);\n\treturn null;\n    } \n    public void setEditValue(int n, EditInfo ei) {\n\tfwdrop = ei.value;\n\tsetup();\n    }\n    int getShortcut() { return 'd'; }\n}\n"
  },
  {
    "path": "src/EditDialog.java",
    "content": "import java.awt.*;\nimport java.awt.event.*;\nimport java.text.NumberFormat;\nimport java.text.DecimalFormat;\n\ninterface Editable {\n    EditInfo getEditInfo(int n);\n    void setEditValue(int n, EditInfo ei);\n}\n\nclass EditDialog extends Dialog implements AdjustmentListener, ActionListener, ItemListener {\n    Editable elm;\n    CirSim cframe;\n    Button applyButton, okButton;\n    EditInfo einfos[];\n    int einfocount;\n    final int barmax = 1000;\n    NumberFormat noCommaFormat;\n\n    EditDialog(Editable ce, CirSim f) {\n\tsuper(f, \"Edit Component\", false);\n\tcframe = f;\n\telm = ce;\n\tsetLayout(new EditDialogLayout());\n\teinfos = new EditInfo[10];\n\tnoCommaFormat = DecimalFormat.getInstance();\n\tnoCommaFormat.setMaximumFractionDigits(10);\n\tnoCommaFormat.setGroupingUsed(false);\n\tint i;\n\tfor (i = 0; ; i++) {\n\t    einfos[i] = elm.getEditInfo(i);\n\t    if (einfos[i] == null)\n\t\tbreak;\n\t    EditInfo ei = einfos[i];\n\t    add(new Label(ei.name));\n\t    if (ei.choice != null) {\n\t\tadd(ei.choice);\n\t\tei.choice.addItemListener(this);\n\t    } else if (ei.checkbox != null) {\n\t\tadd(ei.checkbox);\n\t\tei.checkbox.addItemListener(this);\n\t    } else {\n\t\tadd(ei.textf =\n\t\t    new TextField(unitString(ei), 10));\n\t\tif (ei.text != null)\n\t\t    ei.textf.setText(ei.text);\n\t\tei.textf.addActionListener(this);\n\t\tif (ei.text == null) {\n\t\t    add(ei.bar = new Scrollbar(Scrollbar.HORIZONTAL,\n\t\t\t\t\t       50, 10, 0, barmax+2));\n\t\t    setBar(ei);\n\t\t    ei.bar.addAdjustmentListener(this);\n\t\t}\n\t    }\n\t}\n\teinfocount = i;\n\tadd(applyButton = new Button(\"Apply\"));\n\tapplyButton.addActionListener(this);\n\tadd(okButton = new Button(\"OK\"));\n\tokButton.addActionListener(this);\n\tPoint x = cframe.main.getLocationOnScreen();\n\tDimension d = getSize();\n\tsetLocation(x.x + (cframe.winSize.width-d.width)/2,\n\t\t    x.y + (cframe.winSize.height-d.height)/2);\n\taddWindowListener(new WindowAdapter()\n\t\t{\n\t\t\tpublic void windowClosing(WindowEvent we)\n\t\t\t{\n\t\t\t\tcloseDialog();\n\t\t\t}\n\t\t}\n\t);\n    }\n\n    String unitString(EditInfo ei) {\n\tdouble v = ei.value;\n\tdouble va = Math.abs(v);\n\tif (ei.dimensionless)\n\t    return noCommaFormat.format(v);\n\tif (v == 0) return \"0\";\n\tif (va < 1e-9)\n\t    return noCommaFormat.format(v*1e12) + \"p\";\n\tif (va < 1e-6)\n\t    return noCommaFormat.format(v*1e9) + \"n\";\n\tif (va < 1e-3)\n\t    return noCommaFormat.format(v*1e6) + \"u\";\n\tif (va < 1 && !ei.forceLargeM)\n\t    return noCommaFormat.format(v*1e3) + \"m\";\n\tif (va < 1e3)\n\t    return noCommaFormat.format(v);\n\tif (va < 1e6)\n\t    return noCommaFormat.format(v*1e-3) + \"k\";\n\tif (va < 1e9)\n\t    return noCommaFormat.format(v*1e-6) + \"M\";\n\treturn noCommaFormat.format(v*1e-9) + \"G\";\n    }\n\n    double parseUnits(EditInfo ei) throws java.text.ParseException {\n\tString s = ei.textf.getText();\n\ts = s.trim();\n\tint len = s.length();\n\tchar uc = s.charAt(len-1);\n\tdouble mult = 1;\n\tswitch (uc) {\n\tcase 'p': case 'P': mult = 1e-12; break;\n\tcase 'n': case 'N': mult = 1e-9; break;\n\tcase 'u': case 'U': mult = 1e-6; break;\n\t    \n\t// for ohm values, we assume mega for lowercase m, otherwise milli\n\tcase 'm': mult = (ei.forceLargeM) ? 1e6 : 1e-3; break;\n\t\n\tcase 'k': case 'K': mult = 1e3; break;\n\tcase 'M': mult = 1e6; break;\n\tcase 'G': case 'g': mult = 1e9; break;\n\t}\n\tif (mult != 1)\n\t    s = s.substring(0, len-1).trim();\n\treturn noCommaFormat.parse(s).doubleValue() * mult;\n    }\n\t\n    void apply() {\n\tint i;\n\tfor (i = 0; i != einfocount; i++) {\n\t    EditInfo ei = einfos[i];\n\t    if (ei.textf == null)\n\t\tcontinue;\n\t    if (ei.text == null) {\n\t\ttry {\n\t\t    double d = parseUnits(ei);\n\t\t    ei.value = d;\n\t\t} catch (Exception ex) { /* ignored */ }\n\t    }\n\t    elm.setEditValue(i, ei);\n\t    if (ei.text == null)\n\t\tsetBar(ei);\n\t}\n\tcframe.needAnalyze();\n    }\n\t\n    public void actionPerformed(ActionEvent e) {\n\tint i;\n\tObject src = e.getSource();\n\tfor (i = 0; i != einfocount; i++) {\n\t    EditInfo ei = einfos[i];\n\t    if (src == ei.textf) {\n\t\tif (ei.text == null) {\n\t\t    try {\n\t\t\tdouble d = parseUnits(ei);\n\t\t\tei.value = d;\n\t\t    } catch (Exception ex) { /* ignored */ }\n\t\t}\n\t\telm.setEditValue(i, ei);\n\t\tif (ei.text == null)\n\t\t    setBar(ei);\n\t\tcframe.needAnalyze();\n\t    }\n\t}\n\tif (e.getSource() == okButton) {\n\t    apply();\n\t    closeDialog();\n\t}\n\tif (e.getSource() == applyButton)\n\t    apply();\n    }\n\t\n    public void adjustmentValueChanged(AdjustmentEvent e) {\n\tObject src = e.getSource();\n\tint i;\n\tfor (i = 0; i != einfocount; i++) {\n\t    EditInfo ei = einfos[i];\n\t    if (ei.bar == src) {\n\t\tdouble v = ei.bar.getValue() / 1000.;\n\t\tif (v < 0)\n\t\t    v = 0;\n\t\tif (v > 1)\n\t\t    v = 1;\n\t\tei.value = (ei.maxval-ei.minval)*v + ei.minval;\n\t\t/*if (ei.maxval-ei.minval > 100)\n\t\t    ei.value = Math.round(ei.value);\n\t\telse\n\t\tei.value = Math.round(ei.value*100)/100.;*/\n\t\tei.value = Math.round(ei.value/ei.minval)*ei.minval;\n\t\telm.setEditValue(i, ei);\n\t\tei.textf.setText(unitString(ei));\n\t\tcframe.needAnalyze();\n\t    }\n\t}\n    }\n\n    public void itemStateChanged(ItemEvent e) {\n\tObject src = e.getItemSelectable();\n\tint i;\n\tboolean changed = false;\n\tfor (i = 0; i != einfocount; i++) {\n\t    EditInfo ei = einfos[i];\n\t    if (ei.choice == src || ei.checkbox == src) {\n\t\telm.setEditValue(i, ei);\n\t\tif (ei.newDialog)\n\t\t    changed = true;\n\t\tcframe.needAnalyze();\n\t    }\n\t}\n\tif (changed) {\n\t    setVisible(false);\n\t    cframe.editDialog = new EditDialog(elm, cframe);\n\t    cframe.editDialog.show();\n\t}\n    }\n\t\n    public boolean handleEvent(Event ev) {\n\tif (ev.id == Event.WINDOW_DESTROY) {\n\t    closeDialog();\n\t    return true;\n\t}\n\treturn super.handleEvent(ev);\n    }\n\n    void setBar(EditInfo ei) {\n\tint x = (int) (barmax*(ei.value-ei.minval)/(ei.maxval-ei.minval));\n\tei.bar.setValue(x);\n    }\n\n    protected void closeDialog()\n    {\n\tcframe.main.requestFocus();\n\tsetVisible(false);\n\tcframe.editDialog = null;\n    }\n}\n\n"
  },
  {
    "path": "src/EditDialogLayout.java",
    "content": "import java.awt.*;\nimport java.awt.event.*;\n\nclass EditDialogLayout implements LayoutManager {\n    public EditDialogLayout() {}\n    public void addLayoutComponent(String name, Component c) {}\n    public void removeLayoutComponent(Component c) {}\n    public Dimension preferredLayoutSize(Container target) {\n\treturn new Dimension(500, 500);\n    }\n    public Dimension minimumLayoutSize(Container target) {\n\treturn new Dimension(100,100);\n    }\n    public void layoutContainer(Container target) {\n\tInsets insets = target.insets();\n\tint targetw = target.size().width - insets.left - insets.right;\n\tint targeth = target.size().height - (insets.top+insets.bottom);\n\tint i;\n\tint h = insets.top;\n\tint pw = 300;\n\tint x = 0;\n\tfor (i = 0; i < target.getComponentCount(); i++) {\n\t    Component m = target.getComponent(i);\n\t    boolean newline = true;\n\t    if (m.isVisible()) {\n\t\tDimension d = m.getPreferredSize();\n\t\tif (pw < d.width)\n\t\t    pw = d.width;\n\t\tif (m instanceof Scrollbar) {\n\t\t    h += 10;\n\t\t    d.width = targetw-x;\n\t\t}\n\t\tif (m instanceof Choice && d.width > targetw)\n\t\t    d.width = targetw-x;\n\t\tif (m instanceof Label) {\n\t\t    Dimension d2 =\n\t\t\ttarget.getComponent(i+1).getPreferredSize();\n\t\t    if (d.height < d2.height)\n\t\t\td.height = d2.height;\n\t\t    h += d.height/5;\n\t\t    newline = false;\n\t\t}\n\t\tif (m instanceof Button) {\n\t\t    if (x == 0)\n\t\t\th += 20;\n\t\t    if (i != target.getComponentCount()-1)\n\t\t\tnewline = false;\n\t\t}\n\t\tm.move(insets.left+x, h);\n\t\tm.resize(d.width, d.height);\n\t\tif (newline) {\n\t\t    h += d.height;\n\t\t    x = 0;\n\t\t} else\n\t\t    x += d.width;\n\t    }\n\t}\n\tif (target.size().height < h)\n\t    target.resize(pw + insets.right, h + insets.bottom);\n    }\n};\n\n"
  },
  {
    "path": "src/EditInfo.java",
    "content": "import java.awt.*;\n\nclass EditInfo {\n    EditInfo(String n, double val, double mn, double mx) {\n\tname = n;\n\tvalue = val;\n\tif (mn == 0 && mx == 0 && val > 0) {\n\t    minval = 1e10;\n\t    while (minval > val/100)\n\t\tminval /= 10.;\n\t    maxval = minval * 1000;\n\t} else {\n\t    minval = mn;\n\t    maxval = mx;\n\t}\n\tforceLargeM = name.indexOf(\"(ohms)\") > 0 ||\n\t    name.indexOf(\"(Hz)\") > 0;\n\tdimensionless = false;\n    }\n    EditInfo setDimensionless() { dimensionless = true; return this; }\n    String name, text;\n    double value, minval, maxval;\n    TextField textf;\n    Scrollbar bar;\n    Choice choice;\n    Checkbox checkbox;\n    boolean newDialog;\n    boolean forceLargeM;\n    boolean dimensionless;\n}\n    \n"
  },
  {
    "path": "src/EditOptions.java",
    "content": "class EditOptions implements Editable {\n    CirSim sim;\n    public EditOptions(CirSim s) { sim = s; }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"Time step size (s)\", sim.timeStep, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Range for voltage color (V)\",\n\t\t\t\tCircuitElm.voltageRange, 0, 0);\n\t    \n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0 && ei.value > 0)\n\t    sim.timeStep = ei.value;\n\tif (n == 1 && ei.value > 0)\n\t    CircuitElm.voltageRange = ei.value;\n    }\n};\n"
  },
  {
    "path": "src/GateElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    abstract class GateElm extends CircuitElm {\n\tfinal int FLAG_SMALL = 1;\n\tint inputCount = 2;\n\tboolean lastOutput;\n\t\n\tpublic GateElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    noDiagonal = true;\n\t    inputCount = 2;\n\t    setSize(sim.smallGridCheckItem.getState() ? 1 : 2);\n\t}\n\tpublic GateElm(int xa, int ya, int xb, int yb, int f,\n\t\t\tStringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    inputCount = new Integer(st.nextToken()).intValue();\n\t    lastOutput = new Double (st.nextToken()).doubleValue() > 2.5;\n\t    noDiagonal = true;\n\t    setSize((f & FLAG_SMALL) != 0 ? 1 : 2);\n\t}\n\tboolean isInverting() { return false; }\n\tint gsize, gwidth, gwidth2, gheight, hs2;\n\tvoid setSize(int s) {\n\t    gsize = s;\n\t    gwidth = 7*s;\n\t    gwidth2 = 14*s;\n\t    gheight = 8*s;\n\t    flags = (s == 1) ? FLAG_SMALL : 0;\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + inputCount + \" \" + volts[inputCount];\n\t}\n\tPoint inPosts[], inGates[];\n\tint ww;\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    if (dn > 150 && this == sim.dragElm)\n\t\tsetSize(2);\n\t    int hs = gheight;\n\t    int i;\n\t    ww = gwidth2; // was 24\n\t    if (ww > dn/2)\n\t\tww = (int) (dn/2);\n\t    if (isInverting() && ww+8 > dn/2)\n\t\tww = (int) (dn/2-8);\n\t    calcLeads(ww*2);\n\t    inPosts = new Point[inputCount];\n\t    inGates = new Point[inputCount];\n\t    allocNodes();\n\t    int i0 = -inputCount/2;\n\t    for (i = 0; i != inputCount; i++, i0++) {\n\t\tif (i0 == 0 && (inputCount & 1) == 0)\n\t\t    i0++;\n\t\tinPosts[i] = interpPoint(point1, point2, 0, hs*i0);\n\t\tinGates[i] = interpPoint(lead1,  lead2,  0, hs*i0);\n\t\tvolts[i] = (lastOutput ^ isInverting()) ? 5 : 0;\n\t    }\n\t    hs2 = gwidth*(inputCount/2+1);\n\t    setBbox(point1, point2, hs2);\n\t}\n\tvoid draw(Graphics g) {\n\t    int i;\n\t    for (i = 0; i != inputCount; i++) {\n\t\tsetVoltageColor(g, volts[i]);\n\t\tdrawThickLine(g, inPosts[i], inGates[i]);\n\t    }\n\t    setVoltageColor(g, volts[inputCount]);\n\t    drawThickLine(g, lead2, point2);\n\t    g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\t    drawThickPolygon(g, gatePoly);\n\t    if (linePoints != null)\n\t\tfor (i = 0; i != linePoints.length-1; i++)\n\t\t    drawThickLine(g, linePoints[i], linePoints[i+1]);\n\t    if (isInverting())\n\t\tdrawThickCircle(g, pcircle.x, pcircle.y, 3);\n\t    curcount = updateDotCount(current, curcount);\n\t    drawDots(g, lead2, point2, curcount);\n\t    drawPosts(g);\n\t}\n\tPolygon gatePoly;\n\tPoint pcircle, linePoints[];\n\tint getPostCount() { return inputCount+1; }\n\tPoint getPost(int n) {\n\t    if (n == inputCount)\n\t\treturn point2;\n\t    return inPosts[n];\n\t}\n\tint getVoltageSourceCount() { return 1; }\n\tabstract String getGateName();\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = getGateName();\n\t    arr[1] = \"Vout = \" + getVoltageText(volts[inputCount]);\n\t    arr[2] = \"Iout = \" + getCurrentText(getCurrent());\n\t}\n\tvoid stamp() {\n\t    sim.stampVoltageSource(0, nodes[inputCount], voltSource);\n\t}\n\tboolean getInput(int x) {\n\t    return volts[x] > 2.5;\n\t}\n\tabstract boolean calcFunction();\n\tvoid doStep() {\n\t    int i;\n\t    boolean f = calcFunction();\n\t    if (isInverting())\n\t\tf = !f;\n\t    lastOutput = f;\n\t    double res = f ? 5 : 0;\n\t    sim.updateVoltageSource(0, nodes[inputCount], voltSource, res);\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"# of Inputs\", inputCount, 1, 8).\n\t\t    setDimensionless();\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    inputCount = (int) ei.value;\n\t    setPoints();\n\t}\n\t// there is no current path through the gate inputs, but there\n\t// is an indirect path through the output to ground.\n\tboolean getConnection(int n1, int n2) { return false; }\n\tboolean hasGroundConnection(int n1) {\n\t    return (n1 == inputCount);\n\t}\n    }\n\n"
  },
  {
    "path": "src/GraphicElm.java",
    "content": "class GraphicElm extends CircuitElm\n{\n\n    public GraphicElm(int xx, int yy)\n    {\n\tsuper(xx,yy);\n    }\n\n    public GraphicElm(int xa, int ya, int xb, int yb, int flags)\n    {\n\tsuper(xa, ya, xb, yb, flags);\n    }\n\n    int getPostCount() { return 0; }\n}\n\n"
  },
  {
    "path": "src/GroundElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class GroundElm extends CircuitElm {\n\tpublic GroundElm(int xx, int yy) { super(xx, yy); }\n\tpublic GroundElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t}\n\tint getDumpType() { return 'g'; }\n\tint getPostCount() { return 1; }\n\tvoid draw(Graphics g) {\n\t    setVoltageColor(g, 0);\n\t    drawThickLine(g, point1, point2);\n\t    int i;\n\t    for (i = 0; i != 3; i++) {\n\t\tint a = 10-i*4;\n\t\tint b = i*5; // -10;\n\t\tinterpPoint2(point1, point2, ps1, ps2, 1+b/dn, a);\n\t\tdrawThickLine(g, ps1, ps2);\n\t    }\n\t    doDots(g);\n\t    interpPoint(point1, point2, ps2, 1+11./dn);\n\t    setBbox(point1, ps2, 11);\n\t    drawPost(g, x, y, nodes[0]);\n\t}\n\tvoid setCurrent(int x, double c) { current = -c; }\n\tvoid stamp() {\n\t    sim.stampVoltageSource(0, nodes[0], voltSource, 0);\n\t}\n\tdouble getVoltageDiff() { return 0; }\n\tint getVoltageSourceCount() { return 1; }\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"ground\";\n\t    arr[1] = \"I = \" + getCurrentText(getCurrent());\n\t}\n\tboolean hasGroundConnection(int n1) { return true; }\n\tint getShortcut() { return 'g'; }\n    }\n"
  },
  {
    "path": "src/ImportExportAppletDialog.java",
    "content": "import java.awt.Dialog;\nimport java.applet.Applet;\nimport java.awt.Frame;\nimport netscape.javascript.*; // add plugin.jar to classpath during compilation\n\nclass ImportExportAppletDialog\nextends Dialog\nimplements ImportExportDialog\n{\n    Action type;\n    CirSim cframe;\n    String circuitDump;\n\n    ImportExportAppletDialog(CirSim f, Action type)\n    throws Exception\n    {\n\tsuper(f, (type == Action.EXPORT) ? \"Export\" : \"Import\", false);\n\tthis.type = type;\n\tcframe = f;\n\tif ( cframe.applet == null )\n\t    throw new Exception(\"Not running as an applet!\");\n    }\n\n    public void setDump(String dump)\n    {\n\tcircuitDump = dump;\n    }\n\n    public void execute()\n    {\n    \ttry\n\t{\n\t    JSObject window = JSObject.getWindow(cframe.applet);\n\t    if ( type == Action.EXPORT )\n\t    {\n\t\t//cframe.setVisible(false);\n\t\twindow.call(\"exportCircuit\", new  Object[] { circuitDump });\n\t    }\n\t    else\n\t    {\n\t\t//cframe.setVisible(false);\n\t\tcircuitDump = (String)window.eval(\"importCircuit()\");\n\t\tcframe.readSetup( circuitDump );\n\t    }\n\t}\n\tcatch (Exception e)\n\t{\n\t    e.printStackTrace();\n\t}\n    }\n}\n"
  },
  {
    "path": "src/ImportExportClipboardDialog.java",
    "content": "import java.awt.*;\nimport java.awt.event.*;\n\nimport java.awt.datatransfer.Clipboard;\nimport java.awt.datatransfer.DataFlavor;\nimport java.awt.datatransfer.StringSelection;\nimport java.awt.datatransfer.Transferable;\n\nclass ImportExportClipboardDialog\nextends Dialog\nimplements ImportExportDialog,ActionListener\n{\n    CirSim cframe;\n    Button importButton, closeButton;\n    TextArea text;\n    Action type;\n\n    Clipboard clipboard = null;\n\n    ImportExportClipboardDialog(CirSim f, Action type) {\n\tsuper(f, (type == Action.EXPORT) ? \"Export\" : \"Import\", false);\n\tcframe = f;\n\tsetLayout(new ImportExportDialogLayout());\n\tadd(text = new TextArea(\"\", 10, 60, TextArea.SCROLLBARS_BOTH));\n\tif (type == Action.EXPORT)\n\t    importButton = new Button(\"Copy to clipboard\");\n\telse\n\t    importButton = new Button(\"Import\");\n\tthis.type = type;\n\tadd(importButton);\n\timportButton.addActionListener(this);\n\tadd(closeButton = new Button(\"Close\"));\n\tcloseButton.addActionListener(this);\n\tPoint x = cframe.main.getLocationOnScreen();\n\tresize(400, 300);\n\tDimension d = getSize();\n\tsetLocation(x.x + (cframe.winSize.width-d.width)/2,\n\t\t    x.y + (cframe.winSize.height-d.height)/2);\n    }\n\n    public void setDump(String dump)\n    {\n\ttext.setText(dump);\n    }\n\n    public void execute()\n    {\n\tif ( type == Action.EXPORT )\n\t    text.selectAll();\n\tsetVisible(true);\n    }\n\n    public void actionPerformed(ActionEvent e) {\n\tint i;\n\tObject src = e.getSource();\n\tif (src == importButton) {\n\t    if (clipboard == null)\n\t\tclipboard = getToolkit().getSystemClipboard();\n\t    if ( type == Action.EXPORT )\n\t    {\n\t\tStringSelection data = new StringSelection(text.getText());\n\t\tclipboard.setContents(data, data);\n\t    }\n\t    else\n\t    {\n\t        cframe.readSetup(text.getText());\n\t    }\n\t}\n\tif (src == closeButton)\n\t    setVisible(false);\n    }\n\n    public boolean handleEvent(Event ev) {\n\tif (ev.id == Event.WINDOW_DESTROY) {\n\t    CirSim.main.requestFocus();\n\t    setVisible(false);\n\t    cframe.impDialog = null;\n\t    return true;\n\t}\n\treturn super.handleEvent(ev);\n    }\n\n}\n"
  },
  {
    "path": "src/ImportExportDialog.java",
    "content": "import java.awt.*;\nimport java.awt.event.*;\n\npublic interface ImportExportDialog {\n    public enum Action { IMPORT, EXPORT };\n\n    public void setDump(String dump);\n\n    public void execute();\n}\n\n"
  },
  {
    "path": "src/ImportExportDialogFactory.java",
    "content": "public class ImportExportDialogFactory\n{\n    public static ImportExportDialog Create(CirSim f,\n\tImportExportDialog.Action type)\n    {\n\tif (f.applet != null)\n\t{\n\t    try\n\t    {\n\t\treturn new ImportExportAppletDialog(f, type);\n\t    }\n\t    catch (Exception e)\n\t    {\n\t\treturn new ImportExportClipboardDialog(f, type);\n\t    }\n\t}\n\telse\n\t{\n\t    return new ImportExportFileDialog(f, type);\n\t}\n    }\n}\n"
  },
  {
    "path": "src/ImportExportDialogLayout.java",
    "content": "import java.awt.*;\n\nclass ImportExportDialogLayout implements LayoutManager {\n    public ImportExportDialogLayout() {}\n    public void addLayoutComponent(String name, Component c) {}\n    public void removeLayoutComponent(Component c) {}\n    public Dimension preferredLayoutSize(Container target) {\n\treturn new Dimension(500, 500);\n    }\n    public Dimension minimumLayoutSize(Container target) {\n\treturn new Dimension(100,100);\n    }\n    public void layoutContainer(Container target) {\n\tInsets insets = target.insets();\n\tint targetw = target.size().width - insets.left - insets.right;\n\tint targeth = target.size().height - (insets.top+insets.bottom);\n\tint i;\n\tint pw = 300;\n\tif (target.getComponentCount() == 0)\n\t    return;\n\tComponent cl = target.getComponent(target.getComponentCount()-1);\n\tDimension dl = cl.getPreferredSize();\n\ttarget.getComponent(0).move(insets.left, insets.top);\n\tint cw = target.size().width - insets.left - insets.right;\n\tint ch = target.size().height - insets.top - insets.bottom -\n\t    dl.height;\n\ttarget.getComponent(0).resize(cw, ch);\n\tint h = ch + insets.top;\n\tint x = 0;\n\tfor (i = 1; i < target.getComponentCount(); i++) {\n\t    Component m = target.getComponent(i);\n\t    if (m.isVisible()) {\n\t\tDimension d = m.getPreferredSize();\n\t\tm.move(insets.left+x, h);\n\t\tm.resize(d.width, d.height);\n\t\tx += d.width;\n\t    }\n\t}\n    }\n};\n\n"
  },
  {
    "path": "src/ImportExportFileDialog.java",
    "content": "import java.awt.*;\nimport java.awt.event.*;\nimport java.io.*;\nimport java.nio.ByteBuffer;\nimport java.nio.MappedByteBuffer;\nimport java.nio.channels.FileChannel;\nimport java.nio.charset.Charset;\n\nclass ImportExportFileDialog\nimplements ImportExportDialog\n{\n    CirSim cframe;\n    private static String circuitDump;\n    Action type;\n    private static String directory = \".\";\n\n    ImportExportFileDialog(CirSim f, Action type)\n    {\n\tif ( directory.equals(\".\") )\n\t{\n\t    File file = new File(\"circuits\");\n\t    if ( file.isDirectory() )\n\t\tdirectory = \"circuits\";\n\t}\n\tthis.type = type;\n\tcframe = f;\n    }\n\n    public void setDump(String dump)\n    {\n\tcircuitDump = dump;\n    }\n\n    public String getDump()\n    {\n\treturn circuitDump;\n    }\n\n    public void execute()\n    {\n\tFileDialog fd = new FileDialog(new Frame(),\n\t\t\t(type == Action.EXPORT) ? \"Save File\" :\n\t\t\t\"Open File\",\n\t\t\t(type == Action.EXPORT) ? FileDialog.SAVE :\n\t\t\tFileDialog.LOAD );\n\tfd.setDirectory(directory);\n\tfd.setVisible(true);\n\tString file = fd.getFile();\n\tString dir = fd.getDirectory();\n\tif ( dir != null )\n\t    directory = dir;\n\tif ( file == null )\n\t    return;\n\tSystem.err.println(dir + File.separator + file);\n\tif ( type == Action.EXPORT )\n\t{\n\t    try\n\t    {\n\t\twriteFile(dir + file);\n\t    }\n\t    catch (Exception e)\n\t    {\n\t\te.printStackTrace();\n\t    }\n\t}\n\telse\n\t{\n\t    try\n\t    {\n\t\tString dump = readFile(dir + file);\n\t\tcircuitDump = dump;\n\t\tcframe.readSetup(circuitDump);\n\t    }\n\t    catch (Exception e)\n\t    {\n\t\te.printStackTrace();\n\t    }\n\t}\n    }\n\n    private static String readFile(String path)\n    throws IOException, FileNotFoundException\n    {\n\tFileInputStream stream = null;\n\ttry\n\t{\n\t    stream = new FileInputStream(new File(path));\n\t    FileChannel fc = stream.getChannel();\n\t    MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY,\n\t\t\t\t\t 0, fc.size());\n\t    return Charset.forName(\"UTF-8\").decode(bb).toString();\n\t}\n\tfinally\n\t{\n\t    stream.close();\n\t}\n    }\n\n    private static void writeFile(String path)\n    throws IOException, FileNotFoundException\n    {\n\tFileOutputStream stream = null;\n\ttry\n\t{\n\t    stream = new FileOutputStream(new File(path));\n\t    FileChannel fc = stream.getChannel();\n\t    ByteBuffer bb = Charset.forName(\"UTF-8\").encode(circuitDump);\n\t    fc.write(bb);\n\t}\n\tfinally\n\t{\n\t    stream.close();\n\t}\n    }\n}\n"
  },
  {
    "path": "src/Inductor.java",
    "content": "class Inductor {\n    public static final int FLAG_BACK_EULER = 2;\n    int nodes[];\n    int flags;\n    CirSim sim;\n    \n    double inductance;\n    double compResistance, current;\n    double curSourceValue;\n    Inductor(CirSim s) {\n\tsim = s;\n\tnodes = new int[2];\n    }\n    void setup(double ic, double cr, int f) {\n\tinductance = ic;\n\tcurrent = cr;\n\tflags = f;\n    }\n    boolean isTrapezoidal() { return (flags & FLAG_BACK_EULER) == 0; }\n    void reset() {\n\tcurrent = 0;\n    }\n    void stamp(int n0, int n1) {\n\t// inductor companion model using trapezoidal or backward euler\n\t// approximations (Norton equivalent) consists of a current\n\t// source in parallel with a resistor.  Trapezoidal is more\n\t// accurate than backward euler but can cause oscillatory behavior.\n\t// The oscillation is a real problem in circuits with switches.\n\tnodes[0] = n0;\n\tnodes[1] = n1;\n\tif (isTrapezoidal())\n\t    compResistance = 2*inductance/sim.timeStep;\n\telse // backward euler\n\t    compResistance = inductance/sim.timeStep;\n\tsim.stampResistor(nodes[0], nodes[1], compResistance);\n\tsim.stampRightSide(nodes[0]);\n\tsim.stampRightSide(nodes[1]);\n    }\n    boolean nonLinear() { return false; }\n\n    void startIteration(double voltdiff) {\n\tif (isTrapezoidal())\n\t    curSourceValue = voltdiff/compResistance+current;\n\telse // backward euler\n\t    curSourceValue = current;\n    }\n    \n    double calculateCurrent(double voltdiff) {\n\t// we check compResistance because this might get called\n\t// before stamp(), which sets compResistance, causing\n\t// infinite current\n\tif (compResistance > 0)\n\t    current = voltdiff/compResistance + curSourceValue;\n\treturn current;\n    }\n    void doStep(double voltdiff) {\n\tsim.stampCurrentSource(nodes[0], nodes[1], curSourceValue);\n    }\n}\n"
  },
  {
    "path": "src/InductorElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class InductorElm extends CircuitElm {\n\tInductor ind;\n\tdouble inductance;\n\tpublic InductorElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    ind = new Inductor(sim);\n\t    inductance = 1;\n\t    ind.setup(inductance, current, flags);\n\t}\n\tpublic InductorElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    ind = new Inductor(sim);\n\t    inductance = new Double(st.nextToken()).doubleValue();\n\t    current = new Double(st.nextToken()).doubleValue();\n\t    ind.setup(inductance, current, flags);\n\t}\n\tint getDumpType() { return 'l'; }\n\tString dump() {\n\t    return super.dump() + \" \" + inductance + \" \" + current;\n\t}\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    calcLeads(32);\n\t}\n\tvoid draw(Graphics g) {\n\t    double v1 = volts[0];\n\t    double v2 = volts[1];\n\t    int i;\n\t    int hs = 8;\n\t    setBbox(point1, point2, hs);\n\t    draw2Leads(g);\n\t    setPowerColor(g, false);\n\t    drawCoil(g, 8, lead1, lead2, v1, v2);\n\t    if (sim.showValuesCheckItem.getState()) {\n\t\tString s = getShortUnitText(inductance, \"H\");\n\t\tdrawValues(g, s, hs);\n\t    }\n\t    doDots(g);\n\t    drawPosts(g);\n\t}\n\tvoid reset() {\n\t    current = volts[0] = volts[1] = curcount = 0;\n\t    ind.reset();\n\t}\n\tvoid stamp() { ind.stamp(nodes[0], nodes[1]); }\n\tvoid startIteration() {\n\t    ind.startIteration(volts[0]-volts[1]);\n\t}\n\tboolean nonLinear() { return ind.nonLinear(); }\n\tvoid calculateCurrent() {\n\t    double voltdiff = volts[0]-volts[1];\n\t    current = ind.calculateCurrent(voltdiff);\n\t}\n\tvoid doStep() {\n\t    double voltdiff = volts[0]-volts[1];\n\t    ind.doStep(voltdiff);\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"inductor\";\n\t    getBasicInfo(arr);\n\t    arr[3] = \"L = \" + getUnitText(inductance, \"H\");\n\t    arr[4] = \"P = \" + getUnitText(getPower(), \"W\");\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Inductance (H)\", inductance, 0, 0);\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Trapezoidal Approximation\",\n\t\t\t\t\t   ind.isTrapezoidal());\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tinductance = ei.value;\n\t    if (n == 1) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags &= ~Inductor.FLAG_BACK_EULER;\n\t\telse\n\t\t    flags |= Inductor.FLAG_BACK_EULER;\n\t    }\n\t    ind.setup(inductance, current, flags);\n\t}\n    }\n"
  },
  {
    "path": "src/InverterElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class InverterElm extends CircuitElm {\n\tdouble slewRate; // V/ns\n\tpublic InverterElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    noDiagonal = true;\n\t    slewRate = .5;\n\t}\n\tpublic InverterElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    noDiagonal = true;\n\t    try {\n\t\tslewRate = new Double (st.nextToken()).doubleValue();\n\t    } catch (Exception e) {\n\t\tslewRate = .5;\n\t    }\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + slewRate;\n\t}\n\t\n\tint getDumpType() { return 'I'; }\n\tvoid draw(Graphics g) {\n\t    drawPosts(g);\n\t    draw2Leads(g);\n\t    g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\t    drawThickPolygon(g, gatePoly);\n\t    drawThickCircle(g, pcircle.x, pcircle.y, 3);\n\t    curcount = updateDotCount(current, curcount);\n\t    drawDots(g, lead2, point2, curcount);\n\t}\n\tPolygon gatePoly;\n\tPoint pcircle;\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    int hs = 16;\n\t    int ww = 16;\n\t    if (ww > dn/2)\n\t\tww = (int) (dn/2);\n\t    lead1 = interpPoint(point1, point2, .5-ww/dn);\n\t    lead2 = interpPoint(point1, point2, .5+(ww+2)/dn);\n\t    pcircle = interpPoint(point1, point2, .5+(ww-2)/dn);\n\t    Point triPoints[] = newPointArray(3);\n\t    interpPoint2(lead1, lead2, triPoints[0], triPoints[1], 0, hs);\n\t    triPoints[2] = interpPoint(point1, point2, .5+(ww-5)/dn);\n\t    gatePoly = createPolygon(triPoints);\n\t    setBbox(point1, point2, hs);\n\t}\n\tint getVoltageSourceCount() { return 1; }\n\tvoid stamp() {\n\t    sim.stampVoltageSource(0, nodes[1], voltSource);\n\t}\n\tvoid doStep() {\n\t    double v0 = volts[1];\n\t    double out = volts[0] > 2.5 ? 0 : 5;\n\t    double maxStep = slewRate * sim.timeStep * 1e9;\n\t    out = Math.max(Math.min(v0+maxStep, out), v0-maxStep);\n\t    sim.updateVoltageSource(0, nodes[1], voltSource, out);\n\t}\n\tdouble getVoltageDiff() { return volts[0]; }\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"inverter\";\n\t    arr[1] = \"Vi = \" + getVoltageText(volts[0]);\n\t    arr[2] = \"Vo = \" + getVoltageText(volts[1]);\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Slew Rate (V/ns)\", slewRate, 0, 0);\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    slewRate = ei.value;\n\t}\n\t// there is no current path through the inverter input, but there\n\t// is an indirect path through the output to ground.\n\tboolean getConnection(int n1, int n2) { return false; }\n\tboolean hasGroundConnection(int n1) {\n\t    return (n1 == 1);\n\t}\n\tint getShortcut() { return '1'; }\n    }\n"
  },
  {
    "path": "src/JKFlipFlopElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class JKFlipFlopElm extends ChipElm {\n\tpublic JKFlipFlopElm(int xx, int yy) { super(xx, yy); }\n\tpublic JKFlipFlopElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    pins[4].value = !pins[3].value;\n\t}\n\tString getChipName() { return \"JK flip-flop\"; }\n\tvoid setupPins() {\n\t    sizeX = 2;\n\t    sizeY = 3;\n\t    pins = new Pin[5];\n\t    pins[0] = new Pin(0, SIDE_W, \"J\");\n\t    pins[1] = new Pin(1, SIDE_W, \"\");\n\t    pins[1].clock = true;\n\t    pins[1].bubble = true;\n\t    pins[2] = new Pin(2, SIDE_W, \"K\");\n\t    pins[3] = new Pin(0, SIDE_E, \"Q\");\n\t    pins[3].output = pins[3].state = true;\n\t    pins[4] = new Pin(2, SIDE_E, \"Q\");\n\t    pins[4].output = true;\n\t    pins[4].lineOver = true;\n\t}\n\tint getPostCount() { return 5; }\n\tint getVoltageSourceCount() { return 2; }\n\tvoid execute() {\n\t    if (!pins[1].value && lastClock) {\n\t\tboolean q = pins[3].value;\n\t\tif (pins[0].value) {\n\t\t    if (pins[2].value)\n\t\t\tq = !q;\n\t\t    else\n\t\t\tq = true;\n\t\t} else if (pins[2].value)\n\t\t    q = false;\n\t\tpins[3].value = q;\n\t\tpins[4].value = !q;\n\t    }\n\t    lastClock = pins[1].value;\n\t}\n\tint getDumpType() { return 156; }\n    }\n"
  },
  {
    "path": "src/JfetElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class JfetElm extends MosfetElm {\n\tJfetElm(int xx, int yy, boolean pnpflag) {\n\t    super(xx, yy, pnpflag);\n\t    noDiagonal = true;\n\t}\n\tpublic JfetElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    noDiagonal = true;\n\t}\n\t\n\tPolygon gatePoly;\n\tPolygon arrowPoly;\n\tPoint gatePt;\n\n\tvoid draw(Graphics g) {\n\t    setBbox(point1, point2, hs);\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, src[0], src[1]);\n\t    drawThickLine(g, src[1], src[2]);\n\t    setVoltageColor(g, volts[2]);\n\t    drawThickLine(g, drn[0], drn[1]);\n\t    drawThickLine(g, drn[1], drn[2]);\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, gatePt);\n\t    g.fillPolygon(arrowPoly);\n\t    setPowerColor(g, true);\n\t    g.fillPolygon(gatePoly);\n\t    curcount = updateDotCount(-ids, curcount);\n\t    if (curcount != 0) {\n\t\tdrawDots(g, src[0], src[1], curcount);\n\t\tdrawDots(g, src[1], src[2], curcount+8);\n\t\tdrawDots(g, drn[0], drn[1], -curcount);\n\t\tdrawDots(g, drn[1], drn[2], -(curcount+8));\n\t    }\n\t    drawPosts(g);\n\t}\n\tvoid setPoints() {\n\t    super.setPoints();\n\n\t    // find the coordinates of the various points we need to draw\n\t    // the JFET.\n\t    int hs2 = hs*dsign;\n\t    src = newPointArray(3);\n\t    drn = newPointArray(3);\n\t    interpPoint2(point1, point2, src[0], drn[0], 1, hs2);\n\t    interpPoint2(point1, point2, src[1], drn[1], 1, hs2/2);\n\t    interpPoint2(point1, point2, src[2], drn[2], 1-10/dn, hs2/2);\n\n\t    gatePt = interpPoint(point1, point2, 1-14/dn);\n\n\t    Point ra[] = newPointArray(4);\n\t    interpPoint2(point1, point2, ra[0], ra[1], 1-13/dn, hs);\n\t    interpPoint2(point1, point2, ra[2], ra[3], 1-10/dn, hs);\n\t    gatePoly = createPolygon(ra[0], ra[1], ra[3], ra[2]);\n\t    if (pnp == -1) {\n\t\tPoint x = interpPoint(gatePt, point1, 18/dn);\n\t\tarrowPoly = calcArrow(gatePt, x, 8, 3);\n\t    } else\n\t\tarrowPoly = calcArrow(point1, gatePt, 8, 3);\n\t}\n\tint getDumpType() { return 'j'; }\n\t// these values are taken from Hayes+Horowitz p155\n\tdouble getDefaultThreshold() { return -4; }\n\tdouble getBeta() { return .00125; }\n\tvoid getInfo(String arr[]) {\n\t    getFetInfo(arr, \"JFET\");\n\t}\n    }\n"
  },
  {
    "path": "src/LEDElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class LEDElm extends DiodeElm {\n\tdouble colorR, colorG, colorB;\n\tpublic LEDElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    fwdrop = 2.1024259;\n\t    setup();\n\t    colorR = 1; colorG = colorB = 0;\n\t}\n\tpublic LEDElm(int xa, int ya, int xb, int yb, int f,\n\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    if ((f & FLAG_FWDROP) == 0)\n\t\tfwdrop = 2.1024259;\n\t    setup();\n\t    colorR = new Double(st.nextToken()).doubleValue();\n\t    colorG = new Double(st.nextToken()).doubleValue();\n\t    colorB = new Double(st.nextToken()).doubleValue();\n\t}\n\tint getDumpType() { return 162; }\n\tString dump() {\n\t    return super.dump() + \" \" + colorR + \" \" + colorG + \" \" + colorB;\n\t}\n\n\tPoint ledLead1, ledLead2, ledCenter;\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    int cr = 12;\n\t    ledLead1  = interpPoint(point1, point2, .5-cr/dn);\n\t    ledLead2  = interpPoint(point1, point2, .5+cr/dn);\n\t    ledCenter = interpPoint(point1, point2, .5);\n\t}\n\t\n\tvoid draw(Graphics g) {\n\t    if (needsHighlight() || this == sim.dragElm) {\n\t\tsuper.draw(g);\n\t\treturn;\n\t    }\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, ledLead1);\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, ledLead2, point2);\n\t    \n\t    g.setColor(Color.gray);\n\t    int cr = 12;\n\t    drawThickCircle(g, ledCenter.x, ledCenter.y, cr);\n\t    cr -= 4;\n\t    double w = 255*current/.01;\n\t    if (w > 255)\n\t\tw = 255;\n\t    Color cc = new Color((int) (colorR*w), (int) (colorG*w),\n\t\t\t\t (int) (colorB*w));\n\t    g.setColor(cc);\n\t    g.fillOval(ledCenter.x-cr, ledCenter.y-cr, cr*2, cr*2);\n\t    setBbox(point1, point2, cr);\n\t    updateDotCount();\n\t    drawDots(g, point1, ledLead1, curcount);\n\t    drawDots(g, point2, ledLead2, -curcount);\n\t    drawPosts(g);\n\t}\n\n\tvoid getInfo(String arr[]) {\n\t    super.getInfo(arr);\n\t    arr[0] = \"LED\";\n\t}\n\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn super.getEditInfo(n);\n\t    if (n == 1)\n\t\treturn new EditInfo(\"Red Value (0-1)\", colorR, 0, 1).\n\t\t    setDimensionless();\n\t    if (n == 2)\n\t\treturn new EditInfo(\"Green Value (0-1)\", colorG, 0, 1).\n\t\t    setDimensionless();\n\t    if (n == 3)\n\t\treturn new EditInfo(\"Blue Value (0-1)\", colorB, 0, 1).\n\t\t    setDimensionless();\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tsuper.setEditValue(0, ei);\n\t    if (n == 1)\n\t\tcolorR = ei.value;\n\t    if (n == 2)\n\t\tcolorG = ei.value;\n\t    if (n == 3)\n\t\tcolorB = ei.value;\n\t}\n\tint getShortcut() { return 'l'; }\n    }\n"
  },
  {
    "path": "src/LampElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class LampElm extends CircuitElm {\n\tdouble resistance;\n\tfinal double roomTemp = 300;\n\tdouble temp, nom_pow, nom_v, warmTime, coolTime;\n\tpublic LampElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    temp = roomTemp;\n\t    nom_pow = 100;\n\t    nom_v = 120;\n\t    warmTime = .4;\n\t    coolTime = .4;\n\t}\n\tpublic LampElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    temp = new Double(st.nextToken()).doubleValue();\n\t    nom_pow = new Double(st.nextToken()).doubleValue();\n\t    nom_v = new Double(st.nextToken()).doubleValue();\n\t    warmTime = new Double(st.nextToken()).doubleValue();\n\t    coolTime = new Double(st.nextToken()).doubleValue();\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + temp + \" \" + nom_pow + \" \" + nom_v +\n\t\t\" \" + warmTime + \" \" + coolTime;\n\t}\n\tint getDumpType() { return 181; }\n\n\tPoint bulbLead[], filament[], bulb;\n\tint bulbR;\n\n\tvoid reset() {\n\t    super.reset();\n\t    temp = roomTemp;\n\t}\n\tfinal int filament_len = 24;\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    int llen = 16;\n\t    calcLeads(llen);\n\t    bulbLead = newPointArray(2);\n\t    filament = newPointArray(2);\n\t    bulbR = 20;\n\t    filament[0] = interpPoint(lead1, lead2, 0, filament_len);\n\t    filament[1] = interpPoint(lead1, lead2, 1, filament_len);\n\t    double br = filament_len-Math.sqrt(bulbR*bulbR-llen*llen);\n\t    bulbLead[0] = interpPoint(lead1, lead2, 0, br);\n\t    bulbLead[1] = interpPoint(lead1, lead2, 1, br);\n\t    bulb = interpPoint(filament[0], filament[1], .5);\n\t}\n\n\tColor getTempColor() {\n\t    if (temp < 1200) {\n\t\tint x = (int) (255*(temp-800)/400);\n\t\tif (x < 0)\n\t\t    x = 0;\n\t\treturn new Color(x, 0, 0);\n\t    }\n\t    if (temp < 1700) {\n\t\tint x = (int) (255*(temp-1200)/500);\n\t\tif (x < 0)\n\t\t    x = 0;\n\t\treturn new Color(255, x, 0);\n\t    }\n\t    if (temp < 2400) {\n\t\tint x = (int) (255*(temp-1700)/700);\n\t\tif (x < 0)\n\t\t    x = 0;\n\t\treturn new Color(255, 255, x);\n\t    }\n\t    return Color.white;\n\t}\n\t\n\tvoid draw(Graphics g) {\n\t    double v1 = volts[0];\n\t    double v2 = volts[1];\n\t    setBbox(point1, point2, 4);\n\t    adjustBbox(bulb.x-bulbR, bulb.y-bulbR,\n\t\t       bulb.x+bulbR, bulb.y+bulbR);\n\t    // adjustbbox\n\t    draw2Leads(g);\n\t    setPowerColor(g, true);\n\t    g.setColor(getTempColor());\n\t    g.fillOval(bulb.x-bulbR, bulb.y-bulbR, bulbR*2, bulbR*2);\n\t    g.setColor(Color.white);\n\t    drawThickCircle(g, bulb.x, bulb.y, bulbR);\n\t    setVoltageColor(g, v1);\n\t    drawThickLine(g, lead1, filament[0]);\n\t    setVoltageColor(g, v2);\n\t    drawThickLine(g, lead2, filament[1]);\n\t    setVoltageColor(g, (v1+v2)*.5);\n\t    drawThickLine(g, filament[0], filament[1]);\n\t    updateDotCount();\n\t    if (sim.dragElm != this) {\n\t\tdrawDots(g, point1, lead1, curcount);\n\t\tdouble cc = curcount+(dn-16)/2;\n\t\tdrawDots(g, lead1,  filament[0], cc);\n\t\tcc += filament_len;\n\t\tdrawDots(g, filament[0], filament[1], cc);\n\t\tcc += 16;\n\t\tdrawDots(g, filament[1], lead2, cc);\n\t\tcc += filament_len;\n\t\tdrawDots(g, lead2, point2, curcount);\n\t    }\n\t    drawPosts(g);\n\t}\n\n\tvoid calculateCurrent() {\n\t    current = (volts[0]-volts[1])/resistance;\n\t    //System.out.print(this + \" res current set to \" + current + \"\\n\");\n\t}\n\tvoid stamp() {\n\t    sim.stampNonLinear(nodes[0]);\n\t    sim.stampNonLinear(nodes[1]);\n\t}\n\tboolean nonLinear() { return true; }\n\tvoid startIteration() {\n\t    // based on http://www.intusoft.com/nlpdf/nl11.pdf\n\t    double nom_r = nom_v*nom_v/nom_pow;\n\t    // this formula doesn't work for values over 5390\n\t    double tp = (temp > 5390) ? 5390 : temp;\n\t    resistance = nom_r*(1.26104 -\n\t\t\t\t4.90662*Math.sqrt(17.1839/tp - 0.00318794) -\n\t\t\t\t7.8569/(tp - 187.56));\n\t    double cap = 1.57e-4*nom_pow;\n\t    double capw = cap * warmTime/.4;\n\t    double capc = cap * coolTime/.4;\n\t    //System.out.println(nom_r + \" \" + (resistance/nom_r));\n\t    temp += getPower()*sim.timeStep/capw;\n\t    double cr = 2600/nom_pow;\n\t    temp -= sim.timeStep*(temp-roomTemp)/(capc*cr);\n\t    //System.out.println(capw + \" \" + capc + \" \" + temp + \" \" +resistance);\n\t}\n\tvoid doStep() {\n\t    sim.stampResistor(nodes[0], nodes[1], resistance);\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"lamp\";\n\t    getBasicInfo(arr);\n\t    arr[3] = \"R = \" + getUnitText(resistance, sim.ohmString);\n\t    arr[4] = \"P = \" + getUnitText(getPower(), \"W\");\n\t    arr[5] = \"T = \" + ((int) temp) + \" K\";\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    // ohmString doesn't work here on linux\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Nominal Power\", nom_pow, 0, 0);\n\t    if (n == 1)\n\t\treturn new EditInfo(\"Nominal Voltage\", nom_v, 0, 0);\n\t    if (n == 2)\n\t\treturn new EditInfo(\"Warmup Time (s)\", warmTime, 0, 0);\n\t    if (n == 3)\n\t\treturn new EditInfo(\"Cooldown Time (s)\", coolTime, 0, 0);\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0 && ei.value > 0)\n\t\tnom_pow = ei.value;\n\t    if (n == 1 && ei.value > 0)\n\t\tnom_v = ei.value;\n\t    if (n == 2 && ei.value > 0)\n\t\twarmTime = ei.value;\n\t    if (n == 3 && ei.value > 0)\n\t\tcoolTime = ei.value;\n\t}\n    }\n"
  },
  {
    "path": "src/LatchElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass LatchElm extends ChipElm {\n    public LatchElm(int xx, int yy) { super(xx, yy); }\n    public LatchElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n    }\n    String getChipName() { return \"Latch\"; }\n    boolean needsBits() { return true; }\n    int loadPin;\n    void setupPins() {\n\tsizeX = 2;\n\tsizeY = bits+1;\n\tpins = new Pin[getPostCount()];\n\tint i;\n\tfor (i = 0; i != bits; i++)\n\t    pins[i] = new Pin(bits-1-i, SIDE_W, \"I\" + i);\n\tfor (i = 0; i != bits; i++) {\n\t    pins[i+bits] = new Pin(bits-1-i, SIDE_E, \"O\");\n\t    pins[i+bits].output = true;\n\t}\n\tpins[loadPin = bits*2] = new Pin(bits, SIDE_W, \"Ld\");\n\tallocNodes();\n    }\n    boolean lastLoad = false;\n    void execute() {\n\tint i;\n\tif (pins[loadPin].value && !lastLoad)\n\t    for (i = 0; i != bits; i++)\n\t\tpins[i+bits].value = pins[i].value;\n\tlastLoad = pins[loadPin].value;\n    }\n    int getVoltageSourceCount() { return bits; }\n    int getPostCount() { return bits*2+1; }\n    int getDumpType() { return 168; }\n}\n    \n"
  },
  {
    "path": "src/LogicInputElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class LogicInputElm extends SwitchElm {\n\tfinal int FLAG_TERNARY = 1;\n\tfinal int FLAG_NUMERIC = 2;\n\tdouble hiV, loV;\n\tPolygon arrowPoly;\n\tpublic LogicInputElm(int xx, int yy) {\n\t    super(xx, yy, false);\n\t    hiV = 5;\n\t    loV = 0;\n\t    flags = 2; // hausen: default to numeric\n\t}\n\tpublic LogicInputElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t     StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    try {\n\t\thiV = new Double(st.nextToken()).doubleValue();\n\t\tloV = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) {\n\t\thiV = 5;\n\t\tloV = 0;\n\t    }\n\t    if (isTernary())\n\t\tposCount = 3;\n\t}\n\tboolean isTernary() { return (flags & FLAG_TERNARY) != 0; }\n\tboolean isNumeric() { return (flags & (FLAG_TERNARY|FLAG_NUMERIC)) != 0; }\n\tint getDumpType() { return 'L'; }\n\tString dump() {\n\t    return super.dump() + \" \" + hiV + \" \" + loV;\n\t}\n\tint getPostCount() { return 1; }\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    lead1 = interpPoint(point1, point2, 1-12/dn);\n\t    arrowPoly = calcArrowReverse(point1, lead1, 8, 8);\n\t}\n\tvoid draw(Graphics g) {\n\t    Font f = new Font(\"SansSerif\", Font.BOLD, 20);\n\t    g.setFont(f);\n\t    g.setColor(needsHighlight() ? selectColor : whiteColor);\n\t    String s = position == 0 ? \"L\" : \"H\";\n\t    if (isNumeric())\n\t\ts = \"\" + position;\n\t    setBbox(point1, lead1, 0);\n\t    drawCenteredText(g, s, x2, y2, true);\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, lead1);\n\t    g.fillPolygon(arrowPoly);\n\t    updateDotCount();\n\t    drawDots(g, point1, lead1, curcount);\n\t    drawPosts(g);\n\t}\n\tvoid setCurrent(int vs, double c) { current = -c; }\n\tvoid stamp() {\n\t    double v = (position == 0) ? loV : hiV;\n\t    if (isTernary())\n\t\tv = position * 2.5;\n\t    sim.stampVoltageSource(0, nodes[0], voltSource, v);\n\t}\n\tint getVoltageSourceCount() { return 1; }\n\tdouble getVoltageDiff() { return volts[0]; }\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"logic input\";\n\t    arr[1] = (position == 0) ? \"low\" : \"high\";\n\t    if (isNumeric())\n\t\tarr[1] = \"\" + position;\n\t    arr[1] += \" (\" + getVoltageText(volts[0]) + \")\";\n\t    arr[2] = \"I = \" + getCurrentText(getCurrent());\n\t}\n\tboolean hasGroundConnection(int n1) { return true; }\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, 0, 0);\n\t\tei.checkbox = new Checkbox(\"Momentary Switch\", momentary);\n\t\treturn ei;\n\t    }\n\t    if (n == 1)\n\t\treturn new EditInfo(\"High Voltage\", hiV, 10, -10);\n\t    if (n == 2)\n\t\treturn new EditInfo(\"Low Voltage\", loV, 10, -10);\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tmomentary = ei.checkbox.getState();\n\t    if (n == 1)\n\t\thiV = ei.value;\n\t    if (n == 2)\n\t\tloV = ei.value;\n\t}\n\tint getShortcut() { return 'i'; }\n    }\n"
  },
  {
    "path": "src/LogicOutputElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class LogicOutputElm extends CircuitElm {\n\tfinal int FLAG_TERNARY = 1;\n\tfinal int FLAG_NUMERIC = 2;\n\tfinal int FLAG_PULLDOWN = 4;\n\tdouble threshold;\n\tString value;\n\tPolygon arrowPoly;\n\tpublic LogicOutputElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    threshold = 3; // hausen: default to 3\n\t    flags = 6; // hausen: default to numeric and pulldown\n\t}\n\tpublic LogicOutputElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    try {\n\t\tthreshold = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) {\n\t\tthreshold = 3;\n\t    }\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + threshold;\n\t}\n\tint getDumpType() { return 'M'; }\n\tint getPostCount() { return 1; }\n\tboolean isTernary() { return (flags & FLAG_TERNARY) != 0; }\n\t//boolean isNumeric() { return (flags & (FLAG_TERNARY|FLAG_NUMERIC)) != 0; }\n\tboolean isNumeric() { return true; } // hausen: always numeric\n\tboolean needsPullDown() { return (flags & FLAG_PULLDOWN) != 0; }\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    lead1 = interpPoint(point1, point2, 1-12/dn);\n\t    arrowPoly = calcArrow(point1, lead1, 8, 8);\n\t}\n\tvoid draw(Graphics g) {\n\t    Font f = new Font(\"SansSerif\", Font.BOLD, 20);\n\t    g.setFont(f);\n\t    //g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\t    g.setColor(lightGrayColor);\n\t    String s = (volts[0] < threshold) ? \"L\" : \"H\";\n\t    if (isTernary()) {\n\t\tif (volts[0] > 3.75)\n\t\t    s = \"2\";\n\t\telse if (volts[0] > 1.25)\n\t\t    s = \"1\";\n\t\telse\n\t\t    s = \"0\";\n\t    } else if (isNumeric())\n\t\ts = (volts[0] < threshold) ? \"0\" : \"1\";\n\t    value = s;\n\t    setBbox(point1, lead1, 0);\n\t    drawCenteredText(g, s, x2, y2, true);\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, lead1);\n\t    g.fillPolygon(arrowPoly);\n\t    drawPosts(g);\n\t}\n\tvoid stamp() {\n\t    if (needsPullDown())\n\t\tsim.stampResistor(nodes[0], 0, 1e6);\n\t}\n\tdouble getVoltageDiff() { return volts[0]; }\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"logic output\";\n\t    arr[1] = (volts[0] < threshold) ? \"low\" : \"high\";\n\t    if (isNumeric())\n\t\tarr[1] = value;\n\t    arr[2] = \"V = \" + getVoltageText(volts[0]);\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Threshold\", threshold, 10, -10);\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Current Required\", needsPullDown());\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tthreshold = ei.value;\n\t    if (n == 1) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags = FLAG_PULLDOWN;\n\t\telse\n\t\t    flags &= ~FLAG_PULLDOWN;\n\t    }\n\t}\n\tint getShortcut() { return 'o'; }\n    }\n"
  },
  {
    "path": "src/Makefile",
    "content": "PLUGINJAR=/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/plugin.jar\n#PLUGINJAR=/usr/share/icedtea-web/plugin.jar\n\nall:\n\tjavac -classpath $(PLUGINJAR):. *.java\n\njar: circuit.jar\n\nsrc:\n\tcd .. && zip -r circuit-src.zip src/Makefile src/*.java src/*.txt src/circuits/\n\nrun: all\n\tjava Circuit\n\ncircuit.jar: all\n\tjar cfm circuit.jar Manifest.txt *.class *.txt circuits/\n\nclean:\n\trm -f *.class circuit.jar\n"
  },
  {
    "path": "src/Manifest.txt",
    "content": "Main-Class: Circuit\n"
  },
  {
    "path": "src/MemristorElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass MemristorElm extends CircuitElm {\n    double r_on, r_off, dopeWidth, totalWidth, mobility, resistance;\n    public MemristorElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tr_on = 100;\n\tr_off = 160*r_on;\n\tdopeWidth = 0;\n\ttotalWidth = 10e-9; // meters\n\tmobility = 1e-10;   // m^2/sV\n\tresistance = 100;\n    }\n    public MemristorElm(int xa, int ya, int xb, int yb, int f,\n\t\t\tStringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tr_on = new Double(st.nextToken()).doubleValue();\n\tr_off = new Double(st.nextToken()).doubleValue();\n\tdopeWidth = new Double(st.nextToken()).doubleValue();\n\ttotalWidth = new Double(st.nextToken()).doubleValue();\n\tmobility = new Double(st.nextToken()).doubleValue();\n\tresistance = 100;\n    }\n    int getDumpType() { return 'm'; }\n    String dump() {\n\treturn super.dump() + \" \" + r_on + \" \" + r_off + \" \" + dopeWidth + \" \" +\n\t    totalWidth + \" \" + mobility;\n    }\n\n    Point ps3, ps4;\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(32);\n\tps3 = new Point();\n\tps4 = new Point();\n    }\n\t\n    void draw(Graphics g) {\n\tint segments = 6;\n\tint i;\n\tint ox = 0;\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\tint hs = 2+(int) (8*(1-dopeWidth/totalWidth));\n\tsetBbox(point1, point2, hs);\n\tdraw2Leads(g);\n\tsetPowerColor(g, true);\n\tdouble segf = 1./segments;\n\n\t// draw zigzag\n\tfor (i = 0; i <= segments; i++) {\n\t    int nx = (i & 1) == 0 ? 1 : -1;\n\t    if (i == segments)\n\t\tnx = 0;\n\t    double v = v1+(v2-v1)*i/segments;\n\t    setVoltageColor(g, v);\n\t    interpPoint(lead1, lead2, ps1, i*segf, hs*ox);\n\t    interpPoint(lead1, lead2, ps2, i*segf, hs*nx);\n\t    drawThickLine(g, ps1, ps2);\n\t    if (i == segments)\n\t\tbreak;\n\t    interpPoint(lead1, lead2, ps1, (i+1)*segf, hs*nx);\n\t    drawThickLine(g, ps1, ps2);\n\t    ox = nx;\n\t}\n\t    \n\tdoDots(g);\n\tdrawPosts(g);\n    }\n    \n    boolean nonLinear() { return true; }\n    void calculateCurrent() {\n\tcurrent = (volts[0]-volts[1])/resistance;\n    }\n    void reset() {\n\tdopeWidth = 0;\n    }\n    void startIteration() {\n\tdouble wd = dopeWidth/totalWidth;\n\tdopeWidth += sim.timeStep*mobility*r_on*current/totalWidth;\n\tif (dopeWidth < 0)\n\t    dopeWidth = 0;\n\tif (dopeWidth > totalWidth)\n\t    dopeWidth = totalWidth;\n\tresistance = r_on * wd + r_off * (1-wd);\n    }\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    void doStep() {\n\tsim.stampResistor(nodes[0], nodes[1], resistance);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"memristor\";\n\tgetBasicInfo(arr);\n\tarr[3] = \"R = \" + getUnitText(resistance, sim.ohmString);\n\tarr[4] = \"P = \" + getUnitText(getPower(), \"W\");\n    }\n    double getScopeValue(int x) {\n\treturn (x == 2) ? resistance : (x == 1) ? getPower() : getVoltageDiff();\n    }\n    String getScopeUnits(int x) {\n\treturn (x == 2) ? sim.ohmString : (x == 1) ? \"W\" : \"V\";\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"Max Resistance (ohms)\", r_on, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Min Resistance (ohms)\", r_off, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Width of Doped Region (nm)\", dopeWidth*1e9, 0, 0);\n\tif (n == 3)\n\t    return new EditInfo(\"Total Width (nm)\", totalWidth*1e9, 0, 0);\n\tif (n == 4)\n\t    return new EditInfo(\"Mobility (um^2/(s*V))\", mobility*1e12, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0)\n\t    r_on = ei.value;\n\tif (n == 1)\n\t    r_off = ei.value;\n\tif (n == 2)\n\t    dopeWidth = ei.value*1e-9;\n\tif (n == 3)\n\t    totalWidth = ei.value*1e-9;\n\tif (n == 4)\n\t    mobility = ei.value*1e-12;\n    }\n}\n\n"
  },
  {
    "path": "src/MosfetElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class MosfetElm extends CircuitElm {\n\tint pnp;\n\tint FLAG_PNP = 1;\n\tint FLAG_SHOWVT = 2;\n\tint FLAG_DIGITAL = 4;\n\tdouble vt;\n\tMosfetElm(int xx, int yy, boolean pnpflag) {\n\t    super(xx, yy);\n\t    pnp = (pnpflag) ? -1 : 1;\n\t    flags = (pnpflag) ? FLAG_PNP : 0;\n\t    noDiagonal = true;\n\t    vt = getDefaultThreshold();\n\t}\n\tpublic MosfetElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    pnp = ((f & FLAG_PNP) != 0) ? -1 : 1;\n\t    noDiagonal = true;\n\t    vt = getDefaultThreshold();\n\t    try {\n\t\tvt = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) {}\n\t}\n\tdouble getDefaultThreshold() { return 1.5; }\n\tdouble getBeta() { return .02; }\n\tboolean nonLinear() { return true; }\n\tboolean drawDigital() { return (flags & FLAG_DIGITAL) != 0; }\n\tvoid reset() {\n\t    lastv1 = lastv2 = volts[0] = volts[1] = volts[2] = curcount = 0;\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + vt;\n\t}\n\tint getDumpType() { return 'f'; }\n\tfinal int hs = 16;\n\t\n\tvoid draw(Graphics g) {\n\t    setBbox(point1, point2, hs);\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, src[0], src[1]);\n\t    setVoltageColor(g, volts[2]);\n\t    drawThickLine(g, drn[0], drn[1]);\n\t    int segments = 6;\n\t    int i;\n\t    setPowerColor(g, true);\n\t    double segf = 1./segments;\n\t    for (i = 0; i != segments; i++) {\n\t\tdouble v = volts[1]+(volts[2]-volts[1])*i/segments;\n\t\tsetVoltageColor(g, v);\n\t\tinterpPoint(src[1], drn[1], ps1, i*segf);\n\t\tinterpPoint(src[1], drn[1], ps2, (i+1)*segf);\n\t\tdrawThickLine(g, ps1, ps2);\n\t    }\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, src[1], src[2]);\n\t    setVoltageColor(g, volts[2]);\n\t    drawThickLine(g, drn[1], drn[2]);\n\t    if (!drawDigital()) {\n\t\tsetVoltageColor(g, pnp == 1 ? volts[1] : volts[2]);\n\t\tg.fillPolygon(arrowPoly);\n\t    }\n\t    if (sim.powerCheckItem.getState())\n\t\tg.setColor(Color.gray);\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, gate[1]);\n\t    drawThickLine(g, gate[0], gate[2]);\n\t    if (drawDigital() && pnp == -1)\n\t\tdrawThickCircle(g, pcircle.x, pcircle.y, pcircler);\n\t    if ((flags & FLAG_SHOWVT) != 0) {\n\t\tString s = \"\" + (vt*pnp);\n\t\tg.setColor(whiteColor);\n\t\tg.setFont(unitsFont);\n\t\tdrawCenteredText(g, s, x2+2, y2, false);\n\t    }\n\t    if ((needsHighlight() || sim.dragElm == this) && dy == 0) {\n\t\tg.setColor(Color.white);\n\t\tg.setFont(unitsFont);\n\t\tint ds = sign(dx);\n\t\tg.drawString(\"G\", gate[1].x-10*ds, gate[1].y-5);\n\t\tg.drawString(pnp == -1 ? \"D\" : \"S\", src[0].x-3+9*ds, src[0].y+4); // x+6 if ds=1, -12 if -1\n\t\tg.drawString(pnp == -1 ? \"S\" : \"D\", drn[0].x-3+9*ds, drn[0].y+4);\n\t    }\t    \n\t    curcount = updateDotCount(-ids, curcount);\n\t    drawDots(g, src[0], src[1], curcount);\n\t    drawDots(g, src[1], drn[1], curcount);\n\t    drawDots(g, drn[1], drn[0], curcount);\n\t    drawPosts(g);\n\t}\n\tPoint getPost(int n) {\n\t    return (n == 0) ? point1 : (n == 1) ? src[0] : drn[0];\n\t}\n\tdouble getCurrent() { return ids; }\n\tdouble getPower() { return ids*(volts[2]-volts[1]); }\n\tint getPostCount() { return 3; }\n\n\tint pcircler;\n\tPoint src[], drn[], gate[], pcircle;\n\tPolygon arrowPoly;\n\t\n\tvoid setPoints() {\n\t    super.setPoints();\n\n\t    // find the coordinates of the various points we need to draw\n\t    // the MOSFET.\n\t    int hs2 = hs*dsign;\n\t    src = newPointArray(3);\n\t    drn = newPointArray(3);\n\t    interpPoint2(point1, point2, src[0], drn[0], 1, -hs2);\n\t    interpPoint2(point1, point2, src[1], drn[1], 1-22/dn, -hs2);\n\t    interpPoint2(point1, point2, src[2], drn[2], 1-22/dn, -hs2*4/3);\n\n\t    gate = newPointArray(3);\n\t    interpPoint2(point1, point2, gate[0], gate[2], 1-28/dn, hs2/2); // was 1-20/dn\n\t    interpPoint(gate[0], gate[2], gate[1], .5);\n\n\t    if (!drawDigital()) {\n\t\tif (pnp == 1)\n\t\t    arrowPoly = calcArrow(src[1], src[0], 10, 4);\n\t\telse\n\t\t    arrowPoly = calcArrow(drn[0], drn[1], 12, 5);\n\t    } else if (pnp == -1) {\n\t\tinterpPoint(point1, point2, gate[1], 1-36/dn);\n\t\tint dist = (dsign < 0) ? 32 : 31;\n\t\tpcircle = interpPoint(point1, point2, 1-dist/dn);\n\t\tpcircler = 3;\n\t    }\n\t}\n\n\tdouble lastv1, lastv2;\n\tdouble ids;\n\tint mode = 0;\n\tdouble gm = 0;\n\t\n\tvoid stamp() {\n\t    sim.stampNonLinear(nodes[1]);\n\t    sim.stampNonLinear(nodes[2]);\n\t}\n\tvoid doStep() {\n\t    double vs[] = new double[3];\n\t    vs[0] = volts[0];\n\t    vs[1] = volts[1];\n\t    vs[2] = volts[2];\n\t    if (vs[1] > lastv1 + .5)\n\t\tvs[1] = lastv1 + .5;\n\t    if (vs[1] < lastv1 - .5)\n\t\tvs[1] = lastv1 - .5;\n\t    if (vs[2] > lastv2 + .5)\n\t\tvs[2] = lastv2 + .5;\n\t    if (vs[2] < lastv2 - .5)\n\t\tvs[2] = lastv2 - .5;\n\t    int source = 1;\n\t    int drain = 2;\n\t    if (pnp*vs[1] > pnp*vs[2]) {\n\t\tsource = 2;\n\t\tdrain = 1;\n\t    }\n\t    int gate = 0;\n\t    double vgs = vs[gate ]-vs[source];\n\t    double vds = vs[drain]-vs[source];\n\t    if (Math.abs(lastv1-vs[1]) > .01 ||\n\t\tMath.abs(lastv2-vs[2]) > .01)\n\t\tsim.converged = false;\n\t    lastv1 = vs[1];\n\t    lastv2 = vs[2];\n\t    double realvgs = vgs;\n\t    double realvds = vds;\n\t    vgs *= pnp;\n\t    vds *= pnp;\n\t    ids = 0;\n\t    gm = 0;\n\t    double Gds = 0;\n\t    double beta = getBeta();\n\t    if (vgs > .5 && this instanceof JfetElm) {\n\t\tsim.stop(\"JFET is reverse biased!\", this);\n\t\treturn;\n\t    }\n\t    if (vgs < vt) {\n\t\t// should be all zero, but that causes a singular matrix,\n\t\t// so instead we treat it as a large resistor\n\t\tGds = 1e-8;\n\t\tids = vds*Gds;\n\t\tmode = 0;\n\t    } else if (vds < vgs-vt) {\n\t\t// linear\n\t\tids = beta*((vgs-vt)*vds - vds*vds*.5);\n\t\tgm  = beta*vds;\n\t\tGds = beta*(vgs-vds-vt);\n\t\tmode = 1;\n\t    } else {\n\t\t// saturation; Gds = 0\n\t\tgm  = beta*(vgs-vt);\n\t\t// use very small Gds to avoid nonconvergence\n\t\tGds = 1e-8;\n\t\tids = .5*beta*(vgs-vt)*(vgs-vt) + (vds-(vgs-vt))*Gds;\n\t\tmode = 2;\n\t    }\n\t    double rs = -pnp*ids + Gds*realvds + gm*realvgs;\n\t    //System.out.println(\"M \" + vds + \" \" + vgs + \" \" + ids + \" \" + gm + \" \"+ Gds + \" \" + volts[0] + \" \" + volts[1] + \" \" + volts[2] + \" \" + source + \" \" + rs + \" \" + this);\n\t    sim.stampMatrix(nodes[drain],  nodes[drain],  Gds);\n\t    sim.stampMatrix(nodes[drain],  nodes[source], -Gds-gm); \n\t    sim.stampMatrix(nodes[drain],  nodes[gate],   gm);\n\t    \n\t    sim.stampMatrix(nodes[source], nodes[drain],  -Gds);\n\t    sim.stampMatrix(nodes[source], nodes[source], Gds+gm); \n\t    sim.stampMatrix(nodes[source], nodes[gate],  -gm);\n\t    \n\t    sim.stampRightSide(nodes[drain],  rs);\n\t    sim.stampRightSide(nodes[source], -rs);\n\t    if (source == 2 && pnp == 1 ||\n\t\tsource == 1 && pnp == -1)\n\t\tids = -ids;\n\t}\n\tvoid getFetInfo(String arr[], String n) {\n\t    arr[0] = ((pnp == -1) ? \"p-\" : \"n-\") + n;\n\t    arr[0] += \" (Vt = \" + getVoltageText(pnp*vt) + \")\";\n\t    arr[1] = ((pnp == 1) ? \"Ids = \" : \"Isd = \") + getCurrentText(ids);\n\t    arr[2] = \"Vgs = \" + getVoltageText(volts[0]-volts[pnp == -1 ? 2 : 1]);\n\t    arr[3] = ((pnp == 1) ? \"Vds = \" : \"Vsd = \") + getVoltageText(volts[2]-volts[1]);\n\t    arr[4] = (mode == 0) ? \"off\" :\n\t\t(mode == 1) ? \"linear\" : \"saturation\";\n\t    arr[5] = \"gm = \" + getUnitText(gm, \"A/V\");\n\t}\n\tvoid getInfo(String arr[]) {\n\t    getFetInfo(arr, \"MOSFET\");\n\t}\n\tboolean canViewInScope() { return true; }\n\tdouble getVoltageDiff() { return volts[2] - volts[1]; }\n\tboolean getConnection(int n1, int n2) {\n\t    return !(n1 == 0 || n2 == 0);\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Threshold Voltage\", pnp*vt, .01, 5);\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Digital Symbol\", drawDigital());\n\t\treturn ei;\n\t    }\n\t\t\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tvt = pnp*ei.value;\n\t    if (n == 1) {\n\t\tflags = (ei.checkbox.getState()) ? (flags | FLAG_DIGITAL) :\n\t\t    (flags & ~FLAG_DIGITAL);\n\t\tsetPoints();\n\t    }\n\t}\n    }\n"
  },
  {
    "path": "src/NJfetElm.java",
    "content": "    class NJfetElm extends JfetElm {\n\tpublic NJfetElm(int xx, int yy) { super(xx, yy, false); }\n\tClass getDumpClass() { return JfetElm.class; }\n    }\n\n    class PJfetElm extends JfetElm {\n\tpublic PJfetElm(int xx, int yy) { super(xx, yy, true); }\n\tClass getDumpClass() { return JfetElm.class; }\n    }\n\n"
  },
  {
    "path": "src/NMosfetElm.java",
    "content": "    class NMosfetElm extends MosfetElm {\n\tpublic NMosfetElm(int xx, int yy) { super(xx, yy, false); }\n\tClass getDumpClass() { return MosfetElm.class; }\n    }\n"
  },
  {
    "path": "src/NTransistorElm.java",
    "content": "    class NTransistorElm extends TransistorElm {\n\tpublic NTransistorElm(int xx, int yy) { super(xx, yy, false); }\n\tClass getDumpClass() { return TransistorElm.class; }\n    }\n"
  },
  {
    "path": "src/NandGateElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class NandGateElm extends AndGateElm {\n\tpublic NandGateElm(int xx, int yy) { super(xx, yy); }\n\tpublic NandGateElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t   StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tboolean isInverting() { return true; }\n\tString getGateName() { return \"NAND gate\"; }\n\tint getDumpType() { return 151; }\n\tint getShortcut() { return '@'; }\n    }\n"
  },
  {
    "path": "src/NorGateElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class NorGateElm extends OrGateElm {\n\tpublic NorGateElm(int xx, int yy) { super(xx, yy); }\n\tpublic NorGateElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t   StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tString getGateName() { return \"NOR gate\"; }\n\tboolean isInverting() { return true; }\n\tint getDumpType() { return 153; }\n\tint getShortcut() { return '#'; }\n    }\n"
  },
  {
    "path": "src/OpAmpElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class OpAmpElm extends CircuitElm {\n\tint opsize, opheight, opwidth, opaddtext;\n\tdouble maxOut, minOut, gain, gbw;\n\tboolean reset;\n\tfinal int FLAG_SWAP = 1;\n\tfinal int FLAG_SMALL = 2;\n\tfinal int FLAG_LOWGAIN = 4;\n\tpublic OpAmpElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    noDiagonal = true;\n\t    maxOut = 15;\n\t    minOut = -15;\n\t    gbw = 1e6;\n\t    setSize(sim.smallGridCheckItem.getState() ? 1 : 2);\n\t    setGain();\n\t}\n\tpublic OpAmpElm(int xa, int ya, int xb, int yb, int f,\n\t\t\tStringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    maxOut = 15;\n\t    minOut = -15;\n\t    // GBW has no effect in this version of the simulator, but we\n\t    // retain it to keep the file format the same\n\t    gbw = 1e6;\n\t    try {\n\t\tmaxOut = new Double(st.nextToken()).doubleValue();\n\t\tminOut = new Double(st.nextToken()).doubleValue();\n\t\tgbw = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) {\n\t    }\n\t    noDiagonal = true;\n\t    setSize((f & FLAG_SMALL) != 0 ? 1 : 2);\n\t    setGain();\n\t}\n\tvoid setGain() {\n\t    // gain of 100000 breaks e-amp-dfdx.txt\n\t    // gain was 1000, but it broke amp-schmitt.txt\n\t    gain = ((flags & FLAG_LOWGAIN) != 0) ? 1000 : 100000;\n\t    \n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + maxOut + \" \" + minOut + \" \" + gbw;\n\t}\n\tboolean nonLinear() { return true; }\n\tvoid draw(Graphics g) {\n\t    setBbox(point1, point2, opheight*2);\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, in1p[0], in1p[1]);\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, in2p[0], in2p[1]);\n\t    g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\t    setPowerColor(g, true);\n\t    drawThickPolygon(g, triangle);\n\t    g.setFont(plusFont);\n\t    drawCenteredText(g, \"-\", textp[0].x, textp[0].y-2, true);\n\t    drawCenteredText(g, \"+\", textp[1].x, textp[1].y  , true);\n\t    setVoltageColor(g, volts[2]);\n\t    drawThickLine(g, lead2, point2);\n\t    curcount = updateDotCount(current, curcount);\n\t    drawDots(g, point2, lead2, curcount);\n\t    drawPosts(g);\n\t}\n\tdouble getPower() { return volts[2]*current; }\n\tPoint in1p[], in2p[], textp[];\n\tPolygon triangle;\n\tFont plusFont;\n\tvoid setSize(int s) {\n\t    opsize = s;\n\t    opheight = 8*s;\n\t    opwidth = 13*s;\n\t    flags = (flags & ~FLAG_SMALL) | ((s == 1) ? FLAG_SMALL : 0);\n\t}\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    if (dn > 150 && this == sim.dragElm)\n\t\tsetSize(2);\n\t    int ww = opwidth;\n\t    if (ww > dn/2)\n\t\tww = (int) (dn/2);\n\t    calcLeads(ww*2);\n\t    int hs = opheight*dsign;\n\t    if ((flags & FLAG_SWAP) != 0)\n\t\ths = -hs;\n\t    in1p = newPointArray(2);\n\t    in2p = newPointArray(2);\n\t    textp = newPointArray(2);\n\t    interpPoint2(point1, point2, in1p[0],  in2p[0], 0, hs);\n\t    interpPoint2(lead1 , lead2,  in1p[1],  in2p[1], 0, hs);\n\t    interpPoint2(lead1 , lead2,  textp[0], textp[1], .2, hs);\n\t    Point tris[] = newPointArray(2);\n\t    interpPoint2(lead1,  lead2,  tris[0], tris[1],  0, hs*2);\n\t    triangle = createPolygon(tris[0], tris[1], lead2);\n\t    plusFont = new Font(\"SansSerif\", 0, opsize == 2 ? 14 : 10);\n\t}\n\tint getPostCount() { return 3; }\n\tPoint getPost(int n) {\n\t    return (n == 0) ? in1p[0] : (n == 1) ? in2p[0] : point2;\n\t}\n\tint getVoltageSourceCount() { return 1; }\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"op-amp\";\n\t    arr[1] = \"V+ = \" + getVoltageText(volts[1]);\n\t    arr[2] = \"V- = \" + getVoltageText(volts[0]);\n\t    // sometimes the voltage goes slightly outside range, to make\n\t    // convergence easier.  so we hide that here.\n\t    double vo = Math.max(Math.min(volts[2], maxOut), minOut);\n\t    arr[3] = \"Vout = \" + getVoltageText(vo);\n\t    arr[4] = \"Iout = \" + getCurrentText(getCurrent());\n\t    arr[5] = \"range = \" + getVoltageText(minOut) + \" to \" +\n\t\tgetVoltageText(maxOut);\n\t}\n\n\tdouble lastvd;\n\n\tvoid stamp() {\n\t    int vn = sim.nodeList.size()+voltSource;\n\t    sim.stampNonLinear(vn);\n\t    sim.stampMatrix(nodes[2], vn, 1);\n\t}\n\tvoid doStep() {\n\t    double vd = volts[1] - volts[0];\n\t    if (Math.abs(lastvd-vd) > .1)\n\t\tsim.converged = false;\n\t    else if (volts[2] > maxOut+.1 || volts[2] < minOut-.1)\n\t\tsim.converged = false;\n\t    double x = 0;\n\t    int vn = sim.nodeList.size()+voltSource;\n\t    double dx = 0;\n\t    if (vd >= maxOut/gain && (lastvd >= 0 || sim.getrand(4) == 1)) {\n\t\tdx = 1e-4;\n\t\tx = maxOut - dx*maxOut/gain;\n\t    } else if (vd <= minOut/gain && (lastvd <= 0 || sim.getrand(4) == 1)) {\n\t\tdx = 1e-4;\n\t\tx = minOut - dx*minOut/gain;\n\t    } else\n\t\tdx = gain;\n\t    //System.out.println(\"opamp \" + vd + \" \" + volts[2] + \" \" + dx + \" \"  + x + \" \" + lastvd + \" \" + sim.converged);\n\t    \n\t    // newton-raphson\n\t    sim.stampMatrix(vn, nodes[0], dx);\n\t    sim.stampMatrix(vn, nodes[1], -dx);\n\t    sim.stampMatrix(vn, nodes[2], 1);\n\t    sim.stampRightSide(vn, x);\n\t    \n\t    lastvd = vd;\n\t    /*if (sim.converged)\n\t      System.out.println((volts[1]-volts[0]) + \" \" + volts[2] + \" \" + initvd);*/\n\t}\n\t// there is no current path through the op-amp inputs, but there\n\t// is an indirect path through the output to ground.\n\tboolean getConnection(int n1, int n2) { return false; }\n\tboolean hasGroundConnection(int n1) {\n\t    return (n1 == 2);\n\t}\n\tdouble getVoltageDiff() { return volts[2] - volts[1]; }\n\tint getDumpType() { return 'a'; }\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Max Output (V)\", maxOut, 1, 20);\n\t    if (n == 1)\n\t\treturn new EditInfo(\"Min Output (V)\", minOut, -20, 0);\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tmaxOut = ei.value;\n\t    if (n == 1)\n\t\tminOut = ei.value;\n\t}\n    }\n"
  },
  {
    "path": "src/OpAmpSwapElm.java",
    "content": "    class OpAmpSwapElm extends OpAmpElm {\n\tpublic OpAmpSwapElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    flags |= FLAG_SWAP;\n\t}\n\tClass getDumpClass() { return OpAmpElm.class; }\n    }\n"
  },
  {
    "path": "src/OrGateElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class OrGateElm extends GateElm {\n\tpublic OrGateElm(int xx, int yy) { super(xx, yy); }\n\tpublic OrGateElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t  StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tString getGateName() { return \"OR gate\"; }\n\tvoid setPoints() {\n\t    super.setPoints();\n\n\t    // 0-15 = top curve, 16 = right, 17-32=bottom curve,\n\t    // 33-37 = left curve\n\t    Point triPoints[] = newPointArray(38);\n\t    if (this instanceof XorGateElm)\n\t\tlinePoints = new Point[5];\n\t    int i;\n\t    for (i = 0; i != 16; i++) {\n\t\tdouble a = i/16.;\n\t\tdouble b = 1-a*a;\n\t\tinterpPoint2(lead1, lead2,\n\t\t\t     triPoints[i], triPoints[32-i],\n\t\t\t     .5+a/2, b*hs2);\n\t    }\n\t    double ww2 = (ww == 0) ? dn*2 : ww*2;\n\t    for (i = 0; i != 5; i++) {\n\t\tdouble a = (i-2)/2.;\n\t\tdouble b = 4*(1-a*a)-2;\n\t\tinterpPoint(lead1, lead2,\n\t\t\t    triPoints[33+i], b/(ww2), a*hs2);\n\t\tif (this instanceof XorGateElm)\n\t\t    linePoints[i] = interpPoint(lead1, lead2,\n\t\t\t\t\t\t(b-5)/(ww2), a*hs2);\n\t    }\n\t    triPoints[16] = new Point(lead2);\n\t    if (isInverting()) {\n\t\tpcircle = interpPoint(point1, point2, .5+(ww+4)/dn);\n\t\tlead2 = interpPoint(point1, point2, .5+(ww+8)/dn);\n\t    }\n\t    gatePoly = createPolygon(triPoints);\n\t}\n\tboolean calcFunction() {\n\t    int i;\n\t    boolean f = false;\n\t    for (i = 0; i != inputCount; i++)\n\t\tf |= getInput(i);\n\t    return f;\n\t}\n\tint getDumpType() { return 152; }\n\tint getShortcut() { return '3'; }\n    }\n"
  },
  {
    "path": "src/OutputElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class OutputElm extends CircuitElm {\n\tfinal int FLAG_VALUE = 1;\n\tpublic OutputElm(int xx, int yy) { super(xx, yy); }\n\tpublic OutputElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t}\n\tint getDumpType() { return 'O'; }\n\tint getPostCount() { return 1; }\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    lead1 = new Point();\n\t}\n\tvoid draw(Graphics g) {\n\t    boolean selected = (needsHighlight() || sim.plotYElm == this);\n\t    Font f = new Font(\"SansSerif\", selected ? Font.BOLD : 0, 14);\n\t    g.setFont(f);\n\t    g.setColor(selected ? selectColor : whiteColor);\n\t    String s = (flags & FLAG_VALUE) != 0 ? getVoltageText(volts[0]) : \"out\";\n\t    FontMetrics fm = g.getFontMetrics();\n\t    if (this == sim.plotXElm)\n\t\ts = \"X\";\n\t    if (this == sim.plotYElm)\n\t\ts = \"Y\";\n\t    interpPoint(point1, point2, lead1, 1-(fm.stringWidth(s)/2+8)/dn);\n\t    setBbox(point1, lead1, 0);\n\t    drawCenteredText(g, s, x2, y2, true);\n\t    setVoltageColor(g, volts[0]);\n\t    if (selected)\n\t\tg.setColor(selectColor);\n\t    drawThickLine(g, point1, lead1);\n\t    drawPosts(g);\n\t}\n\tdouble getVoltageDiff() { return volts[0]; }\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"output\";\n\t    arr[1] = \"V = \" + getVoltageText(volts[0]);\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Show Voltage\",\n\t\t\t\t\t   (flags & FLAG_VALUE) != 0);\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tflags = (ei.checkbox.getState()) ?\n\t\t    (flags | FLAG_VALUE) :\n\t\t    (flags & ~FLAG_VALUE);\n\t}\n    }\n"
  },
  {
    "path": "src/PMosfetElm.java",
    "content": "    class PMosfetElm extends MosfetElm {\n\tpublic PMosfetElm(int xx, int yy) { super(xx, yy, true); }\n\tClass getDumpClass() { return MosfetElm.class; }\n    }\n"
  },
  {
    "path": "src/PTransistorElm.java",
    "content": "    class PTransistorElm extends TransistorElm {\n\tpublic PTransistorElm(int xx, int yy) { super(xx, yy, true); }\n\tClass getDumpClass() { return TransistorElm.class; }\n    }\n"
  },
  {
    "path": "src/PhaseCompElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass PhaseCompElm extends ChipElm {\n    public PhaseCompElm(int xx, int yy) { super(xx, yy); }\n    public PhaseCompElm(int xa, int ya, int xb, int yb, int f,\n\t\t\tStringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n    }\n    String getChipName() { return \"phase comparator\"; }\n    void setupPins() {\n\tsizeX = 2;\n\tsizeY = 2;\n\tpins = new Pin[3];\n\tpins[0] = new Pin(0, SIDE_W, \"I1\");\n\tpins[1] = new Pin(1, SIDE_W, \"I2\");\n\tpins[2] = new Pin(0, SIDE_E, \"O\");\n\tpins[2].output = true;\n    }\n    boolean nonLinear() { return true; }\n    void stamp() {\n\tint vn = sim.nodeList.size()+pins[2].voltSource;\n\tsim.stampNonLinear(vn);\n\tsim.stampNonLinear(0);\n\tsim.stampNonLinear(nodes[2]);\n    }\n    boolean ff1, ff2;\n    void doStep() {\n\tboolean v1 = volts[0] > 2.5;\n\tboolean v2 = volts[1] > 2.5;\n\tif (v1 && !pins[0].value)\n\t    ff1 = true;\n\tif (v2 && !pins[1].value)\n\t    ff2 = true;\n\tif (ff1 && ff2)\n\t    ff1 = ff2 = false;\n\tdouble out = (ff1) ? 5 : (ff2) ? 0 : -1;\n\t//System.out.println(out + \" \" + v1 + \" \" + v2);\n\tif (out != -1)\n\t    sim.stampVoltageSource(0, nodes[2], pins[2].voltSource, out);\n\telse {\n\t    // tie current through output pin to 0\n\t    int vn = sim.nodeList.size()+pins[2].voltSource;\n\t    sim.stampMatrix(vn, vn, 1);\n\t}\n\tpins[0].value = v1;\n\tpins[1].value = v2;\n    }\n    int getPostCount() { return 3; }\n    int getVoltageSourceCount() { return 1; }\n    int getDumpType() { return 161; }\n}\n    \n"
  },
  {
    "path": "src/PhotoResistorElm.java",
    "content": "// stub PhotoResistorElm based on SparkGapElm\n// FIXME need to uncomment PhotoResistorElm line from CirSim.java\n// FIXME need to add PhotoResistorElm.java to srclist\n\nimport java.awt.*;\nimport java.util.StringTokenizer;\n\nclass PhotoResistorElm extends CircuitElm {\n    double minresistance, maxresistance;\n    double resistance;\n    Scrollbar slider;\n    Label label;\n    public PhotoResistorElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tmaxresistance = 1e9;\n\tminresistance = 1e3;\n\tcreateSlider();\n    }\n    public PhotoResistorElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tminresistance = new Double(st.nextToken()).doubleValue();\n\tmaxresistance = new Double(st.nextToken()).doubleValue();\n\tcreateSlider();\n    }\n    boolean nonLinear() {return true;}\n    int getDumpType() { return 186; }\n    String dump() {\n\treturn super.dump() + \" \" + minresistance + \" \" + maxresistance;\n    }\n    Point ps3, ps4;\n    void createSlider() {\n\tsim.main.add(label = new Label(\"Light Level\", Label.CENTER));\n\tint value = 50;\n\tsim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101));\n\tsim.main.validate();\n    }\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(32);\n\tps3 = new Point();\n\tps4 = new Point();\n    }\n    void delete() {\n\tsim.main.remove(label);\n\tsim.main.remove(slider);\n    }\n    \n    void draw(Graphics g) {\n\tint i;\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\tsetBbox(point1, point2, 6);\n\tdraw2Leads(g);\n\t// FIXME need to draw properly, see ResistorElm.java\n\tsetPowerColor(g, true);\n\tdoDots(g);\n\tdrawPosts(g);\n    }\n    \n    void calculateCurrent() {\n\tdouble vd = volts[0] - volts[1];\n\tcurrent = vd/resistance;\n    }\n    void startIteration() {\n\tdouble vd = volts[0] - volts[1];\n\t// FIXME set resistance as appropriate, using slider.getValue()\n\tresistance = minresistance;\n\t//System.out.print(this + \" res current set to \" + current + \"\\n\");\n    }\n    void doStep() {\n\tsim.stampResistor(nodes[0], nodes[1], resistance);\n    }\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    void getInfo(String arr[]) {\n\t// FIXME\n\tarr[0] = \"spark gap\";\n\tgetBasicInfo(arr);\n\tarr[3] = \"R = \" + getUnitText(resistance, sim.ohmString);\n\tarr[4] = \"Ron = \" + getUnitText(minresistance, sim.ohmString);\n\tarr[5] = \"Roff = \" + getUnitText(maxresistance, sim.ohmString);\n    }\n    public EditInfo getEditInfo(int n) {\n\t// ohmString doesn't work here on linux\n\tif (n == 0)\n\t    return new EditInfo(\"Min resistance (ohms)\", minresistance, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Max resistance (ohms)\", maxresistance, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (ei.value > 0 && n == 0)\n\t    minresistance = ei.value;\n\tif (ei.value > 0 && n == 1)\n\t    maxresistance = ei.value;\n    }\n}\n\n"
  },
  {
    "path": "src/PotElm.java",
    "content": "import java.awt.*;\nimport java.awt.event.*;\nimport java.util.StringTokenizer;\n\nclass PotElm extends CircuitElm implements AdjustmentListener {\n    double position, maxResistance, resistance1, resistance2;\n    double current1, current2, current3;\n    double curcount1, curcount2, curcount3;\n    Scrollbar slider;\n    Label label;\n    String sliderText;\n    public PotElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tsetup();\n\tmaxResistance = 1000;\n\tposition = .5;\n\tsliderText = \"Resistance\";\n\tcreateSlider();\n    }\n    public PotElm(int xa, int ya, int xb, int yb, int f,\n\t\t  StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tmaxResistance = new Double(st.nextToken()).doubleValue();\n\tposition = new Double(st.nextToken()).doubleValue();\n\tsliderText = st.nextToken();\n\twhile (st.hasMoreTokens())\n\t    sliderText += ' ' + st.nextToken();\n\tcreateSlider();\n    }\n    void setup() {\n    }\n    int getPostCount() { return 3; }\n    int getDumpType() { return 174; }\n    Point getPost(int n) {\n\treturn (n == 0) ? point1 : (n == 1) ? point2 : post3;\n    }\n    String dump() { return super.dump() + \" \" + maxResistance + \" \" +\n\t    position + \" \" + sliderText; }\n    void createSlider() {\n\tsim.main.add(label = new Label(sliderText, Label.CENTER));\n\tint value = (int) (position*100);\n\tsim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101));\n\tsim.main.validate();\n\tslider.addAdjustmentListener(this);\n    }\n    public void adjustmentValueChanged(AdjustmentEvent e) {\n\tsim.analyzeFlag = true;\n\tsetPoints();\n    }\n    void delete() {\n\tsim.main.remove(label);\n\tsim.main.remove(slider);\n    }\n    Point post3, corner2, arrowPoint, midpoint, arrow1, arrow2;\n    Point ps3, ps4;\n    int bodyLen;\n    void setPoints() {\n\tsuper.setPoints();\n\tint offset = 0;\n\tif (abs(dx) > abs(dy)) {\n\t    dx = sim.snapGrid(dx/2)*2;\n\t    point2.x = x2 = point1.x + dx;\n\t    offset = (dx < 0) ? dy : -dy;\n\t    point2.y = point1.y;\n\t} else {\n\t    dy = sim.snapGrid(dy/2)*2;\n\t    point2.y = y2 = point1.y + dy;\n\t    offset = (dy > 0) ? dx : -dx;\n\t    point2.x = point1.x;\n\t}\n\tif (offset == 0)\n\t    offset = sim.gridSize;\n\tdn = distance(point1, point2);\n\tint bodyLen = 32;\n\tcalcLeads(bodyLen);\n\tposition = slider.getValue()*.0099+.005;\n\tint soff = (int) ((position-.5)*bodyLen);\n\t//int offset2 = offset - sign(offset)*4;\n\tpost3 =      interpPoint(point1, point2, .5, offset);\n\tcorner2 =    interpPoint(point1, point2, soff/dn+.5, offset);\n\tarrowPoint = interpPoint(point1, point2, soff/dn+.5,\n\t\t\t\t 8*sign(offset));\n\tmidpoint = interpPoint(point1, point2, soff/dn+.5);\n\tarrow1 = new Point();\n\tarrow2 = new Point();\n\tdouble clen = abs(offset)-8;\n\tinterpPoint2(corner2, arrowPoint, arrow1, arrow2, (clen-8)/clen, 8);\n\tps3 = new Point();\n\tps4 = new Point();\n    }\n\t\n    void draw(Graphics g) {\n\tint segments = 16;\n\tint i;\n\tint ox = 0;\n\tint hs = sim.euroResistorCheckItem.getState() ? 6 : 8;\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\tdouble v3 = volts[2];\n\tsetBbox(point1, point2, hs);\n\tdraw2Leads(g);\n\tsetPowerColor(g, true);\n\tdouble segf = 1./segments;\n\tint divide = (int) (segments*position);\n\tif (!sim.euroResistorCheckItem.getState()) {\n\t    // draw zigzag\n\t    for (i = 0; i != segments; i++) {\n\t\tint nx = 0;\n\t\tswitch (i & 3) {\n\t\tcase 0: nx = 1; break;\n\t\tcase 2: nx = -1; break;\n\t\tdefault: nx = 0; break;\n\t\t}\n\t\tdouble v = v1+(v3-v1)*i/divide;\n\t\tif (i >= divide)\n\t\t    v = v3+(v2-v3)*(i-divide)/(segments-divide);\n\t\tsetVoltageColor(g, v);\n\t\tinterpPoint(lead1, lead2, ps1, i*segf, hs*ox);\n\t\tinterpPoint(lead1, lead2, ps2, (i+1)*segf, hs*nx);\n\t\tdrawThickLine(g, ps1, ps2);\n\t\tox = nx;\n\t    }\n\t} else {\n\t    // draw rectangle\n\t    setVoltageColor(g, v1);\n\t    interpPoint2(lead1, lead2, ps1, ps2, 0, hs);\n\t    drawThickLine(g, ps1, ps2);\n\t    for (i = 0; i != segments; i++) {\n\t\tdouble v = v1+(v3-v1)*i/divide;\n\t\tif (i >= divide)\n\t\t    v = v3+(v2-v3)*(i-divide)/(segments-divide);\n\t\tsetVoltageColor(g, v);\n\t\tinterpPoint2(lead1, lead2, ps1, ps2, i*segf, hs);\n\t\tinterpPoint2(lead1, lead2, ps3, ps4, (i+1)*segf, hs);\n\t\tdrawThickLine(g, ps1, ps3);\n\t\tdrawThickLine(g, ps2, ps4);\n\t    }\n\t    interpPoint2(lead1, lead2, ps1, ps2, 1, hs);\n\t    drawThickLine(g, ps1, ps2);\n\t}\n\tsetVoltageColor(g, v3);\n\tdrawThickLine(g, post3, corner2);\n\tdrawThickLine(g, corner2, arrowPoint);\n\tdrawThickLine(g, arrow1, arrowPoint);\n\tdrawThickLine(g, arrow2, arrowPoint);\n\tcurcount1 = updateDotCount(current1, curcount1);\n\tcurcount2 = updateDotCount(current2, curcount2);\n\tcurcount3 = updateDotCount(current3, curcount3);\n\tif (sim.dragElm != this) {\n\t    drawDots(g, point1, midpoint, curcount1);\n\t    drawDots(g, point2, midpoint, curcount2);\n\t    drawDots(g, post3, corner2, curcount3);\n\t    drawDots(g, corner2, midpoint,\n\t\t     curcount3+distance(post3, corner2));\n\t}\n\tdrawPosts(g);\n    }\n    void calculateCurrent() {\n\tcurrent1 = (volts[0]-volts[2])/resistance1;\n\tcurrent2 = (volts[1]-volts[2])/resistance2;\n\tcurrent3 = -current1-current2;\n    }\n    void stamp() {\n\tresistance1 = maxResistance*position;\n\tresistance2 = maxResistance*(1-position);\n\tsim.stampResistor(nodes[0], nodes[2], resistance1);\n\tsim.stampResistor(nodes[2], nodes[1], resistance2);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"potentiometer\";\n\tarr[1] = \"Vd = \" + getVoltageDText(getVoltageDiff());\n\tarr[2] = \"R1 = \" + getUnitText(resistance1, sim.ohmString);\n\tarr[3] = \"R2 = \" + getUnitText(resistance2, sim.ohmString);\n\tarr[4] = \"I1 = \" + getCurrentDText(current1);\n\tarr[5] = \"I2 = \" + getCurrentDText(current2);\n    }\n    public EditInfo getEditInfo(int n) {\n\t// ohmString doesn't work here on linux\n\tif (n == 0)\n\t    return new EditInfo(\"Resistance (ohms)\", maxResistance, 0, 0);\n\tif (n == 1) {\n\t    EditInfo ei = new EditInfo(\"Slider Text\", 0, -1, -1);\n\t    ei.text = sliderText;\n\t    return ei;\n\t}\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0)\n\t    maxResistance = ei.value;\n\tif (n == 1) {\n\t    sliderText = ei.textf.getText();\n\t    label.setText(sliderText);\n\t}\n    }\n}\n\n"
  },
  {
    "path": "src/ProbeElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass ProbeElm extends CircuitElm {\n    static final int FLAG_SHOWVOLTAGE = 1;\n    public ProbeElm(int xx, int yy) { super(xx, yy); }\n    public ProbeElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n    }\n    int getDumpType() { return 'p'; }\n\t\n    Point center;\n    void setPoints() {\n\tsuper.setPoints();\n\t// swap points so that we subtract higher from lower\n\tif (point2.y < point1.y) {\n\t    Point x = point1;\n\t    point1 = point2;\n\t    point2 = x;\n\t}\n\tcenter = interpPoint(point1, point2, .5);\n    }\n    void draw(Graphics g) {\n\tint hs = 8;\n\tsetBbox(point1, point2, hs);\n\tboolean selected = (needsHighlight() || sim.plotYElm == this);\n\tdouble len = (selected || sim.dragElm == this) ? 16 : dn-32;\n\tcalcLeads((int) len);\n\tsetVoltageColor(g, volts[0]);\n\tif (selected)\n\t    g.setColor(selectColor);\n\tdrawThickLine(g, point1, lead1);\n\tsetVoltageColor(g, volts[1]);\n\tif (selected)\n\t    g.setColor(selectColor);\n\tdrawThickLine(g, lead2, point2);\n\tFont f = new Font(\"SansSerif\", Font.BOLD, 14);\n\tg.setFont(f);\n\tif (this == sim.plotXElm)\n\t    drawCenteredText(g, \"X\", center.x, center.y, true);\n\tif (this == sim.plotYElm)\n\t    drawCenteredText(g, \"Y\", center.x, center.y, true);\n\tif (mustShowVoltage()) {\n\t    String s = getShortUnitText(volts[0], \"V\");\n\t    drawValues(g, s, 4);\n\t}\n\tdrawPosts(g);\n    }\n\t\n    boolean mustShowVoltage() {\n\treturn (flags & FLAG_SHOWVOLTAGE) != 0;\n    }\n\n    void getInfo(String arr[]) {\n\tarr[0] = \"scope probe\";\n\tarr[1] = \"Vd = \" + getVoltageText(getVoltageDiff());\n    }\n    boolean getConnection(int n1, int n2) { return false; }\n\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Show Voltage\", mustShowVoltage());\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags = FLAG_SHOWVOLTAGE;\n\t\telse\n\t\t    flags &= ~FLAG_SHOWVOLTAGE;\n\t    }\n\t}\n}\n\n"
  },
  {
    "path": "src/PushSwitchElm.java",
    "content": "    class PushSwitchElm extends SwitchElm {\n\tpublic PushSwitchElm(int xx, int yy) { super(xx, yy, true); }\n\tClass getDumpClass() { return SwitchElm.class; }\n\tint getShortcut() { return 0; }\n    }\n"
  },
  {
    "path": "src/RailElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass RailElm extends VoltageElm {\n    public RailElm(int xx, int yy) { super(xx, yy, WF_DC); }\n    RailElm(int xx, int yy, int wf) { super(xx, yy, wf); }\n    public RailElm(int xa, int ya, int xb, int yb, int f,\n\t\t   StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n    }\n    final int FLAG_CLOCK = 1;\n    int getDumpType() { return 'R'; }\n    int getPostCount() { return 1; }\n\t\n    void setPoints() {\n\tsuper.setPoints();\n\tlead1 = interpPoint(point1, point2, 1-circleSize/dn);\n    }\n    void draw(Graphics g) {\n\tsetBbox(point1, point2, circleSize);\n\tsetVoltageColor(g, volts[0]);\n\tdrawThickLine(g, point1, lead1);\n\tboolean clock = waveform == WF_SQUARE && (flags & FLAG_CLOCK) != 0;\n\tif (waveform == WF_DC || waveform == WF_VAR || clock) {\n\t    Font f = new Font(\"SansSerif\", 0, 12);\n\t    g.setFont(f);\n\t    g.setColor(needsHighlight() ? selectColor : whiteColor);\n\t    setPowerColor(g, false);\n\t    double v = getVoltage();\n\t    String s = getShortUnitText(v, \"V\");\n\t    if (Math.abs(v) < 1)\n\t\ts = showFormat.format(v) + \"V\";\n\t    if (getVoltage() > 0)\n\t\ts = \"+\" + s;\n\t    if (this instanceof AntennaElm)\n\t\ts = \"Ant\";\n\t    if (clock)\n\t\ts = \"CLK\";\n\t    drawCenteredText(g, s, x2, y2, true);\n\t} else {\n\t    drawWaveform(g, point2);\n\t}\n\tdrawPosts(g);\n\tcurcount = updateDotCount(-current, curcount);\n\tif (sim.dragElm != this)\n\t    drawDots(g, point1, lead1, curcount);\n    }\n    double getVoltageDiff() { return volts[0]; }\n    void stamp() {\n\tif (waveform == WF_DC)\n\t    sim.stampVoltageSource(0, nodes[0], voltSource, getVoltage());\n\telse\n\t    sim.stampVoltageSource(0, nodes[0], voltSource);\n    }\n    void doStep() {\n\tif (waveform != WF_DC)\n\t    sim.updateVoltageSource(0, nodes[0], voltSource, getVoltage());\n    }\n    boolean hasGroundConnection(int n1) { return true; }\n    int getShortcut() { return 'V'; }\n}\n"
  },
  {
    "path": "src/RelayElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n// 0 = switch\n// 1 = switch end 1\n// 2 = switch end 2\n// ...\n// 3n   = coil\n// 3n+1 = coil\n// 3n+2 = end of coil resistor\n\nclass RelayElm extends CircuitElm {\n    double inductance;\n    Inductor ind;\n    double r_on, r_off, onCurrent;\n    Point coilPosts[], coilLeads[], swposts[][], swpoles[][], ptSwitch[];\n    Point lines[];\n    double coilCurrent, switchCurrent[], coilCurCount, switchCurCount[];\n    double d_position, coilR;\n    int i_position;\n    int poleCount;\n    int openhs;\n    final int nSwitch0 = 0;\n    final int nSwitch1 = 1;\n    final int nSwitch2 = 2;\n    int nCoil1, nCoil2, nCoil3;\n    final int FLAG_SWAP_COIL = 1;\n    \n    public RelayElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tind = new Inductor(sim);\n\tinductance = .2;\n\tind.setup(inductance, 0, Inductor.FLAG_BACK_EULER);\n\tnoDiagonal = true;\n\tonCurrent = .02;\n\tr_on = .05;\n\tr_off = 1e6;\n\tcoilR = 20;\n\tcoilCurrent = coilCurCount = 0;\n\tpoleCount = 1;\n\tsetupPoles();\n    }\n    public RelayElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tpoleCount = new Integer(st.nextToken()).intValue();\n\tinductance = new Double(st.nextToken()).doubleValue();\n\tcoilCurrent = new Double(st.nextToken()).doubleValue();\n\tr_on = new Double(st.nextToken()).doubleValue();\n\tr_off = new Double(st.nextToken()).doubleValue();\n\tonCurrent = new Double(st.nextToken()).doubleValue();\n\tcoilR = new Double(st.nextToken()).doubleValue();\n\tnoDiagonal = true;\n\tind = new Inductor(sim);\n\tind.setup(inductance, coilCurrent, Inductor.FLAG_BACK_EULER);\n\tsetupPoles();\n    }\n    \n    void setupPoles() {\n\tnCoil1 = 3*poleCount;\n\tnCoil2 = nCoil1+1;\n\tnCoil3 = nCoil1+2;\n\tif (switchCurrent == null || switchCurrent.length != poleCount) {\n\t    switchCurrent = new double[poleCount];\n\t    switchCurCount = new double[poleCount];\n\t}\n    }\n    \n    int getDumpType() { return 178; }\n    \n    String dump() {\n\treturn super.dump() + \" \" + poleCount + \" \" +\n\t    inductance + \" \" + coilCurrent + \" \" +\n\t    r_on + \" \" + r_off + \" \" + onCurrent + \" \" + coilR;\n    }\n    \n    void draw(Graphics g) {\n\tint i, p;\n\tfor (i = 0; i != 2; i++) {\n\t    setVoltageColor(g, volts[nCoil1+i]);\n\t    drawThickLine(g, coilLeads[i], coilPosts[i]);\n\t}\n\tint x = ((flags & FLAG_SWAP_COIL) != 0) ? 1 : 0;\n\tdrawCoil(g, dsign*6, coilLeads[x], coilLeads[1-x],\n\t\t volts[nCoil1+x], volts[nCoil2-x]);\n\n\t// draw lines\n\tg.setColor(Color.darkGray);\n\tfor (i = 0; i != poleCount; i++) {\n\t    if (i == 0)\n\t\tinterpPoint(point1, point2, lines[i*2  ], .5,\n\t\t\t    openhs*2+5*dsign-i*openhs*3);\n\t    else\n\t\tinterpPoint(point1, point2, lines[i*2], .5,\n\t\t\t    (int) (openhs*(-i*3+3-.5+d_position))+5*dsign);\n\t    interpPoint(point1, point2, lines[i*2+1], .5,\n\t\t\t(int) (openhs*(-i*3-.5+d_position))-5*dsign);\n\t    g.drawLine(lines[i*2].x, lines[i*2].y, lines[i*2+1].x, lines[i*2+1].y);\n\t}\n\t\n\tfor (p = 0; p != poleCount; p++) {\n\t    int po = p*3;\n\t    for (i = 0; i != 3; i++) {\n\t\t// draw lead\n\t\tsetVoltageColor(g, volts[nSwitch0+po+i]);\n\t\tdrawThickLine(g, swposts[p][i], swpoles[p][i]);\n\t    }\n\t    \n\t    interpPoint(swpoles[p][1], swpoles[p][2], ptSwitch[p], d_position);\n\t    //setVoltageColor(g, volts[nSwitch0]);\n\t    g.setColor(Color.lightGray);\n\t    drawThickLine(g, swpoles[p][0], ptSwitch[p]);\n\t    switchCurCount[p] = updateDotCount(switchCurrent[p],\n\t\t\t\t\t       switchCurCount[p]);\n\t    drawDots(g, swposts[p][0], swpoles[p][0], switchCurCount[p]);\n\t    \n\t    if (i_position != 2)\n\t\tdrawDots(g, swpoles[p][i_position+1], swposts[p][i_position+1],\n\t\t\t switchCurCount[p]);\n\t}\n\t\n\tcoilCurCount = updateDotCount(coilCurrent, coilCurCount);\n\t\n\tdrawDots(g, coilPosts[0], coilLeads[0], coilCurCount);\n\tdrawDots(g, coilLeads[0], coilLeads[1], coilCurCount);\n\tdrawDots(g, coilLeads[1], coilPosts[1], coilCurCount);\n\t    \n\tdrawPosts(g);\n\tsetBbox(coilPosts[0], coilLeads[1], 0);\n\tadjustBbox(swpoles[poleCount-1][0], swposts[poleCount-1][1]); // XXX\n    }\n\t\n    void setPoints() {\n\tsuper.setPoints();\n\tsetupPoles();\n\tallocNodes();\n\topenhs = -dsign*16;\n\n\t// switch\n\tcalcLeads(32);\n\tswposts = new Point[poleCount][3];\n\tswpoles = new Point[poleCount][3];\n\tint i, j;\n\tfor (i = 0; i != poleCount; i++) {\n\t    for (j = 0; j != 3; j++) {\n\t\tswposts[i][j] = new Point();\n\t\tswpoles[i][j] = new Point();\n\t    }\n\t    interpPoint(lead1,  lead2, swpoles[i][0], 0, -openhs*3*i);\n\t    interpPoint(lead1,  lead2, swpoles[i][1], 1, -openhs*3*i-openhs);\n\t    interpPoint(lead1,  lead2, swpoles[i][2], 1, -openhs*3*i+openhs);\n\t    interpPoint(point1, point2, swposts[i][0], 0, -openhs*3*i);\n\t    interpPoint(point1, point2, swposts[i][1], 1, -openhs*3*i-openhs);\n\t    interpPoint(point1, point2, swposts[i][2], 1, -openhs*3*i+openhs);\n\t}\n\n\t// coil\n\tcoilPosts = newPointArray(2);\n\tcoilLeads   = newPointArray(2);\n\tptSwitch = newPointArray(poleCount);\n\n\tint x = ((flags & FLAG_SWAP_COIL) != 0) ? 1 : 0;\n\tinterpPoint(point1, point2, coilPosts[0],  x, openhs*2);\n\tinterpPoint(point1, point2, coilPosts[1],  x, openhs*3);\n\tinterpPoint(point1, point2, coilLeads[0], .5, openhs*2);\n\tinterpPoint(point1, point2, coilLeads[1], .5, openhs*3);\n\n\t// lines\n\tlines = newPointArray(poleCount*2);\n    }\n    Point getPost(int n) {\n\tif (n < 3*poleCount)\n\t    return swposts[n / 3][n % 3];\n\treturn coilPosts[n-3*poleCount];\n    }\n    int getPostCount() { return 2+poleCount*3; }\n    int getInternalNodeCount() { return 1; }\n    void reset() {\n\tsuper.reset();\n\tind.reset();\n\tcoilCurrent = coilCurCount = 0;\n\tint i;\n\tfor (i = 0; i != poleCount; i++)\n\t    switchCurrent[i] = switchCurCount[i] = 0;\n    }\n    double a1, a2, a3, a4;\n    void stamp() {\n\t// inductor from coil post 1 to internal node\n\tind.stamp(nodes[nCoil1], nodes[nCoil3]);\n\t// resistor from internal node to coil post 2\n\tsim.stampResistor(nodes[nCoil3], nodes[nCoil2], coilR);\n\n\tint i;\n\tfor (i = 0; i != poleCount*3; i++)\n\t    sim.stampNonLinear(nodes[nSwitch0+i]);\n    }\n    void startIteration() {\n\tind.startIteration(volts[nCoil1]-volts[nCoil3]);\n\n\t// magic value to balance operate speed with reset speed semi-realistically\n\tdouble magic = 1.3;\n\tdouble pmult = Math.sqrt(magic+1);\n\tdouble p = coilCurrent*pmult/onCurrent;\n\td_position = Math.abs(p*p) - 1.3;\n\tif (d_position < 0)\n\t    d_position = 0;\n\tif (d_position > 1)\n\t    d_position = 1;\n\tif (d_position < .1)\n\t    i_position = 0;\n\telse if (d_position > .9)\n\t    i_position = 1;\n\telse\n\t    i_position = 2;\n\t//System.out.println(\"ind \" + this + \" \" + current + \" \" + voltdiff);\n    }\n    \t\n    // we need this to be able to change the matrix for each step\n    boolean nonLinear() { return true; }\n\n    void doStep() {\n\tdouble voltdiff = volts[nCoil1]-volts[nCoil3];\n\tind.doStep(voltdiff);\n\tint p;\n\tfor (p = 0; p != poleCount*3; p += 3) {\n\t    sim.stampResistor(nodes[nSwitch0+p], nodes[nSwitch1+p],\n\t\t\t      i_position == 0 ? r_on : r_off);\n\t    sim.stampResistor(nodes[nSwitch0+p], nodes[nSwitch2+p],\n\t\t\t      i_position == 1 ? r_on : r_off);\n\t}\n    }\n    void calculateCurrent() {\n\tdouble voltdiff = volts[nCoil1]-volts[nCoil3];\n\tcoilCurrent = ind.calculateCurrent(voltdiff);\n\n\t// actually this isn't correct, since there is a small amount\n\t// of current through the switch when off\n\tint p;\n\tfor (p = 0; p != poleCount; p++) {\n\t    if (i_position == 2)\n\t\tswitchCurrent[p] = 0;\n\t    else\n\t\tswitchCurrent[p] =\n\t\t    (volts[nSwitch0+p*3]-volts[nSwitch1+p*3+i_position])/r_on;\n\t}\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = i_position == 0 ? \"relay (off)\" :\n\t    i_position == 1 ? \"relay (on)\" : \"relay\";\n\tint i;\n\tint ln = 1;\n\tfor (i = 0; i != poleCount; i++)\n\t    arr[ln++] = \"I\" + (i+1) + \" = \" + getCurrentDText(switchCurrent[i]);\n\tarr[ln++] = \"coil I = \" + getCurrentDText(coilCurrent);\n\tarr[ln++] = \"coil Vd = \" +\n\t    getVoltageDText(volts[nCoil1] - volts[nCoil2]);\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"Inductance (H)\", inductance, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"On Resistance (ohms)\", r_on, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Off Resistance (ohms)\", r_off, 0, 0);\n\tif (n == 3)\n\t    return new EditInfo(\"On Current (A)\", onCurrent, 0, 0);\n\tif (n == 4)\n\t    return new EditInfo(\"Number of Poles\", poleCount, 1, 4).\n\t\tsetDimensionless();\n\tif (n == 5)\n\t    return new EditInfo(\"Coil Resistance (ohms)\", coilR, 0, 0);\n\tif (n == 6) {\n\t    EditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t    ei.checkbox = new Checkbox(\"Swap Coil Direction\",\n\t\t\t\t       (flags & FLAG_SWAP_COIL) != 0);\n\t    return ei;\n\t}\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0 && ei.value > 0) {\n\t    inductance = ei.value;\n\t    ind.setup(inductance, coilCurrent, Inductor.FLAG_BACK_EULER);\n\t}\n\tif (n == 1 && ei.value > 0)\n\t    r_on = ei.value;\n\tif (n == 2 && ei.value > 0)\n\t    r_off = ei.value;\n\tif (n == 3 && ei.value > 0)\n\t    onCurrent = ei.value;\n\tif (n == 4 && ei.value >= 1) {\n\t    poleCount = (int) ei.value;\n\t    setPoints();\n\t}\n\tif (n == 5 && ei.value > 0)\n\t    coilR = ei.value;\n\tif (n == 6) {\n\t    if (ei.checkbox.getState())\n\t\tflags |= FLAG_SWAP_COIL;\n\t    else\n\t\tflags &= ~FLAG_SWAP_COIL;\n\t    setPoints();\n\t}\n    }\n    boolean getConnection(int n1, int n2) {\n\treturn (n1 / 3 == n2 / 3);\n    }\n    int getShortcut() { return 'R'; }\n}\n    \n"
  },
  {
    "path": "src/ResistorElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class ResistorElm extends CircuitElm {\n\tdouble resistance;\n\tpublic ResistorElm(int xx, int yy) { super(xx, yy); resistance = 100; }\n\tpublic ResistorElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    resistance = new Double(st.nextToken()).doubleValue();\n\t}\n\tint getDumpType() { return 'r'; }\n\tString dump() {\n\t    return super.dump() + \" \" + resistance;\n\t}\n\n\tPoint ps3, ps4;\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    calcLeads(32);\n\t    ps3 = new Point();\n\t    ps4 = new Point();\n\t}\n\t\n\tvoid draw(Graphics g) {\n\t    int segments = 16;\n\t    int i;\n\t    int ox = 0;\n\t    int hs = sim.euroResistorCheckItem.getState() ? 6 : 8;\n\t    double v1 = volts[0];\n\t    double v2 = volts[1];\n\t    setBbox(point1, point2, hs);\n\t    draw2Leads(g);\n\t    setPowerColor(g, true);\n\t    double segf = 1./segments;\n\t    if (!sim.euroResistorCheckItem.getState()) {\n\t\t// draw zigzag\n\t\tfor (i = 0; i != segments; i++) {\n\t\t    int nx = 0;\n\t\t    switch (i & 3) {\n\t\t    case 0: nx = 1; break;\n\t\t    case 2: nx = -1; break;\n\t\t    default: nx = 0; break;\n\t\t    }\n\t\t    double v = v1+(v2-v1)*i/segments;\n\t\t    setVoltageColor(g, v);\n\t\t    interpPoint(lead1, lead2, ps1, i*segf, hs*ox);\n\t\t    interpPoint(lead1, lead2, ps2, (i+1)*segf, hs*nx);\n\t\t    drawThickLine(g, ps1, ps2);\n\t\t    ox = nx;\n\t\t}\n\t    } else {\n\t\t// draw rectangle\n\t\tsetVoltageColor(g, v1);\n\t\tinterpPoint2(lead1, lead2, ps1, ps2, 0, hs);\n\t\tdrawThickLine(g, ps1, ps2);\n\t\tfor (i = 0; i != segments; i++) {\n\t\t    double v = v1+(v2-v1)*i/segments;\n\t\t    setVoltageColor(g, v);\n\t\t    interpPoint2(lead1, lead2, ps1, ps2, i*segf, hs);\n\t\t    interpPoint2(lead1, lead2, ps3, ps4, (i+1)*segf, hs);\n\t\t    drawThickLine(g, ps1, ps3);\n\t\t    drawThickLine(g, ps2, ps4);\n\t\t}\n\t\tinterpPoint2(lead1, lead2, ps1, ps2, 1, hs);\n\t\tdrawThickLine(g, ps1, ps2);\n\t    }\n\t    if (sim.showValuesCheckItem.getState()) {\n\t\tString s = getShortUnitText(resistance, \"\");\n\t\tdrawValues(g, s, hs);\n\t    }\n\t    doDots(g);\n\t    drawPosts(g);\n\t}\n    \n\tvoid calculateCurrent() {\n\t    current = (volts[0]-volts[1])/resistance;\n\t    //System.out.print(this + \" res current set to \" + current + \"\\n\");\n\t}\n\tvoid stamp() {\n\t    sim.stampResistor(nodes[0], nodes[1], resistance);\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"resistor\";\n\t    getBasicInfo(arr);\n\t    arr[3] = \"R = \" + getUnitText(resistance, sim.ohmString);\n\t    arr[4] = \"P = \" + getUnitText(getPower(), \"W\");\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    // ohmString doesn't work here on linux\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Resistance (ohms)\", resistance, 0, 0);\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (ei.value > 0)\n\t        resistance = ei.value;\n\t}\n\tint getShortcut() { return 'r'; }\n    }\n"
  },
  {
    "path": "src/RowInfo.java",
    "content": "    // info about each row/column of the matrix for simplification purposes\n    class RowInfo {\n\tstatic final int ROW_NORMAL = 0;  // ordinary value\n\tstatic final int ROW_CONST  = 1;  // value is constant\n\tstatic final int ROW_EQUAL  = 2;  // value is equal to another value\n\tint nodeEq, type, mapCol, mapRow;\n\tdouble value;\n\tboolean rsChanges; // row's right side changes\n\tboolean lsChanges; // row's left side changes\n\tboolean dropRow;   // row is not needed in matrix\n\tRowInfo() { type = ROW_NORMAL; }\n    }\n"
  },
  {
    "path": "src/SCRElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n// Silicon-Controlled Rectifier\n// 3 nodes, 1 internal node\n// 0 = anode, 1 = cathode, 2 = gate\n// 0, 3 = variable resistor\n// 3, 2 = diode\n// 2, 1 = 50 ohm resistor\n\nclass SCRElm extends CircuitElm {\n    final int anode = 0;\n    final int cnode = 1;\n    final int gnode = 2;\n    final int inode = 3;\n    Diode diode;\n    public SCRElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tsetDefaults();\n\tsetup();\n    }\n    public SCRElm(int xa, int ya, int xb, int yb, int f,\n\t\t  StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tsetDefaults();\n\ttry {\n\t    lastvac = new Double(st.nextToken()).doubleValue();\n\t    lastvag = new Double(st.nextToken()).doubleValue();\n\t    volts[anode] = 0;\n\t    volts[cnode] = -lastvac;\n\t    volts[gnode] = -lastvag;\n\t    triggerI = new Double(st.nextToken()).doubleValue();\n\t    holdingI = new Double(st.nextToken()).doubleValue();\n\t    cresistance = new Double(st.nextToken()).doubleValue();\n\t} catch (Exception e) {\n\t}\n\tsetup();\n    }\n    void setDefaults() {\n\tcresistance = 50;\n\tholdingI = .0082;\n\ttriggerI = .01;\n    }\n    void setup() {\n\tdiode = new Diode(sim);\n\tdiode.setup(.8, 0);\n    }\n    boolean nonLinear() { return true; }\n    void reset() {\n\tvolts[anode] = volts[cnode] = volts[gnode] = 0;\n\tdiode.reset();\n\tlastvag = lastvac = curcount_a = curcount_c = curcount_g = 0;\n    }\n    int getDumpType() { return 177; }\n    String dump() {\n\treturn super.dump() + \" \" + (volts[anode]-volts[cnode]) + \" \" +\n\t    (volts[anode]-volts[gnode]) + \" \" + triggerI + \" \"+  holdingI + \" \" +\n\t    cresistance;\n    }\n    double ia, ic, ig, curcount_a, curcount_c, curcount_g;\n    double lastvac, lastvag;\n    double cresistance, triggerI, holdingI;\n\n    final int hs = 8;\n    Polygon poly;\n    Point cathode[], gate[];\n\t\n    void setPoints() {\n\tsuper.setPoints();\n\tint dir = 0;\n\tif (abs(dx) > abs(dy)) {\n\t    dir = -sign(dx)*sign(dy);\n\t    point2.y = point1.y;\n\t} else {\n\t    dir = sign(dy)*sign(dx);\n\t    point2.x = point1.x;\n\t}\n\tif (dir == 0)\n\t    dir = 1;\n\tcalcLeads(16);\n\tcathode = newPointArray(2);\n\tPoint pa[] = newPointArray(2);\n\tinterpPoint2(lead1, lead2, pa[0], pa[1], 0, hs);\n\tinterpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs);\n\tpoly = createPolygon(pa[0], pa[1], lead2);\n\n\tgate = newPointArray(2);\n\tdouble leadlen = (dn-16)/2;\n\tint gatelen = sim.gridSize;\n\tgatelen += leadlen % sim.gridSize;\n\tif (leadlen < gatelen) {\n\t    x2 = x; y2 = y;\n\t    return;\n\t}\n\tinterpPoint(lead2, point2, gate[0], gatelen/leadlen, gatelen*dir);\n\tinterpPoint(lead2, point2, gate[1], gatelen/leadlen, sim.gridSize*2*dir);\n    }\n\t\n    void draw(Graphics g) {\n\tsetBbox(point1, point2, hs);\n\tadjustBbox(gate[0], gate[1]);\n\n\tdouble v1 = volts[anode];\n\tdouble v2 = volts[cnode];\n\n\tdraw2Leads(g);\n\n\t// draw arrow thingy\n\tsetPowerColor(g, true);\n\tsetVoltageColor(g, v1);\n\tg.fillPolygon(poly);\n\n\t// draw thing arrow is pointing to\n\tsetVoltageColor(g, v2);\n\tdrawThickLine(g, cathode[0], cathode[1]);\n\n\tdrawThickLine(g, lead2,   gate[0]);\n\tdrawThickLine(g, gate[0], gate[1]);\n\t\n\tcurcount_a = updateDotCount(ia, curcount_a);\n\tcurcount_c = updateDotCount(ic, curcount_c);\n\tcurcount_g = updateDotCount(ig, curcount_g);\n\tif (sim.dragElm != this) {\n\t    drawDots(g, point1, lead2, curcount_a);\n\t    drawDots(g, point2, lead2, curcount_c);\n\t    drawDots(g, gate[1], gate[0], curcount_g);\n\t    drawDots(g, gate[0], lead2, curcount_g+distance(gate[1], gate[0]));\n\t}\n\tdrawPosts(g);\n    }\n\t\n    \n    Point getPost(int n) {\n\treturn (n == 0) ? point1 : (n == 1) ? point2 : gate[1];\n    }\n\t\n    int getPostCount() { return 3; }\n    int getInternalNodeCount() { return 1; }\n    double getPower() {\n\treturn (volts[anode]-volts[gnode])*ia + (volts[cnode]-volts[gnode])*ic;\n    }\n\n    double aresistance;\n    void stamp() {\n\tsim.stampNonLinear(nodes[anode]);\n\tsim.stampNonLinear(nodes[cnode]);\n\tsim.stampNonLinear(nodes[gnode]);\n\tsim.stampNonLinear(nodes[inode]);\n\tsim.stampResistor(nodes[gnode], nodes[cnode], cresistance);\n\tdiode.stamp(nodes[inode], nodes[gnode]);\n    }\n\n    void doStep() {\n\tdouble vac = volts[anode]-volts[cnode]; // typically negative\n\tdouble vag = volts[anode]-volts[gnode]; // typically positive\n\tif (Math.abs(vac-lastvac) > .01 ||\n\t    Math.abs(vag-lastvag) > .01)\n\t    sim.converged = false;\n\tlastvac = vac;\n\tlastvag = vag;\n\tdiode.doStep(volts[inode]-volts[gnode]);\n\tdouble icmult = 1/triggerI;\n\tdouble iamult = 1/holdingI - icmult;\n\t//System.out.println(icmult + \" \" + iamult);\n\taresistance = (-icmult*ic + ia*iamult > 1) ? .0105 : 10e5;\n\t//System.out.println(vac + \" \" + vag + \" \" + sim.converged + \" \" + ic + \" \" + ia + \" \" + aresistance + \" \" + volts[inode] + \" \" + volts[gnode] + \" \" + volts[anode]);\n\tsim.stampResistor(nodes[anode], nodes[inode], aresistance);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"SCR\";\n\tdouble vac = volts[anode]-volts[cnode];\n\tdouble vag = volts[anode]-volts[gnode];\n\tdouble vgc = volts[gnode]-volts[cnode];\n\tarr[1] = \"Ia = \" + getCurrentText(ia);\n\tarr[2] = \"Ig = \" + getCurrentText(ig);\n\tarr[3] = \"Vac = \" + getVoltageText(vac);\n\tarr[4] = \"Vag = \" + getVoltageText(vag);\n\tarr[5] = \"Vgc = \" + getVoltageText(vgc);\n    }\n    void calculateCurrent() {\n\tic = (volts[cnode]-volts[gnode])/cresistance;\n\tia = (volts[anode]-volts[inode])/aresistance;\n\tig = -ic-ia;\n    }\n    public EditInfo getEditInfo(int n) {\n\t// ohmString doesn't work here on linux\n\tif (n == 0)\n\t    return new EditInfo(\"Trigger Current (A)\", triggerI, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Holding Current (A)\", holdingI, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Gate-Cathode Resistance (ohms)\", cresistance, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0 && ei.value > 0)\n\t    triggerI = ei.value;\n\tif (n == 1 && ei.value > 0)\n\t    holdingI = ei.value;\n\tif (n == 2 && ei.value > 0)\n\t    cresistance = ei.value;\n    }\n}\n\n"
  },
  {
    "path": "src/Scope.java",
    "content": "import java.awt.*;\nimport java.awt.image.*;\nimport java.awt.event.*;\nimport java.util.StringTokenizer;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\n\nclass Scope {\n    final int FLAG_YELM = 32;\n    static final int VAL_POWER = 1;\n    static final int VAL_IB = 1;\n    static final int VAL_IC = 2;\n    static final int VAL_IE = 3;\n    static final int VAL_VBE = 4;\n    static final int VAL_VBC = 5;\n    static final int VAL_VCE = 6;\n    static final int VAL_R = 2;\n    double minV[], maxV[], minMaxV;\n    double minI[], maxI[], minMaxI;\n    int scopePointCount = 128;\n    int ptr, ctr, speed, position;\n    int value, ivalue;\n    String text;\n    Rectangle rect;\n    boolean showI, showV, showMax, showMin, showFreq, lockScale, plot2d, plotXY;\n    CircuitElm elm, xElm, yElm;\n    MemoryImageSource imageSource;\n    Image image;\n    int pixels[];\n    int draw_ox, draw_oy;\n    float dpixels[];\n    CirSim sim;\n    Scope(CirSim s) {\n\trect = new Rectangle();\n\treset();\n\tsim = s;\n    }\n    void showCurrent(boolean b) { showI = b; value = ivalue = 0; }\n    void showVoltage(boolean b) { showV = b; value = ivalue = 0; }\n    void showMax    (boolean b) { showMax = b; }\n    void showMin    (boolean b) { showMin = b; }\n    void showFreq   (boolean b) { showFreq = b; }\n    void setLockScale  (boolean b) { lockScale = b; }\n    void resetGraph() {\n\tscopePointCount = 1;\n\twhile (scopePointCount <= rect.width)\n\t    scopePointCount *= 2;\n\tminV = new double[scopePointCount];\n\tmaxV = new double[scopePointCount];\n\tminI = new double[scopePointCount];\n\tmaxI = new double[scopePointCount];\n\tptr = ctr = 0;\n\tallocImage();\n    }\n    boolean active() { return elm != null; }\n    void reset() {\n\tresetGraph();\n\tminMaxV = 5;\n\tminMaxI = .1;\n\tspeed = 64;\n\tshowI = showV = showMax = true;\n\tshowFreq = lockScale = showMin = false;\n\tplot2d = false;\n\t// no showI for Output\n\tif (elm != null && (elm instanceof OutputElm ||\n\t\t\t    elm instanceof LogicOutputElm ||\n\t\t\t    elm instanceof ProbeElm))\n\t    showI = false;\n\tvalue = ivalue = 0;\n\tif (elm instanceof TransistorElm)\n\t    value = VAL_VCE;\n    }\n    void setRect(Rectangle r) {\n\trect = r;\n\tresetGraph();\n    }\n    int getWidth() { return rect.width; }\n    int rightEdge() { return rect.x+rect.width; }\n\t\n    void setElm(CircuitElm ce) {\n\telm = ce;\n\treset();\n    }\n\t\n    void timeStep() {\n\tif (elm == null)\n\t    return;\n\tdouble v = elm.getScopeValue(value);\n\tif (v < minV[ptr])\n\t    minV[ptr] = v;\n\tif (v > maxV[ptr])\n\t    maxV[ptr] = v;\n\tdouble i = 0;\n\tif (value == 0 || ivalue != 0) {\n\t    i = (ivalue == 0) ? elm.getCurrent() : elm.getScopeValue(ivalue);\n\t    if (i < minI[ptr])\n\t\tminI[ptr] = i;\n\t    if (i > maxI[ptr])\n\t\tmaxI[ptr] = i;\n\t}\n\n\tif (plot2d && dpixels != null) {\n\t    boolean newscale = false;\n\t    while (v > minMaxV || v < -minMaxV) {\n\t\tminMaxV *= 2;\n\t\tnewscale = true;\n\t    }\n\t    double yval = i;\n\t    if (plotXY)\n\t\tyval = (yElm == null) ? 0 : yElm.getVoltageDiff();\n\t    while (yval > minMaxI || yval < -minMaxI) {\n\t\tminMaxI *= 2;\n\t\tnewscale = true;\n\t    }\n\t    if (newscale)\n\t\tclear2dView();\n\t    double xa = v/minMaxV;\n\t    double ya = yval/minMaxI;\n\t    int x = (int) (rect.width *(1+xa)*.499);\n\t    int y = (int) (rect.height*(1-ya)*.499);\n\t    drawTo(x, y);\n\t} else {\n\t    ctr++;\n\t    if (ctr >= speed) {\n\t\tptr = (ptr+1) & (scopePointCount-1);\n\t\tminV[ptr] = maxV[ptr] = v;\n\t\tminI[ptr] = maxI[ptr] = i;\n\t\tctr = 0;\n\t    }\n\t}\n    }\n\n    void drawTo(int x2, int y2) {\n\tif (draw_ox == -1) {\n\t    draw_ox = x2;\n\t    draw_oy = y2;\n\t}\n\t// need to draw a line from x1,y1 to x2,y2\n\tif (draw_ox == x2 && draw_oy == y2) {\n\t    dpixels[x2+rect.width*y2] = 1;\n\t} else if (CircuitElm.abs(y2-draw_oy) > CircuitElm.abs(x2-draw_ox)) {\n\t    // y difference is greater, so we step along y's\n\t    // from min to max y and calculate x for each step\n\t    double sgn = CircuitElm.sign(y2-draw_oy);\n\t    int x, y;\n\t    for (y = draw_oy; y != y2+sgn; y += sgn) {\n\t\tx = draw_ox+(x2-draw_ox)*(y-draw_oy)/(y2-draw_oy);\n\t\tdpixels[x+rect.width*y] = 1;\n\t    }\n\t} else {\n\t    // x difference is greater, so we step along x's\n\t    // from min to max x and calculate y for each step\n\t    double sgn = CircuitElm.sign(x2-draw_ox);\n\t    int x, y;\n\t    for (x = draw_ox; x != x2+sgn; x += sgn) {\n\t\ty = draw_oy+(y2-draw_oy)*(x-draw_ox)/(x2-draw_ox);\n\t\tdpixels[x+rect.width*y] = 1;\n\t    }\n\t}\n\tdraw_ox = x2;\n\tdraw_oy = y2;\n    }\n\t\n    void clear2dView() {\n\tint i;\n\tfor (i = 0; i != dpixels.length; i++)\n\t    dpixels[i] = 0;\n\tdraw_ox = draw_oy = -1;\n    }\n\t\n    void adjustScale(double x) {\n\tminMaxV *= x;\n\tminMaxI *= x;\n    }\n\n    void draw2d(Graphics g) {\n\tint i;\n\tif (pixels == null || dpixels == null)\n\t    return;\n\tint col = (sim.printableCheckItem.getState()) ? 0xFFFFFFFF : 0;\n\tfor (i = 0; i != pixels.length; i++)\n\t    pixels[i] = col;\n\tfor (i = 0; i != rect.width; i++)\n\t    pixels[i+rect.width*(rect.height/2)] = 0xFF00FF00;\n\tint ycol = (plotXY) ? 0xFF00FF00 : 0xFFFFFF00;\n\tfor (i = 0; i != rect.height; i++)\n\t    pixels[rect.width/2+rect.width*i] = ycol;\n\tfor (i = 0; i != pixels.length; i++) {\n\t    int q = (int) (255*dpixels[i]);\n\t    if (q > 0)\n\t\tpixels[i] = 0xFF000000 | (0x10101*q);\n\t    dpixels[i] *= .997;\n\t}\n\tg.drawImage(image, rect.x, rect.y, null);\n\tg.setColor(elm.whiteColor);\n\tg.fillOval(rect.x+draw_ox-2, rect.y+draw_oy-2, 5, 5);\n\tint yt = rect.y+10;\n\tint x = rect.x;\n\tif (text != null && rect.y + rect.height > yt+5) {\n\t    g.drawString(text, x, yt);\n\t    yt += 15;\n\t}\n    }\n\t\n    void draw(Graphics g) {\n\tif (elm == null)\n\t    return;\n\tif (plot2d) {\n\t    draw2d(g);\n\t    return;\n\t}\n\tif (pixels == null)\n\t    return;\n\tint i;\n\tint col = (sim.printableCheckItem.getState()) ? 0xFFFFFFFF : 0;\n\tfor (i = 0; i != pixels.length; i++)\n\t    pixels[i] = col;\n\tint x = 0;\n\tint maxy = (rect.height-1)/2;\n\tint y = maxy;\n\n\tboolean gotI = false;\n\tboolean gotV = false;\n\tint minRange = 4;\n\tdouble realMaxV = -1e8;\n\tdouble realMaxI = -1e8;\n\tdouble realMinV =  1e8;\n\tdouble realMinI =  1e8;\n\tint curColor = 0xFFFFFF00;\n\tint voltColor = (value > 0) ? 0xFFFFFFFF : 0xFF00FF00;\n\tif (sim.scopeSelected == -1 && elm == sim.mouseElm)\n\t    curColor = voltColor = 0xFF00FFFF;\n\tint ipa = ptr+scopePointCount-rect.width;\n\tfor (i = 0; i != rect.width; i++) {\n\t    int ip = (i+ipa) & (scopePointCount-1);\n\t    while (maxV[ip] > minMaxV)\n\t\tminMaxV *= 2;\n\t    while (minV[ip] < -minMaxV)\n\t\tminMaxV *= 2;\n\t    while (maxI[ip] > minMaxI)\n\t\tminMaxI *= 2;\n\t    while (minI[ip] < -minMaxI)\n\t\tminMaxI *= 2;\n\t}\n\n\tdouble gridStep = 1e-8;\n\tdouble gridMax = (showI ? minMaxI : minMaxV);\n\twhile (gridStep*100 < gridMax)\n\t    gridStep *= 10;\n\tif (maxy*gridStep/gridMax < .3)\n\t    gridStep = 0;\n\t    \n\tint ll;\n\tboolean sublines = (maxy*gridStep/gridMax > 3);\n\tfor (ll = -100; ll <= 100; ll++) {\n\t    // don't show gridlines if plotting multiple values,\n\t    // or if lines are too close together (except for center line)\n\t    if (ll != 0 && ((showI && showV) || gridStep == 0))\n\t\tcontinue;\n\t    int yl = maxy-(int) (maxy*ll*gridStep/gridMax);\n\t    if (yl < 0 || yl >= rect.height-1)\n\t\tcontinue;\n\t    col = ll == 0 ? 0xFF909090 : 0xFF404040;\n\t    if (ll % 10 != 0) {\n\t\tcol = 0xFF101010;\n\t\tif (!sublines)\n\t\t    continue;\n\t    }\n\t    for (i = 0; i != rect.width; i++)\n\t\tpixels[i+yl*rect.width] = col;\n\t}\n\n\tgridStep = 1e-15;\n\tdouble ts = sim.timeStep*speed;\n\twhile (gridStep < ts*5)\n\t    gridStep *= 10;\n\tdouble tstart = sim.t-sim.timeStep*speed*rect.width;\n\tdouble tx = sim.t-(sim.t % gridStep);\n\tint first = 1;\n\tfor (ll = 0; ; ll++) {\n\t    double tl = tx-gridStep*ll;\n\t    int gx = (int) ((tl-tstart)/ts);\n\t    if (gx < 0)\n\t\tbreak;\n\t    if (gx >= rect.width)\n\t\tcontinue;\n\t    if (tl < 0)\n\t\tcontinue;\n\t    col = 0xFF202020;\n\t    first = 0;\n\t    if (((tl+gridStep/4) % (gridStep*10)) < gridStep) {\n\t\tcol = 0xFF909090;\n\t\tif (((tl+gridStep/4) % (gridStep*100)) < gridStep)\n\t\t    col = 0xFF4040D0;\n\t    }\n\t    for (i = 0; i < pixels.length; i += rect.width)\n\t\tpixels[i+gx] = col;\n\t}\n\t    \n\t// these two loops are pretty much the same, and should be\n\t// combined!\n\tif (value == 0 && showI) {\n\t    int ox = -1, oy = -1;\n\t    int j;\n\t    for (i = 0; i != rect.width; i++) {\n\t\tint ip = (i+ipa) & (scopePointCount-1);\n\t\tint miniy = (int) ((maxy/minMaxI)*minI[ip]);\n\t\tint maxiy = (int) ((maxy/minMaxI)*maxI[ip]);\n\t\tif (maxI[ip] > realMaxI)\n\t\t    realMaxI = maxI[ip];\n\t\tif (minI[ip] < realMinI)\n\t\t    realMinI = minI[ip];\n\t\tif (miniy <= maxy) {\n\t\t    if (miniy < -minRange || maxiy > minRange)\n\t\t\tgotI = true;\n\t\t    if (ox != -1) {\n\t\t\tif (miniy == oy && maxiy == oy)\n\t\t\t    continue;\n\t\t\tfor (j = ox; j != x+i; j++)\n\t\t\t    pixels[j+rect.width*(y-oy)] = curColor;\n\t\t\tox = oy = -1;\n\t\t    }\n\t\t    if (miniy == maxiy) {\n\t\t\tox = x+i;\n\t\t\toy = miniy;\n\t\t\tcontinue;\n\t\t    }\n\t\t    for (j = miniy; j <= maxiy; j++)\n\t\t\tpixels[x+i+rect.width*(y-j)] = curColor;\n\t\t}\n\t    }\n\t    if (ox != -1)\n\t\tfor (j = ox; j != x+i; j++)\n\t\t    pixels[j+rect.width*(y-oy)] = curColor;\n\t}\n\tif (value != 0 || showV) {\n\t    int ox = -1, oy = -1, j;\n\t    for (i = 0; i != rect.width; i++) {\n\t\tint ip = (i+ipa) & (scopePointCount-1);\n\t\tint minvy = (int) ((maxy/minMaxV)*minV[ip]);\n\t\tint maxvy = (int) ((maxy/minMaxV)*maxV[ip]);\n\t\tif (maxV[ip] > realMaxV)\n\t\t    realMaxV = maxV[ip];\n\t\tif (minV[ip] < realMinV)\n\t\t    realMinV = minV[ip];\n\t\tif ((value != 0 || showV) && minvy <= maxy) {\n\t\t    if (minvy < -minRange || maxvy > minRange)\n\t\t\tgotV = true;\n\t\t    if (ox != -1) {\n\t\t\tif (minvy == oy && maxvy == oy)\n\t\t\t    continue;\n\t\t\tfor (j = ox; j != x+i; j++)\n\t\t\t    pixels[j+rect.width*(y-oy)] = voltColor;\n\t\t\tox = oy = -1;\n\t\t    }\n\t\t    if (minvy == maxvy) {\n\t\t\tox = x+i;\n\t\t\toy = minvy;\n\t\t\tcontinue;\n\t\t    }\n\t\t    for (j = minvy; j <= maxvy; j++)\n\t\t\tpixels[x+i+rect.width*(y-j)] = voltColor;\n\t\t}\n\t    }\n\t    if (ox != -1)\n\t\tfor (j = ox; j != x+i; j++)\n\t\t    pixels[j+rect.width*(y-oy)] = voltColor;\n\t}\n\tdouble freq = 0;\n\tif (showFreq) {\n\t    // try to get frequency\n\t    // get average\n\t    double avg = 0;\n\t    for (i = 0; i != rect.width; i++) {\n\t\tint ip = (i+ipa) & (scopePointCount-1);\n\t\tavg += minV[ip]+maxV[ip];\n\t    }\n\t    avg /= i*2;\n\t    int state = 0;\n\t    double thresh = avg*.05;\n\t    int oi = 0;\n\t    double avperiod = 0;\n\t    int periodct = -1;\n\t    double avperiod2 = 0;\n\t    // count period lengths\n\t    for (i = 0; i != rect.width; i++) {\n\t\tint ip = (i+ipa) & (scopePointCount-1);\n\t\tdouble q = maxV[ip]-avg;\n\t\tint os = state;\n\t\tif (q < thresh)\n\t\t    state = 1;\n\t\telse if (q > -thresh)\n\t\t    state = 2;\n\t\tif (state == 2 && os == 1) {\n\t\t    int pd = i-oi;\n\t\t    oi = i;\n\t\t    // short periods can't be counted properly\n\t\t    if (pd < 12)\n\t\t\tcontinue;\n\t\t    // skip first period, it might be too short\n\t\t    if (periodct >= 0) {\n\t\t\tavperiod += pd;\n\t\t\tavperiod2 += pd*pd;\n\t\t    }\n\t\t    periodct++;\n\t\t}\n\t    }\n\t    avperiod /= periodct;\n\t    avperiod2 /= periodct;\n\t    double periodstd = Math.sqrt(avperiod2-avperiod*avperiod);\n\t    freq = 1/(avperiod*sim.timeStep*speed);\n\t    // don't show freq if standard deviation is too great\n\t    if (periodct < 1 || periodstd > 2)\n\t\tfreq = 0;\n\t    // System.out.println(freq + \" \" + periodstd + \" \" + periodct);\n\t}\n\tg.drawImage(image, rect.x, rect.y, null);\n\tg.setColor(elm.whiteColor);\n\tint yt = rect.y+10;\n\tx += rect.x;\n\tif (showMax) {\n\t    if (value != 0)\n\t\tg.drawString(elm.getUnitText(realMaxV,\n\t\t\t\t\t elm.getScopeUnits(value)),\n\t\t\t     x, yt);\n\t    else if (showV)\n\t\tg.drawString(elm.getVoltageText(realMaxV), x, yt);\n\t    else if (showI)\n\t\tg.drawString(elm.getCurrentText(realMaxI), x, yt);\n\t    yt += 15;\n\t}\n\tif (showMin) {\n\t    int ym = rect.y+rect.height-5;\n\t    if (value != 0)\n\t\tg.drawString(elm.getUnitText(realMinV,\n\t\t\t\t\t elm.getScopeUnits(value)),\n\t\t\t     x, ym);\n\t    else if (showV)\n\t\tg.drawString(elm.getVoltageText(realMinV), x, ym);\n\t    else if (showI)\n\t\tg.drawString(elm.getCurrentText(realMinI), x, ym);\n\t}\n\tif (text != null && rect.y + rect.height > yt+5) {\n\t    g.drawString(text, x, yt);\n\t    yt += 15;\n\t}\n\tif (showFreq && freq != 0 && rect.y + rect.height > yt+5)\n\t    g.drawString(elm.getUnitText(freq, \"Hz\"), x, yt);\n\tif (ptr > 5 && !lockScale) {\n\t    if (!gotI && minMaxI > 1e-4)\n\t\tminMaxI /= 2;\n\t    if (!gotV && minMaxV > 1e-4)\n\t\tminMaxV /= 2;\n\t}\n    }\n\t\n    void speedUp() {\n\tif (speed > 1) {\n\t    speed /= 2;\n\t    resetGraph();\n\t}\n    }\n    void slowDown() {\n\tspeed *= 2;\n\tresetGraph();\n    }\n\t\n    PopupMenu getMenu() {\n\tif (elm == null)\n\t    return null;\n\tif (elm instanceof TransistorElm) {\n\t    sim.scopeIbMenuItem.setState(value == VAL_IB);\n\t    sim.scopeIcMenuItem.setState(value == VAL_IC);\n\t    sim.scopeIeMenuItem.setState(value == VAL_IE);\n\t    sim.scopeVbeMenuItem.setState(value == VAL_VBE);\n\t    sim.scopeVbcMenuItem.setState(value == VAL_VBC);\n\t    sim.scopeVceMenuItem.setState(value == VAL_VCE && ivalue != VAL_IC);\n\t    sim.scopeVceIcMenuItem.setState(value == VAL_VCE && ivalue == VAL_IC);\n\t    return sim.transScopeMenu;\n\t} else {\n\t    sim.scopeVMenuItem    .setState(showV && value == 0);\n\t    sim.scopeIMenuItem    .setState(showI && value == 0);\n\t    sim.scopeMaxMenuItem  .setState(showMax);\n\t    sim.scopeMinMenuItem  .setState(showMin);\n\t    sim.scopeFreqMenuItem .setState(showFreq);\n\t    sim.scopePowerMenuItem.setState(value == VAL_POWER);\n\t    sim.scopeVIMenuItem   .setState(plot2d && !plotXY);\n\t    sim.scopeXYMenuItem   .setState(plotXY);\n\t    sim.scopeSelectYMenuItem.setEnabled(plotXY);\n\t    sim.scopeResistMenuItem.setState(value == VAL_R);\n\t    sim.scopeResistMenuItem.setEnabled(elm instanceof MemristorElm);\n\t    return sim.scopeMenu;\n\t}\n    }\n    void setValue(int x) { reset(); value = x; }\n    String dump() {\n\tif (elm == null)\n\t    return null;\n\tint flags = (showI ? 1 : 0) | (showV ? 2 : 0) |\n\t    (showMax ? 0 : 4) |   // showMax used to be always on\n\t    (showFreq ? 8 : 0) |\n\t    (lockScale ? 16 : 0) | (plot2d ? 64 : 0) |\n\t    (plotXY ? 128 : 0) | (showMin ? 256 : 0);\n\tflags |= FLAG_YELM; // yelm present\n\tint eno = sim.locateElm(elm);\n\tif (eno < 0)\n\t    return null;\n\tint yno = yElm == null ? -1 : sim.locateElm(yElm);\n\tString x = \"o \" + eno + \" \" +\n\t    speed + \" \" + value + \" \" + flags + \" \" +\n\t    minMaxV + \" \" + minMaxI + \" \" + position + \" \" + yno;\n\tif (text != null)\n\t    x += \" \" + text;\n\treturn x;\n    }\n    void undump(StringTokenizer st) {\n\treset();\n\tint e = new Integer(st.nextToken()).intValue();\n\tif (e == -1)\n\t    return;\n\telm = sim.getElm(e);\n\tspeed = new Integer(st.nextToken()).intValue();\n\tvalue = new Integer(st.nextToken()).intValue();\n\tint flags = new Integer(st.nextToken()).intValue();\n\tminMaxV = new Double(st.nextToken()).doubleValue();\n\tminMaxI = new Double(st.nextToken()).doubleValue();\n\tif (minMaxV == 0)\n\t    minMaxV = .5;\n\tif (minMaxI == 0)\n\t    minMaxI = 1;\n\ttext = null;\n\tyElm = null;\n\ttry {\n\t    position = new Integer(st.nextToken()).intValue();\n\t    int ye = -1;\n\t    if ((flags & FLAG_YELM) != 0) {\n\t\tye = new Integer(st.nextToken()).intValue();\n\t\tif (ye != -1)\n\t\t    yElm = sim.getElm(ye);\n\t    }\n\t    while (st.hasMoreTokens()) {\n\t\tif (text == null)\n\t\t    text = st.nextToken();\n\t\telse\n\t\t    text += \" \" + st.nextToken();\n\t    }\n\t} catch (Exception ee) {\n\t}\n\tshowI = (flags & 1) != 0;\n\tshowV = (flags & 2) != 0;\n\tshowMax = (flags & 4) == 0;\n\tshowFreq = (flags & 8) != 0;\n\tlockScale = (flags & 16) != 0;\n\tplot2d = (flags & 64) != 0;\n\tplotXY = (flags & 128) != 0;\n\tshowMin = (flags & 256) != 0;\n    }\n    void allocImage() {\n\tpixels = null;\n\tint w = rect.width;\n\tint h = rect.height;\n\tif (w == 0 || h == 0)\n\t    return;\n\tif (sim.useBufferedImage) {\n\t    try {\n\t\t/* simulate the following code using reflection:\n\t\t   dbimage = new BufferedImage(d.width, d.height,\n\t\t   BufferedImage.TYPE_INT_RGB);\n\t\t   DataBuffer db = (DataBuffer)(((BufferedImage)dbimage).\n\t\t   getRaster().getDataBuffer());\n\t\t   DataBufferInt dbi = (DataBufferInt) db;\n\t\t   pixels = dbi.getData();\n\t\t*/\n\t\tClass biclass = Class.forName(\"java.awt.image.BufferedImage\");\n\t\tClass dbiclass = Class.forName(\"java.awt.image.DataBufferInt\");\n\t\tClass rasclass = Class.forName(\"java.awt.image.Raster\");\n\t\tConstructor cstr = biclass.getConstructor(\n\t\t    new Class[] { int.class, int.class, int.class });\n\t\timage = (Image) cstr.newInstance(new Object[] {\n\t\t\t\t\t\t     new Integer(w), new Integer(h),\n\t\t\t\t\t\t     new Integer(BufferedImage.TYPE_INT_RGB)});\n\t\tMethod m = biclass.getMethod(\"getRaster\");\n\t\tObject ras = m.invoke(image);\n\t\tObject db = rasclass.getMethod(\"getDataBuffer\").invoke(ras);\n\t\tpixels = (int[])\n\t\t    dbiclass.getMethod(\"getData\").invoke(db);\n\t    } catch (Exception ee) {\n\t\t// ee.printStackTrace();\n\t\tSystem.out.println(\"BufferedImage failed\");\n\t    }\n\t}\n\tif (pixels == null) {\n\t    pixels = new int[w*h];\n\t    int i;\n\t    for (i = 0; i != w*h; i++)\n\t\tpixels[i] = 0xFF000000;\n\t    imageSource = new MemoryImageSource(w, h, pixels, 0, w);\n\t    imageSource.setAnimated(true);\n\t    imageSource.setFullBufferUpdates(true);\n\t    image = sim.cv.createImage(imageSource);\n\t}\n\tdpixels = new float[w*h];\n\tdraw_ox = draw_oy = -1;\n    }\n\n    void handleMenu(ItemEvent e, Object mi) {\n\tif (mi == sim.scopeVMenuItem)\n\t    showVoltage(sim.scopeVMenuItem.getState());\n\tif (mi == sim.scopeIMenuItem)\n\t    showCurrent(sim.scopeIMenuItem.getState());\n\tif (mi == sim.scopeMaxMenuItem)\n\t    showMax(sim.scopeMaxMenuItem.getState());\n\tif (mi == sim.scopeMinMenuItem)\n\t    showMin(sim.scopeMinMenuItem.getState());\n\tif (mi == sim.scopeFreqMenuItem)\n\t    showFreq(sim.scopeFreqMenuItem.getState());\n\tif (mi == sim.scopePowerMenuItem)\n\t    setValue(VAL_POWER);\n\tif (mi == sim.scopeIbMenuItem)\n\t    setValue(VAL_IB);\n\tif (mi == sim.scopeIcMenuItem)\n\t    setValue(VAL_IC);\n\tif (mi == sim.scopeIeMenuItem)\n\t    setValue(VAL_IE);\n\tif (mi == sim.scopeVbeMenuItem)\n\t    setValue(VAL_VBE);\n\tif (mi == sim.scopeVbcMenuItem)\n\t    setValue(VAL_VBC);\n\tif (mi == sim.scopeVceMenuItem)\n\t    setValue(VAL_VCE);\n\tif (mi == sim.scopeVceIcMenuItem) {\n\t    plot2d = true;\n\t    plotXY = false;\n\t    value = VAL_VCE;\n\t    ivalue = VAL_IC;\n\t    resetGraph();\n\t}\n\t\n\tif (mi == sim.scopeVIMenuItem) {\n\t    plot2d = sim.scopeVIMenuItem.getState();\n\t    plotXY = false;\n\t    resetGraph();\n\t}\n\tif (mi == sim.scopeXYMenuItem) {\n\t    plotXY = plot2d = sim.scopeXYMenuItem.getState();\n\t    if (yElm == null)\n\t\tselectY();\n\t    resetGraph();\n\t}\n\tif (mi == sim.scopeResistMenuItem)\n\t    setValue(VAL_R);\n    }\n\n    void select() {\n\tsim.mouseElm = elm;\n\tif (plotXY) {\n\t    sim.plotXElm = elm;\n\t    sim.plotYElm = yElm;\n\t}\n    }\n\n    void selectY() {\n\tint e = yElm == null ? -1 : sim.locateElm(yElm);\n\tint firstE = e;\n\twhile (true) {\n\t    for (e++; e < sim.elmList.size(); e++) {\n\t\tCircuitElm ce = sim.getElm(e);\n\t\tif ((ce instanceof OutputElm || ce instanceof ProbeElm) &&\n\t\t    ce != elm) {\n\t\t    yElm = ce;\n\t\t    return;\n\t\t}\n\t    }\n\t    if (firstE == -1)\n\t\treturn;\n\t    e = firstE = -1;\n\t}\n    }\n}\n"
  },
  {
    "path": "src/SevenSegElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class SevenSegElm extends ChipElm {\n\tpublic SevenSegElm(int xx, int yy) { super(xx, yy); }\n\tpublic SevenSegElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t   StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tString getChipName() { return \"7-segment driver/display\"; }\n\tColor darkred;\n\tvoid setupPins() {\n\t    darkred = new Color(30, 0, 0);\n\t    sizeX = 4;\n\t    sizeY = 4;\n\t    pins = new Pin[7];\n\t    pins[0] = new Pin(0, SIDE_W, \"a\");\n\t    pins[1] = new Pin(1, SIDE_W, \"b\");\n\t    pins[2] = new Pin(2, SIDE_W, \"c\");\n\t    pins[3] = new Pin(3, SIDE_W, \"d\");\n\t    pins[4] = new Pin(1, SIDE_S, \"e\");\n\t    pins[5] = new Pin(2, SIDE_S, \"f\");\n\t    pins[6] = new Pin(3, SIDE_S, \"g\");\n\t}\n\tvoid draw(Graphics g) {\n\t    drawChip(g);\n\t    g.setColor(Color.red);\n\t    int xl = x+cspc*5;\n\t    int yl = y+cspc;\n\t    setColor(g, 0);\n\t    drawThickLine(g, xl, yl, xl+cspc, yl);\n\t    setColor(g, 1);\n\t    drawThickLine(g, xl+cspc, yl, xl+cspc, yl+cspc);\n\t    setColor(g, 2);\n\t    drawThickLine(g, xl+cspc, yl+cspc, xl+cspc, yl+cspc2);\n\t    setColor(g, 3);\n\t    drawThickLine(g, xl, yl+cspc2, xl+cspc, yl+cspc2);\n\t    setColor(g, 4);\n\t    drawThickLine(g, xl, yl+cspc, xl, yl+cspc2);\n\t    setColor(g, 5);\n\t    drawThickLine(g, xl, yl, xl, yl+cspc);\n\t    setColor(g, 6);\n\t    drawThickLine(g, xl, yl+cspc, xl+cspc, yl+cspc);\n\t}\n\tvoid setColor(Graphics g, int p) {\n\t    g.setColor(pins[p].value ? Color.red :\n\t\t       sim.printableCheckItem.getState() ? Color.white : darkred);\n\t}\n\tint getPostCount() { return 7; }\n\tint getVoltageSourceCount() { return 0; }\n\tint getDumpType() { return 157; }\n    }\n"
  },
  {
    "path": "src/SparkGapElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass SparkGapElm extends CircuitElm {\n    double resistance, onresistance, offresistance, breakdown, holdcurrent;\n    boolean state;\n    public SparkGapElm(int xx, int yy) {\n\tsuper(xx, yy);\n\toffresistance = 1e9;\n\tonresistance = 1e3;\n\tbreakdown = 1e3;\n\tholdcurrent = 0.001;\n\tstate = false;\n    }\n    public SparkGapElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tonresistance = new Double(st.nextToken()).doubleValue();\n\toffresistance = new Double(st.nextToken()).doubleValue();\n\tbreakdown = new Double(st.nextToken()).doubleValue();\n\tholdcurrent = new Double(st.nextToken()).doubleValue();\n    }\n    boolean nonLinear() {return true;}\n    int getDumpType() { return 187; }\n    String dump() {\n\treturn super.dump() + \" \" + onresistance + \" \" + offresistance + \" \"\n\t    + breakdown + \" \" + holdcurrent;\n    }\n    Polygon arrow1, arrow2;\n    void setPoints() {\n\tsuper.setPoints();\n\tint dist = 16;\n\tint alen = 8;\n\tcalcLeads(dist+alen);\n\tPoint p1 = interpPoint(point1, point2, (dn-alen)/(2*dn));\n\tarrow1 = calcArrow(point1, p1, alen, alen);\n\tp1 = interpPoint(point1, point2, (dn+alen)/(2*dn));\n\tarrow2 = calcArrow(point2, p1, alen, alen);\n    }\n    \n    void draw(Graphics g) {\n\tint i;\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\tsetBbox(point1, point2, 8);\n\tdraw2Leads(g);\n\tsetPowerColor(g, true);\n\tsetVoltageColor(g, volts[0]);\n\tg.fillPolygon(arrow1);\n\tsetVoltageColor(g, volts[1]);\n\tg.fillPolygon(arrow2);\n\tif (state)\n\t    doDots(g);\n\tdrawPosts(g);\n    }\n    \n    void calculateCurrent() {\n\tdouble vd = volts[0] - volts[1];\n\tcurrent = vd/resistance;\n    }\n\n    void reset() {\n\tsuper.reset();\n\tstate = false;\n    }\n\n    void startIteration() {\n\tif (Math.abs(current) < holdcurrent)\n\t    state = false;\n\tdouble vd = volts[0] - volts[1];\n\tif (Math.abs(vd) > breakdown)\n\t    state = true;\n    }\n    \n    void doStep() {\n\tresistance = (state) ? onresistance : offresistance;\n\tsim.stampResistor(nodes[0], nodes[1], resistance);\n    }\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"spark gap\";\n\tgetBasicInfo(arr);\n\tarr[3] = state ? \"on\" : \"off\";\n\tarr[4] = \"Ron = \" + getUnitText(onresistance, sim.ohmString);\n\tarr[5] = \"Roff = \" + getUnitText(offresistance, sim.ohmString);\n\tarr[6] = \"Vbreakdown = \" + getUnitText(breakdown, \"V\");\n    }\n    public EditInfo getEditInfo(int n) {\n\t// ohmString doesn't work here on linux\n\tif (n == 0)\n\t    return new EditInfo(\"On resistance (ohms)\", onresistance, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Off resistance (ohms)\", offresistance, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Breakdown voltage\", breakdown, 0, 0);\n\tif (n == 3)\n\t    return new EditInfo(\"Holding current (A)\", holdcurrent, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (ei.value > 0 && n == 0)\n\t    onresistance = ei.value;\n\tif (ei.value > 0 && n == 1)\n\t    offresistance = ei.value;\n\tif (ei.value > 0 && n == 2)\n\t    breakdown = ei.value;\n\tif (ei.value > 0 && n == 3)\n\t    holdcurrent = ei.value;\n    }\n}\n\n"
  },
  {
    "path": "src/SquareRailElm.java",
    "content": "    class SquareRailElm extends RailElm {\n\tpublic SquareRailElm(int xx, int yy) { super(xx, yy, WF_SQUARE); }\n\tClass getDumpClass() { return RailElm.class; }\n\tint getShortcut() { return 0; }\n    }\n"
  },
  {
    "path": "src/SweepElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass SweepElm extends CircuitElm {\n    double maxV, maxF, minF, sweepTime, frequency;\n    final int FLAG_LOG = 1;\n    final int FLAG_BIDIR = 2;\n\t\n    public SweepElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tminF = 20; maxF = 4000;\n\tmaxV = 5;\n\tsweepTime = .1;\n\tflags = FLAG_BIDIR;\n\treset();\n    }\n    public SweepElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tminF = new Double(st.nextToken()).doubleValue();\n\tmaxF = new Double(st.nextToken()).doubleValue();\n\tmaxV = new Double(st.nextToken()).doubleValue();\n\tsweepTime = new Double(st.nextToken()).doubleValue();\n\treset();\n    }\n    int getDumpType() { return 170; }\n    int getPostCount() { return 1; }\n    final int circleSize = 17;\n\n    String dump() {\n\treturn super.dump() + \" \" + minF + \" \" + maxF + \" \" + maxV + \" \" +\n\t    sweepTime;\n    }\n    void setPoints() {\n\tsuper.setPoints();\n\tlead1 = interpPoint(point1, point2, 1-circleSize/dn);\n    }\n    void draw(Graphics g) {\n\tsetBbox(point1, point2, circleSize);\n\tsetVoltageColor(g, volts[0]);\n\tdrawThickLine(g, point1, lead1);\n\tg.setColor(needsHighlight() ? selectColor : Color.gray);\n\tsetPowerColor(g, false);\n\tint xc = point2.x; int yc = point2.y;\n\tdrawThickCircle(g, xc, yc, circleSize);\n\tint wl = 8;\n\tadjustBbox(xc-circleSize, yc-circleSize,\n\t\t   xc+circleSize, yc+circleSize);\n\tint i;\n\tint xl = 10;\n\tint ox = -1, oy = -1;\n\tlong tm = System.currentTimeMillis();\n\t//double w = (this == mouseElm ? 3 : 2);\n\ttm %= 2000;\n\tif (tm > 1000)\n\t    tm = 2000-tm;\n\tdouble w = 1+tm*.002;\n\tif (!sim.stoppedCheck.getState())\n\t    w = 1+2*(frequency-minF)/(maxF-minF);\n\tfor (i = -xl; i <= xl; i++) {\n\t    int yy = yc+(int) (.95*Math.sin(i*pi*w/xl)*wl);\n\t    if (ox != -1)\n\t\tdrawThickLine(g, ox, oy, xc+i, yy);\n\t    ox = xc+i; oy = yy;\n\t}\n\tif (sim.showValuesCheckItem.getState()) {\n\t    String s = getShortUnitText(frequency, \"Hz\");\n\t    if (dx == 0 || dy == 0)\n\t\tdrawValues(g, s, circleSize);\n\t}\n\t    \n\tdrawPosts(g);\n\tcurcount = updateDotCount(-current, curcount);\n\tif (sim.dragElm != this)\n\t    drawDots(g, point1, lead1, curcount);\n    }\n\t\n    void stamp() {\n\tsim.stampVoltageSource(0, nodes[0], voltSource);\n    }\n    double fadd, fmul, freqTime, savedTimeStep;\n    int dir = 1;\n    void setParams() {\n\tif (frequency < minF || frequency > maxF) {\n\t    frequency = minF;\n\t    freqTime = 0;\n\t    dir = 1;\n\t}\n\tif ((flags & FLAG_LOG) == 0) {\n\t    fadd = dir*sim.timeStep*(maxF-minF)/sweepTime;\n\t    fmul = 1;\n\t} else {\n\t    fadd = 0;\n\t    fmul = Math.pow(maxF/minF, dir*sim.timeStep/sweepTime);\n\t}\n\tsavedTimeStep = sim.timeStep;\n    }\n    void reset() {\n\tfrequency = minF;\n\tfreqTime = 0;\n\tdir = 1;\n\tsetParams();\n    }\n    double v;\n    void startIteration() {\n\t// has timestep been changed?\n\tif (sim.timeStep != savedTimeStep)\n\t    setParams();\n\tv = Math.sin(freqTime)*maxV;\n\tfreqTime += frequency*2*pi*sim.timeStep;\n\tfrequency = frequency*fmul+fadd;\n\tif (frequency >= maxF && dir == 1) {\n\t    if ((flags & FLAG_BIDIR) != 0) {\n\t\tfadd = -fadd;\n\t\tfmul = 1/fmul;\n\t\tdir = -1;\n\t    } else\n\t\tfrequency = minF;\n\t}\n\tif (frequency <= minF && dir == -1) {\n\t    fadd = -fadd;\n\t    fmul = 1/fmul;\n\t    dir = 1;\n\t}\n    }\n    void doStep() {\n\tsim.updateVoltageSource(0, nodes[0], voltSource, v);\n    }\n\t\n    double getVoltageDiff() { return volts[0]; }\n    int getVoltageSourceCount() { return 1; }\n    boolean hasGroundConnection(int n1) { return true; }\n    void getInfo(String arr[]) {\n\tarr[0] = \"sweep \" + (((flags & FLAG_LOG) == 0) ? \"(linear)\" : \"(log)\");\n\tarr[1] = \"I = \" + getCurrentDText(getCurrent());\n\tarr[2] = \"V = \" + getVoltageText(volts[0]);\n\tarr[3] = \"f = \" + getUnitText(frequency, \"Hz\");\n\tarr[4] = \"range = \" + getUnitText(minF, \"Hz\") + \" .. \" +\n\t    getUnitText(maxF, \"Hz\");\n\tarr[5] = \"time = \" + getUnitText(sweepTime, \"s\");\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"Min Frequency (Hz)\", minF, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Max Frequency (Hz)\", maxF, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Sweep Time (s)\", sweepTime, 0, 0);\n\tif (n == 3) {\n\t    EditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t    ei.checkbox = new Checkbox(\"Logarithmic\", (flags & FLAG_LOG) != 0);\n\t    return ei;\n\t}\n\tif (n == 4)\n\t    return new EditInfo(\"Max Voltage\", maxV, 0, 0);\n\tif (n == 5) {\n\t    EditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t    ei.checkbox = new Checkbox(\"Bidirectional\", (flags & FLAG_BIDIR) != 0);\n\t    return ei;\n\t}\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tdouble maxfreq = 1/(8*sim.timeStep);\n\tif (n == 0) {\n\t    minF = ei.value;\n\t    if (minF > maxfreq)\n\t\tminF = maxfreq;\n\t}\n\tif (n == 1) {\n\t    maxF = ei.value;\n\t    if (maxF > maxfreq)\n\t\tmaxF = maxfreq;\n\t}\n\tif (n == 2)\n\t    sweepTime = ei.value;\n\tif (n == 3) {\n\t    flags &= ~FLAG_LOG;\n\t    if (ei.checkbox.getState())\n\t\tflags |= FLAG_LOG;\n\t}\n\tif (n == 4)\n\t    maxV = ei.value;\n\tif (n == 5) {\n\t    flags &= ~FLAG_BIDIR;\n\t    if (ei.checkbox.getState())\n\t\tflags |= FLAG_BIDIR;\n\t}\n\tsetParams();\n    }\n}\n    \n"
  },
  {
    "path": "src/Switch2Elm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class Switch2Elm extends SwitchElm {\n\tint link;\n\tstatic final int FLAG_CENTER_OFF = 1;\n\t\n\tpublic Switch2Elm(int xx, int yy) {\n\t    super(xx, yy, false);\n\t    noDiagonal = true;\n\t}\n\tSwitch2Elm(int xx, int yy, boolean mm) {\n\t    super(xx, yy, mm);\n\t    noDiagonal = true;\n\t}\n\tpublic Switch2Elm(int xa, int ya, int xb, int yb, int f,\n\t\t\t  StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    link = new Integer(st.nextToken()).intValue();\n\t    noDiagonal = true;\n\t}\n\tint getDumpType() { return 'S'; }\n\tString dump() {\n\t    return super.dump() + \" \" + link;\n\t}\n\n\tfinal int openhs = 16;\n\tPoint swposts[], swpoles[];\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    calcLeads(32);\n\t    swposts = newPointArray(2);\n\t    swpoles = newPointArray(3);\n\t    interpPoint2(lead1,  lead2,  swpoles[0], swpoles[1], 1, openhs);\n\t    swpoles[2] = lead2;\n\t    interpPoint2(point1, point2, swposts[0], swposts[1], 1, openhs);\n\t    posCount = hasCenterOff() ? 3 : 2;\n\t}\n\t\n\tvoid draw(Graphics g) {\n\t    setBbox(point1, point2, openhs);\n\n\t    // draw first lead\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, lead1);\n\n\t    // draw second lead\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, swpoles[0], swposts[0]);\n\t    \n\t    // draw third lead\n\t    setVoltageColor(g, volts[2]);\n\t    drawThickLine(g, swpoles[1], swposts[1]);\n\n\t    // draw switch\n\t    if (!needsHighlight())\n\t\tg.setColor(whiteColor);\n\t    drawThickLine(g, lead1, swpoles[position]);\n\t    \n\t    updateDotCount();\n\t    drawDots(g, point1, lead1, curcount);\n\t    if (position != 2)\n\t\tdrawDots(g, swpoles[position], swposts[position], curcount);\n\t    drawPosts(g);\n\t}\n\tPoint getPost(int n) {\n\t    return (n == 0) ? point1 : swposts[n-1];\n\t}\n\tint getPostCount() { return 3; }\n\tvoid calculateCurrent() {\n\t    if (position == 2)\n\t\tcurrent = 0;\n\t}\n\tvoid stamp() {\n\t    if (position == 2) // in center?\n\t\treturn;\n\t    sim.stampVoltageSource(nodes[0], nodes[position+1], voltSource, 0);\n\t}\n\tint getVoltageSourceCount() {\n\t    return (position == 2) ? 0 : 1;\n\t}\n\tvoid toggle() {\n\t    super.toggle();\n\t    if (link != 0) {\n\t\tint i;\n\t\tfor (i = 0; i != sim.elmList.size(); i++) {\n\t\t    Object o = sim.elmList.elementAt(i);\n\t\t    if (o instanceof Switch2Elm) {\n\t\t\tSwitch2Elm s2 = (Switch2Elm) o;\n\t\t\tif (s2.link == link)\n\t\t\t    s2.position = position;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\tboolean getConnection(int n1, int n2) {\n\t    if (position == 2)\n\t\treturn false;\n\t    return comparePair(n1, n2, 0, 1+position);\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = (link == 0) ? \"switch (SPDT)\" : \"switch (DPDT)\";\n\t    arr[1] = \"I = \" + getCurrentDText(getCurrent());\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Center Off\", hasCenterOff());\n\t\treturn ei;\n\t    }\n\t    return super.getEditInfo(n);\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 1) {\n\t\tflags &= ~FLAG_CENTER_OFF;\n\t\tif (ei.checkbox.getState())\n\t\t    flags |= FLAG_CENTER_OFF;\n\t\tif (hasCenterOff())\n\t\t    momentary = false;\n\t\tsetPoints();\n\t    } else\n\t\tsuper.setEditValue(n, ei);\n\t}\n\tboolean hasCenterOff() { return (flags & FLAG_CENTER_OFF) != 0; }\n\tint getShortcut() { return 'S'; }\n    }\n"
  },
  {
    "path": "src/SwitchElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass SwitchElm extends CircuitElm {\n    boolean momentary;\n    // position 0 == closed, position 1 == open\n    int position, posCount;\n    public SwitchElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tmomentary = false;\n\tposition = 0;\n\tposCount = 2;\n    }\n    SwitchElm(int xx, int yy, boolean mm) {\n\tsuper(xx, yy);\n\tposition = (mm) ? 1 : 0;\n\tmomentary = mm;\n\tposCount = 2;\n    }\n    public SwitchElm(int xa, int ya, int xb, int yb, int f,\n\t\t     StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tString str = st.nextToken();\n\tif (str.compareTo(\"true\") == 0)\n\t    position = (this instanceof LogicInputElm) ? 0 : 1;\n\telse if (str.compareTo(\"false\") == 0)\n\t    position = (this instanceof LogicInputElm) ? 1 : 0;\n\telse\n\t    position = new Integer(str).intValue();\n\tmomentary = new Boolean(st.nextToken()).booleanValue();\n\tposCount = 2;\n    }\n    int getDumpType() { return 's'; }\n    String dump() {\n\treturn super.dump() + \" \" + position + \" \" + momentary;\n    }\n\n    Point ps, ps2;\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(32);\n\tps  = new Point();\n\tps2 = new Point();\n    }\n\t\n    void draw(Graphics g) {\n\tint openhs = 16;\n\tint hs1 = (position == 1) ? 0 : 2;\n\tint hs2 = (position == 1) ? openhs : 2;\n\tsetBbox(point1, point2, openhs);\n\n\tdraw2Leads(g);\n\t    \n\tif (position == 0)\n\t    doDots(g);\n\t    \n\tif (!needsHighlight())\n\t    g.setColor(whiteColor);\n\tinterpPoint(lead1, lead2, ps,  0, hs1);\n\tinterpPoint(lead1, lead2, ps2, 1, hs2);\n\t    \n\tdrawThickLine(g, ps, ps2);\n\tdrawPosts(g);\n    }\n    void calculateCurrent() {\n\tif (position == 1)\n\t    current = 0;\n    }\n    void stamp() {\n\tif (position == 0)\n\t    sim.stampVoltageSource(nodes[0], nodes[1], voltSource, 0);\n    }\n    int getVoltageSourceCount() {\n\treturn (position == 1) ? 0 : 1;\n    }\n    void mouseUp() {\n\tif (momentary)\n\t    toggle();\n    }\n    void toggle() {\n\tposition++;\n\tif (position >= posCount)\n\t    position = 0;\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = (momentary) ? \"push switch (SPST)\" : \"switch (SPST)\";\n\tif (position == 1) {\n\t    arr[1] = \"open\";\n\t    arr[2] = \"Vd = \" + getVoltageDText(getVoltageDiff());\n\t} else {\n\t    arr[1] = \"closed\";\n\t    arr[2] = \"V = \" + getVoltageText(volts[0]);\n\t    arr[3] = \"I = \" + getCurrentDText(getCurrent());\n\t}\n    }\n    boolean getConnection(int n1, int n2) { return position == 0; }\n    boolean isWire() { return true; }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0) {\n\t    EditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t    ei.checkbox = new Checkbox(\"Momentary Switch\", momentary);\n\t    return ei;\n\t}\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0)\n\t    momentary = ei.checkbox.getState();\n    }\n    int getShortcut() { return 's'; }\n}\n"
  },
  {
    "path": "src/TappedTransformerElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class TappedTransformerElm extends CircuitElm {\n\tdouble inductance, ratio;\n\tPoint ptEnds[], ptCoil[], ptCore[];\n\tdouble current[], curcount[];\n\tpublic TappedTransformerElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    inductance = 4;\n\t    ratio = 1;\n\t    noDiagonal = true;\n\t    current  = new double[4];\n\t    curcount = new double[4];\n\t    voltdiff = new double[3];\n\t    curSourceValue = new double[3];\n\t    a = new double[9];\n\t}\n\tpublic TappedTransformerElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    inductance = new Double(st.nextToken()).doubleValue();\n\t    ratio = new Double(st.nextToken()).doubleValue();\n\t    current  = new double[4];\n\t    curcount = new double[4];\n\t    current[0] = new Double(st.nextToken()).doubleValue();\n\t    current[1] = new Double(st.nextToken()).doubleValue();\n\t    try {\n\t\tcurrent[2] = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) { }\n\t    voltdiff = new double[3];\n\t    curSourceValue = new double[3];\n\t    noDiagonal = true;\n\t    a = new double[9];\n\t}\n\tint getDumpType() { return 169; }\n\tString dump() {\n\t    return super.dump() + \" \" + inductance + \" \" + ratio + \" \" +\n\t\tcurrent[0] + \" \" + current[1] + \" \" + current[2];\n\t}\n\tvoid draw(Graphics g) {\n\t    int i;\n\t    for (i = 0; i != 5; i++) {\n\t\tsetVoltageColor(g, volts[i]);\n\t\tdrawThickLine(g, ptEnds[i], ptCoil[i]);\n\t    }\n\t    for (i = 0; i != 4; i++) {\n\t\tif (i == 1)\n\t\t    continue;\n\t\tsetPowerColor(g, current[i]*(volts[i]-volts[i+1]));\n\t\tdrawCoil(g, i > 1 ? -6 : 6,\n\t\t\t ptCoil[i], ptCoil[i+1], volts[i], volts[i+1]);\n\t    }\n\t    g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\t    for (i = 0; i != 4; i += 2) {\n\t\tdrawThickLine(g, ptCore[i], ptCore[i+1]);\n\t    }\n\t    // calc current of tap wire\n\t    current[3] = current[1]-current[2];\n\t    for (i = 0; i != 4; i++)\n\t\tcurcount[i] = updateDotCount(current[i], curcount[i]);\n\n\t    // primary dots\n\t    drawDots(g, ptEnds[0], ptCoil[0], curcount[0]);\n\t    drawDots(g, ptCoil[0], ptCoil[1], curcount[0]);\n\t    drawDots(g, ptCoil[1], ptEnds[1], curcount[0]);\n\n\t    // secondary dots\n\t    drawDots(g, ptEnds[2], ptCoil[2], curcount[1]);\n\t    drawDots(g, ptCoil[2], ptCoil[3], curcount[1]);\n\t    drawDots(g, ptCoil[3], ptEnds[3], curcount[3]);\n\t    drawDots(g, ptCoil[3], ptCoil[4], curcount[2]);\n\t    drawDots(g, ptCoil[4], ptEnds[4], curcount[2]);\n\t    \n\t    drawPosts(g);\n\t    setBbox(ptEnds[0], ptEnds[4], 0);\n\t}\n\t\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    int hs = 32;\n\t    ptEnds = newPointArray(5);\n\t    ptCoil = newPointArray(5);\n\t    ptCore = newPointArray(4);\n\t    ptEnds[0] = point1;\n\t    ptEnds[2] = point2;\n\t    interpPoint(point1, point2, ptEnds[1], 0, -hs*2);\n\t    interpPoint(point1, point2, ptEnds[3], 1, -hs);\n\t    interpPoint(point1, point2, ptEnds[4], 1, -hs*2);\n\t    double ce = .5-12/dn;\n\t    double cd = .5-2/dn;\n\t    int i;\n\t    interpPoint(ptEnds[0], ptEnds[2], ptCoil[0], ce);\n\t    interpPoint(ptEnds[0], ptEnds[2], ptCoil[1], ce, -hs*2);\n\t    interpPoint(ptEnds[0], ptEnds[2], ptCoil[2], 1-ce);\n\t    interpPoint(ptEnds[0], ptEnds[2], ptCoil[3], 1-ce, -hs);\n\t    interpPoint(ptEnds[0], ptEnds[2], ptCoil[4], 1-ce, -hs*2);\n\t    for (i = 0; i != 2; i++) {\n\t\tint b = -hs*i*2;\n\t\tinterpPoint(ptEnds[0], ptEnds[2], ptCore[i],   cd,   b);\n\t\tinterpPoint(ptEnds[0], ptEnds[2], ptCore[i+2], 1-cd, b);\n\t    }\n\t}\n\tPoint getPost(int n) {\n\t    return ptEnds[n];\n\t}\n\tint getPostCount() { return 5; }\n\tvoid reset() {\n\t    current[0] = current[1] = volts[0] = volts[1] = volts[2] =\n\t\tvolts[3] = curcount[0] = curcount[1] = 0;\n\t}\n\tdouble a[];\n\tvoid stamp() {\n\t    // equations for transformer:\n\t    //   v1 = L1 di1/dt + M1 di2/dt + M1 di3/dt\n\t    //   v2 = M1 di1/dt + L2 di2/dt + M2 di3/dt\n\t    //   v3 = M1 di1/dt + M2 di2/dt + L2 di3/dt\n\t    // we invert that to get:\n\t    //   di1/dt = a1 v1 + a2 v2 + a3 v3\n\t    //   di2/dt = a4 v1 + a5 v2 + a6 v3\n\t    //   di3/dt = a7 v1 + a8 v2 + a9 v3\n\t    // integrate di1/dt using trapezoidal approx and we get:\n\t    //   i1(t2) = i1(t1) + dt/2 (i1(t1) + i1(t2))\n\t    //          = i1(t1) + a1 dt/2 v1(t1)+a2 dt/2 v2(t1)+a3 dt/2 v3(t3) +\n\t    //                     a1 dt/2 v1(t2)+a2 dt/2 v2(t2)+a3 dt/2 v3(t3)\n\t    // the norton equivalent of this for i1 is:\n\t    //  a. current source, I = i1(t1) + a1 dt/2 v1(t1) + a2 dt/2 v2(t1)\n\t    //                                + a3 dt/2 v3(t1)\n\t    //  b. resistor, G = a1 dt/2\n\t    //  c. current source controlled by voltage v2, G = a2 dt/2\n\t    //  d. current source controlled by voltage v3, G = a3 dt/2\n\t    // and similarly for i2\n\t    // \n\t    // first winding goes from node 0 to 1, second is from 2 to 3 to 4\n\t    double l1 = inductance;\n\t    // second winding is split in half, so each part has half the turns;\n\t    // we square the 1/2 to divide by 4\n\t    double l2 = inductance*ratio*ratio/4;\n\t    double cc = .99;\n\t    //double m1 = .999*Math.sqrt(l1*l2);\n\t    // mutual inductance between two halves of the second winding\n\t    // is equal to self-inductance of either half (slightly less\n\t    // because the coupling is not perfect)\n\t    //double m2 = .999*l2;\n\t    // load pre-inverted matrix\n\t    a[0] = (1+cc)/(l1*(1+cc-2*cc*cc));\n\t    a[1] = a[2] = a[3] = a[6] = 2*cc/((2*cc*cc-cc-1)*inductance*ratio);\n\t    a[4] = a[8] = -4*(1+cc)/((2*cc*cc-cc-1)*l1*ratio*ratio);\n\t    a[5] = a[7] = 4*cc/((2*cc*cc-cc-1)*l1*ratio*ratio);\n\t    int i;\n\t    for (i = 0; i != 9; i++)\n\t\ta[i] *= sim.timeStep/2;\n\t    sim.stampConductance(nodes[0], nodes[1], a[0]);\n\t    sim.stampVCCurrentSource(nodes[0], nodes[1], nodes[2], nodes[3], a[1]);\n\t    sim.stampVCCurrentSource(nodes[0], nodes[1], nodes[3], nodes[4], a[2]);\n\t    \n\t    sim.stampVCCurrentSource(nodes[2], nodes[3], nodes[0], nodes[1], a[3]);\n\t    sim.stampConductance    (nodes[2], nodes[3], a[4]);\n\t    sim.stampVCCurrentSource(nodes[2], nodes[3], nodes[3], nodes[4], a[5]);\n\t    \n\t    sim.stampVCCurrentSource(nodes[3], nodes[4], nodes[0], nodes[1], a[6]);\n\t    sim.stampVCCurrentSource(nodes[3], nodes[4], nodes[2], nodes[3], a[7]);\n\t    sim.stampConductance    (nodes[3], nodes[4], a[8]);\n\n\t    for (i = 0; i != 5; i++)\n\t\tsim.stampRightSide(nodes[i]);\n\t}\n\tvoid startIteration() {\n\t    voltdiff[0] = volts[0]-volts[1];\n\t    voltdiff[1] = volts[2]-volts[3];\n\t    voltdiff[2] = volts[3]-volts[4];\n\t    int i, j;\n\t    for (i = 0; i != 3; i++) {\n\t\tcurSourceValue[i] = current[i];\n\t\tfor (j = 0; j != 3; j++)\n\t\t    curSourceValue[i] += a[i*3+j]*voltdiff[j];\n\t    }\n\t}\n\tdouble curSourceValue[], voltdiff[];\n\tvoid doStep() {\n\t    sim.stampCurrentSource(nodes[0], nodes[1], curSourceValue[0]);\n\t    sim.stampCurrentSource(nodes[2], nodes[3], curSourceValue[1]);\n\t    sim.stampCurrentSource(nodes[3], nodes[4], curSourceValue[2]);\n \t}\n\tvoid calculateCurrent() {\n\t    voltdiff[0] = volts[0]-volts[1];\n\t    voltdiff[1] = volts[2]-volts[3];\n\t    voltdiff[2] = volts[3]-volts[4];\n\t    int i, j;\n\t    for (i = 0; i != 3; i++) {\n\t\tcurrent[i] = curSourceValue[i];\n\t\tfor (j = 0; j != 3; j++)\n\t\t    current[i] += a[i*3+j]*voltdiff[j];\n\t    }\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"transformer\";\n\t    arr[1] = \"L = \" + getUnitText(inductance, \"H\");\n\t    arr[2] = \"Ratio = \" + ratio;\n\t    //arr[3] = \"I1 = \" + getCurrentText(current1);\n\t    arr[3] = \"Vd1 = \" + getVoltageText(volts[0]-volts[2]);\n\t    //arr[5] = \"I2 = \" + getCurrentText(current2);\n\t    arr[4] = \"Vd2 = \" + getVoltageText(volts[1]-volts[3]);\n\t}\n\tboolean getConnection(int n1, int n2) {\n\t    if (comparePair(n1, n2, 0, 1))\n\t\treturn true;\n\t    if (comparePair(n1, n2, 2, 3))\n\t\treturn true;\n\t    if (comparePair(n1, n2, 3, 4))\n\t\treturn true;\n\t    if (comparePair(n1, n2, 2, 4))\n\t\treturn true;\n\t    return false;\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Primary Inductance (H)\", inductance, .01, 5);\n\t    if (n == 1)\n\t\treturn new EditInfo(\"Ratio\", ratio, 1, 10).setDimensionless();\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tinductance = ei.value;\n\t    if (n == 1)\n\t\tratio = ei.value;\n\t}\n    }\n"
  },
  {
    "path": "src/TextElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\nimport java.util.Vector;\n\nclass TextElm extends GraphicElm {\n    String text;\n    Vector<String> lines;\n    int size;\n    final int FLAG_CENTER = 1;\n    final int FLAG_BAR = 2;\n    public TextElm(int xx, int yy) {\n\tsuper(xx, yy);\n\ttext = \"hello\";\n\tlines = new Vector<String>();\n\tlines.add(text);\n\tsize = 24;\n    }\n    public TextElm(int xa, int ya, int xb, int yb, int f,\n\t\t   StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tsize = new Integer(st.nextToken()).intValue();\n\ttext = st.nextToken();\n\twhile (st.hasMoreTokens())\n\t    text += ' ' + st.nextToken();\n\tsplit();\n    }\n    void split() {\n\tint i;\n\tlines = new Vector<String>();\n\tStringBuffer sb = new StringBuffer(text);\n\tfor (i = 0; i < sb.length(); i++) {\n\t    char c = sb.charAt(i);\n\t    if (c == '\\\\') {\n\t\tsb.deleteCharAt(i);\n\t\tc = sb.charAt(i);\n\t\tif (c == 'n') {\n\t\t    lines.add(sb.substring(0, i));\n\t\t    sb.delete(0, i+1);\n\t\t    i = -1;\n\t\t    continue;\n\t\t}\n\t    }\n\t}\n\tlines.add(sb.toString());\n    }\n    String dump() {\n\treturn super.dump() + \" \" + size + \" \" + text;\n    }\n    int getDumpType() { return 'x'; }\n    void drag(int xx, int yy) {\n\tx = xx;\n\ty = yy;\n\tx2 = xx+16;\n\ty2 = yy;\n    }\n    void draw(Graphics g) {\n\t//Graphics2D g2 = (Graphics2D)g;\n\t//g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\n\t//\tRenderingHints.VALUE_ANTIALIAS_ON);\n\tg.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\tFont f = new Font(\"SansSerif\", 0, size);\n\tg.setFont(f);\n\tFontMetrics fm = g.getFontMetrics();\n\tint i;\n\tint maxw = -1;\n\tfor (i = 0; i != lines.size(); i++) {\n\t    int w = fm.stringWidth((String) (lines.elementAt(i)));\n\t    if (w > maxw)\n\t\tmaxw = w;\n\t}\n\tint cury = y;\n\tsetBbox(x, y, x, y);\n\tfor (i = 0; i != lines.size(); i++) {\n\t    String s = (String) (lines.elementAt(i));\n\t    if ((flags & FLAG_CENTER) != 0)\n\t\tx = (sim.winSize.width-fm.stringWidth(s))/2;\n\t    g.drawString(s, x, cury);\n\t    if ((flags & FLAG_BAR) != 0) {\n\t\tint by = cury-fm.getAscent();\n\t\tg.drawLine(x, by, x+fm.stringWidth(s)-1, by);\n\t    }\n\t    adjustBbox(x, cury-fm.getAscent(),\n\t\t       x+fm.stringWidth(s), cury+fm.getDescent());\n\t    cury += fm.getHeight();\n\t}\n\tx2 = boundingBox.x + boundingBox.width;\n\ty2 = boundingBox.y + boundingBox.height;\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0) {\n\t    EditInfo ei = new EditInfo(\"Text\", 0, -1, -1);\n\t    ei.text = text;\n\t    return ei;\n\t}\n\tif (n == 1)\n\t    return new EditInfo(\"Size\", size, 5, 100);\n\tif (n == 2) {\n\t    EditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t    ei.checkbox =\n\t\tnew Checkbox(\"Center\", (flags & FLAG_CENTER) != 0);\n\t    return ei;\n\t}\n\tif (n == 3) {\n\t    EditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t    ei.checkbox =\n\t\tnew Checkbox(\"Draw Bar On Top\", (flags & FLAG_BAR) != 0);\n\t    return ei;\n\t}\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0) {\n\t    text = ei.textf.getText();\n\t    split();\n\t}\n\tif (n == 1)\n\t    size = (int) ei.value;\n\tif (n == 3) {\n\t    if (ei.checkbox.getState())\n\t\tflags |= FLAG_BAR;\n\t    else\n\t\tflags &= ~FLAG_BAR;\n\t}\n\tif (n == 2) {\n\t    if (ei.checkbox.getState())\n\t\tflags |= FLAG_CENTER;\n\t    else\n\t\tflags &= ~FLAG_CENTER;\n\t}\n    }\n    boolean isCenteredText() { return (flags & FLAG_CENTER) != 0; }\n    void getInfo(String arr[]) {\n\tarr[0] = text;\n    }\n    @Override\n    int getShortcut() { return 't'; }\n}\n\n"
  },
  {
    "path": "src/ThermistorElm.java",
    "content": "// stub ThermistorElm based on SparkGapElm\n// FIXME need to uncomment ThermistorElm line from CirSim.java\n// FIXME need to add ThermistorElm.java to srclist\n\nimport java.awt.*;\nimport java.util.StringTokenizer;\n\nclass ThermistorElm extends CircuitElm {\n    double minresistance, maxresistance;\n    double resistance;\n    Scrollbar slider;\n    Label label;\n    public ThermistorElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tmaxresistance = 1e9;\n\tminresistance = 1e3;\n\tcreateSlider();\n    }\n    public ThermistorElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tminresistance = new Double(st.nextToken()).doubleValue();\n\tmaxresistance = new Double(st.nextToken()).doubleValue();\n\tcreateSlider();\n    }\n    boolean nonLinear() {return true;}\n    int getDumpType() { return 188; }\n    String dump() {\n\treturn super.dump() + \" \" + minresistance + \" \" + maxresistance;\n    }\n    Point ps3, ps4;\n    void createSlider() {\n\tsim.main.add(label = new Label(\"Temperature\", Label.CENTER));\n\tint value = 50;\n\tsim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101));\n\tsim.main.validate();\n    }\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(32);\n\tps3 = new Point();\n\tps4 = new Point();\n    }\n    void delete() {\n\tsim.main.remove(label);\n\tsim.main.remove(slider);\n    }\n    \n    void draw(Graphics g) {\n\tint i;\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\tsetBbox(point1, point2, 6);\n\tdraw2Leads(g);\n\t// FIXME need to draw properly, see ResistorElm.java\n\tsetPowerColor(g, true);\n\tdoDots(g);\n\tdrawPosts(g);\n    }\n    \n    void calculateCurrent() {\n\tdouble vd = volts[0] - volts[1];\n\tcurrent = vd/resistance;\n    }\n    void startIteration() {\n\tdouble vd = volts[0] - volts[1];\n\t// FIXME set resistance as appropriate, using slider.getValue()\n\tresistance = minresistance;\n\t//System.out.print(this + \" res current set to \" + current + \"\\n\");\n    }\n    void doStep() {\n\tsim.stampResistor(nodes[0], nodes[1], resistance);\n    }\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    void getInfo(String arr[]) {\n\t// FIXME\n\tarr[0] = \"spark gap\";\n\tgetBasicInfo(arr);\n\tarr[3] = \"R = \" + getUnitText(resistance, sim.ohmString);\n\tarr[4] = \"Ron = \" + getUnitText(minresistance, sim.ohmString);\n\tarr[5] = \"Roff = \" + getUnitText(maxresistance, sim.ohmString);\n    }\n    public EditInfo getEditInfo(int n) {\n\t// ohmString doesn't work here on linux\n\tif (n == 0)\n\t    return new EditInfo(\"Min resistance (ohms)\", minresistance, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Max resistance (ohms)\", maxresistance, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (ei.value > 0 && n == 0)\n\t    minresistance = ei.value;\n\tif (ei.value > 0 && n == 1)\n\t    maxresistance = ei.value;\n    }\n}\n\n"
  },
  {
    "path": "src/TimerElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass TimerElm extends ChipElm {\n    final int FLAG_RESET = 2;\n    final int N_DIS  = 0;\n    final int N_TRIG = 1;\n    final int N_THRES = 2;\n    final int N_VIN = 3;\n    final int N_CTL = 4;\n    final int N_OUT = 5;\n    final int N_RST = 6;\n    int getDefaultFlags() { return FLAG_RESET; }\n    public TimerElm(int xx, int yy) { super(xx, yy); }\n    public TimerElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n    }\n    String getChipName() { return \"555 Timer\"; }\n    void setupPins() {\n\tsizeX = 3;\n\tsizeY = 5;\n\tpins = new Pin[7];\n\tpins[N_DIS] = new Pin(1, SIDE_W, \"dis\");\n\tpins[N_TRIG] = new Pin(3, SIDE_W, \"tr\");\n\tpins[N_TRIG].lineOver = true;\n\tpins[N_THRES] = new Pin(4, SIDE_W, \"th\");\n\tpins[N_VIN] = new Pin(1, SIDE_N, \"Vin\");\n\tpins[N_CTL] = new Pin(1, SIDE_S, \"ctl\");\n\tpins[N_OUT] = new Pin(2, SIDE_E, \"out\");\n\tpins[N_OUT].output = pins[N_OUT].state = true;\n\tpins[N_RST] = new Pin(1, SIDE_E, \"rst\");\n    }\n    boolean nonLinear() { return true; }\n    boolean hasReset() { return (flags & FLAG_RESET) != 0; }\n    void stamp() {\n\t// stamp voltage divider to put ctl pin at 2/3 V\n\tsim.stampResistor(nodes[N_VIN], nodes[N_CTL],  5000);\n\tsim.stampResistor(nodes[N_CTL], 0,        10000);\n\t// output pin\n\tsim.stampVoltageSource(0, nodes[N_OUT], pins[N_OUT].voltSource);\n\t// discharge pin\n\tsim.stampNonLinear(nodes[N_DIS]);\n    }\n    void calculateCurrent() {\n\t// need current for V, discharge, control; output current is\n\t// calculated for us, and other pins have no current\n\tpins[N_VIN].current = (volts[N_CTL]-volts[N_VIN])/5000;\n\tpins[N_CTL].current = -volts[N_CTL]/10000 - pins[N_VIN].current;\n\tpins[N_DIS].current = (!out && !setOut) ? -volts[N_DIS]/10 : 0;\n    }\n    boolean setOut, out;\n    void startIteration() {\n\tout = volts[N_OUT] > volts[N_VIN]/2;\n\tsetOut = false;\n\t// check comparators\n\tif (volts[N_CTL]/2 > volts[N_TRIG])\n\t    setOut = out = true;\n\tif (volts[N_THRES] > volts[N_CTL] || (hasReset() && volts[N_RST] < .7))\n\t    out = false;\n    }\n    void doStep() {\n\t// if output is low, discharge pin 0.  we use a small\n\t// resistor because it's easier, and sometimes people tie\n\t// the discharge pin to the trigger and threshold pins.\n\t// We check setOut to properly emulate the case where\n\t// trigger is low and threshold is high.\n\tif (!out && !setOut)\n\t    sim.stampResistor(nodes[N_DIS], 0, 10);\n\t// output\n\tsim.updateVoltageSource(0, nodes[N_OUT], pins[N_OUT].voltSource,\n\t\t\t    out ? volts[N_VIN] : 0);\n    }\n    int getPostCount() { return hasReset() ? 7 : 6; }\n    int getVoltageSourceCount() { return 1; }\n    int getDumpType() { return 165; }\n}\n    \n"
  },
  {
    "path": "src/TransLineElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass TransLineElm extends CircuitElm {\n    double delay, imped;\n    double voltageL[], voltageR[];\n    int lenSteps, ptr, width;\n    public TransLineElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tdelay = 1000*sim.timeStep;\n\timped = 75;\n\tnoDiagonal = true;\n\treset();\n    }\n    public TransLineElm(int xa, int ya, int xb, int yb, int f,\n\t\t\tStringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tdelay = new Double(st.nextToken()).doubleValue();\n\timped = new Double(st.nextToken()).doubleValue();\n\twidth = new Integer(st.nextToken()).intValue();\n\t// next slot is for resistance (losses), which is not implemented\n\tst.nextToken();\n\tnoDiagonal = true;\n\treset();\n    }\n    int getDumpType() { return 171; }\n    int getPostCount() { return 4; }\n    int getInternalNodeCount() { return 2; }\n    String dump() {\n\treturn super.dump() + \" \" + delay + \" \" + imped + \" \" + width + \" \" + 0.;\n    }\n    void drag(int xx, int yy) {\n\txx = sim.snapGrid(xx);\n\tyy = sim.snapGrid(yy);\n\tint w1 = max(sim.gridSize, abs(yy-y));\n\tint w2 = max(sim.gridSize, abs(xx-x));\n\tif (w1 > w2) {\n\t    xx = x;\n\t    width = w2;\n\t} else {\n\t    yy = y;\n\t    width = w1;\n\t}\n\tx2 = xx; y2 = yy;\n\tsetPoints();\n    }\n\t\n    Point posts[], inner[];\n\t\n    void reset() {\n\tif (sim.timeStep == 0)\n\t    return;\n\tlenSteps = (int) (delay/sim.timeStep);\n\tSystem.out.println(lenSteps + \" steps\");\n\tif (lenSteps > 100000)\n\t    voltageL = voltageR = null;\n\telse {\n\t    voltageL = new double[lenSteps];\n\t    voltageR = new double[lenSteps];\n\t}\n\tptr = 0;\n\tsuper.reset();\n    }\n    void setPoints() {\n\tsuper.setPoints();\n\tint ds = (dy == 0) ? sign(dx) : -sign(dy);\n\tPoint p3 = interpPoint(point1, point2, 0, -width*ds);\n\tPoint p4 = interpPoint(point1, point2, 1, -width*ds);\n\tint sep = sim.gridSize/2;\n\tPoint p5 = interpPoint(point1, point2, 0, -(width/2-sep)*ds);\n\tPoint p6 = interpPoint(point1, point2, 1, -(width/2-sep)*ds);\n\tPoint p7 = interpPoint(point1, point2, 0, -(width/2+sep)*ds);\n\tPoint p8 = interpPoint(point1, point2, 1, -(width/2+sep)*ds);\n\t    \n\t// we number the posts like this because we want the lower-numbered\n\t// points to be on the bottom, so that if some of them are unconnected\n\t// (which is often true) then the bottom ones will get automatically\n\t// attached to ground.\n\tposts = new Point[] { p3, p4, point1, point2 };\n\tinner = new Point[] { p7, p8, p5, p6 };\n    }\n    void draw(Graphics g) {\n\tsetBbox(posts[0], posts[3], 0);\n\tint segments = (int) (dn/2);\n\tint ix0 = ptr-1+lenSteps;\n\tdouble segf = 1./segments;\n\tint i;\n\tg.setColor(Color.darkGray);\n\tg.fillRect(inner[2].x, inner[2].y,\n\t\t   inner[1].x-inner[2].x+2, inner[1].y-inner[2].y+2);\n\tfor (i = 0; i != 4; i++) {\n\t    setVoltageColor(g, volts[i]);\n\t    drawThickLine(g, posts[i], inner[i]);\n\t}\n\tif (voltageL != null) {\n\t    for (i = 0; i != segments; i++) {\n\t\tint ix1 = (ix0-lenSteps*i/segments) % lenSteps;\n\t\tint ix2 = (ix0-lenSteps*(segments-1-i)/segments) % lenSteps;\n\t\tdouble v = (voltageL[ix1]+voltageR[ix2])/2;\n\t\tsetVoltageColor(g, v);\n\t\tinterpPoint(inner[0], inner[1], ps1, i*segf);\n\t\tinterpPoint(inner[2], inner[3], ps2, i*segf);\n\t\tg.drawLine(ps1.x, ps1.y, ps2.x, ps2.y);\n\t\tinterpPoint(inner[2], inner[3], ps1, (i+1)*segf);\n\t\tdrawThickLine(g, ps1, ps2);\n\t    }\n\t}\n\tsetVoltageColor(g, volts[0]);\n\tdrawThickLine(g, inner[0], inner[1]);\n\tdrawPosts(g);\n\n\tcurCount1 = updateDotCount(-current1, curCount1);\n\tcurCount2 = updateDotCount(current2, curCount2);\n\tif (sim.dragElm != this) {\n\t    drawDots(g, posts[0], inner[0], curCount1);\n\t    drawDots(g, posts[2], inner[2], -curCount1);\n\t    drawDots(g, posts[1], inner[1], -curCount2);\n\t    drawDots(g, posts[3], inner[3], curCount2);\n\t}\n    }\n\n    int voltSource1, voltSource2;\n    double current1, current2, curCount1, curCount2;\n    void setVoltageSource(int n, int v) {\n\tif (n == 0)\n\t    voltSource1 = v;\n\telse\n\t    voltSource2 = v;\n    }\n    void setCurrent(int v, double c) {\n\tif (v == voltSource1)\n\t    current1 = c;\n\telse\n\t    current2 = c;\n    }\n\t\n    void stamp() {\n\tsim.stampVoltageSource(nodes[4], nodes[0], voltSource1);\n\tsim.stampVoltageSource(nodes[5], nodes[1], voltSource2);\n\tsim.stampResistor(nodes[2], nodes[4], imped);\n\tsim.stampResistor(nodes[3], nodes[5], imped);\n    }\n\n    void startIteration() {\n\t// calculate voltages, currents sent over wire\n\tif (voltageL == null) {\n\t    sim.stop(\"Transmission line delay too large!\", this);\n\t    return;\n\t}\n\tvoltageL[ptr] = volts[2]-volts[0] + volts[2]-volts[4];\n\tvoltageR[ptr] = volts[3]-volts[1] + volts[3]-volts[5];\n\t//System.out.println(volts[2] + \" \" + volts[0] + \" \" + (volts[2]-volts[0]) + \" \" + (imped*current1) + \" \" + voltageL[ptr]);\n\t/*System.out.println(\"sending fwd  \" + currentL[ptr] + \" \" + current1);\n\t  System.out.println(\"sending back \" + currentR[ptr] + \" \" + current2);*/\n\t//System.out.println(\"sending back \" + voltageR[ptr]);\n\tptr = (ptr+1) % lenSteps;\n    }\n    void doStep() {\n\tif (voltageL == null) {\n\t    sim.stop(\"Transmission line delay too large!\", this);\n\t    return;\n\t}\n\tsim.updateVoltageSource(nodes[4], nodes[0], voltSource1, -voltageR[ptr]);\n\tsim.updateVoltageSource(nodes[5], nodes[1], voltSource2, -voltageL[ptr]);\n\tif (Math.abs(volts[0]) > 1e-5 || Math.abs(volts[1]) > 1e-5) {\n\t    sim.stop(\"Need to ground transmission line!\", this);\n\t    return;\n\t}\n    }\n\n    Point getPost(int n) {\n\treturn posts[n];\n    }\n\t\n    //double getVoltageDiff() { return volts[0]; }\n    int getVoltageSourceCount() { return 2; }\n    boolean hasGroundConnection(int n1) { return false; }\n    boolean getConnection(int n1, int n2) {\n\treturn false;\n\t/*if (comparePair(n1, n2, 0, 1))\n\t  return true;\n\t  if (comparePair(n1, n2, 2, 3))\n\t  return true;\n\t  return false;*/\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"transmission line\";\n\tarr[1] = getUnitText(imped, sim.ohmString);\n\tarr[2] = \"length = \" + getUnitText(2.9979e8*delay, \"m\");\n\tarr[3] = \"delay = \" + getUnitText(delay, \"s\");\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"Delay (s)\", delay, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Impedance (ohms)\", imped, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0) {\n\t    delay = ei.value;\n\t    reset();\n\t}\n\tif (n == 1) {\n\t    imped = ei.value;\n\t    reset();\n\t}\n    }\n}\n\n"
  },
  {
    "path": "src/TransformerElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class TransformerElm extends CircuitElm {\n\tdouble inductance, ratio, couplingCoef;\n\tPoint ptEnds[], ptCoil[], ptCore[];\n\tdouble current[], curcount[];\n\tint width;\n\tpublic static final int FLAG_BACK_EULER = 2;\n\tpublic TransformerElm(int xx, int yy) {\n\t    super(xx, yy);\n\t    inductance = 4;\n\t    ratio = 1;\n\t    width = 32;\n\t    noDiagonal = true;\n\t    couplingCoef = .999;\n\t    current  = new double[2];\n\t    curcount = new double[2];\n\t}\n\tpublic TransformerElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    width = max(32, abs(yb-ya));\n\t    inductance = new Double(st.nextToken()).doubleValue();\n\t    ratio = new Double(st.nextToken()).doubleValue();\n\t    current  = new double[2];\n\t    curcount = new double[2];\n\t    current[0] = new Double(st.nextToken()).doubleValue();\n\t    current[1] = new Double(st.nextToken()).doubleValue();\n\t    couplingCoef = .999;\n\t    try {\n\t\tcouplingCoef = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) { }\n\t    noDiagonal = true;\n\t}\n\tvoid drag(int xx, int yy) {\n\t    xx = sim.snapGrid(xx);\n\t    yy = sim.snapGrid(yy);\n\t    width = max(32, abs(yy-y));\n\t    if (xx == x)\n\t        yy = y;\n\t    x2 = xx; y2 = yy;\n\t    setPoints();\n\t}\n\tint getDumpType() { return 'T'; }\n\tString dump() {\n\t    return super.dump() + \" \" + inductance + \" \" + ratio + \" \" +\n\t\tcurrent[0] + \" \" + current[1] + \" \" + couplingCoef;\n\t}\n\tboolean isTrapezoidal() { return (flags & FLAG_BACK_EULER) == 0; }\n\tvoid draw(Graphics g) {\n\t    int i;\n\t    for (i = 0; i != 4; i++) {\n\t\tsetVoltageColor(g, volts[i]);\n\t\tdrawThickLine(g, ptEnds[i], ptCoil[i]);\n\t    }\n\t    for (i = 0; i != 2; i++) {\n\t\tsetPowerColor(g, current[i]*(volts[i]-volts[i+2]));\n\t\tdrawCoil(g, dsign*(i == 1 ? -6 : 6),\n\t\t\t ptCoil[i], ptCoil[i+2], volts[i], volts[i+2]);\n\t    }\n\t    g.setColor(needsHighlight() ? selectColor : lightGrayColor);\n\t    for (i = 0; i != 2; i++) {\n\t\tdrawThickLine(g, ptCore[i], ptCore[i+2]);\n\t\tcurcount[i] = updateDotCount(current[i], curcount[i]);\n\t    }\n\t    for (i = 0; i != 2; i++) {\n\t\tdrawDots(g, ptEnds[i],   ptCoil[i],    curcount[i]);\n\t\tdrawDots(g, ptCoil[i],   ptCoil[i+2],  curcount[i]);\n\t\tdrawDots(g, ptEnds[i+2], ptCoil[i+2],  -curcount[i]);\n\t    }\n\t    \n\t    drawPosts(g);\n\t    setBbox(ptEnds[0], ptEnds[3], 0);\n\t}\n\t\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    point2.y = point1.y;\n\t    ptEnds = newPointArray(4);\n\t    ptCoil = newPointArray(4);\n\t    ptCore = newPointArray(4);\n\t    ptEnds[0] = point1;\n\t    ptEnds[1] = point2;\n\t    interpPoint(point1, point2, ptEnds[2], 0, -dsign*width);\n\t    interpPoint(point1, point2, ptEnds[3], 1, -dsign*width);\n\t    double ce = .5-12/dn;\n\t    double cd = .5-2/dn;\n\t    int i;\n\t    for (i = 0; i != 4; i += 2) {\n\t\tinterpPoint(ptEnds[i], ptEnds[i+1], ptCoil[i],   ce);\n\t\tinterpPoint(ptEnds[i], ptEnds[i+1], ptCoil[i+1], 1-ce);\n\t\tinterpPoint(ptEnds[i], ptEnds[i+1], ptCore[i],   cd);\n\t\tinterpPoint(ptEnds[i], ptEnds[i+1], ptCore[i+1], 1-cd);\n\t    }\n\t}\n\tPoint getPost(int n) {\n\t    return ptEnds[n];\n\t}\n\tint getPostCount() { return 4; }\n\tvoid reset() {\n\t    current[0] = current[1] = volts[0] = volts[1] = volts[2] =\n\t\tvolts[3] = curcount[0] = curcount[1] = 0;\n\t}\n\tdouble a1, a2, a3, a4;\n\tvoid stamp() {\n\t    // equations for transformer:\n\t    //   v1 = L1 di1/dt + M  di2/dt\n\t    //   v2 = M  di1/dt + L2 di2/dt\n\t    // we invert that to get:\n\t    //   di1/dt = a1 v1 + a2 v2\n\t    //   di2/dt = a3 v1 + a4 v2\n\t    // integrate di1/dt using trapezoidal approx and we get:\n\t    //   i1(t2) = i1(t1) + dt/2 (i1(t1) + i1(t2))\n\t    //          = i1(t1) + a1 dt/2 v1(t1) + a2 dt/2 v2(t1) +\n\t    //                     a1 dt/2 v1(t2) + a2 dt/2 v2(t2)\n\t    // the norton equivalent of this for i1 is:\n\t    //  a. current source, I = i1(t1) + a1 dt/2 v1(t1) + a2 dt/2 v2(t1)\n\t    //  b. resistor, G = a1 dt/2\n\t    //  c. current source controlled by voltage v2, G = a2 dt/2\n\t    // and for i2:\n\t    //  a. current source, I = i2(t1) + a3 dt/2 v1(t1) + a4 dt/2 v2(t1)\n\t    //  b. resistor, G = a3 dt/2\n\t    //  c. current source controlled by voltage v2, G = a4 dt/2\n\t    //\n\t    // For backward euler,\n\t    //\n\t    //   i1(t2) = i1(t1) + a1 dt v1(t2) + a2 dt v2(t2)\n\t    //\n\t    // So the current source value is just i1(t1) and we use\n\t    // dt instead of dt/2 for the resistor and VCCS.\n\t    //\n\t    // first winding goes from node 0 to 2, second is from 1 to 3\n\t    double l1 = inductance;\n\t    double l2 = inductance*ratio*ratio;\n\t    double m = couplingCoef*Math.sqrt(l1*l2);\n\t    // build inverted matrix\n\t    double deti = 1/(l1*l2-m*m);\n\t    double ts = isTrapezoidal() ? sim.timeStep/2 : sim.timeStep;\n\t    a1 = l2*deti*ts; // we multiply dt/2 into a1..a4 here\n\t    a2 = -m*deti*ts;\n\t    a3 = -m*deti*ts;\n\t    a4 = l1*deti*ts;\n\t    sim.stampConductance(nodes[0], nodes[2], a1);\n\t    sim.stampVCCurrentSource(nodes[0], nodes[2], nodes[1], nodes[3], a2);\n\t    sim.stampVCCurrentSource(nodes[1], nodes[3], nodes[0], nodes[2], a3);\n\t    sim.stampConductance(nodes[1], nodes[3], a4);\n\t    sim.stampRightSide(nodes[0]);\n\t    sim.stampRightSide(nodes[1]);\n\t    sim.stampRightSide(nodes[2]);\n\t    sim.stampRightSide(nodes[3]);\n\t}\n\tvoid startIteration() {\n\t    double voltdiff1 = volts[0]-volts[2];\n\t    double voltdiff2 = volts[1]-volts[3];\n\t    if (isTrapezoidal()) {\n\t\tcurSourceValue1 = voltdiff1*a1+voltdiff2*a2+current[0];\n\t\tcurSourceValue2 = voltdiff1*a3+voltdiff2*a4+current[1];\n\t    } else {\n\t\tcurSourceValue1 = current[0];\n\t\tcurSourceValue2 = current[1];\n\t    } \n\t}\n\tdouble curSourceValue1, curSourceValue2;\n\tvoid doStep() {\n\t    sim.stampCurrentSource(nodes[0], nodes[2], curSourceValue1);\n\t    sim.stampCurrentSource(nodes[1], nodes[3], curSourceValue2);\n \t}\n\tvoid calculateCurrent() {\n\t    double voltdiff1 = volts[0]-volts[2];\n\t    double voltdiff2 = volts[1]-volts[3];\n\t    current[0] = voltdiff1*a1 + voltdiff2*a2 + curSourceValue1;\n\t    current[1] = voltdiff1*a3 + voltdiff2*a4 + curSourceValue2;\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"transformer\";\n\t    arr[1] = \"L = \" + getUnitText(inductance, \"H\");\n\t    arr[2] = \"Ratio = 1:\" + ratio;\n\t    arr[3] = \"Vd1 = \" + getVoltageText(volts[0]-volts[2]);\n\t    arr[4] = \"Vd2 = \" + getVoltageText(volts[1]-volts[3]);\n\t    arr[5] = \"I1 = \" + getCurrentText(current[0]);\n\t    arr[6] = \"I2 = \" + getCurrentText(current[1]);\n\t}\n\tboolean getConnection(int n1, int n2) {\n\t    if (comparePair(n1, n2, 0, 2))\n\t\treturn true;\n\t    if (comparePair(n1, n2, 1, 3))\n\t\treturn true;\n\t    return false;\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Primary Inductance (H)\", inductance, .01, 5);\n\t    if (n == 1)\n\t\treturn new EditInfo(\"Ratio\", ratio, 1, 10).setDimensionless();\n\t    if (n == 2)\n\t\treturn new EditInfo(\"Coupling Coefficient\", couplingCoef, 0, 1).\n\t\t    setDimensionless();\n\t    if (n == 3) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Trapezoidal Approximation\",\n\t\t\t\t\t   isTrapezoidal());\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tinductance = ei.value;\n\t    if (n == 1)\n\t\tratio = ei.value;\n\t    if (n == 2 && ei.value > 0 && ei.value < 1)\n\t\tcouplingCoef = ei.value;\n\t    if (n == 3) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags &= ~Inductor.FLAG_BACK_EULER;\n\t\telse\n\t\t    flags |= Inductor.FLAG_BACK_EULER;\n\t    }\n\t}\n    }\n"
  },
  {
    "path": "src/TransistorElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class TransistorElm extends CircuitElm {\n\tint pnp;\n\tdouble beta;\n\tdouble fgain;\n\tdouble gmin;\n\tfinal int FLAG_FLIP = 1;\n\tTransistorElm(int xx, int yy, boolean pnpflag) {\n\t    super(xx, yy);\n\t    pnp = (pnpflag) ? -1 : 1;\n\t    beta = 100;\n\t    setup();\n\t}\n\tpublic TransistorElm(int xa, int ya, int xb, int yb, int f,\n\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f);\n\t    pnp = new Integer(st.nextToken()).intValue();\n\t    beta = 100;\n\t    try {\n\t\tlastvbe = new Double(st.nextToken()).doubleValue();\n\t\tlastvbc = new Double(st.nextToken()).doubleValue();\n\t\tvolts[0] = 0;\n\t\tvolts[1] = -lastvbe;\n\t\tvolts[2] = -lastvbc;\n\t\tbeta = new Double(st.nextToken()).doubleValue();\n\t    } catch (Exception e) {\n\t    }\n\t    setup();\n\t}\n\tvoid setup() {\n\t    vcrit = vt * Math.log(vt/(Math.sqrt(2)*leakage));\n\t    fgain = beta/(beta+1);\n\t    noDiagonal = true;\n\t}\n\tboolean nonLinear() { return true; }\n\tvoid reset() {\n\t    volts[0] = volts[1] = volts[2] = 0;\n\t    lastvbc = lastvbe = curcount_c = curcount_e = curcount_b = 0;\n\t}\n\tint getDumpType() { return 't'; }\n\tString dump() {\n\t    return super.dump() + \" \" + pnp + \" \" + (volts[0]-volts[1]) + \" \" +\n\t\t(volts[0]-volts[2]) + \" \" + beta;\n\t}\n\tdouble ic, ie, ib, curcount_c, curcount_e, curcount_b;\n\tPolygon rectPoly, arrowPoly;\n\t\n\tvoid draw(Graphics g) {\n\t    setBbox(point1, point2, 16);\n\t    setPowerColor(g, true);\n\t    // draw collector\n\t    setVoltageColor(g, volts[1]);\n\t    drawThickLine(g, coll[0], coll[1]);\n\t    // draw emitter\n\t    setVoltageColor(g, volts[2]);\n\t    drawThickLine(g, emit[0], emit[1]);\n\t    // draw arrow\n\t    g.setColor(lightGrayColor);\n\t    g.fillPolygon(arrowPoly);\n\t    // draw base\n\t    setVoltageColor(g, volts[0]);\n\t    if (sim.powerCheckItem.getState())\n\t\tg.setColor(Color.gray);\n\t    drawThickLine(g, point1, base);\n\t    // draw dots\n\t    curcount_b = updateDotCount(-ib, curcount_b);\n\t    drawDots(g, base, point1, curcount_b);\n\t    curcount_c = updateDotCount(-ic, curcount_c);\n\t    drawDots(g, coll[1], coll[0], curcount_c);\n\t    curcount_e = updateDotCount(-ie, curcount_e);\n\t    drawDots(g, emit[1], emit[0], curcount_e);\n\t    // draw base rectangle\n\t    setVoltageColor(g, volts[0]);\n\t    setPowerColor(g, true);\n\t    g.fillPolygon(rectPoly);\n\n\t    if ((needsHighlight() || sim.dragElm == this) && dy == 0) {\n\t\tg.setColor(Color.white);\n\t\tg.setFont(unitsFont);\n\t\tint ds = sign(dx);\n\t\tg.drawString(\"B\", base.x-10*ds, base.y-5);\n\t\tg.drawString(\"C\", coll[0].x-3+9*ds, coll[0].y+4); // x+6 if ds=1, -12 if -1\n\t\tg.drawString(\"E\", emit[0].x-3+9*ds, emit[0].y+4);\n\t    }\n\t    drawPosts(g);\n\t}\n\tPoint getPost(int n) {\n\t    return (n == 0) ? point1 : (n == 1) ? coll[0] : emit[0];\n\t}\n\t\n\tint getPostCount() { return 3; }\n\tdouble getPower() {\n\t    return (volts[0]-volts[2])*ib + (volts[1]-volts[2])*ic;\n\t}\n\n\tPoint rect[], coll[], emit[], base;\n\tvoid setPoints() {\n\t    super.setPoints();\n\t    int hs = 16;\n\t    if ((flags & FLAG_FLIP) != 0)\n\t\tdsign = -dsign;\n\t    int hs2 = hs*dsign*pnp;\n\t    // calc collector, emitter posts\n\t    coll = newPointArray(2);\n\t    emit = newPointArray(2);\n\t    interpPoint2(point1, point2, coll[0], emit[0], 1, hs2);\n\t    // calc rectangle edges\n\t    rect = newPointArray(4);\n\t    interpPoint2(point1, point2, rect[0], rect[1], 1-16/dn, hs);\n\t    interpPoint2(point1, point2, rect[2], rect[3], 1-13/dn, hs);\n\t    // calc points where collector/emitter leads contact rectangle\n\t    interpPoint2(point1, point2, coll[1], emit[1], 1-13/dn, 6*dsign*pnp);\n\t    // calc point where base lead contacts rectangle\n\t    base = new Point();\n\t    interpPoint (point1, point2, base, 1-16/dn);\n\n\t    // rectangle\n\t    rectPoly = createPolygon(rect[0], rect[2], rect[3], rect[1]);\n\n\t    // arrow\n\t    if (pnp == 1)\n\t\tarrowPoly = calcArrow(emit[1], emit[0], 8, 4);\n\t    else {\n\t\tPoint pt = interpPoint(point1, point2, 1-11/dn, -5*dsign*pnp);\n\t\tarrowPoly = calcArrow(emit[0], pt, 8, 4);\n\t    }\n\t}\n\t\n\tstatic final double leakage = 1e-13; // 1e-6;\n\tstatic final double vt = .025;\n\tstatic final double vdcoef = 1/vt;\n\tstatic final double rgain = .5;\n\tdouble vcrit;\n\tdouble lastvbc, lastvbe;\n\tdouble limitStep(double vnew, double vold) {\n\t    double arg;\n\t    double oo = vnew;\n\t    \n\t    if (vnew > vcrit && Math.abs(vnew - vold) > (vt + vt)) {\n\t\tif(vold > 0) {\n\t\t    arg = 1 + (vnew - vold) / vt;\n\t\t    if(arg > 0) {\n\t\t\tvnew = vold + vt * Math.log(arg);\n\t\t    } else {\n\t\t\tvnew = vcrit;\n\t\t    }\n\t\t} else {\n\t\t    vnew = vt *Math.log(vnew/vt);\n\t\t}\n\t\tsim.converged = false;\n\t\t//System.out.println(vnew + \" \" + oo + \" \" + vold);\n\t    }\n\t    return(vnew);\n\t}\n\tvoid stamp() {\n\t    sim.stampNonLinear(nodes[0]);\n\t    sim.stampNonLinear(nodes[1]);\n\t    sim.stampNonLinear(nodes[2]);\n\t}\n\tvoid doStep() {\n\t    double vbc = volts[0]-volts[1]; // typically negative\n\t    double vbe = volts[0]-volts[2]; // typically positive\n\t    if (Math.abs(vbc-lastvbc) > .01 || // .01\n\t\tMath.abs(vbe-lastvbe) > .01)\n\t\tsim.converged = false;\n\t    gmin = 0;\n\t    if (sim.subIterations > 100) {\n\t\t// if we have trouble converging, put a conductance in parallel with all P-N junctions.\n\t\t// Gradually increase the conductance value for each iteration.\n\t\tgmin = Math.exp(-9*Math.log(10)*(1-sim.subIterations/3000.));\n\t\tif (gmin > .1)\n\t\t    gmin = .1;\n\t    }\n\t    //System.out.print(\"T \" + vbc + \" \" + vbe + \"\\n\");\n\t    vbc = pnp*limitStep(pnp*vbc, pnp*lastvbc);\n\t    vbe = pnp*limitStep(pnp*vbe, pnp*lastvbe);\n\t    lastvbc = vbc;\n\t    lastvbe = vbe;\n\t    double pcoef = vdcoef*pnp;\n\t    double expbc = Math.exp(vbc*pcoef);\n\t    /*if (expbc > 1e13 || Double.isInfinite(expbc))\n\t      expbc = 1e13;*/\n\t    double expbe = Math.exp(vbe*pcoef);\n\t    if (expbe < 1)\n\t\texpbe = 1;\n\t    /*if (expbe > 1e13 || Double.isInfinite(expbe))\n\t      expbe = 1e13;*/\n\t    ie = pnp*leakage*(-(expbe-1)+rgain*(expbc-1));\n\t    ic = pnp*leakage*(fgain*(expbe-1)-(expbc-1));\n\t    ib = -(ie+ic);\n\t    //System.out.println(\"gain \" + ic/ib);\n\t    //System.out.print(\"T \" + vbc + \" \" + vbe + \" \" + ie + \" \" + ic + \"\\n\");\n\t    double gee = -leakage*vdcoef*expbe;\n\t    double gec = rgain*leakage*vdcoef*expbc;\n\t    double gce = -gee*fgain;\n\t    double gcc = -gec*(1/rgain);\n\n\t    /*System.out.print(\"gee = \" + gee + \"\\n\");\n\t    System.out.print(\"gec = \" + gec + \"\\n\");\n\t    System.out.print(\"gce = \" + gce + \"\\n\");\n\t    System.out.print(\"gcc = \" + gcc + \"\\n\");\n\t    System.out.print(\"gce+gcc = \" + (gce+gcc) + \"\\n\");\n\t    System.out.print(\"gee+gec = \" + (gee+gec) + \"\\n\");*/\n\t    \n\t    // stamps from page 302 of Pillage.  Node 0 is the base,\n\t    // node 1 the collector, node 2 the emitter.  Also stamp\n\t    // minimum conductance (gmin) between b,e and b,c\n\t    sim.stampMatrix(nodes[0], nodes[0], -gee-gec-gce-gcc + gmin*2);\n\t    sim.stampMatrix(nodes[0], nodes[1], gec+gcc - gmin);\n\t    sim.stampMatrix(nodes[0], nodes[2], gee+gce - gmin);\n\t    sim.stampMatrix(nodes[1], nodes[0], gce+gcc - gmin);\n\t    sim.stampMatrix(nodes[1], nodes[1], -gcc + gmin);\n\t    sim.stampMatrix(nodes[1], nodes[2], -gce);\n\t    sim.stampMatrix(nodes[2], nodes[0], gee+gec - gmin);\n\t    sim.stampMatrix(nodes[2], nodes[1], -gec);\n\t    sim.stampMatrix(nodes[2], nodes[2], -gee + gmin);\n\n\t    // we are solving for v(k+1), not delta v, so we use formula\n\t    // 10.5.13, multiplying J by v(k)\n\t    sim.stampRightSide(nodes[0], -ib - (gec+gcc)*vbc - (gee+gce)*vbe);\n\t    sim.stampRightSide(nodes[1], -ic + gce*vbe + gcc*vbc);\n\t    sim.stampRightSide(nodes[2], -ie + gee*vbe + gec*vbc);\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"transistor (\" + ((pnp == -1) ? \"PNP)\" : \"NPN)\") + \" beta=\" +\n\t\tshowFormat.format(beta);\n\t    double vbc = volts[0]-volts[1];\n\t    double vbe = volts[0]-volts[2];\n\t    double vce = volts[1]-volts[2];\n\t    if (vbc*pnp > .2)\n\t\tarr[1] = vbe*pnp > .2 ? \"saturation\" : \"reverse active\";\n\t    else\n\t\tarr[1] = vbe*pnp > .2 ? \"fwd active\" : \"cutoff\";\n\t    arr[2] = \"Ic = \" + getCurrentText(ic);\n\t    arr[3] = \"Ib = \" + getCurrentText(ib);\n\t    arr[4] = \"Vbe = \" + getVoltageText(vbe);\n\t    arr[5] = \"Vbc = \" + getVoltageText(vbc);\n\t    arr[6] = \"Vce = \" + getVoltageText(vce);\n\t}\n\tdouble getScopeValue(int x) {\n\t    switch (x) {\n\t    case Scope.VAL_IB: return ib;\n\t    case Scope.VAL_IC: return ic;\n\t    case Scope.VAL_IE: return ie;\n\t    case Scope.VAL_VBE: return volts[0]-volts[2];\n\t    case Scope.VAL_VBC: return volts[0]-volts[1];\n\t    case Scope.VAL_VCE: return volts[1]-volts[2];\n\t    }\n\t    return 0;\n\t}\n\tString getScopeUnits(int x) {\n\t    switch (x) {\n\t    case Scope.VAL_IB: case Scope.VAL_IC:\n\t    case Scope.VAL_IE: return \"A\";\n\t    default: return \"V\";\n\t    }\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Beta/hFE\", beta, 10, 1000).\n\t\t    setDimensionless();\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Swap E/C\", (flags & FLAG_FLIP) != 0);\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0) {\n\t\tbeta = ei.value;\n\t\tsetup();\n\t    }\n\t    if (n == 1) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags |= FLAG_FLIP;\n\t\telse\n\t\t    flags &= ~FLAG_FLIP;\n\t\tsetPoints();\n\t    }\n\t}\n\tboolean canViewInScope() { return true; }\n    }\n"
  },
  {
    "path": "src/TriacElm.java",
    "content": "// stub implementation of TriacElm, based on SCRElm\n// FIXME need to add TriacElm to srclist\n// FIXME need to uncomment TriacElm line from CirSim.java\n\nimport java.awt.*;\nimport java.util.StringTokenizer;\n\n// Silicon-Controlled Rectifier\n// 3 nodes, 1 internal node\n// 0 = anode, 1 = cathode, 2 = gate\n// 0, 3 = variable resistor\n// 3, 2 = diode\n// 2, 1 = 50 ohm resistor\n\nclass TriacElm extends CircuitElm {\n    final int anode = 0;\n    final int cnode = 1;\n    final int gnode = 2;\n    final int inode = 3;\n    Diode diode;\n    public TriacElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tsetDefaults();\n\tsetup();\n    }\n    public TriacElm(int xa, int ya, int xb, int yb, int f,\n\t\t  StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tsetDefaults();\n\ttry {\n\t    lastvac = new Double(st.nextToken()).doubleValue();\n\t    lastvag = new Double(st.nextToken()).doubleValue();\n\t    volts[anode] = 0;\n\t    volts[cnode] = -lastvac;\n\t    volts[gnode] = -lastvag;\n\t    triggerI = new Double(st.nextToken()).doubleValue();\n\t    holdingI = new Double(st.nextToken()).doubleValue();\n\t    cresistance = new Double(st.nextToken()).doubleValue();\n\t} catch (Exception e) {\n\t}\n\tsetup();\n    }\n    void setDefaults() {\n\tcresistance = 50;\n\tholdingI = .0082;\n\ttriggerI = .01;\n    }\n    void setup() {\n\tdiode = new Diode(sim);\n\tdiode.setup(.8, 0);\n    }\n    boolean nonLinear() { return true; }\n    void reset() {\n\tvolts[anode] = volts[cnode] = volts[gnode] = 0;\n\tdiode.reset();\n\tlastvag = lastvac = curcount_a = curcount_c = curcount_g = 0;\n    }\n    int getDumpType() { return 183; }\n    String dump() {\n\treturn super.dump() + \" \" + (volts[anode]-volts[cnode]) + \" \" +\n\t    (volts[anode]-volts[gnode]) + \" \" + triggerI + \" \"+  holdingI + \" \" +\n\t    cresistance;\n    }\n    double ia, ic, ig, curcount_a, curcount_c, curcount_g;\n    double lastvac, lastvag;\n    double cresistance, triggerI, holdingI;\n\n    final int hs = 8;\n    Polygon poly;\n    Point cathode[], gate[];\n\t\n    void setPoints() {\n\tsuper.setPoints();\n\tint dir = 0;\n\tif (abs(dx) > abs(dy)) {\n\t    dir = -sign(dx)*sign(dy);\n\t    point2.y = point1.y;\n\t} else {\n\t    dir = sign(dy)*sign(dx);\n\t    point2.x = point1.x;\n\t}\n\tif (dir == 0)\n\t    dir = 1;\n\tcalcLeads(16);\n\tcathode = newPointArray(2);\n\tPoint pa[] = newPointArray(2);\n\tinterpPoint2(lead1, lead2, pa[0], pa[1], 0, hs);\n\tinterpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs);\n\tpoly = createPolygon(pa[0], pa[1], lead2);\n\n\tgate = newPointArray(2);\n\tdouble leadlen = (dn-16)/2;\n\tint gatelen = sim.gridSize;\n\tgatelen += leadlen % sim.gridSize;\n\tif (leadlen < gatelen) {\n\t    x2 = x; y2 = y;\n\t    return;\n\t}\n\tinterpPoint(lead2, point2, gate[0], gatelen/leadlen, gatelen*dir);\n\tinterpPoint(lead2, point2, gate[1], gatelen/leadlen, sim.gridSize*2*dir);\n    }\n\t\n    void draw(Graphics g) {\n\tsetBbox(point1, point2, hs);\n\tadjustBbox(gate[0], gate[1]);\n\n\tdouble v1 = volts[anode];\n\tdouble v2 = volts[cnode];\n\n\tdraw2Leads(g);\n\n\t// draw arrow thingy\n\tsetPowerColor(g, true);\n\tsetVoltageColor(g, v1);\n\tg.fillPolygon(poly);\n\n\t// draw thing arrow is pointing to\n\tsetVoltageColor(g, v2);\n\tdrawThickLine(g, cathode[0], cathode[1]);\n\n\tdrawThickLine(g, lead2,   gate[0]);\n\tdrawThickLine(g, gate[0], gate[1]);\n\t\n\tcurcount_a = updateDotCount(ia, curcount_a);\n\tcurcount_c = updateDotCount(ic, curcount_c);\n\tcurcount_g = updateDotCount(ig, curcount_g);\n\tif (sim.dragElm != this) {\n\t    drawDots(g, point1, lead2, curcount_a);\n\t    drawDots(g, point2, lead2, curcount_c);\n\t    drawDots(g, gate[1], gate[0], curcount_g);\n\t    drawDots(g, gate[0], lead2, curcount_g+distance(gate[1], gate[0]));\n\t}\n\tdrawPosts(g);\n    }\n\t\n    \n    Point getPost(int n) {\n\treturn (n == 0) ? point1 : (n == 1) ? point2 : gate[1];\n    }\n\t\n    int getPostCount() { return 3; }\n    int getInternalNodeCount() { return 1; }\n    double getPower() {\n\treturn (volts[anode]-volts[gnode])*ia + (volts[cnode]-volts[gnode])*ic;\n    }\n\n    double aresistance;\n    void stamp() {\n\tsim.stampNonLinear(nodes[anode]);\n\tsim.stampNonLinear(nodes[cnode]);\n\tsim.stampNonLinear(nodes[gnode]);\n\tsim.stampNonLinear(nodes[inode]);\n\tsim.stampResistor(nodes[gnode], nodes[cnode], cresistance);\n\tdiode.stamp(nodes[inode], nodes[gnode]);\n    }\n\n    void doStep() {\n\tdouble vac = volts[anode]-volts[cnode]; // typically negative\n\tdouble vag = volts[anode]-volts[gnode]; // typically positive\n\tif (Math.abs(vac-lastvac) > .01 ||\n\t    Math.abs(vag-lastvag) > .01)\n\t    sim.converged = false;\n\tlastvac = vac;\n\tlastvag = vag;\n\tdiode.doStep(volts[inode]-volts[gnode]);\n\tdouble icmult = 1/triggerI;\n\tdouble iamult = 1/holdingI - icmult;\n\t//System.out.println(icmult + \" \" + iamult);\n\taresistance = (-icmult*ic + ia*iamult > 1) ? .0105 : 10e5;\n\t//System.out.println(vac + \" \" + vag + \" \" + sim.converged + \" \" + ic + \" \" + ia + \" \" + aresistance + \" \" + volts[inode] + \" \" + volts[gnode] + \" \" + volts[anode]);\n\tsim.stampResistor(nodes[anode], nodes[inode], aresistance);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"SCR\";\n\tdouble vac = volts[anode]-volts[cnode];\n\tdouble vag = volts[anode]-volts[gnode];\n\tdouble vgc = volts[gnode]-volts[cnode];\n\tarr[1] = \"Ia = \" + getCurrentText(ia);\n\tarr[2] = \"Ig = \" + getCurrentText(ig);\n\tarr[3] = \"Vac = \" + getVoltageText(vac);\n\tarr[4] = \"Vag = \" + getVoltageText(vag);\n\tarr[5] = \"Vgc = \" + getVoltageText(vgc);\n    }\n    void calculateCurrent() {\n\tic = (volts[cnode]-volts[gnode])/cresistance;\n\tia = (volts[anode]-volts[inode])/aresistance;\n\tig = -ic-ia;\n    }\n    public EditInfo getEditInfo(int n) {\n\t// ohmString doesn't work here on linux\n\tif (n == 0)\n\t    return new EditInfo(\"Trigger Current (A)\", triggerI, 0, 0);\n\tif (n == 1)\n\t    return new EditInfo(\"Holding Current (A)\", holdingI, 0, 0);\n\tif (n == 2)\n\t    return new EditInfo(\"Gate-Cathode Resistance (ohms)\", cresistance, 0, 0);\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0 && ei.value > 0)\n\t    triggerI = ei.value;\n\tif (n == 1 && ei.value > 0)\n\t    holdingI = ei.value;\n\tif (n == 2 && ei.value > 0)\n\t    cresistance = ei.value;\n    }\n}\n\n"
  },
  {
    "path": "src/TriodeElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass TriodeElm extends CircuitElm {\n    double mu, kg1;\n    double curcountp, curcountc, curcountg, currentp, currentg, currentc;\n    final double gridCurrentR = 6000;\n    public TriodeElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tmu = 93;\n\tkg1 = 680;\n\tsetup();\n    }\n    public TriodeElm(int xa, int ya, int xb, int yb, int f,\n\t\t     StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tmu  = new Double(st.nextToken()).doubleValue();\n\tkg1 = new Double(st.nextToken()).doubleValue();\n\tsetup();\n    }\n    void setup() {\n\tnoDiagonal = true;\n    }\n    boolean nonLinear() { return true; }\n    void reset() {\n\tvolts[0] = volts[1] = volts[2] = 0;\n\tcurcount = 0;\n    }\n    String dump() {\n\treturn super.dump() + \" \" + mu + \" \" + kg1;\n    }\n    int getDumpType() { return 173; }\n\t\n    Point plate[], grid[], cath[], midgrid, midcath;\n    int circler;\n    void setPoints() {\n\tsuper.setPoints();\n\tplate = newPointArray(4);\n\tgrid  = newPointArray(8);\n\tcath  = newPointArray(4);\n\tgrid[0] = point1;\n\tint nearw = 8;\n\tinterpPoint(point1, point2, plate[1], 1, nearw);\n\tint farw  = 32;\n\tinterpPoint(point1, point2, plate[0], 1, farw);\n\tint platew = 18;\n\tinterpPoint2(point2, plate[1], plate[2], plate[3], 1, platew);\n\t    \n\tcircler = 24;\n\tinterpPoint(point1, point2, grid[1], (dn-circler)/dn, 0);\n\tint i;\n\tfor (i = 0; i != 3; i++) {\n\t    interpPoint(grid[1], point2, grid[2+i*2], (i*3+1)/4.5, 0);\n\t    interpPoint(grid[1], point2, grid[3+i*2], (i*3+2)/4.5, 0);\n\t}\n\tmidgrid = point2;\n\n\tint cathw = 16;\n\tmidcath = interpPoint(point1, point2, 1, -nearw);\n\tinterpPoint2(point2, plate[1], cath[1], cath[2], -1, cathw);\n\tinterpPoint(point2, plate[1], cath[3], -1.2, -cathw);\n\tinterpPoint(point2, plate[1], cath[0], -farw/(double) nearw, cathw);\n    }\n\t\n    void draw(Graphics g) {\n\tg.setColor(Color.gray);\n\tdrawThickCircle(g, point2.x, point2.y, circler);\n\tsetBbox(point1, plate[0], 16);\n\tadjustBbox(cath[0].x, cath[1].y, point2.x+circler, point2.y+circler);\n\tsetPowerColor(g, true);\n\t// draw plate\n\tsetVoltageColor(g, volts[0]);\n\tdrawThickLine(g, plate[0], plate[1]);\n\tdrawThickLine(g, plate[2], plate[3]);\n\t// draw grid\n\tsetVoltageColor(g, volts[1]);\n\tint i;\n\tfor (i = 0; i != 8; i += 2)\n\t    drawThickLine(g, grid[i], grid[i+1]);\n\t// draw cathode\n\tsetVoltageColor(g, volts[2]);\n\tfor (i = 0; i != 3; i++)\n\t    drawThickLine(g, cath[i], cath[i+1]);\n\t// draw dots\n\tcurcountp = updateDotCount(currentp, curcountp);\n\tcurcountc = updateDotCount(currentc, curcountc);\n\tcurcountg = updateDotCount(currentg, curcountg);\n\tif (sim.dragElm != this) {\n\t    drawDots(g, plate[0], midgrid, curcountp);\n\t    drawDots(g, midgrid,  midcath, curcountc);\n\t    drawDots(g, midcath,  cath[1], curcountc+8);\n\t    drawDots(g, cath[1],  cath[0], curcountc+8);\n\t    drawDots(g, point1, midgrid, curcountg);\n\t}\n\tdrawPosts(g);\n    }\n    Point getPost(int n) {\n\treturn (n == 0) ? plate[0] : (n == 1) ? grid[0] : cath[0];\n    }\n    int getPostCount() { return 3; }\n    double getPower() { return (volts[0]-volts[2])*current; }\n\n    double lastv0, lastv1, lastv2;\n    void doStep() {\n\tdouble vs[] = new double[3];\n\tvs[0] = volts[0];\n\tvs[1] = volts[1];\n\tvs[2] = volts[2];\n\tif (vs[1] > lastv1 + .5)\n\t    vs[1] = lastv1 + .5;\n\tif (vs[1] < lastv1 - .5)\n\t    vs[1] = lastv1 - .5;\n\tif (vs[2] > lastv2 + .5)\n\t    vs[2] = lastv2 + .5;\n\tif (vs[2] < lastv2 - .5)\n\t    vs[2] = lastv2 - .5;\n\tint grid = 1;\n\tint cath = 2;\n\tint plate = 0;\n\tdouble vgk = vs[grid] -vs[cath];\n\tdouble vpk = vs[plate]-vs[cath];\n\tif (Math.abs(lastv0-vs[0]) > .01 ||\n\t    Math.abs(lastv1-vs[1]) > .01 ||\n\t    Math.abs(lastv2-vs[2]) > .01)\n\t    sim.converged = false;\n\tlastv0 = vs[0];\n\tlastv1 = vs[1];\n\tlastv2 = vs[2];\n\tdouble ids = 0;\n\tdouble gm = 0;\n\tdouble Gds = 0;\n\tdouble ival = vgk+vpk/mu;\n\tcurrentg = 0;\n\tif (vgk > .01) {\n\t    sim.stampResistor(nodes[grid], nodes[cath], gridCurrentR);\n\t    currentg = vgk/gridCurrentR;\n\t}\n\tif (ival < 0) {\n\t    // should be all zero, but that causes a singular matrix,\n\t    // so instead we treat it as a large resistor\n\t    Gds = 1e-8;\n\t    ids = vpk*Gds;\n\t} else {\n\t    ids = Math.pow(ival, 1.5)/kg1;\n\t    double q = 1.5*Math.sqrt(ival)/kg1;\n\t    // gm = dids/dgk;\n\t    // Gds = dids/dpk;\n\t    Gds = q;\n\t    gm = q/mu;\n\t}\n\tcurrentp = ids;\n\tcurrentc = ids+currentg;\n\tdouble rs = -ids + Gds*vpk + gm*vgk;\n\tsim.stampMatrix(nodes[plate],  nodes[plate],  Gds);\n\tsim.stampMatrix(nodes[plate],  nodes[cath],  -Gds-gm); \n\tsim.stampMatrix(nodes[plate],  nodes[grid],   gm);\n\t    \n\tsim.stampMatrix(nodes[cath],   nodes[plate],  -Gds);\n\tsim.stampMatrix(nodes[cath],   nodes[cath],    Gds+gm); \n\tsim.stampMatrix(nodes[cath],   nodes[grid],   -gm);\n\t    \n\tsim.stampRightSide(nodes[plate],  rs);\n\tsim.stampRightSide(nodes[cath ], -rs);\n    }\n\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n\tsim.stampNonLinear(nodes[2]);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"triode\";\n\tdouble vbc = volts[0]-volts[1];\n\tdouble vbe = volts[0]-volts[2];\n\tdouble vce = volts[1]-volts[2];\n\tarr[1] = \"Vbe = \" + getVoltageText(vbe);\n\tarr[2] = \"Vbc = \" + getVoltageText(vbc);\n\tarr[3] = \"Vce = \" + getVoltageText(vce);\n    }\n    // grid not connected to other terminals\n    boolean getConnection(int n1, int n2) { return !(n1 == 1 || n2 == 1); }\n}\n\n"
  },
  {
    "path": "src/TunnelDiodeElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass TunnelDiodeElm extends CircuitElm {\n    public TunnelDiodeElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tsetup();\n    }\n    public TunnelDiodeElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t  StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tsetup();\n    }\n    boolean nonLinear() { return true; }\n    void setup() {\n    }\n    int getDumpType() { return 175; }\n\t\n    final int hs = 8;\n    Polygon poly;\n    Point cathode[];\n\t\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(16);\n\tcathode = newPointArray(4);\n\tPoint pa[] = newPointArray(2);\n\tinterpPoint2(lead1, lead2, pa[0], pa[1], 0, hs);\n\tinterpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs);\n\tinterpPoint2(lead1, lead2, cathode[2], cathode[3], .8, hs);\n\tpoly = createPolygon(pa[0], pa[1], lead2);\n    }\n\t\n    void draw(Graphics g) {\n\tsetBbox(point1, point2, hs);\n\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\n\tdraw2Leads(g);\n\n\t// draw arrow thingy\n\tsetPowerColor(g, true);\n\tsetVoltageColor(g, v1);\n\tg.fillPolygon(poly);\n\n\t// draw thing arrow is pointing to\n\tsetVoltageColor(g, v2);\n\tdrawThickLine(g, cathode[0], cathode[1]);\n\tdrawThickLine(g, cathode[2], cathode[0]);\n\tdrawThickLine(g, cathode[3], cathode[1]);\n\n\tdoDots(g);\n\tdrawPosts(g);\n    }\n\t\n    void reset() {\n\tlastvoltdiff = volts[0] = volts[1] = curcount = 0;\n    }\n\t\n    double lastvoltdiff;\n    double limitStep(double vnew, double vold) {\n\t// Prevent voltage changes of more than 1V when iterating.  Wow, I thought it would be\n\t// much harder than this to prevent convergence problems.\n\tif (vnew > vold+1)\n\t    return vold+1;\n\tif (vnew < vold-1)\n\t    return vold-1;\n\treturn vnew;\n    }\n    void stamp() {\n\tsim.stampNonLinear(nodes[0]);\n\tsim.stampNonLinear(nodes[1]);\n    }\n    static final double pvp = .1;\n    static final double pip = 4.7e-3;\n    static final double pvv = .37;\n    static final double pvt = .026;\n    static final double pvpp = .525;\n    static final double piv = 370e-6;\n    void doStep() {\n\tdouble voltdiff = volts[0] - volts[1];\n\tif (Math.abs(voltdiff-lastvoltdiff) > .01)\n\t    sim.converged = false;\n\t//System.out.println(voltdiff + \" \" + lastvoltdiff + \" \" + Math.abs(voltdiff-lastvoltdiff));\n\tvoltdiff = limitStep(voltdiff, lastvoltdiff);\n\tlastvoltdiff = voltdiff;\n\t\n\tdouble i = pip*Math.exp(-pvpp/pvt)*(Math.exp(voltdiff/pvt)-1) +\n\t    pip*(voltdiff/pvp)*Math.exp(1-voltdiff/pvp) +\n\t    piv*Math.exp(voltdiff-pvv);\n\t\n\tdouble geq = pip*Math.exp(-pvpp/pvt)*Math.exp(voltdiff/pvt)/pvt +\n\t    pip*Math.exp(1-voltdiff/pvp)/pvp\n\t    - Math.exp(1-voltdiff/pvp)*pip*voltdiff/(pvp*pvp) +\n\t    Math.exp(voltdiff-pvv)*piv;\n\tdouble nc = i - geq*voltdiff;\n\tsim.stampConductance(nodes[0], nodes[1], geq);\n\tsim.stampCurrentSource(nodes[0], nodes[1], nc);\n    }\n    void calculateCurrent() {\n\tdouble voltdiff = volts[0] - volts[1];\n\tcurrent = pip*Math.exp(-pvpp/pvt)*(Math.exp(voltdiff/pvt)-1) +\n\t    pip*(voltdiff/pvp)*Math.exp(1-voltdiff/pvp) +\n\t    piv*Math.exp(voltdiff-pvv);\n    }\n    void getInfo(String arr[]) {\n\tarr[0] = \"tunnel diode\";\n\tarr[1] = \"I = \" + getCurrentText(getCurrent());\n\tarr[2] = \"Vd = \" + getVoltageText(getVoltageDiff());\n\tarr[3] = \"P = \" + getUnitText(getPower(), \"W\");\n    }\n}\n"
  },
  {
    "path": "src/VCOElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class VCOElm extends ChipElm {\n\tpublic VCOElm(int xx, int yy) { super(xx, yy); }\n\tpublic VCOElm(int xa, int ya, int xb, int yb, int f,\n\t\t      StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tString getChipName() { return \"VCO\"; }\n\tvoid setupPins() {\n\t    sizeX = 2;\n\t    sizeY = 4;\n\t    pins = new Pin[6];\n\t    pins[0] = new Pin(0, SIDE_W, \"Vi\");\n\t    pins[1] = new Pin(3, SIDE_W, \"Vo\");\n\t    pins[1].output = true;\n\t    pins[2] = new Pin(0, SIDE_E, \"C\");\n\t    pins[3] = new Pin(1, SIDE_E, \"C\");\n\t    pins[4] = new Pin(2, SIDE_E, \"R1\");\n\t    pins[4].output = true;\n\t    pins[5] = new Pin(3, SIDE_E, \"R2\");\n\t    pins[5].output = true;\n\t}\n\tboolean nonLinear() { return true; }\n\tvoid stamp() {\n\t    // output pin\n\t    sim.stampVoltageSource(0, nodes[1], pins[1].voltSource);\n\t    // attach Vi to R1 pin so its current is proportional to Vi\n\t    sim.stampVoltageSource(nodes[0], nodes[4], pins[4].voltSource, 0);\n\t    // attach 5V to R2 pin so we get a current going\n\t    sim.stampVoltageSource(0, nodes[5], pins[5].voltSource, 5);\n\t    // put resistor across cap pins to give current somewhere to go\n\t    // in case cap is not connected\n\t    sim.stampResistor(nodes[2], nodes[3], cResistance);\n\t    sim.stampNonLinear(nodes[2]);\n\t    sim.stampNonLinear(nodes[3]);\n\t}\n\tfinal double cResistance = 1e6;\n\tdouble cCurrent;\n\tint cDir;\n\tvoid doStep() {\n\t    double vc = volts[3]-volts[2];\n\t    double vo = volts[1];\n\t    int dir = (vo < 2.5) ? 1 : -1;\n\t    // switch direction of current through cap as we oscillate\n\t    if (vo < 2.5 && vc > 4.5) {\n\t\tvo = 5;\n\t\tdir = -1;\n\t    }\n\t    if (vo > 2.5 && vc < .5) {\n\t\tvo = 0;\n\t\tdir = 1;\n\t    }\n\n\t    // generate output voltage\n\t    sim.updateVoltageSource(0, nodes[1], pins[1].voltSource, vo);\n\t    // now we set the current through the cap to be equal to the\n\t    // current through R1 and R2, so we can measure the voltage\n\t    // across the cap\n\t    int cur1 = sim.nodeList.size() + pins[4].voltSource;\n\t    int cur2 = sim.nodeList.size() + pins[5].voltSource;\n\t    sim.stampMatrix(nodes[2], cur1, dir);\n\t    sim.stampMatrix(nodes[2], cur2, dir);\n\t    sim.stampMatrix(nodes[3], cur1, -dir);\n\t    sim.stampMatrix(nodes[3], cur2, -dir);\n\t    cDir = dir;\n\t}\n\t// can't do this in calculateCurrent() because it's called before\n        // we get pins[4].current and pins[5].current, which we need\n\tvoid computeCurrent() {\n\t    if (cResistance == 0)\n\t\treturn;\n\t    double c = cDir*(pins[4].current + pins[5].current) +\n\t\t(volts[3]-volts[2])/cResistance;\n\t    pins[2].current = -c;\n\t    pins[3].current = c;\n\t    pins[0].current = -pins[4].current;\n\t}\n\tvoid draw(Graphics g) {\n\t    computeCurrent();\n\t    drawChip(g);\n\t}\n\tint getPostCount() { return 6; }\n\tint getVoltageSourceCount() { return 3; }\n\tint getDumpType() { return 158; }\n    }\n"
  },
  {
    "path": "src/VarRailElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class VarRailElm extends RailElm {\n\tScrollbar slider;\n\tLabel label;\n\tString sliderText;\n\tpublic VarRailElm(int xx, int yy) {\n\t    super(xx, yy, WF_VAR);\n\t    sliderText = \"Voltage\";\n\t    frequency = maxVoltage;\n\t    createSlider();\n\t}\n\tpublic VarRailElm(int xa, int ya, int xb, int yb, int f,\n\t\t       StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t    sliderText = st.nextToken();\n\t    while (st.hasMoreTokens())\n\t\tsliderText += ' ' + st.nextToken();\n\t    createSlider();\n\t}\n\tString dump() {\n\t    return super.dump() + \" \" + sliderText;\n\t}\n\tint getDumpType() { return 172; }\n\tvoid createSlider() {\n\t    waveform = WF_VAR;\n\t    sim.main.add(label = new Label(sliderText, Label.CENTER));\n\t    int value = (int) ((frequency-bias)*100/(maxVoltage-bias));\n\t    sim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101));\n\t    sim.main.validate();\n\t}\n\tdouble getVoltage() {\n\t    frequency = slider.getValue() * (maxVoltage-bias) / 100. + bias;\n\t    return frequency;\n\t}\n\tvoid delete() {\n\t    sim.main.remove(label);\n\t    sim.main.remove(slider);\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0)\n\t\treturn new EditInfo(\"Min Voltage\", bias, -20, 20);\n\t    if (n == 1)\n\t\treturn new EditInfo(\"Max Voltage\", maxVoltage, -20, 20);\n\t    if (n == 2) {\n\t\tEditInfo ei = new EditInfo(\"Slider Text\", 0, -1, -1);\n\t\tei.text = sliderText;\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0)\n\t\tbias = ei.value;\n\t    if (n == 1)\n\t\tmaxVoltage = ei.value;\n\t    if (n == 2) {\n\t\tsliderText = ei.textf.getText();\n\t\tlabel.setText(sliderText);\n\t    }\n\t}\n\tint getShortcut() { return 0; }\n    }\n"
  },
  {
    "path": "src/VoltageElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\nclass VoltageElm extends CircuitElm {\n    static final int FLAG_COS = 2;\n    int waveform;\n    static final int WF_DC = 0;\n    static final int WF_AC = 1;\n    static final int WF_SQUARE = 2;\n    static final int WF_TRIANGLE = 3;\n    static final int WF_SAWTOOTH = 4;\n    static final int WF_PULSE = 5;\n    static final int WF_VAR = 6;\n    double frequency, maxVoltage, freqTimeZero, bias,\n\tphaseShift, dutyCycle;\n    VoltageElm(int xx, int yy, int wf) {\n\tsuper(xx, yy);\n\twaveform = wf;\n\tmaxVoltage = 5;\n\tfrequency = 40;\n\tdutyCycle = .5;\n\treset();\n    }\n    public VoltageElm(int xa, int ya, int xb, int yb, int f,\n\t\t      StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f);\n\tmaxVoltage = 5;\n\tfrequency = 40;\n\twaveform = WF_DC;\n\tdutyCycle = .5;\n\ttry {\n\t    waveform = new Integer(st.nextToken()).intValue();\n\t    frequency = new Double(st.nextToken()).doubleValue();\n\t    maxVoltage = new Double(st.nextToken()).doubleValue();\n\t    bias = new Double(st.nextToken()).doubleValue();\n\t    phaseShift = new Double(st.nextToken()).doubleValue();\n\t    dutyCycle = new Double(st.nextToken()).doubleValue();\n\t} catch (Exception e) {\n\t}\n\tif ((flags & FLAG_COS) != 0) {\n\t    flags &= ~FLAG_COS;\n\t    phaseShift = pi/2;\n\t}\n\treset();\n    }\n    int getDumpType() { return 'v'; }\n    String dump() {\n\treturn super.dump() + \" \" + waveform + \" \" + frequency + \" \" +\n\t    maxVoltage + \" \" + bias + \" \" + phaseShift + \" \" +\n\t    dutyCycle;\n    }\n    /*void setCurrent(double c) {\n      current = c;\n      System.out.print(\"v current set to \" + c + \"\\n\");\n      }*/\n\n    void reset() {\n\tfreqTimeZero = 0;\n\tcurcount = 0;\n    }\n    double triangleFunc(double x) {\n\tif (x < pi)\n\t    return x*(2/pi)-1;\n\treturn 1-(x-pi)*(2/pi);\n    }\n    void stamp() {\n\tif (waveform == WF_DC)\n\t    sim.stampVoltageSource(nodes[0], nodes[1], voltSource,\n\t\t\t       getVoltage());\n\telse\n\t    sim.stampVoltageSource(nodes[0], nodes[1], voltSource);\n    }\n    void doStep() {\n\tif (waveform != WF_DC)\n\t    sim.updateVoltageSource(nodes[0], nodes[1], voltSource,\n\t\t\t\tgetVoltage());\n    }\n    double getVoltage() {\n\tdouble w = 2*pi*(sim.t-freqTimeZero)*frequency + phaseShift;\n\tswitch (waveform) {\n\tcase WF_DC: return maxVoltage+bias;\n\tcase WF_AC: return Math.sin(w)*maxVoltage+bias;\n\tcase WF_SQUARE:\n\t    return bias+((w % (2*pi) > (2*pi*dutyCycle)) ?\n\t\t\t -maxVoltage : maxVoltage);\n\tcase WF_TRIANGLE:\n\t    return bias+triangleFunc(w % (2*pi))*maxVoltage;\n\tcase WF_SAWTOOTH:\n\t    return bias+(w % (2*pi))*(maxVoltage/pi)-maxVoltage;\n\tcase WF_PULSE:\n\t    return ((w % (2*pi)) < 1) ? maxVoltage+bias : bias;\n\tdefault: return 0;\n\t}\n    }\n    final int circleSize = 17;\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads((waveform == WF_DC || waveform == WF_VAR) ? 8 : circleSize*2);\n    }\n    void draw(Graphics g) {\n\tsetBbox(x, y, x2, y2);\n\tdraw2Leads(g);\n\tif (waveform == WF_DC) {\n\t    setPowerColor(g, false);\n\t    setVoltageColor(g, volts[0]);\n\t    interpPoint2(lead1, lead2, ps1, ps2, 0, 10);\n\t    drawThickLine(g, ps1, ps2);\n\t    setVoltageColor(g, volts[1]);\n\t    int hs = 16;\n\t    setBbox(point1, point2, hs);\n\t    interpPoint2(lead1, lead2, ps1, ps2, 1, hs);\n\t    drawThickLine(g, ps1, ps2);\n\t} else {\n\t    setBbox(point1, point2, circleSize);\n\t    interpPoint(lead1, lead2, ps1, .5);\n\t    drawWaveform(g, ps1);\n\t}\n\tupdateDotCount();\n\tif (sim.dragElm != this) {\n\t    if (waveform == WF_DC)\n\t\tdrawDots(g, point1, point2, curcount);\n\t    else {\n\t\tdrawDots(g, point1, lead1, curcount);\n\t\tdrawDots(g, point2, lead2, -curcount);\n\t    }\n\t}\n\tdrawPosts(g);\n    }\n\t\n    void drawWaveform(Graphics g, Point center) {\n\tg.setColor(needsHighlight() ? selectColor : Color.gray);\n\tsetPowerColor(g, false);\n\tint xc = center.x; int yc = center.y;\n\tdrawThickCircle(g, xc, yc, circleSize);\n\tint wl = 8;\n\tadjustBbox(xc-circleSize, yc-circleSize,\n\t\t   xc+circleSize, yc+circleSize);\n\tint xc2;\n\tswitch (waveform) {\n\tcase WF_DC:\n\t{\n\t    break;\n\t}\n\tcase WF_SQUARE:\n\t    xc2 = (int) (wl*2*dutyCycle-wl+xc);\n\t    xc2 = max(xc-wl+3, min(xc+wl-3, xc2));\n\t    drawThickLine(g, xc-wl, yc-wl, xc-wl, yc   );\n\t    drawThickLine(g, xc-wl, yc-wl, xc2  , yc-wl);\n\t    drawThickLine(g, xc2  , yc-wl, xc2  , yc+wl);\n\t    drawThickLine(g, xc+wl, yc+wl, xc2  , yc+wl);\n\t    drawThickLine(g, xc+wl, yc   , xc+wl, yc+wl);\n\t    break;\n\tcase WF_PULSE:\n\t    yc += wl/2;\n\t    drawThickLine(g, xc-wl, yc-wl, xc-wl, yc   );\n\t    drawThickLine(g, xc-wl, yc-wl, xc-wl/2, yc-wl);\n\t    drawThickLine(g, xc-wl/2, yc-wl, xc-wl/2, yc);\n\t    drawThickLine(g, xc-wl/2, yc, xc+wl, yc);\n\t    break;\n\tcase WF_SAWTOOTH:\n\t    drawThickLine(g, xc   , yc-wl, xc-wl, yc   );\n\t    drawThickLine(g, xc   , yc-wl, xc   , yc+wl);\n\t    drawThickLine(g, xc   , yc+wl, xc+wl, yc   );\n\t    break;\n\tcase WF_TRIANGLE:\n\t{\n\t    int xl = 5;\n\t    drawThickLine(g, xc-xl*2, yc   , xc-xl, yc-wl);\n\t    drawThickLine(g, xc-xl, yc-wl, xc, yc);\n\t    drawThickLine(g, xc   , yc, xc+xl, yc+wl);\n\t    drawThickLine(g, xc+xl, yc+wl, xc+xl*2, yc);\n\t    break;\n\t}\n\tcase WF_AC:\n\t{\n\t    int i;\n\t    int xl = 10;\n\t    int ox = -1, oy = -1;\n\t    for (i = -xl; i <= xl; i++) {\n\t\tint yy = yc+(int) (.95*Math.sin(i*pi/xl)*wl);\n\t\tif (ox != -1)\n\t\t    drawThickLine(g, ox, oy, xc+i, yy);\n\t\tox = xc+i; oy = yy;\n\t    }\n\t    break;\n\t}\n\t}\n\tif (sim.showValuesCheckItem.getState()) {\n\t    String s = getShortUnitText(frequency, \"Hz\");\n\t    if (dx == 0 || dy == 0)\n\t\tdrawValues(g, s, circleSize);\n\t}\n    }\n\t\n    int getVoltageSourceCount() {\n\treturn 1;\n    }\n    double getPower() { return -getVoltageDiff()*current; }\n    double getVoltageDiff() { return volts[1] - volts[0]; }\n    void getInfo(String arr[]) {\n\tswitch (waveform) {\n\tcase WF_DC: case WF_VAR:\n\t    arr[0] = \"voltage source\"; break;\n\tcase WF_AC:       arr[0] = \"A/C source\"; break;\n\tcase WF_SQUARE:   arr[0] = \"square wave gen\"; break;\n\tcase WF_PULSE:    arr[0] = \"pulse gen\"; break;\n\tcase WF_SAWTOOTH: arr[0] = \"sawtooth gen\"; break;\n\tcase WF_TRIANGLE: arr[0] = \"triangle gen\"; break;\n\t}\n\tarr[1] = \"I = \" + getCurrentText(getCurrent());\n\tarr[2] = ((this instanceof RailElm) ? \"V = \" : \"Vd = \") +\n\t    getVoltageText(getVoltageDiff());\n\tif (waveform != WF_DC && waveform != WF_VAR) {\n\t    arr[3] = \"f = \" + getUnitText(frequency, \"Hz\");\n\t    arr[4] = \"Vmax = \" + getVoltageText(maxVoltage);\n\t    int i = 5;\n\t    if (bias != 0)\n\t\tarr[i++] = \"Voff = \" + getVoltageText(bias);\n\t    else if (frequency > 500)\n\t\tarr[i++] = \"wavelength = \" +\n\t\t    getUnitText(2.9979e8/frequency, \"m\");\n\t    arr[i++] = \"P = \" + getUnitText(getPower(), \"W\");\n\t}\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(waveform == WF_DC ? \"Voltage\" :\n\t\t\t\t\"Max Voltage\", maxVoltage, -20, 20);\n\tif (n == 1) {\n\t    EditInfo ei =  new EditInfo(\"Waveform\", waveform, -1, -1);\n\t    ei.choice = new Choice();\n\t    ei.choice.add(\"D/C\");\n\t    ei.choice.add(\"A/C\");\n\t    ei.choice.add(\"Square Wave\");\n\t    ei.choice.add(\"Triangle\");\n\t    ei.choice.add(\"Sawtooth\");\n\t    ei.choice.add(\"Pulse\");\n\t    ei.choice.select(waveform);\n\t    return ei;\n\t}\n\tif (waveform == WF_DC)\n\t    return null;\n\tif (n == 2)\n\t    return new EditInfo(\"Frequency (Hz)\", frequency, 4, 500);\n\tif (n == 3)\n\t    return new EditInfo(\"DC Offset (V)\", bias, -20, 20);\n\tif (n == 4)\n\t    return new EditInfo(\"Phase Offset (degrees)\", phaseShift*180/pi,\n\t\t\t\t-180, 180).setDimensionless();\n\tif (n == 5 && waveform == WF_SQUARE)\n\t    return new EditInfo(\"Duty Cycle\", dutyCycle*100, 0, 100).\n\t\tsetDimensionless();\n\treturn null;\n    }\n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0)\n\t    maxVoltage = ei.value;\n\tif (n == 3)\n\t    bias = ei.value;\n\tif (n == 2) {\n\t    // adjust time zero to maintain continuity ind the waveform\n\t    // even though the frequency has changed.\n\t    double oldfreq = frequency;\n\t    frequency = ei.value;\n\t    double maxfreq = 1/(8*sim.timeStep);\n\t    if (frequency > maxfreq)\n\t\tfrequency = maxfreq;\n\t    double adj = frequency-oldfreq;\n\t    freqTimeZero = sim.t-oldfreq*(sim.t-freqTimeZero)/frequency;\n\t}\n\tif (n == 1) {\n\t    int ow = waveform;\n\t    waveform = ei.choice.getSelectedIndex();\n\t    if (waveform == WF_DC && ow != WF_DC) {\n\t\tei.newDialog = true;\n\t\tbias = 0;\n\t    } else if (waveform != WF_DC && ow == WF_DC) {\n\t\tei.newDialog = true;\n\t    }\n\t    if ((waveform == WF_SQUARE || ow == WF_SQUARE) &&\n\t\twaveform != ow)\n\t\tei.newDialog = true;\n\t    setPoints();\n\t}\n\tif (n == 4)\n\t    phaseShift = ei.value*pi/180;\n\tif (n == 5)\n\t    dutyCycle = ei.value*.01;\n    }\n}\n"
  },
  {
    "path": "src/WireElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class WireElm extends ResistorElm {\n\tpublic static boolean ideal = false;\n\tprivate static final double defaultResistance = 1E-06;\n\tpublic WireElm(int xx, int yy) { super(xx, yy); resistance = defaultResistance; }\n\tpublic WireElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, new StringTokenizer(\"0.0\"));\n\t    resistance = defaultResistance;\n\t}\n\tstatic final int FLAG_SHOWCURRENT = 1;\n\tstatic final int FLAG_SHOWVOLTAGE = 2;\n\tvoid draw(Graphics g) {\n\t    setVoltageColor(g, volts[0]);\n\t    drawThickLine(g, point1, point2);\n\t    doDots(g);\n\t    setBbox(point1, point2, 3);\n\t    if (mustShowCurrent()) {\n\t        String s = getShortUnitText(Math.abs(getCurrent()), \"A\");\n\t        drawValues(g, s, 4);\n\t    } else if (mustShowVoltage()) {\n\t        String s = getShortUnitText(volts[0], \"V\");\n\t        drawValues(g, s, 4);\n\t    }\n\t    drawPosts(g);\n\t}\n\n\tvoid calculateCurrent() {\n\t    if (!ideal) {\n\t\tsuper.calculateCurrent();\n\t    }\n\t}\n\tvoid stamp() {\n\t    if (ideal) {\n\t\tsim.stampVoltageSource(nodes[0], nodes[1], voltSource, 0);\n\t    } else {\n\t\tsim.stampResistor(nodes[0], nodes[1], resistance);\n\t    }\n\t}\n\tboolean mustShowCurrent() {\n\t    return (flags & FLAG_SHOWCURRENT) != 0;\n\t}\n\tboolean mustShowVoltage() {\n\t    return (flags & FLAG_SHOWVOLTAGE) != 0;\n\t}\n\tint getVoltageSourceCount() {\n\t    if(ideal) {\n\t\treturn 1;\n\t    } else {\n\t\treturn super.getVoltageSourceCount();\n\t    }\n\t}\n\tvoid getInfo(String arr[]) {\n\t    arr[0] = \"wire\";\n\t    arr[1] = \"I = \" + getCurrentDText(getCurrent());\n\t    arr[2] = \"V = \" + getVoltageText(volts[0]);\n\t}\n\tdouble getPower() {\n\t    if (ideal) {\n\t\treturn 0;\n\t    } else {\n\t\treturn super.getPower();\n\t    }\n\t}\n\tdouble getVoltageDiff() {\n\t    if (ideal) {\n\t\treturn volts[0];\n\t    } else {\n\t\treturn super.getVoltageDiff();\n\t    }\n\t}\n\tboolean isWire() {\n\t    return ideal;\n\t}\n\tpublic EditInfo getEditInfo(int n) {\n\t    if (n == 0) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Show Current\", mustShowCurrent());\n\t\treturn ei;\n\t    }\n\t    if (n == 1) {\n\t\tEditInfo ei = new EditInfo(\"\", 0, -1, -1);\n\t\tei.checkbox = new Checkbox(\"Show Voltage\", mustShowVoltage());\n\t\treturn ei;\n\t    }\n\t    return null;\n\t}\n\tpublic void setEditValue(int n, EditInfo ei) {\n\t    if (n == 0) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags = FLAG_SHOWCURRENT;\n\t\telse\n\t\t    flags &= ~FLAG_SHOWCURRENT;\n\t    }\n\t    if (n == 1) {\n\t\tif (ei.checkbox.getState())\n\t\t    flags = FLAG_SHOWVOLTAGE;\n\t\telse\n\t\t    flags &= ~FLAG_SHOWVOLTAGE;\n\t    }\n\t}\n        int getShortcut() { return 'w'; }\n\tint getDumpType() { return 'w'; }\n\tString dump() {\n\t    int t = getDumpType();\n\t    return (t < 127 ? ((char)t)+\" \" : t+\" \") + x + \" \" + y + \" \" +\n\t\tx2 + \" \" + y2 + \" \" + flags;\n\t}\n    }\n"
  },
  {
    "path": "src/XorGateElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n    class XorGateElm extends OrGateElm {\n\tpublic XorGateElm(int xx, int yy) { super(xx, yy); }\n\tpublic XorGateElm(int xa, int ya, int xb, int yb, int f,\n\t\t\t  StringTokenizer st) {\n\t    super(xa, ya, xb, yb, f, st);\n\t}\n\tString getGateName() { return \"XOR gate\"; }\n\tboolean calcFunction() {\n\t    int i;\n\t    boolean f = false;\n\t    for (i = 0; i != inputCount; i++)\n\t\tf ^= getInput(i);\n\t    return f;\n\t}\n\tint getDumpType() { return 154; }\n\tint getShortcut() { return '4'; }\n    }\n"
  },
  {
    "path": "src/ZenerElm.java",
    "content": "import java.awt.*;\nimport java.util.StringTokenizer;\n\n// Zener code contributed by J. Mike Rollins\n// http://www.camotruck.net/rollins/simulator.html\nclass ZenerElm extends DiodeElm {\n    public ZenerElm(int xx, int yy) {\n\tsuper(xx, yy);\n\tzvoltage = default_zvoltage;\n\tsetup();\n    }\n    public ZenerElm(int xa, int ya, int xb, int yb, int f,\n\t\t    StringTokenizer st) {\n\tsuper(xa, ya, xb, yb, f, st);\n\tzvoltage = new Double(st.nextToken()).doubleValue();\n\tsetup();\n    }\n    void setup() {\n\tdiode.leakage = 5e-6; // 1N4004 is 5.0 uAmp\n\tsuper.setup();\n    }\n    int getDumpType() { return 'z'; }\n    String dump() {\n\treturn super.dump() + \" \" + zvoltage;\n    }\n\t\n    final int hs = 8;\n    Polygon poly;\n    Point cathode[];\n    Point wing[];\n\t\n    void setPoints() {\n\tsuper.setPoints();\n\tcalcLeads(16);\n\tcathode = newPointArray(2);\n\twing = newPointArray(2);\n\tPoint pa[] = newPointArray(2);\n\tinterpPoint2(lead1, lead2, pa[0], pa[1], 0, hs);\n\tinterpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs);\n\tinterpPoint(cathode[0], cathode[1], wing[0], -0.2, -hs);\n\tinterpPoint(cathode[1], cathode[0], wing[1], -0.2, -hs);\n\tpoly = createPolygon(pa[0], pa[1], lead2);\n    }\n\t\n    void draw(Graphics g) {\n\tsetBbox(point1, point2, hs);\n\n\tdouble v1 = volts[0];\n\tdouble v2 = volts[1];\n\n\tdraw2Leads(g);\n\n\t// draw arrow thingy\n\tsetPowerColor(g, true);\n\tsetVoltageColor(g, v1);\n\tg.fillPolygon(poly);\n\n\t// draw thing arrow is pointing to\n\tsetVoltageColor(g, v2);\n\tdrawThickLine(g, cathode[0], cathode[1]);\n\n\t// draw wings on cathode\n\tdrawThickLine(g, wing[0], cathode[0]);\n\tdrawThickLine(g, wing[1], cathode[1]);\n\t    \n\tdoDots(g);\n\tdrawPosts(g);\n    }\n\t\n    final double default_zvoltage = 5.6;\n\n    void getInfo(String arr[]) {\n\tsuper.getInfo(arr);\n\tarr[0] = \"Zener diode\";\n\tarr[5] = \"Vz = \" + getVoltageText(zvoltage);\n    }\n    public EditInfo getEditInfo(int n) {\n\tif (n == 0)\n\t    return new EditInfo(\"Fwd Voltage @ 1A\", fwdrop, 10, 1000);\n\tif (n == 1)\n\t    return new EditInfo(\"Zener Voltage @ 5mA\", zvoltage, 1, 25);\n\treturn null;\n    } \n    public void setEditValue(int n, EditInfo ei) {\n\tif (n == 0)\n\t    fwdrop = ei.value;\n\tif (n == 1)\n\t    zvoltage = ei.value;\n\tsetup();\n    }\n    int getShortcut() { return 0; }\n}\n"
  },
  {
    "path": "src/circuits/3-cgand.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 50 5.0 50\nf 352 416 464 416 6 3.25\nf 352 368 464 368 6 3.25\nw 464 384 464 400 0\nf 304 304 352 304 7 -1.75\nf 224 304 272 304 7 -1.75\nw 352 320 352 336 0\nw 272 320 272 336 0\nw 272 336 352 336 0\nw 352 336 464 336 0\nw 464 336 464 352 0\nw 272 272 272 288 0\nw 272 272 352 272 0\nw 352 272 352 288 0\nf 304 240 352 240 6 -1.75\nf 304 192 352 192 6 -1.75\nw 352 256 352 272 0\nw 352 208 352 224 0\nR 352 176 352 144 0 0 40.0 2.5 0.0 0.0 0.5\nw 304 192 224 192 0\nw 224 192 224 304 0\nw 304 240 304 304 0\nw 304 240 192 240 0\nw 192 240 192 368 0\nw 192 368 352 368 0\nw 160 192 224 192 0\nw 160 192 160 416 0\nw 160 416 352 416 0\ng 464 432 464 448 0\nf 368 112 416 112 7 3.25\nf 400 64 464 64 7 3.25\nw 464 16 464 48 0\nw 416 16 416 96 0\nw 416 16 464 16 0\nw 464 240 464 336 0\nw 400 64 160 64 0\nw 160 64 160 192 0\nw 192 240 192 112 0\nw 192 112 368 112 0\nR 416 16 368 16 0 0 40.0 5.0 0.0 0.0 0.5\nw 416 128 416 144 0\nw 416 144 464 144 0\nw 464 144 464 80 0\nw 464 144 464 240 0\nM 464 240 528 240 1 2.5\nL 160 192 96 192 1 2 false 5.0 0.0\nL 192 240 96 240 1 1 false 5.0 0.0\n"
  },
  {
    "path": "src/circuits/3-cgor.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\nf 368 368 480 368 6 3.25\nw 480 384 480 400 0\nw 368 320 368 336 0\nw 288 320 288 336 0\nw 288 336 368 336 0\nw 480 336 480 352 0\nw 288 272 288 288 0\nw 288 272 368 272 0\nw 368 272 368 288 0\nw 368 256 368 272 0\nw 368 208 368 224 0\nR 368 176 368 144 0 0 40.0 2.5 0.0 0.0 0.5\nw 320 192 240 192 0\nw 240 192 240 304 0\nw 320 240 320 304 0\nw 320 240 208 240 0\nw 208 240 208 368 0\nw 208 368 368 368 0\nw 176 192 240 192 0\nw 176 192 176 416 0\nw 176 416 368 416 0\nf 416 64 480 64 7 3.25\nw 480 16 480 48 0\nw 432 16 480 16 0\nw 480 240 480 336 0\nM 480 240 544 240 1 2.5\nw 416 64 176 64 0\nw 176 64 176 192 0\nw 208 240 208 112 0\nL 176 192 80 192 1 2 false 5.0 0.0\nL 208 240 80 240 1 1 false 5.0 0.0\nR 432 16 384 16 0 0 40.0 5.0 0.0 0.0 0.5\nw 480 144 480 240 0\nf 416 112 480 112 7 3.25\nw 480 80 480 96 0\nw 480 128 480 144 0\nw 208 112 416 112 0\nf 368 416 432 416 6 3.25\ng 480 400 480 416 0\ng 432 432 432 448 0\nw 368 336 432 336 0\nw 432 336 432 400 0\nw 432 336 480 336 0\nf 240 304 288 304 6 -1.75\nf 320 304 368 304 6 -1.75\nf 320 192 368 192 7 -1.75\nf 320 240 368 240 7 -1.75\n"
  },
  {
    "path": "src/circuits/3-f211.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\nf 288 288 352 288 6 -1.75\nw 352 272 352 240 0\nw 352 240 352 208 0\nf 288 192 352 192 7 3.25\nw 288 192 288 240 0\nw 288 240 288 288 0\nR 352 176 352 128 0 0 40.0 5.0 0.0 0.0 0.5\nM 352 240 400 240 1 2.5\nL 288 240 240 240 1 0 false 5.0 0.0\nR 352 304 352 352 0 0 40.0 2.5 0.0 0.0 0.5\n"
  },
  {
    "path": "src/circuits/3-f220.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\nf 288 288 352 288 6 3.25\nw 352 272 352 240 0\nw 352 240 352 208 0\nf 288 192 352 192 7 0.75\nw 288 192 288 240 0\nw 288 240 288 288 0\nR 352 176 352 128 0 0 40.0 5.0 0.0 0.0 0.5\nM 352 240 400 240 1 2.5\nL 288 240 240 240 1 0 false 5.0 0.0\ng 352 304 352 336 0\n"
  },
  {
    "path": "src/circuits/3-f221.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\nf 288 288 352 288 6 0.75\nw 352 272 352 240 0\nw 352 240 352 208 0\nf 288 192 352 192 7 0.75\nw 288 192 288 240 0\nw 288 240 288 288 0\nR 352 176 352 128 0 0 40.0 5.0 0.0 0.0 0.5\nM 352 240 400 240 1 2.5\nL 288 240 240 240 1 0 false 5.0 0.0\nR 352 304 352 352 0 0 40.0 2.5 0.0 0.0 0.5\n"
  },
  {
    "path": "src/circuits/3-invert.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\nf 336 352 384 352 6 3.25\nf 256 272 304 272 6 -1.75\nf 256 208 304 208 7 -1.75\nw 304 320 384 320 0\nw 384 320 384 336 0\nw 256 272 256 352 0\nw 256 352 336 352 0\nw 304 224 304 256 0\nR 304 192 304 160 0 0 40.0 2.5 0.0 0.0 0.5\nf 256 128 384 128 7 3.25\nw 256 128 256 208 0\nR 384 112 384 80 0 0 40.0 5.0 0.0 0.0 0.5\ng 384 368 384 400 0\nw 384 240 384 320 0\nw 384 144 384 240 0\nM 384 240 448 240 1 2.5\nw 256 272 256 240 0\nw 256 240 256 208 0\nL 256 240 192 240 1 2 false 5.0 0.0\nw 304 288 304 320 0\n"
  },
  {
    "path": "src/circuits/3way.txt",
    "content": "$ 1 5.0E-6 3 44 120.0 15\nv 32 320 32 80 0 1 60.0 120.0 0.0\nr 496 80 496 320 0 150.0\nw 32 80 112 80 0\nw 416 80 496 80 0\nS 112 208 192 208 0 true false 0\nw 112 80 112 208 0\nw 416 80 416 208 0\nS 416 208 336 208 0 false false 0\nw 192 192 336 192 0\nw 336 224 192 224 0\nw 32 320 496 320 0\n"
  },
  {
    "path": "src/circuits/4way.txt",
    "content": "$ 1 5.0E-6 3 44 120.0 15\nv 32 320 32 80 0 1 60.0 120.0 0.0\nr 480 80 480 320 0 150.0\nw 32 80 80 80 0\nS 336 176 240 176 0 false false 2\nS 336 240 240 240 0 false false 2\nw 432 80 480 80 0\nw 32 320 80 320 0\nw 80 320 480 320 0\nw 208 256 240 256 0\nw 208 160 240 160 0\nw 240 192 240 224 0\nS 80 208 176 208 0 false false 0\nw 80 80 80 208 0\nw 176 224 240 224 0\nw 208 160 208 192 0\nw 176 192 208 192 0\nw 208 192 208 256 0\nS 432 208 336 208 0 false false 0\nw 336 176 336 192 0\nw 336 224 336 240 0\nw 432 80 432 208 0\n"
  },
  {
    "path": "src/circuits/555int.txt",
    "content": "$ 3 5.0E-6 5 64 7.0\na 288 168 384 168 1 5.0 0.0\na 288 264 384 264 1 5.0 0.0\nr 240 56 240 104 0 5000.0\nr 240 104 240 152 0 5000.0\nw 240 152 240 280 0\nr 240 280 240 328 0 5000.0\ng 240 328 240 336 0\nw 240 152 288 152 0\nw 240 104 272 104 0\nw 272 104 272 280 0\nw 272 280 288 280 0\nw 464 176 464 192 0\nw 384 184 384 192 0\nw 384 192 464 240 0\nw 464 240 464 256 0\nw 384 240 384 248 0\nw 384 240 464 192 0\nR 240 56 240 24 0 0 40.0 10.0 0.0\nR 88 56 88 24 0 0 40.0 10.0 0.0\nr 88 56 88 120 0 10000.0\nr 88 120 88 184 0 10000.0\nw 88 120 216 120 0\nw 216 120 216 352 0\nw 88 184 88 248 0\nc 88 248 88 352 0 3.0E-7 0\ng 88 352 88 368 0\nr 384 368 464 368 0 10000.0\nw 464 176 496 176 0\nw 464 368 496 368 0\n153 384 256 464 256 1 2 5.0\n153 384 176 464 176 1 2 0.0\nw 496 176 496 368 0\nO 464 256 544 256 0\nw 88 184 288 184 0\nw 88 248 288 248 0\nt 328 368 296 368 0 1 -7.876671689823544 4.999999997999999E-10\nw 216 352 296 352 0\ng 296 384 296 400 0\nw 328 368 384 368 0\nx 120 115 136 115 0 16 discharge\nx 129 178 145 178 0 16 trigger\nx 120 242 136 242 0 16 threshold\nw 272 104 272 56 0\nx 284 62 300 62 0 16 control\no 24 16 0 3 10.0 7.8125E-4 0\no 32 32 0 10 5.0 9.765625E-5 1\n"
  },
  {
    "path": "src/circuits/555lowduty.txt",
    "content": "$ 1 5.0E-6 10 69 10.0 50\n165 224 144 272 144 0 0.0\nw 224 176 192 176 0\nr 192 176 192 240 0 150000.0\nw 192 240 224 240 0\nw 192 240 192 272 0\nw 192 272 224 272 0\nw 192 272 192 336 0\nc 192 336 192 384 0 1.0E-7 4.232783461263634\ng 192 384 192 400 0\nr 192 336 304 336 0 10000.0\nd 352 336 304 336 0\nw 352 208 352 336 0\nR 288 112 288 80 0 0 40.0 10.0 0.0\nO 352 208 416 208 0\no 7 16 0 3 10.0 0.0015625 0\no 13 64 0 10 10.0 9.765625E-5 1\n"
  },
  {
    "path": "src/circuits/555missing.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 56 5.0 50\n165 336 176 448 176 0 5.0\nw 336 208 336 304 0\nw 336 208 304 208 0\nw 304 208 304 304 0\nc 304 304 304 368 0 9.999999999999999E-6 -0.21686387276521343\ng 304 368 304 384 0\nr 304 208 304 144 0 1000.0\nw 304 144 400 144 0\nO 464 240 528 240 0\n82 304 144 304 96 0 0 40.0 5.0 0.0 0.0 0.5\nt 208 336 256 336 0 -1 0.0 0.21686387276521343\nw 256 320 256 304 0\nr 256 304 304 304 0 100\nw 256 352 256 368 0\nw 256 368 304 368 0\nw 208 272 208 336 0\n152 96 272 208 272 0 2 0.0\n82 96 288 96 336 0 2 60.0 2.5 2.5 0.0 0.5\nL 96 256 96 208 0 true false 5.0 0.0\nw 208 272 336 272 0\no 19 64 0 6 5.0 9.765625E-5 0 input\no 8 64 0 6 5.0 9.765625E-5 0 output\n"
  },
  {
    "path": "src/circuits/555monostable.txt",
    "content": "$ 1 5.0E-6 10 56 5.0 50\n165 208 144 320 144 0 0.0\nw 208 176 208 272 0\nw 208 176 176 176 0\nw 208 240 128 240 0\nw 176 176 176 272 0\nc 176 272 176 320 0 9.999999999999999E-6 0.04950495049504963\ng 176 320 176 336 0\nr 176 176 176 112 0 1000.0\nw 176 112 272 112 0\nR 128 112 48 112 0 0 40.0 5.0 0.0\nO 336 208 400 208 0\nr 128 112 128 240 0 100.0\nw 128 112 176 112 0\nc 128 240 80 240 0 1.0E-5 0.7835212122555424\nL 80 240 48 240 0 false true 5.0 0.0\no 14 64 0 6 5.0 9.765625E-5 0\no 10 64 0 6 5.0 9.765625E-5 0\nh 2 7 5\n"
  },
  {
    "path": "src/circuits/555pulsemod.txt",
    "content": "$ 1 5.0E-6 4.8 56 5.0 50\n165 240 128 256 128 0 5.0\nR 304 96 304 80 0 0 40.0 5.0 0.0\nR 304 288 304 336 0 3 20.0 2.0 3.0\nO 368 192 416 192 0\nw 240 160 208 160 0\nr 208 160 208 96 0 300.0\nw 208 96 304 96 0\nw 208 256 240 256 0\nc 208 256 208 304 0 3.0E-6 2.1430988725222426\ng 208 304 208 320 0\nw 208 224 208 256 0\nw 208 224 240 224 0\nr 208 160 208 224 0 300.0\no 2 32 0 6 5.0 3.90625E-4 0 ctl\no 3 32 0 6 5.0 9.765625E-5 0 output\n"
  },
  {
    "path": "src/circuits/555saw.txt",
    "content": "$ 1 5.0E-6 16.817414165184545 66 15.0 50\nr 240 112 240 48 0 39000.0\nr 192 128 192 48 0 27000.0\nr 192 128 192 208 0 120000.0\nw 192 48 240 48 0\nR 192 48 144 48 0 0 40.0 15.0 0.0 0.0 0.5\nw 240 144 240 208 1\ng 192 208 192 224 0\nw 240 208 240 272 0\nw 240 272 240 304 0\nw 240 304 240 368 0\nc 240 368 240 400 0 2.0E-7 5.858523256602457\ng 240 400 240 416 0\nr 240 208 288 208 0 10000.0\nw 288 272 240 272 0\nw 240 304 288 304 0\nw 240 48 352 48 0\nw 352 48 352 144 0\nO 240 368 468 368 0\nt 192 128 240 128 0 -1 6.398899615692838 -0.5042009986318234 100.0\n165 288 176 304 176 2 15.0\nw 352 48 416 48 0\nw 416 48 416 208 0\no 17 64 0 42 11.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/555schmitt.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 56 5.0 50\n165 304 160 416 160 0 0.0\nw 256 128 368 128 0\nR 256 128 144 128 0 0 40.0 5.0 0.0\nO 432 224 496 224 0\nw 256 288 256 256 0\nw 256 256 304 256 0\nw 256 288 304 288 0\nv 256 256 192 256 0 1 400.0 1 0.0\nR 192 256 144 256 0 1 40.0 2.5 2.5\np 256 288 256 336 0\ng 256 336 256 352 0\no 9 64 0 6 6.1 9.765625E-5 0\no 3 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/555sequencer.txt",
    "content": "$ 3 5.0E-6 2.800975890892825 50 5.0 50\n165 160 208 168 208 1 -0.0\nw 160 224 152 224 0\nw 152 224 152 272 0\nw 152 272 160 272 0\nc 152 272 152 336 0 2.0E-6 0.04950495049504953\nw 152 224 152 192 0\nr 152 192 152 136 0 1000.0\nr 112 192 112 136 0 100.0\nw 112 192 112 256 0\nw 112 256 160 256 0\nc 112 256 72 256 0 1.0E-5 4.534530440025719E-8\nL 72 256 48 256 0 false true 5.0 0.0\nw 112 136 152 136 0\nw 152 136 192 136 0\nw 192 136 192 192 0\n82 112 136 48 136 0 0 40.0 5.0 0.0 0.0 0.5\ng 152 336 152 352 0\nw 224 240 224 256 0\nc 224 256 272 256 0 1.0E-5 -4.9999993594834615\nw 272 256 272 192 0\nr 272 136 272 192 0 100.0\nr 312 136 312 192 0 1000.0\nw 192 136 272 136 0\nw 272 136 312 136 0\n165 320 208 352 208 1 -0.0\nw 352 192 352 136 0\nw 352 136 312 136 0\nw 312 224 320 224 0\nw 312 192 312 224 0\nw 312 224 312 272 0\nw 312 272 320 272 0\nw 272 256 320 256 0\nc 312 272 312 336 0 2.0E-6 0.04950495049504953\ng 312 336 312 352 0\nw 384 240 384 256 0\nc 384 256 432 256 0 1.0E-5 -4.9999935925136505\nw 432 256 432 192 0\nr 432 192 432 136 0 100.0\nr 472 136 472 192 0 1000.0\nw 352 136 432 136 0\nw 432 136 472 136 0\n165 480 208 488 208 1 0.0\nw 472 192 472 224 0\nw 472 224 480 224 0\nw 472 224 472 272 0\nw 472 272 480 272 0\nw 512 192 512 136 0\nw 512 136 472 136 0\nw 432 256 480 256 0\nc 472 272 472 336 0 2.0E-6 0.04950495049504953\ng 472 336 472 352 0\nM 224 256 224 328 0 2.5\nM 384 256 384 328 0 2.5\nM 544 240 584 240 0 2.5\no 11 16 0 38 5.1 0.0015625 0 -1\no 51 16 0 38 7.781982421875E-5 4.8828125E-5 0 -1\no 52 16 0 38 5.1 9.765625E-5 0 -1\no 53 16 0 38 5.1 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/555square.txt",
    "content": "$ 1 5.0E-6 5.023272298708815 64 7.0 50\nw 272 176 240 176 0\nr 240 176 240 240 0 10000.0\nw 240 240 272 240 0\nw 240 240 240 272 0\nw 240 272 272 272 0\nc 240 272 240 336 0 3.0E-7 6.6394202099608295\ng 240 336 240 352 0\nr 240 176 240 112 0 10000.0\nw 240 112 336 112 0\nR 240 112 176 112 0 0 40.0 10.0 0.0 0.0 0.5\nO 400 208 464 208 0\n165 272 144 288 144 2 10.0\nw 336 112 400 112 0\nw 400 112 400 176 0\no 5 32 0 35 10.0 0.0015625 0 -1\no 10 32 0 42 10.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/7segdecoder.txt",
    "content": "$ 3 5.0E-6 10.20027730826997 50 5.0 50\r\nL 240 40 240 16 2 0 false 5.0 0.0\r\nL 288 40 288 16 2 1 false 5.0 0.0\r\nL 336 40 336 16 2 0 false 5.0 0.0\r\nL 384 40 384 16 2 1 false 5.0 0.0\r\nI 240 40 240 88 0 0.5\r\nI 288 40 288 88 0 0.5\r\nI 336 40 336 88 0 0.5\r\nI 384 40 384 88 0 0.5\r\nw 288 40 312 40 0\r\nw 312 40 312 104 0\r\n151 40 176 40 224 1 4 0.0\r\n151 96 176 96 224 1 3 5.0\r\n151 152 176 152 224 1 2 5.0\r\n151 208 176 208 224 1 4 5.0\r\n151 568 176 568 224 1 3 5.0\r\n151 520 176 520 224 1 3 5.0\r\n151 472 176 472 224 1 3 5.0\r\n151 424 176 424 224 1 3 5.0\r\n151 368 176 368 224 1 3 5.0\r\n150 272 176 272 224 1 2 5.0\r\n152 320 176 320 224 1 2 5.0\r\nw 312 104 88 104 0\r\nw 88 104 88 176 0\r\nw 312 104 480 104 0\r\nw 480 104 528 104 0\r\nw 528 104 576 104 0\r\nw 576 104 576 176 0\r\nw 528 176 528 104 0\r\nw 480 176 480 104 0\r\nw 336 40 360 40 0\r\nw 360 40 360 112 0\r\nw 160 176 160 112 0\r\nw 96 176 96 112 0\r\nw 96 112 160 112 0\r\nw 160 112 360 112 0\r\nw 360 112 424 112 0\r\nw 424 112 424 176 0\r\nw 424 112 568 112 0\r\nw 568 112 568 176 0\r\nw 384 40 408 40 0\r\nw 408 40 408 120 0\r\nw 408 120 520 120 0\r\nw 520 120 520 176 0\r\nw 408 120 376 120 0\r\nw 376 176 376 120 0\r\nw 376 120 224 120 0\r\nw 224 120 224 176 0\r\nw 224 120 104 120 0\r\nw 104 120 104 176 0\r\nw 240 88 240 128 0\r\nw 240 128 216 128 0\r\nw 216 128 216 176 0\r\nw 216 128 24 128 0\r\nw 24 128 24 176 0\r\nw 240 128 328 128 0\r\nw 328 128 328 176 0\r\nw 288 88 288 136 0\r\nw 280 176 280 136 0\r\nw 280 136 288 136 0\r\nw 200 176 200 136 0\r\nw 280 136 200 136 0\r\nw 200 136 144 136 0\r\nw 144 136 144 176 0\r\nw 144 136 32 136 0\r\nw 32 136 32 176 0\r\nw 288 136 360 136 0\r\nw 360 136 360 176 0\r\nw 360 136 432 136 0\r\nw 432 136 432 176 0\r\nw 336 88 336 144 0\r\nw 336 144 368 144 0\r\nw 368 144 368 176 0\r\nw 368 144 472 144 0\r\nw 472 144 472 176 0\r\nw 336 144 264 144 0\r\nw 264 144 264 176 0\r\nw 264 144 192 144 0\r\nw 192 144 192 176 0\r\nw 192 144 48 144 0\r\nw 48 144 48 176 0\r\nw 384 88 384 152 0\r\nw 472 144 512 144 0\r\nw 512 144 512 176 0\r\nw 384 152 416 152 0\r\nw 416 152 416 176 0\r\nw 416 152 464 152 0\r\nw 464 152 464 176 0\r\nw 464 152 560 152 0\r\nw 560 152 560 176 0\r\nw 384 152 240 152 0\r\nw 240 152 56 152 0\r\nw 56 152 56 176 0\r\nw 272 224 296 224 0\r\nw 296 224 296 176 0\r\nw 296 176 312 176 0\r\n150 56 288 56 336 1 4 0.0\r\n150 232 288 232 336 1 4 5.0\r\n150 384 288 384 336 1 4 5.0\r\n150 336 288 336 336 1 3 5.0\r\n150 288 288 288 336 1 2 5.0\r\n150 176 288 176 336 1 3 5.0\r\n150 120 288 120 336 1 4 5.0\r\nw 40 224 40 288 0\r\nw 240 152 240 232 0\r\nw 240 232 168 232 0\r\nw 168 232 168 288 0\r\nw 176 288 176 240 0\r\nw 176 240 240 240 0\r\nw 240 240 240 288 0\r\nw 240 240 400 240 0\r\nw 400 240 400 288 0\r\nw 400 240 472 240 0\r\nw 472 240 472 224 0\r\nw 184 288 184 256 0\r\nw 184 256 128 256 0\r\nw 128 256 128 288 0\r\nw 128 256 64 256 0\r\nw 64 256 64 288 0\r\nw 48 288 48 248 0\r\nw 72 288 72 264 0\r\nw 72 264 136 264 0\r\nw 136 264 136 288 0\r\nw 48 248 96 248 0\r\nw 96 248 96 224 0\r\nw 96 248 112 248 0\r\nw 112 248 112 288 0\r\nw 152 224 152 232 0\r\nw 152 232 104 232 0\r\nw 104 232 104 288 0\r\nw 392 288 392 248 0\r\nw 392 248 344 248 0\r\nw 344 248 344 288 0\r\nw 392 248 568 248 0\r\nw 568 248 568 224 0\r\nw 112 248 224 248 0\r\nw 224 248 224 288 0\r\nw 184 256 216 256 0\r\nw 216 256 216 288 0\r\nw 208 224 208 264 0\r\nw 136 264 208 264 0\r\nw 208 264 368 264 0\r\nw 368 264 368 288 0\r\nw 376 288 376 256 0\r\nw 376 256 328 256 0\r\nw 328 256 328 288 0\r\nw 328 256 280 256 0\r\nw 280 256 280 288 0\r\nw 320 224 328 224 0\r\nw 328 224 328 256 0\r\nw 280 256 216 256 0\r\nw 248 288 248 232 0\r\nw 248 232 368 232 0\r\nw 368 232 368 224 0\r\nw 296 288 296 272 0\r\nw 296 272 424 272 0\r\nw 424 272 424 224 0\r\nw 336 288 336 280 0\r\nw 336 280 520 280 0\r\nw 520 280 520 224 0\r\n157 432 320 552 320 0\r\nw 432 320 416 320 0\r\nw 416 320 416 336 0\r\nw 416 336 384 336 0\r\nw 432 352 336 352 0\r\nw 336 352 336 336 0\r\nw 432 384 288 384 0\r\nw 288 384 288 336 0\r\nw 432 416 232 416 0\r\nw 232 416 232 336 0\r\nw 496 448 176 448 0\r\nw 176 448 176 336 0\r\nw 528 448 528 456 0\r\nw 528 456 120 456 0\r\nw 120 456 120 336 0\r\nw 560 448 560 464 0\r\nw 560 464 56 464 0\r\nw 56 464 56 336 0\r\n"
  },
  {
    "path": "src/circuits/allpass1.txt",
    "content": "$ 1 5.0E-6 10.634267539816555 50 5.0 50\na 320 224 416 224 0 15.0 -15.0\nr 320 208 240 208 0 1000.0\nr 320 240 240 240 0 1000.0\nw 320 208 320 144 0\nr 320 144 416 144 0 1000.0\nw 416 144 416 224 0\nc 320 240 320 320 0 1.0E-6 -3.138168736927825\ng 320 320 320 336 0\nw 240 208 240 240 0\n170 240 208 192 208 3 10.0 2000.0 5.0 0.1\nO 416 224 480 224 0\no 9 8 0 34 6.0 0.00625 0 -1 input\no 10 8 0 34 6.0 9.765625E-55 0 -1 output\n"
  },
  {
    "path": "src/circuits/allpass2.txt",
    "content": "$ 1 5.0E-6 10.634267539816555 55 5.0 50\na 320 224 416 224 0 15.0 -15.0\nr 320 208 240 208 0 1000.0\nr 320 240 240 240 0 1000.0\nw 320 208 320 144 0\nr 320 144 416 144 0 1000.0\nw 416 144 416 224 0\nc 320 240 320 320 0 1.0E-6 -4.292934919713338\ng 320 320 320 336 0\nw 240 208 240 240 0\nO 416 224 480 224 0\nR 240 208 192 208 0 2 100.0 5.0 0.0 0.0 0.5\no 9 16 0 34 24.0 9.765625E-55 0 -1 output\n"
  },
  {
    "path": "src/circuits/amdetect.txt",
    "content": "$ 4 5.0E-6 25.23 50 5.0 50\nr 144 272 208 272 0 3000.0\nl 208 144 208 272 0 0.0010 0.18734471432590385\nw 208 144 272 144 0\nc 272 144 272 272 0 2.8144799999999998E-6 -2.5493952165122247\nw 208 272 272 272 0\nc 400 144 400 272 0 3.0E-7 3.6693609627456207\nw 400 144 464 144 0\nr 464 144 464 272 0 47000.0\nw 400 272 464 272 0\nw 144 144 208 144 0\nA 144 144 144 112 0\ng 144 272 144 320 0\np 144 144 144 272 0\nd 336 144 400 144 0\nw 272 144 336 144 0\nw 272 272 336 272 0\nw 336 272 400 272 0\np 336 144 336 272 0\nx 260 127 276 127 0 20 C1\nx 387 127 403 127 0 20 C2\no 12 8 0 6 40.0 9.765625E-5 0 antenna\no 17 4 0 14 10.0 9.765625E-5 1 carrier\no 7 256 0 14 10.0 9.765625E-5 2 out\nh 1 1 3\n"
  },
  {
    "path": "src/circuits/amp-dfdx.txt",
    "content": "$ 1 5.0E-6 10 57 5.0\nv 112 256 112 96 0 3 40.0 5.0 0.0\ng 112 256 112 304 0\nw 352 128 352 192 0\nw 208 128 208 176 0\nw 112 256 208 256 0\nw 208 208 208 256 0\na 208 192 352 192 4\nc 112 96 208 96 0 2.0E-6 0.16559840149986407\nr 208 128 352 128 0 5000.0\nw 208 96 208 128 0\nO 352 192 416 192 0\no 0 32 0 2 10.0 0.0125 0\no 10 64 0 2 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/amp-diff.txt",
    "content": "$ 1 5.0E-6 10 57 5.0 50\na 288 192 432 192 0 15.0 -15.0\nw 288 112 288 176 0\nw 432 192 432 112 0\nr 288 112 432 112 0 1000.0\nr 192 112 288 112 0 1000.0\nr 288 208 288 256 0 1000.0\ng 288 256 288 304 0\nr 288 208 192 208 0 1000.0\nR 192 112 128 112 0 1 60.0 5.0 0.0\nO 432 192 496 192 0\nv 192 208 128 208 0 2 120.0 1.0 0.0\nR 128 208 96 208 0 1 60.0 5.0 0.0\np 192 208 192 256 0\ng 192 256 192 304 0\no 8 64 0 2 7.0 0.025 0\no 12 64 0 2 7.0 9.765625E-5 0\no 9 64 0 2 2.5 2.44140625E-5 1\n"
  },
  {
    "path": "src/circuits/amp-follower.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 57 5.0 50\nv 96 224 96 80 0 1 40.0 5.0 0.0 0.0 0.5\ng 96 224 96 272 0\nw 192 176 192 224 0\na 192 160 320 160 1 15.0 -15.0\nw 320 160 320 224 0\nw 96 80 192 80 0\nw 192 80 192 144 0\nw 192 224 320 224 0\nO 384 160 432 160 0\nw 320 160 384 160 0\nr 384 160 384 224 0 1000.0\ng 384 224 384 272 0\no 0 64 0 34 5.0 9.765625E-5 0 -1\no 8 64 0 34 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/amp-fullrect.txt",
    "content": "$ 1 5.0E-6 16 62 1.0 50\na 176 288 272 288 0 15.0 -15.0\ng 176 304 176 336 0\nw 272 288 272 240 0\nd 272 240 176 240 0\nw 272 288 304 288 0\nd 304 192 304 288 0\nw 176 240 176 272 0\nw 176 240 176 192 0\nr 176 192 304 192 0 1000.0\nr 176 192 176 128 0 1000.0\nr 176 128 304 128 0 1000.0\nr 304 128 304 192 0 500.0\na 352 144 448 144 0 15.0 -15.0\nw 304 128 352 128 0\nw 352 128 352 96 0\nr 352 96 448 96 0 1000.0\nw 448 96 448 144 0\ng 352 160 352 192 0\nO 448 144 496 144 0\nR 176 128 128 128 0 1 40.0 1.0 0.0\no 19 64 0 2 5.0 0.1\no 18 64 0 2 5.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/amp-integ.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 57 5.0 50\ng 96 224 96 272 0\nw 336 112 336 160 0\nw 192 80 192 112 0\nw 192 112 192 144 0\nw 192 176 192 224 0\na 192 160 336 160 0 15.0 -15.0\nc 192 112 336 112 0 5.8E-6 0\nO 336 160 400 160 0\nv 96 224 96 144 0 2 40.0 5.0 0.0 3.141592653589793 0.5\nv 96 144 96 80 0 2 80.0 2.0 0.0 0.0 0.5\np 128 224 128 80 0\nw 96 224 128 224 0\nw 128 224 192 224 0\nw 96 80 128 80 0\nr 128 80 192 80 0 1000.0\no 10 32 0 34 10.0 9.765625E-5 0 -1 input\no 7 32 0 34 11.0 9.765625E-5 1 -1 integral\n"
  },
  {
    "path": "src/circuits/amp-invert.txt",
    "content": "$ 1 5.0E-6 10 57 5.0\nv 96 256 96 112 0 1 40.0 5.0 0.0\ng 96 256 96 304 0\nr 96 112 192 112 0 1000.0\nr 192 144 336 144 0 3000.0\nw 336 144 336 192 0\nw 192 112 192 144 0\nw 192 144 192 176 0\nw 96 256 192 256 0\nw 192 208 192 256 0\na 192 192 336 192 0\nO 336 192 400 192 0\no 0 64 0 2 5.0 0.025\no 10 64 0 2 20.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/amp-noninvert.txt",
    "content": "$ 1 5.0E-6 10 57 5.0\nv 96 256 96 112 0 1 40.0 5.0 0.0\ng 96 256 96 304 0\nw 192 208 192 256 0\na 192 192 336 192 1\nw 336 192 336 256 0\nr 192 256 336 256 0 2000.0\nr 96 256 192 256 0 1000.0\nw 96 112 192 112 0\nw 192 112 192 176 0\nO 336 192 400 192 0\no 0 64 0 2 5.0 9.765625E-5\no 9 64 0 2 10.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/amp-rect.txt",
    "content": "$ 1 5.0E-6 10 71 1.0\na 240 192 352 192 0\nw 240 176 240 128 0\nd 352 192 352 128 0\nw 208 176 240 176 0\nr 208 176 128 176 0 10000.0\nw 208 176 208 256 0\nw 208 256 352 256 0\nd 352 256 352 192 0\nr 240 128 352 128 0 10000.0\nR 128 176 96 176 0 1 40.0 0.5 0.0\ng 240 208 240 224 0\nO 352 128 416 128 0\no 9 64 0 2 0.625 9.765625E-5\no 11 64 0 2 0.625 4.8828125E-5\n"
  },
  {
    "path": "src/circuits/amp-schmitt.txt",
    "content": "$ 1 5.0E-6 10 66 5.0\na 320 208 432 208 0 15.0 -15.0\nw 432 208 432 272 0\nr 432 272 288 272 0 100000.0\nw 288 224 320 224 0\nw 288 224 288 272 0\nw 288 224 288 144 0\nr 288 144 288 80 0 10000.0\nr 288 272 288 336 0 10000.0\ng 288 336 288 368 0\nO 432 208 480 208 0\nR 288 80 288 48 0 0 40.0 10.0 0.0\nw 320 192 224 192 0\nv 224 192 160 192 0 1 40.0 5.0 0.0\nR 160 192 128 192 0 1 1000.0 1.0 5.0\np 224 192 224 336 0\nw 224 336 256 336 0\nw 256 336 288 336 0\np 256 224 256 336 0\nw 256 224 288 224 0\no 14 32 0 2 11.0 9.765625E-5 0 in\no 17 64 0 2 11.0 9.765625E-5 1 threshold\no 14 64 0 226 20.0 25.6 2 9 out vs in\n"
  },
  {
    "path": "src/circuits/amp-sum.txt",
    "content": "$ 1 5.0E-6 16 57 5.0 50\na 288 208 432 208 0 15.0 -15.0\nw 288 128 288 192 0\nw 432 208 432 128 0\nr 288 128 432 128 0 1000.0\nw 288 224 288 272 0\ng 288 272 288 304 0\nw 288 192 240 192 0\nw 240 192 240 160 0\nw 240 192 240 224 0\nr 240 160 176 160 0 1000.0\nr 176 224 240 224 0 1000.0\nR 176 160 128 160 0 1 200.0 5.0 0.0\nR 176 224 128 224 0 2 20.0 2.0 0.0\nO 432 208 496 208 0\no 11 64 0 2 5.0 0.025 0\no 12 64 0 2 5.0 0.0125 0\no 13 64 0 2 10.0 9.765625E-5 1\n"
  },
  {
    "path": "src/circuits/bandpass.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 5.0 46\nw 352 144 352 208 0\nw 352 288 352 336 0\nw 304 288 352 288 0\nw 352 288 400 288 0\nw 304 208 352 208 0\nw 352 208 400 208 0\nl 304 208 304 288 0 0.5 0\nc 400 208 400 288 0 3.17E-5 0\nr 240 144 352 144 0 250.0\nO 352 144 448 144 0\ng 352 336 352 352 0\n170 240 144 208 144 3 10.0 150.0 5.0 0.5\no 11 128 0 34 5.0 9.765625E-5 0 -1\no 9 128 0 34 5.0 9.765625E-5 1 -1\nh 1 6 7\n\n"
  },
  {
    "path": "src/circuits/besselbutter.txt",
    "content": "$ 1 5.0E-6 1.1685319768402522 49 5.0 50\nc 208 96 208 192 0 6.083084599140672E-6 -4.999993387010308\nl 144 96 208 96 0 0.022668006177034163 -0.09999921210610777\nw 464 96 528 96 0\nr 528 96 528 192 0 50.0\ng 208 192 208 208 0\ng 528 192 528 208 0\nO 528 96 576 96 0\nc 272 96 272 192 0 4.3948121369507934E-6 -5.000480507723924\nl 208 96 272 96 0 0.012560685575556797 -0.1000058296956149\ng 272 192 272 208 0\nc 336 96 336 192 0 3.2704856949098034E-6 -4.999333512699853\nl 272 96 336 96 0 0.009621226664444704 -0.10000178631255717\ng 336 192 336 208 0\nc 400 96 400 192 0 1.9267432478517496E-6 -4.9985368414433955\nl 336 96 400 96 0 0.006573613744873482 -0.0999748516250718\ng 400 192 400 208 0\nc 464 96 464 192 0 3.953712484972596E-7 -4.99868176000584\nl 400 96 464 96 0 0.0029400148153217306 -0.09997178060465385\ng 464 192 464 208 0\ng 464 352 464 368 0\nl 400 272 464 272 0 0.0037033695101520102 -0.10336833872744124\nc 464 272 464 352 0 4.979463676217806E-7 -5.226853560161393\ng 400 352 400 368 0\nl 336 272 400 272 0 0.0082809859705 -0.0973916022814173\nc 400 272 400 352 0 2.427517293683718E-6 -5.045542492104053\ng 336 352 336 368 0\nl 272 272 336 272 0 0.012016178653842758 -0.09363197455759392\nc 336 272 336 352 0 4.112858198910477E-6 -4.706292766508745\ng 272 352 272 368 0\nl 208 272 272 272 0 0.01442033310922977 -0.10308412962676379\nc 272 272 272 352 0 5.369543031057315E-6 -4.878852155807363\nO 528 272 576 272 0\ng 528 352 528 368 0\ng 208 352 208 368 0\nr 528 272 528 352 0 50.0\nw 464 272 528 272 0\nl 144 272 208 272 0 0.012448659190544548 -0.09950752670846397\nc 208 272 208 352 0 5.9051646250635805E-6 -5.184027928619852\nw 144 96 144 192 0\nw 144 192 144 272 0\nR 144 192 96 192 0 2 80.0 5.0 0.0 0.0 0.5\no 6 32 0 34 10.0 9.765625E-5 0 -1 bessel\no 31 32 0 34 10.0 9.765625E-5 1 -1 butterworth\n"
  },
  {
    "path": "src/circuits/blank.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\n"
  },
  {
    "path": "src/circuits/butter10lo.txt",
    "content": "$ 1 5.0E-6 5.023272298708815 49 5.0 50\nc 208 176 208 288 0 5.9051646250635805E-6 4.062633211426473\nl 144 176 208 176 0 0.012448659190544548 0.053140078678806095\nw 464 176 528 176 0\nr 528 176 528 288 0 50.0\ng 208 288 208 304 0\ng 528 288 528 304 0\nO 528 176 576 176 0\n170 144 176 112 176 2 100.0 2000.0 5.0 0.15\nc 272 176 272 288 0 5.369543031057315E-6 5.1257083029780235\nl 208 176 272 176 0 0.01442033310922977 0.09832852911113443\ng 272 288 272 304 0\nc 336 176 336 288 0 4.112858198910477E-6 4.157511982611728\nl 272 176 336 176 0 0.012016178653842758 0.09606883211091816\ng 336 288 336 304 0\nc 400 176 400 288 0 2.427517293683718E-6 2.7175532901374186\nl 336 176 400 176 0 0.0082809859705 0.06809087838027278\ng 400 288 400 304 0\nc 464 176 464 288 0 4.979463676217806E-7 1.9434101865833442\nl 400 176 464 176 0 0.0037033695101520102 0.04419890622586078\ng 464 288 464 304 0\no 6 16 0 34 10.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/cap.txt",
    "content": "$ 1 5.0E-6 16 50 5.0\nv 96 336 96 64 0 0 40.0 5.0 0.0\nS 256 144 256 64 0 false false 0\nw 96 64 240 64 0\nw 272 64 400 64 0\nw 400 64 400 336 0\nc 256 144 256 256 0 1.9999999999999996E-4 0\nr 256 256 256 336 0 100.0\nw 96 336 256 336 0\nw 256 336 400 336 0\no 5 128 0 3 5.0 0.05\nh 2 6 5\n"
  },
  {
    "path": "src/circuits/capac.txt",
    "content": "$ 1 5.0E-6 14.3 55 5.0\nv 176 256 176 80 0 1 40.0 5.0 0.0\nr 176 80 336 80 0 180.0\nc 336 80 336 256 0 3.3E-5 0.20495321439656933\nw 176 256 336 256 0\no 2 64 0 3 5.0 0.05\n"
  },
  {
    "path": "src/circuits/capmult.txt",
    "content": "$ 1 5.0E-6 18.278915558614752 60 5.0 50\na 368 192 480 192 0 15.0 -15.0 1000000.0\nw 368 176 368 128 0\nw 368 128 480 128 0\nw 480 128 480 192 0\nw 480 128 480 96 0\nr 480 96 304 96 0 1000.0\nw 304 96 304 208 0\nr 304 208 368 208 0 100000.0\nc 368 208 368 288 0 1.0E-7 2.3114879192195272\ng 368 288 368 320 0\nw 304 208 240 208 0\nR 240 208 192 208 0 2 30.0 5.0 0.0 0.0 0.5\nR 240 368 192 368 0 2 30.0 5.0 0.0 0.0 0.5\nc 240 368 304 368 0 1.0E-5 2.3114879192202653\nr 304 368 368 368 0 1000.0\ng 368 368 368 400 0\nx 377 70 407 76 0 24 R2\nx 323 180 353 186 0 24 R1\nx 415 258 447 264 0 24 C1\nx 258 408 290 414 0 24 C2\nx 319 408 349 414 0 24 R3\no 13 64 0 34 5.0 0.003125 0 -1\no 8 64 0 34 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/capmultcaps.txt",
    "content": "$ 1 5.0E-6 10 54 5.0 50\nv 176 96 176 32 0 1 80.0 5.0 0.0\nr 176 32 336 32 0 200.0\nc 336 32 336 96 0 7.999999999999999E-5 -0.5102063628995691\nw 176 96 336 96 0\nv 176 192 176 128 0 1 80.0 5.0 0.0\nr 176 128 336 128 0 200.0\nw 176 192 336 192 0\nc 336 128 336 192 0 1.0E-5 -3.485547023514335\nv 176 288 176 224 0 1 80.0 5.0 0.0\nw 176 288 336 288 0\nc 336 224 336 288 0 1.0E-6 -3.321428082201859\nr 176 224 336 224 0 200.0\no 2 64 0 1 1.25 0.05\no 7 64 0 1 5.0 0.05\no 10 64 0 1 5.0 0.05\n"
  },
  {
    "path": "src/circuits/capmultfreq.txt",
    "content": "$ 1 5.0E-6 10 54 5.0 50\nv 224 144 224 80 0 1 15.0 5.0 0.0\nr 224 80 384 80 0 200.0\nc 384 80 384 144 0 2.9999999999999997E-5 0.4703928719421789\nw 224 144 384 144 0\nv 224 240 224 176 0 1 40.0 5.0 0.0\nr 224 176 384 176 0 200.0\nw 224 240 384 240 0\nc 384 176 384 240 0 2.9999999999999997E-5 2.2457974270921146\nv 224 336 224 272 0 1 80.0 5.0 0.0\nw 224 336 384 336 0\nc 384 272 384 336 0 2.9999999999999997E-5 -1.4536204423595571\nr 224 272 384 272 0 200.0\no 2 64 0 17 2.5 0.05 0\no 7 64 0 17 2.5 0.05 1\no 10 64 0 17 2.5 0.05 2\n"
  },
  {
    "path": "src/circuits/cappar.txt",
    "content": "$ 1 5.0E-6 18 50 5.0\nv 48 336 48 64 0 0 40.0 5.0 0.0\nS 144 144 144 64 0 false false 1\nw 240 64 240 336 0\nr 48 336 144 336 0 100.0\nr 144 336 240 336 0 100.0\nw 48 64 128 64 0\nw 160 64 240 64 0\nr 288 336 384 336 0 100.0\nr 384 336 480 336 0 100.0\nw 480 64 480 336 0\nS 384 144 384 64 0 false false 1\nw 288 64 368 64 0\nw 400 64 480 64 0\nc 384 144 384 336 0 3.0E-4 0\nv 288 336 288 64 0 0 40.0 5.0 0.0\nw 144 144 144 192 0\nw 144 336 144 288 0\nw 144 288 96 288 0\nw 96 192 144 192 0\nw 144 192 192 192 0\nc 192 192 192 288 0 1.9999999999999998E-4 0\nr 144 288 192 288 0 0.01\nc 96 192 96 288 0 9.999999999999999E-5 0\n"
  },
  {
    "path": "src/circuits/capseries.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 48 336 48 64 0 0 40.0 5.0 0.0\nS 144 144 144 64 0 false false 1\nw 240 64 240 336 0\nr 48 336 144 336 0 100.0\nr 144 336 240 336 0 100.0\nc 144 144 144 240 0 0.0010 0\nc 144 240 144 336 0 9.999999999999999E-5 0\nw 48 64 128 64 0\nw 160 64 240 64 0\nr 288 336 384 336 0 100.0\nr 384 336 480 336 0 100.0\nw 480 64 480 336 0\nS 384 144 384 64 0 false false 1\nw 288 64 368 64 0\nw 400 64 480 64 0\nc 384 144 384 336 0 9.091E-5 0\nv 288 336 288 64 0 0 40.0 5.0 0.0\n"
  },
  {
    "path": "src/circuits/cc2.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n179 272 224 304 224 0 1.0\nr 368 256 480 256 0 100.0\ng 480 256 480 288 0\n172 272 288 192 288 0 6 4.5 5.0 0.0 0.0 0.5 Y Voltage\n174 272 224 208 176 0 1000.0 0.5 X Resistance\nr 240 176 144 176 0 100.0\ng 144 176 144 192 0\n"
  },
  {
    "path": "src/circuits/cc2imp.txt",
    "content": "$ 1 5.0E-6 1.1208435524800693 51 5.0 50\na 160 208 272 208 1 15.0 -15.0\nf 272 176 336 176 0 1.5\nf 272 240 336 240 1 1.5\nw 272 176 272 208 0\nw 272 208 272 240 0\nw 336 192 336 208 0\nw 336 208 336 224 0\nw 336 208 368 208 0\nw 160 288 160 224 1\nw 336 256 336 320 0\nf 400 368 336 368 0 1.5\nf 400 368 464 368 0 1.5\nw 336 320 400 320 0\nw 400 320 400 368 0\nw 336 320 336 352 0\nf 400 112 336 112 1 1.5\nf 400 112 464 112 1 1.5\nw 336 128 336 160 0\nw 336 160 400 160 0\nw 400 160 400 112 0\nw 464 128 464 208 0\nw 464 208 464 352 0\n172 160 192 96 192 0 6 2.0 4.0 -4.0 0.0 0.5 Y Voltage\n174 64 224 160 256 0 500.0 0.7079000000000001 X Resistance\nr 112 256 112 320 0 100.0\ng 112 320 112 336 0\nw 464 208 512 208 1\nr 512 208 576 208 0 100.0\ng 576 208 576 224 0\nR 336 96 336 48 0 0 40.0 10.0 0.0 0.0 0.5\nR 464 96 464 48 0 0 40.0 10.0 0.0 0.0 0.5\nR 336 384 336 432 0 0 40.0 -10.0 0.0 0.0 0.5\nR 464 384 464 432 0 0 40.0 -10.0 0.0 0.0 0.5\nw 160 288 368 288 2\nw 368 288 368 208 0\nx 94 165 109 171 0 24 Y\nx 156 326 171 332 0 24 X\nx 501 177 516 183 0 24 Z\n"
  },
  {
    "path": "src/circuits/cc2impn.txt",
    "content": "$ 1 5.0E-6 1.1208435524800693 51 5.0 50\na 144 208 240 208 1 15.0 -15.0\nf 240 176 288 176 0 1.5\nf 240 240 288 240 1 1.5\nw 240 176 240 208 0\nw 240 208 240 240 0\nw 288 192 288 208 0\nw 288 208 288 224 0\nw 288 208 336 208 0\nw 144 288 144 224 1\nw 288 256 288 320 0\nf 336 368 288 368 0 1.5\nf 336 368 384 368 0 1.5\nw 288 320 336 320 0\nw 336 320 336 368 0\nw 288 320 288 352 0\nf 336 112 288 112 1 1.5\nf 336 112 384 112 1 1.5\nw 288 128 288 160 0\nw 288 160 336 160 0\nw 336 160 336 112 0\n172 144 192 80 192 0 6 2.6399999999999997 4.0 -4.0 0.0 0.5 Y Voltage\n174 48 224 144 256 0 500.0 0.9158000000000001 X Resistance\nr 96 256 96 320 0 100.0\ng 96 320 96 336 0\nR 288 96 288 48 0 0 40.0 10.0 0.0 0.0 0.5\nR 384 96 384 48 0 0 40.0 10.0 0.0 0.0 0.5\nR 288 384 288 432 0 0 40.0 -10.0 0.0 0.0 0.5\nR 384 384 384 432 0 0 40.0 -10.0 0.0 0.0 0.5\nw 144 288 336 288 2\nw 336 288 336 208 0\nf 496 112 448 112 1 1.5\nf 496 112 544 112 1 1.5\nw 496 112 496 160 0\nw 496 160 448 160 0\nw 448 128 448 160 0\nw 384 128 384 160 0\nf 496 368 448 368 0 1.5\nf 496 368 544 368 0 1.5\nw 448 320 496 320 0\nw 496 320 496 368 0\nw 448 320 448 352 0\nw 544 352 544 208 0\nw 544 208 544 128 0\nw 384 320 384 352 0\nw 384 160 448 320 0\nw 384 320 448 160 0\nR 448 384 448 432 0 0 40.0 -10.0 0.0 0.0 0.5\nR 544 384 544 432 0 0 40.0 -10.0 0.0 0.0 0.5\nR 448 96 448 48 0 0 40.0 10.0 0.0 0.0 0.5\nR 544 96 544 48 0 0 40.0 10.0 0.0 0.0 0.5\nr 592 208 592 272 0 100.0\ng 592 272 592 288 0\nw 544 208 592 208 1\nx 99 172 114 178 0 24 Y\nx 136 327 151 333 0 24 X\nx 578 177 593 183 0 24 Z\n"
  },
  {
    "path": "src/circuits/cc2n.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n179 272 224 304 224 0 -1.0\nr 368 256 480 256 0 100.0\ng 480 256 480 288 0\n172 272 288 192 288 0 6 4.5 5.0 0.0 0.0 0.5 Y Voltage\n174 272 224 208 176 0 1000.0 0.5 X Resistance\nr 240 176 144 176 0 100.0\ng 144 176 144 192 0\n"
  },
  {
    "path": "src/circuits/ccdiff.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n179 368 160 400 160 0 1.0\nc 368 160 304 160 0 1.0E-5 0\nr 304 160 256 160 0 1.0\ng 256 160 256 176 0\nr 464 192 544 192 0 100.0\ng 544 192 544 224 0\n179 144 256 272 256 0 1.0\nr 144 256 96 256 0 100.0\ng 96 256 96 272 0\nw 368 288 368 224 0\nr 368 224 304 224 0 100.0\ng 304 224 304 240 0\nR 144 320 112 320 0 3 40.0 5.0 0.0 1.5707963267948966 0.5\nw 240 288 368 288 0\no 10 64 0 33 2.5 0.05 0 -1 input\no 4 64 0 33 0.5114672824837722 0.009 0 -1 output\n"
  },
  {
    "path": "src/circuits/cciamp.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n179 208 176 304 176 0 1.0\ni 144 304 208 304 0 0.01\ng 144 304 144 320 0\nw 208 240 208 304 0\nr 208 176 112 176 0 10.0\ng 112 176 112 192 0\ng 400 256 400 272 0\nw 208 240 144 240 0\n174 144 240 80 272 0 100.0 0.7277 Multiplier\n174 352 208 448 256 0 100.0 0.32180000000000003 Z Resistance\ng 112 272 112 288 0\nw 304 208 352 208 1\n"
  },
  {
    "path": "src/circuits/ccinductor.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 48 5.0 50\n179 240 80 256 80 1024 1.0\n179 240 256 272 256 1024 -1.0\nR 128 176 96 176 0 1 40.0 5.0 0.0 0.0 0.5\nr 128 176 224 176 0 50.0\nR 480 176 448 176 0 1 40.0 5.0 0.0 0.0 0.5\nr 480 176 544 176 0 50.0\nl 544 176 544 272 0 0.1 -0.05978684403333334\ng 544 272 544 288 0\nw 240 112 224 112 0\nw 224 112 224 176 0\nr 336 80 400 80 0 100.0\ng 400 80 400 96 0\nw 336 144 336 208 0\nw 240 288 240 208 0\nw 240 208 336 208 0\nw 336 256 384 256 0\nr 384 256 384 368 0 100.0\ng 384 368 384 384 0\nw 336 320 336 352 0\nw 336 352 224 352 0\nw 224 352 224 176 0\nw 240 288 176 288 0\nc 176 288 176 368 0 1.0E-5 5.9786844033333315\ng 176 368 176 384 0\no 2 64 0 35 5.0 0.1 0 -1\no 4 64 0 35 5.0 0.1 0 -1\n"
  },
  {
    "path": "src/circuits/ccint.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n179 368 160 400 160 0 1.0\ng 304 160 304 176 0\nr 464 192 544 192 0 100.0\ng 544 192 544 224 0\n179 144 256 272 256 0 1.0\nr 144 256 96 256 0 100.0\ng 96 256 96 272 0\nw 368 288 368 224 0\ng 304 224 304 240 0\nR 144 320 112 320 0 2 40.0 5.0 0.0 1.5707963267948966 0.5\nw 240 288 368 288 0\nc 304 224 368 224 0 1.0E-5 -5.786500000000048\nr 304 160 368 160 0 1000.0\no 10 64 0 33 20.0 0.1 0 -1 input\no 2 64 0 33 2.3384026197294445 0.046768052394588894 0 -1 output\n"
  },
  {
    "path": "src/circuits/ccitov.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 59 5.0 50\nS 224 320 224 240 0 1 false 0\nS 224 160 224 240 0 1 false 0\nw 144 160 144 240 0\nw 144 240 144 320 0\nr 144 240 208 240 0 1000.0\ni 144 160 224 160 0 0.0010\ni 144 320 224 320 0 0.0020\nO 304 176 304 80 1\nw 240 240 304 240 1\nr 304 240 304 320 0 1000.0\ng 304 320 304 336 0\n179 304 176 368 176 0 1.0\ng 400 208 400 288 0\nR 144 240 96 240 0 0 40.0 5.0 0.0 0.0 0.5\no 8 64 0 33 2.5 0.003125 0 -1\no 7 64 0 34 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/ccvccs.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n179 208 192 336 192 0 1.0\nr 208 192 160 192 0 100.0\ng 160 192 160 208 0\nR 208 256 176 256 0 1 40.0 5.0 0.0 1.5707963267948966 0.5\n174 368 224 464 272 0 200.0 0.5297000000000001 Resistance\ng 416 272 416 288 0\nw 304 224 368 224 0\no 3 64 0 34 5.0 9.765625E-5 0 -1\no 6 64 0 33 40.0 0.1 0 -1\n"
  },
  {
    "path": "src/circuits/ceamp.txt",
    "content": "$ 1 5.0E-6 16 60 15.0 53\nw 240 48 336 48 0\nr 240 48 240 208 0 110000.0\nr 240 208 240 352 0 10000.0\nt 240 208 336 208 0 1 -10.980847640834186 0.5689504449104646\nw 240 352 336 352 0\ng 240 352 240 384 0\nR 240 48 144 48 0 0 40.0 20.0 0.0\nr 336 48 336 192 0 10000.0\nr 336 224 336 352 0 1000.0\nc 240 208 160 208 0 4.9999999999999996E-6 1.5542375158881994\nR 160 208 112 208 0 1 80.0 0.5 0.0\nc 336 192 416 192 0 4.9999999999999996E-6 10.088518798851988\nO 416 192 464 192 0\nr 416 192 416 272 0 1000000.0\ng 416 272 416 304 0\no 10 64 0 2 0.625 9.765625E-5\no 12 64 0 2 10.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/classd.txt",
    "content": "$ 1 5.0E-6 8.531194996067258 50 5.0 50\na 160 224 256 224 0 15.0 -15.0\nf 256 256 304 256 1 1.5\nf 256 192 304 192 0 1.5\nw 256 192 256 224 0\nw 256 224 256 256 0\nw 304 208 304 224 0\nw 304 224 304 240 0\nR 304 176 304 128 0 0 40.0 15.0 0.0 0.0 0.5\nl 304 224 400 224 0 0.08 0.062136746137611415\nc 400 224 400 304 0 1.0E-5 -6.657326718051054\ng 400 304 400 336 0\nw 304 272 304 288 0\nO 400 224 464 224 0\nw 160 240 160 256 0\nw 160 208 160 192 0\nR 160 256 112 256 0 3 1000.0 1.001 0.0 0.0 0.5\nR 160 192 112 192 0 1 30.0 1.001 0.0 0.0 0.5\nR 304 288 304 336 0 0 40.0 -15.0 0.0 0.0 0.5\ng 256 320 256 336 0\np 256 256 256 320 0\no 16 64 0 34 1.2 9.765625E-5 0 -1 input\no 19 16 0 34 20.0 9.765625E-5 1 -1\no 12 64 0 34 15.0 4.8828125E-5 2 -1 output\n"
  },
  {
    "path": "src/circuits/clockedsrff.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\n151 256 272 368 272 0 2 5\n151 256 144 368 144 0 2 0\nw 368 144 368 176 0\nw 368 176 256 240 0\nw 368 272 368 240 0\nw 368 240 256 176 0\nw 256 176 256 160 0\nw 256 240 256 256 0\nM 368 144 448 144 0\nM 368 272 448 272 0\n151 128 128 256 128 0 2 5\n151 128 288 256 288 0 2 0\nw 128 304 96 304 0\nw 96 304 96 144 0\nw 96 144 128 144 0\nL 128 112 64 112 0 true true\nL 128 272 64 272 0 true true\nR 96 304 96 352 1 2 100.0 2.5 2.5\no 15 64 0 6 5.0 9.765625E-5 0 set\no 16 64 0 6 5.0 9.765625E-5 0 reset\no 8 64 0 6 5.0 9.765625E-5 0 Q\no 17 64 0 6 5.0 9.765625E-5 0 clk\n"
  },
  {
    "path": "src/circuits/cmosff.txt",
    "content": "$ 0 5.0E-6 10 50 5.0\nf 160 80 208 80 5\nf 160 176 208 176 4\nw 208 96 208 128 0\nw 208 128 208 160 0\nf 160 240 208 240 4\nw 208 192 208 224 0\ng 208 256 208 288 0\nw 160 80 160 176 0\nf 80 80 128 80 5\nw 128 32 128 64 0\nw 128 32 208 32 0\nw 208 32 208 64 0\nR 128 32 80 32 0 0 40.0 5.0 0.0\nw 80 80 80 240 0\nw 80 240 160 240 0\nL 160 176 32 176 0 false true\nw 128 96 128 128 0\nw 128 128 208 128 0\nw 288 240 288 176 0\nw 288 176 288 80 0\nf 288 80 336 80 5\nf 368 80 416 80 5\nw 336 96 336 128 0\nw 336 128 416 128 0\nw 416 96 416 128 0\nw 336 64 336 32 0\nw 416 64 416 32 0\nw 416 32 336 32 0\nw 208 32 336 32 0\nw 368 80 368 176 0\nf 368 176 416 176 4\nf 368 240 416 240 4\nw 416 192 416 224 0\nw 416 128 416 160 0\nw 368 240 288 240 0\ng 416 256 416 288 0\nL 288 240 288 288 0 false true\nw 416 128 464 128 0\nw 464 128 464 336 0\nw 464 336 80 336 0\nw 80 336 80 240 0\nw 368 176 240 176 0\nw 208 128 240 128 0\nw 240 128 240 176 0\nM 240 176 240 368 0\nM 464 336 464 368 0\nx 281 328 297 328 0 24 R\nx 26 151 42 151 0 24 S\nx 202 378 218 378 0 24 Q\nx 422 380 438 380 2 24 Q\n"
  },
  {
    "path": "src/circuits/cmosinverter.txt",
    "content": "$ 0 5.0E-6 10 50 5.0\nf 208 176 272 176 1\nf 208 272 272 272 0\nw 272 192 272 224 0\nw 272 224 272 256 0\nw 208 176 208 224 0\nw 208 224 208 272 0\nL 208 224 160 224 0 false false\nM 272 224 336 224 0\nR 272 160 272 112 0 0 40.0 5.0 0.0\ng 272 288 272 320 0\n"
  },
  {
    "path": "src/circuits/cmosinvertercap.txt",
    "content": "$ 1 1.0E-12 10 50 5.0 38\nf 224 144 288 144 1\nf 224 272 288 272 0\nw 288 160 288 208 0\nM 288 208 352 208 0\nw 288 128 288 96 0\nc 224 96 288 96 0 1.0000000000000001E-11 -5.000000000000001\nc 288 208 224 208 0 1.0000000000000001E-11 4.999999285714189\nw 224 144 224 208 0\nw 224 208 224 272 0\nw 288 208 288 256 0\nc 288 320 224 320 0 1.0000000000000001E-11 1.6279405589908862E-23\nw 288 288 288 320 0\nR 288 96 288 48 0 0 40.0 5.0 0.0\nL 224 208 160 208 0 true false\ng 288 320 288 368 0\nr 224 96 224 144 0 5.0\nr 224 272 224 320 0 5.0\n"
  },
  {
    "path": "src/circuits/cmosinverterslow.txt",
    "content": "$ 1 3.0E-13 10 52 5.0\nf 272 144 336 144 1\nf 272 240 336 240 0\nw 336 160 336 192 0\nw 336 192 336 224 0\nw 272 144 272 192 0\nw 272 192 272 240 0\nM 336 192 400 192 0\nR 336 128 336 80 0 0 40.0 5.0 0.0\ng 336 256 336 288 0\nw 272 192 208 192 0\nc 208 192 208 256 0 1.0000000000000001E-11 4.81990995096849\ng 208 256 208 288 0\nr 208 192 144 192 0 100.0\nL 144 192 96 192 0 false false\no 10 64 0 2 5.0 0.0015625\no 0 64 0 3 5.0 9.765625E-5\no 1 64 0 3 7.62939453125E-5 9.765625E-5\n"
  },
  {
    "path": "src/circuits/cmosmsff.txt",
    "content": "$ 0 5.0E-6 9 50 5.0 50\n159 144 112 208 112 0\nw 208 112 208 192 0\n159 208 192 272 192 0\nI 208 112 272 112 0 2.0E-4\nI 272 112 272 192 0 2.0E-4\n159 272 112 336 112 0\n159 336 192 400 192 0\nw 336 112 336 192 0\nI 336 112 400 112 0 2.0E-4\nI 400 112 400 192 0 2.0E-4\nI 400 112 464 112 0 0.5\nI 400 192 464 192 0 0.5\nw 176 128 176 336 0\nw 240 208 240 240 0\nw 368 240 368 208 0\nI 240 336 240 240 0 0.5\nw 176 336 240 336 0\nw 240 336 368 336 0\nw 240 240 304 240 0\nw 304 240 304 128 0\nw 368 240 368 336 0\nR 176 336 80 336 1 2 100.0 2.5 2.5\nL 144 112 80 112 0 true false 5.0 0.0\nM 464 112 512 112 0 2.5\nM 464 192 512 192 0 2.5\nx 71 80 87 80 0 24 D\nx 543 122 559 122 2 24 Q\nx 542 202 558 202 0 24 Q\n"
  },
  {
    "path": "src/circuits/cmosnand.txt",
    "content": "$ 0 5.0E-6 10 50 5.0\nf 288 128 352 128 5\nf 288 224 352 224 4\nw 352 144 352 176 0\nw 352 176 352 208 0\nM 352 176 416 176 0\nf 288 288 352 288 4\nw 352 240 352 272 0\ng 352 304 352 336 0\nw 288 128 288 224 0\nf 192 128 256 128 5\nw 256 80 256 112 0\nw 256 80 352 80 0\nw 352 80 352 112 0\nR 256 80 192 80 0 0 40.0 5.0 0.0\nw 192 128 192 288 0\nw 192 288 288 288 0\nL 288 224 128 224 0 false false\nL 192 288 128 288 0 false false\nw 256 144 256 176 0\nw 256 176 352 176 0\n"
  },
  {
    "path": "src/circuits/cmosnor.txt",
    "content": "$ 0 5.0E-6 10 50 5.0\nf 272 144 336 144 5\nw 336 160 336 192 0\nR 336 128 336 80 0 0 40.0 5.0 0.0\nf 272 208 336 208 5\nw 336 224 336 240 0\nw 336 240 336 256 0\nf 272 272 336 272 4\nM 336 240 400 240 0\nf 176 272 240 272 4\nw 240 240 240 256 0\nw 240 240 336 240 0\ng 240 288 240 320 0\ng 336 288 336 320 0\nw 272 208 272 272 0\nw 176 144 176 272 0\nw 176 144 272 144 0\nL 176 144 128 144 0 false false\nL 272 208 128 208 0 false false\n"
  },
  {
    "path": "src/circuits/cmostransgate.txt",
    "content": "$ 1 5.0E-6 16.13108636308289 50 5.0 50\nw 320 192 400 192 0\nr 400 192 400 272 0 100.0\ng 400 272 400 304 0\nw 208 240 208 144 0\nw 288 192 144 192 0\nL 208 240 96 240 0 false false\nR 144 192 96 192 0 1 40.0 2.5 2.5\nf 304 144 304 192 1\nf 304 240 304 192 0\nI 208 144 304 144 0\nw 208 240 304 240 0\n"
  },
  {
    "path": "src/circuits/cmosxor.txt",
    "content": "$ 0 5.0E-6 10 50 5.0\nf 192 128 256 128 5\nf 192 224 256 224 4\nw 256 144 256 176 0\nw 256 176 256 208 0\nw 192 128 192 176 0\nw 192 176 192 224 0\nf 336 112 336 176 5\nf 336 240 336 176 4\nw 256 240 336 240 0\nw 256 112 336 112 0\nw 192 176 144 176 0\nw 144 176 144 272 0\nw 144 272 384 272 0\nw 384 272 384 176 0\nw 336 112 336 80 0\nw 336 80 144 80 0\nL 144 80 64 80 0 true false\nL 144 176 64 176 0 true false\nw 336 240 432 240 0\nI 432 80 432 240 0\nw 336 80 432 80 0\nw 256 176 288 176 0\nw 288 176 320 176 0\nw 288 176 288 304 0\nM 288 304 288 352 0\nw 352 176 384 176 0\nx 199 361 215 361 0 20 output\n"
  },
  {
    "path": "src/circuits/colpitts.txt",
    "content": "$ 1 5.0E-6 2.898875293967098 50 5.0 50\nl 80 128 80 304 0 0.01 -0.010136293111238402\nc 192 128 192 224 0 9.999999999999999E-5 0.6813812722941772\nt 256 128 304 128 0 1 0.647542643140423 0.6813812722941772 100.0\nc 192 224 192 304 0 9.999999999999999E-5 -0.627840195243891\nw 80 304 192 304 0\nw 80 128 192 128 0\nw 192 128 256 128 0\nw 192 224 304 224 0\nw 304 144 304 224 0\nw 304 112 352 112 0\nr 352 112 352 304 0 1000.0\nw 192 304 352 304 0\nr 304 112 304 48 0 100.0\nR 304 48 256 48 0 0 40.0 5.0 0.0 0.0 0.5\ng 304 224 304 256 0\nO 352 112 432 112 0\nx 150 182 170 186 0 16 C1\nx 150 271 171 275 0 16 C2\no 15 32 0 42 5.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/counter.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\n156 80 224 128 224 0 0.0\n156 208 224 240 224 0 0.0\n156 336 224 368 224 0 0.0\n156 464 224 480 224 0 0.0\nw 176 224 176 256 0\nw 176 256 208 256 0\nw 304 224 304 256 0\nw 304 256 336 256 0\nw 432 224 432 256 0\nw 432 256 464 256 0\nw 464 224 448 224 0\nw 448 224 448 288 0\nw 448 288 464 288 0\nw 448 288 448 336 0\nw 448 336 320 336 0\nw 320 336 320 288 0\nw 320 288 336 288 0\nw 320 288 320 224 0\nw 320 224 336 224 0\nw 208 224 192 224 0\nw 192 224 192 288 0\nw 192 288 208 288 0\nw 192 288 192 336 0\nw 192 336 320 336 0\nw 80 224 64 224 0\nw 64 224 64 288 0\nw 64 288 80 288 0\nw 64 288 64 336 0\nw 64 336 192 336 0\nR 80 256 32 256 1 2 200.0 2.5 2.5\nR 64 336 32 336 0 0 40.0 5.0 0.0\nw 560 224 560 64 0\nw 432 224 432 96 0\nw 304 224 304 128 0\nw 176 224 176 160 0\nM 560 64 592 64 2\nM 432 96 592 96 2\nM 304 128 592 128 2\nM 176 160 592 160 2\no 35 64 0 6 5.0 9.765625E-5 0\no 36 64 0 6 5.0 9.765625E-5 0\no 37 64 0 6 5.0 9.765625E-5 0\no 38 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/counter8.txt",
    "content": "$ 3 5.0E-6 23 50 5.0\n156 88 272 104 272 1 0\n156 152 272 168 272 1 0\nw 152 272 144 272 0\nw 144 272 144 304 0\nw 144 304 152 304 0\nw 136 272 136 288 0\nw 136 288 152 288 0\n156 216 272 232 272 1 0.0\n156 280 272 296 272 1 0.0\n156 344 272 352 272 1 0.0\n156 408 272 424 272 1 0.0\n156 472 272 488 272 1 0.0\nw 200 272 200 288 0\nw 200 288 216 288 0\nw 264 272 264 288 0\nw 264 288 280 288 0\nw 328 272 328 288 0\nw 328 288 344 288 0\nw 392 272 392 288 0\nw 392 288 408 288 0\nw 456 272 456 288 0\nw 456 288 472 288 0\nw 216 272 208 272 0\nw 208 272 208 304 0\nw 208 304 216 304 0\nw 280 272 272 272 0\nw 272 272 272 304 0\nw 272 304 280 304 0\nw 344 272 336 272 0\nw 336 272 336 304 0\nw 336 304 344 304 0\nw 408 272 400 272 0\nw 400 272 400 304 0\nw 400 304 408 304 0\nw 472 272 464 272 0\nw 464 272 464 304 0\nw 464 304 472 304 0\nw 144 304 144 336 0\nw 208 304 208 336 0\nw 144 336 208 336 0\nw 208 336 272 336 0\nw 272 304 272 336 0\nw 272 336 336 336 0\nw 336 336 400 336 0\nw 400 336 464 336 0\nw 464 336 464 304 0\nw 400 304 400 336 0\nw 336 304 336 336 0\nR 88 288 32 288 1 2 1000.0 2.5 2.5\nw 88 272 80 272 0\nw 80 272 80 304 0\nw 80 304 88 304 0\nw 80 304 80 336 0\nw 80 336 144 336 0\nR 80 336 32 336 0 0 40.0 5.0 0.0\nw 136 272 136 224 0\nw 200 272 200 200 0\nw 264 272 264 176 0\nw 328 272 328 152 0\nw 392 272 392 128 0\nw 456 272 456 104 0\nw 520 272 520 80 0\nM 136 224 80 224 2\nM 200 200 80 200 2\nM 264 176 80 176 2\nM 328 152 80 152 2\nM 392 128 80 128 2\nM 456 104 80 104 2\nM 520 80 80 80 2\nw 464 336 528 336 0\nw 528 336 528 304 0\nw 520 272 520 288 0\nw 520 288 536 288 0\n156 536 272 552 272 1 0.0\nw 528 272 528 304 0\nw 528 272 536 272 0\nw 584 272 584 56 0\nw 528 304 536 304 0\nM 584 56 80 56 2\no 78 64 0 6 5.0 9.765625E-5 0\no 68 64 0 6 7.62939453125E-5 9.765625E-5 0\no 67 64 0 6 5.0 9.765625E-5 0\no 66 64 0 6 5.0 9.765625E-5 0\no 65 64 0 6 5.0 9.765625E-5 0\no 64 64 0 6 5.0 9.765625E-5 0\no 63 64 0 6 5.0 9.765625E-5 0\no 62 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/coupled1.txt",
    "content": "$ 1 5.0E-6 12.682493960703473 55 5.0 50\nl 192 240 304 240 0 1.0 0.0\nl 304 240 416 240 0 1.0 0.0\nc 192 240 192 368 0 1.0E-5 5.0\nc 304 240 304 368 0 1.0E-5 -0.0\nc 416 240 416 368 0 1.0E-5 5.0\nr 192 368 304 368 0 1.0\nr 304 368 416 368 0 1.0\ng 304 368 304 384 0\nl 192 32 304 32 0 1.0 0.0\nl 304 32 416 32 0 1.0 0.0\nc 192 32 192 160 0 1.0E-5 5.0\nc 304 32 304 160 0 1.0E-5 -0.0\nc 416 32 416 160 0 1.0E-5 -5.0\nr 192 160 304 160 0 1.0\nr 304 160 416 160 0 1.0\ng 304 160 304 176 0\no 13 64 0 43 0.01953125 0.025 0 -1\no 5 64 0 43 0.009765625 0.0125 1 -1\n"
  },
  {
    "path": "src/circuits/coupled2.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 63 5.0 50\nl 208 160 320 160 0 1.0 -0.001826652874703726\nl 320 160 432 160 0 1.0 3.59207891615332E-4\nc 208 160 208 288 0 1.0E-6 0.7201238956969189\nc 320 160 320 288 0 1.9999999999999998E-5 0.2893723277533031\nc 432 160 432 288 0 1.0E-6 -1.5075704507629162\nr 208 288 320 288 0 1.0\nr 320 288 432 288 0 1.0\ng 320 288 320 304 0\nw 432 160 480 160 0\nw 432 288 480 288 0\np 480 160 480 288 0\nw 208 160 160 160 0\nw 208 288 160 288 0\np 160 160 160 288 0\no 2 64 0 35 5.0 0.00625 0 -1\no 4 64 0 35 5.0 0.00625 1 -1\no 13 64 0 226 2.8 2.8 2 10\n"
  },
  {
    "path": "src/circuits/coupled3.txt",
    "content": "$ 1 5.0E-6 17.50203994009402 55 5.0 50\nl 144 32 256 32 0 1.0 -0.010526054531836967\nl 256 32 368 32 0 1.0 -0.014780859108181294\nc 144 32 144 112 0 1.0E-5 -1.5283359644818593\nc 256 32 256 112 0 1.0E-5 -0.6226471660960838\nc 368 32 368 112 0 1.0E-5 0.6226471660960479\nr 144 112 256 112 0 1.0\nr 256 112 368 112 0 1.0\nl 368 32 480 32 0 1.0 -0.010526054531837074\nc 480 32 480 112 0 1.0E-5 1.528335964481852\nr 368 112 480 112 0 1.0\ng 144 112 144 128 0\nl 144 160 256 160 0 1.0 0.0146359989059815\nl 256 160 368 160 0 1.0 -7.561108857079762E-17\nc 144 160 144 240 0 1.0E-5 -3.205717865478435\nc 256 160 256 240 0 1.0E-5 3.2057178654783622\nc 368 160 368 240 0 1.0E-5 3.205717865478375\nr 144 240 256 240 0 1.0\nr 256 240 368 240 0 1.0\nl 368 160 480 160 0 1.0 -0.014635998905981084\nc 480 160 480 240 0 1.0E-5 -3.2057178654783813\nr 368 240 480 240 0 1.0\ng 144 240 144 256 0\nl 144 288 256 288 0 1.0 0.009608347545030023\nl 256 288 368 288 0 1.0 -0.013588266474160417\nc 144 288 144 368 0 1.0E-5 0.9505461007504308\nc 256 288 256 368 0 1.0E-5 -2.2948228963492374\nc 368 288 368 368 0 1.0E-5 2.2948228963492827\nr 144 368 256 368 0 1.0\nr 256 368 368 368 0 1.0\nl 368 288 480 288 0 1.0 0.009608347545029965\nc 480 288 480 368 0 1.0E-5 -0.9505461007504287\nr 368 368 480 368 0 1.0\ng 144 368 144 384 0\no 9 128 0 43 0.01953125 0.0125 0 -1\no 20 128 0 43 0.0390625 0.025 1 -1\no 31 128 0 43 0.01953125 0.0125 2 -1\n"
  },
  {
    "path": "src/circuits/crossover.txt",
    "content": "$ 0 5.0E-6 10.812258501325767 50 5.0 50\n170 208 48 160 48 3 100.0 20000.0 5.0 0.25\nl 208 48 304 48 0 0.00212 -0.08881265679389214\nc 304 48 304 112 0 5.9999999999999995E-5 -0.2894173322846854\nl 304 48 400 48 0 7.0E-4 -0.0064227679597185445\nr 400 48 400 112 0 5.6\ng 304 112 304 128 0\ng 400 112 400 128 0\nw 208 48 208 176 0\nc 208 176 272 176 0 2.1E-5 -0.8398710078174956\nc 272 176 336 176 0 6.3E-5 0.090455613711665\nl 336 176 400 176 0 2.4E-4 0.6844180361930992\nl 400 176 464 176 0 8.0E-5 0.6610256500586136\nl 272 176 272 256 0 0.00151 0.030771262133821843\nc 400 176 400 256 0 3.3199999999999996E-6 5.438742670954392\nr 464 176 464 256 0 8.0\ng 272 256 272 272 0\ng 400 256 400 272 0\ng 464 256 464 272 0\nw 208 176 208 320 0\nc 208 320 304 320 0 2.37E-6 4.767372700629853\nc 304 320 400 320 0 7.099999999999999E-6 -0.16235412775659708\nl 304 320 304 400 0 1.5E-4 0.09052584171628873\ng 304 400 304 416 0\nr 400 320 400 400 0 5.6\ng 400 400 400 416 0\no 4 8 0 50 5.1 1.6 0 -1 low\no 14 4 0 50 10.0 0.8 1 -1 mid\no 23 4 0 50 5.1 0.8 2 -1 high\n"
  },
  {
    "path": "src/circuits/cube.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 5.0 50\nr 224 144 384 144 0 100.0\nr 384 144 384 304 0 100.0\nr 384 304 224 304 0 100.0\nr 224 304 224 144 0 100.0\nr 224 144 288 80 0 100.0\nr 384 144 448 80 0 100.0\nr 448 80 288 80 0 100.0\nr 448 80 448 240 0 100.0\nr 448 240 384 304 0 100.0\nr 224 304 288 240 0 100.0\nr 288 240 448 240 0 100.0\nr 288 240 288 80 0 100.0\n82 448 80 448 32 0 0 40.0 5.0 0.0 0.0 0.5\ng 224 304 224 336 0\n"
  },
  {
    "path": "src/circuits/currentsrc.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 58 10.0 50\nt 192 224 256 224 0 1 0.25888403915739877 0.5839501020424223 100.0\nr 256 240 256 288 0 1000.0\ng 256 288 256 320 0\nw 256 208 256 160 1\nw 256 160 304 160 0\nw 256 64 304 64 0\nR 256 64 256 16 0 0 40.0 10.0 0.0 0.0 0.5\ns 304 64 304 160 0 1 false\nr 256 64 256 160 0 6000.0\nw 256 64 192 64 0\nw 192 288 256 288 0\nr 192 224 192 288 0 2000.0\nr 192 224 192 64 0 8000.0\n"
  },
  {
    "path": "src/circuits/currentsrcelm.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nw 112 32 208 32 0\nw 208 32 304 32 0\nw 304 32 400 32 0\ns 208 32 208 112 0 false false\ns 304 32 304 112 0 true false\nr 208 112 208 176 0 100.0\nr 304 112 304 176 0 400.0\nr 400 112 400 176 0 4000.0\nw 208 176 304 176 0\nw 304 176 400 176 0\nw 304 208 304 176 0\nw 304 208 400 208 0\nw 304 208 208 208 0\ns 304 208 304 288 0 false false\nr 208 288 208 352 0 600.0\nr 304 288 304 352 0 200.0\ns 400 208 400 352 0 false false\nw 112 352 208 352 0\nw 208 352 304 352 0\nw 304 352 400 352 0\ni 112 352 112 32 0\ng 112 352 112 384 0\nw 400 32 400 112 0\nw 208 208 208 288 0\no 20 32 0 3 5.0 0.05\n"
  },
  {
    "path": "src/circuits/currentsrcramp.txt",
    "content": "$ 1 5.0E-6 15 53 10.0\nt 176 256 240 256 0 1 0.6557323083416877 0.6568475020864442\nr 240 272 240 320 0 100.0\ng 240 320 240 352 0\nR 176 256 128 256 0 0 40.0 2.0 0.0\nw 240 240 240 192 0\nw 240 192 336 192 0\nw 240 96 336 96 0\nR 240 96 240 48 0 0 40.0 10.0 0.0\nc 240 96 240 192 0 4.9999999999999996E-5 0\nr 336 96 336 192 0 10000.0\nw 240 96 192 96 0\nw 240 192 192 192 0\ns 192 96 192 192 0 true true\no 9 128 0 2 10.0 7.8125E-4\n"
  },
  {
    "path": "src/circuits/dac.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nw 208 128 208 192 0\nw 320 208 320 128 0\nr 208 128 320 128 0 160.6\ng 208 288 208 320 0\nw 208 192 176 192 0\nw 176 192 176 160 0\nr 176 160 112 160 0 200.0\nr 112 224 176 224 0 400.0\nL 112 160 80 160 0 true false 5.0 0.0\nL 112 224 80 224 0 false false 5.0 0.0\nw 176 160 176 96 0\nr 112 288 176 288 0 800.0\nr 112 96 176 96 0 100.0\nL 112 96 80 96 0 true false 5.0 0.0\nL 112 288 80 288 0 false false 5.0 0.0\na 208 208 320 208 0 15.0 -15.0\nO 320 208 368 208 1\nw 208 224 208 288 0\nw 176 288 176 224 0\nw 176 224 176 192 0\n"
  },
  {
    "path": "src/circuits/darlington.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 56 5.0 50\nt 368 288 400 288 0 1 -4.687537934791563 0.09853954519174213 100.0\nr 304 112 304 208 0 2000000.0\ns 304 208 304 288 0 1 false\nw 304 112 448 112 0\nr 448 112 448 224 0 300.0\nw 448 320 448 384 1\nt 400 304 448 304 0 1 -4.786077479983305 0.2139223639566944 100.0\nw 400 272 400 224 0\nw 400 224 448 224 0\nw 448 224 448 288 0\nw 368 288 304 288 1\nR 304 112 240 112 0 0 40.0 5.0 0.0 0.0 0.5\ng 448 384 448 400 0\n"
  },
  {
    "path": "src/circuits/dcrestoration.txt",
    "content": "$ 1 1.0E-6 7 59 5.0\nR 160 144 96 144 0 1 500.0 5.0 0.0\nc 160 144 272 144 0 5.0E-6 -3.0584720734913993\nd 272 256 272 144 0\ng 272 256 272 288 0\nw 272 144 352 144 0\nr 352 144 352 256 0 5000.0\ng 352 256 352 288 0\nO 352 144 416 144 0\no 7 32 0 2 10.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/deccounter.txt",
    "content": "$ 3 5.0E-6 13 50 5.0\n156 72 248 128 248 0 5.0\n156 208 248 240 248 0 0.0\n156 336 248 368 248 0 0.0\n156 464 248 480 248 0 0.0\nw 448 312 464 312 0\nw 320 312 336 312 0\nw 320 312 320 248 0\nw 320 248 336 248 0\nw 72 248 56 248 0\nw 56 248 56 312 0\nw 56 312 72 312 0\nw 432 248 432 88 0\nM 560 64 592 64 2 2.5\nR 56 248 24 248 0 0 40.0 5.0 0.0\nR 72 360 24 360 1 2 200.0 2.5 2.5\nw 72 280 72 360 0\nw 72 360 208 360 0\nw 208 360 208 280 0\nw 336 280 336 360 0\nw 336 360 208 360 0\nw 336 360 464 360 0\nw 464 360 464 280 0\n150 336 176 336 248 1 2 0.0\nw 304 248 304 112 0\nw 304 112 328 112 0\nw 328 112 328 176 0\nw 344 136 344 176 0\nw 168 136 344 136 0\n150 464 176 464 248 1 3 0.0\nw 344 136 472 136 0\nw 472 136 472 176 0\nw 328 112 464 112 0\nw 464 112 464 176 0\nw 432 88 456 88 0\nw 456 88 456 176 0\nM 464 112 592 112 2 2.5\nM 456 88 592 88 2 2.5\n150 192 176 240 176 1 2 5.0\nw 240 176 240 216 0\nw 208 216 208 248 0\nw 208 216 240 216 0\nw 168 248 168 168 0\nw 168 168 192 168 0\nw 168 136 168 168 0\nw 560 312 560 384 0\nw 560 384 184 384 0\nw 184 384 184 184 0\nw 184 184 192 184 0\nw 200 248 208 248 0\nw 200 248 200 312 0\nw 200 312 208 312 0\n150 512 160 512 208 1 2 0.0\nw 472 136 504 136 0\nw 504 136 504 160 0\nw 560 64 560 160 0\nw 560 160 520 160 0\nw 560 160 560 248 0\nw 512 208 584 208 0\nw 584 208 584 344 0\nw 584 344 448 344 0\nw 448 344 448 312 0\nM 504 136 592 136 2 2.5\no 12 64 0 6 5.0 9.765625E-5 0\no 36 64 0 6 5.0 9.765625E-5 0\no 35 64 0 6 5.0 9.765625E-5 0\no 61 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/decoder.txt",
    "content": "$ 1 5.0E-6 1.5 50 5.0\n150 416 128 512 128 0 2 0.0\n150 416 192 512 192 0 2 0.0\n150 416 256 512 256 0 2 0.0\n150 416 320 512 320 0 2 5.0\nw 416 112 352 112 0\nw 352 112 352 176 0\nw 352 176 416 176 0\nw 416 240 352 240 0\nw 352 240 352 304 0\nw 352 304 416 304 0\nw 416 144 384 144 0\nw 384 144 384 272 0\nw 384 272 416 272 0\nw 416 208 320 208 0\nw 320 208 320 336 0\nw 320 336 416 336 0\nw 144 112 352 112 0\nw 352 240 144 240 0\nI 144 112 144 240 0\nL 144 112 64 112 2 true false 5.0 0.0\nw 384 272 144 272 0\nw 320 336 144 336 0\nL 144 272 64 272 2 true false 5.0 0.0\nI 144 272 144 336 0\nM 512 128 560 128 0 2.5\nM 512 192 560 192 0 2.5\nM 512 256 560 256 0 2.5\nM 512 320 560 320 0 2.5\n"
  },
  {
    "path": "src/circuits/delayrc.txt",
    "content": "$ 1 5.0E-9 10 54 5.0\nf 144 144 208 144 1\nf 144 240 208 240 0\nw 208 160 208 192 0\nw 208 192 208 224 0\nw 144 144 144 192 0\nw 144 192 144 240 0\nL 144 192 96 192 0 false false\nR 208 128 208 80 0 0 40.0 5.0 0.0\ng 208 256 208 288 0\nr 208 192 288 192 0 1500.0\nc 288 192 288 256 0 1.0E-8 4.973779073596618\ng 288 256 288 288 0\nw 288 192 336 192 0\nw 336 192 336 144 0\nw 336 192 336 240 0\nf 336 144 400 144 1\nf 336 240 400 240 0\nw 400 160 400 192 0\nw 400 192 400 224 0\nM 400 192 448 192 0\ng 400 256 400 288 0\nR 400 128 400 80 0 0 40.0 5.0 0.0\no 6 64 0 6 5.0 9.765625E-5 0\no 19 64 0 6 5.0 9.765625E-5 0\nh 2 9 10\n"
  },
  {
    "path": "src/circuits/deltasigma.txt",
    "content": "$ 3 5.0E-6 12.185319768402522 50 5.0 50\na 144 248 224 248 0 15.0 -15.0\nw 144 232 144 200 0\nc 144 200 224 200 0 1.4999999999999999E-5 14.45469914811517\nw 224 200 224 248 0\nw 144 232 128 232 0\n160 112 104 112 168 0\nw 128 168 128 232 0\ng 96 168 96 184 0\nr 128 232 64 232 0 1600.0\ni 112 56 112 104 0 0.01\n82 112 56 64 56 0 0 40.0 20.0 0.0 0.0 0.5\na 224 264 312 264 0 5.0 0.0\ng 224 280 224 296 0\n155 312 264 376 264 1 0.0\nw 312 280 312 360 0\nw 376 312 376 360 0\nw 376 360 312 360 0\n82 312 360 288 360 1 2 600.0 2.5 2.5 0.0 0.5\nw 128 136 376 136 0\nw 376 136 376 296 0\n164 432 304 480 304 1 4 0.0 0.0 0.0 0.0\n82 432 400 376 400 0 2 20.0 2.5 2.5 -0.17453292519943295 0.9\n82 144 264 112 264 0 0 40.0 15.0 0.0 0.0 0.5\nw 360 296 376 296 0\n168 480 304 512 304 1 4\nM 528 304 560 304 0 2.5\nM 528 320 576 320 0 2.5\nM 528 336 592 336 0 2.5\nM 528 352 608 352 0 2.5\nw 480 368 480 400 0\nw 432 352 432 400 0\n82 480 400 480 432 0 2 20.0 2.5 2.5 -3.141592653589793 0.5\n82 64 232 40 232 0 4 1.0 7.5 7.5 0.0 0.5\n153 376 304 432 304 1 2 0.0\no 32 64 0 34 10.0 0.00625 0 -1\no 25 64 0 34 7.62939453125E-5 9.765625E-5 1 -1\no 26 64 0 34 5.0 9.765625E-5 1 -1\no 27 64 0 34 5.0 9.765625E-5 1 -1\no 28 64 0 34 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/diff.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 160 288 160 144 0 2 40.0 5.0 0.0\nc 160 144 352 144 0 9.0E-6 4.999340978003125\nr 352 144 352 288 0 120.0\nw 160 288 352 288 0\no 0 64 0 2 10.0 9.765625E-5 0\no 2 64 0 3 20.0 0.2 0\nh 2 2 1\n"
  },
  {
    "path": "src/circuits/digcompare.txt",
    "content": "$ 3 5.0E-6 1.5 50 5.0\nL 64 88 64 56 2 true false 5.0 0.0\nw 64 88 88 88 0\nI 88 88 88 144 0\nL 112 88 112 56 2 true false 5.0 0.0\nL 200 88 200 56 2 true false 5.0 0.0\nL 248 88 248 56 2 true false 5.0 0.0\nw 112 88 136 88 0\nI 136 88 136 144 0\n154 304 176 360 176 1 2 0.0\nw 64 88 64 168 0\nw 64 168 304 168 0\nw 200 88 200 184 0\nw 200 184 304 184 0\n154 304 216 360 216 1 2 0.0\nw 112 88 112 208 0\nw 112 208 304 208 0\nw 248 88 248 224 0\nw 248 224 304 224 0\n151 304 256 360 256 1 2 5.0\nw 200 184 200 264 0\nw 200 264 304 264 0\nw 360 216 360 192 0\nw 416 280 304 280 0\n151 328 312 400 312 1 3 5.0\nw 88 304 328 304 0\nw 136 312 328 312 0\nw 304 280 304 320 0\nw 304 320 328 320 0\n151 328 352 400 352 1 3 5.0\nw 304 320 304 360 0\nw 304 360 328 360 0\nw 416 184 416 280 0\n151 432 312 504 312 1 3 0.0\nw 360 256 432 256 0\nw 432 256 432 304 0\nw 400 312 432 312 0\nw 400 352 432 352 0\nw 432 352 432 320 0\n152 360 184 416 184 1 2 0.0\nw 200 344 328 344 0\nw 200 264 200 344 0\nw 248 224 248 352 0\nw 248 352 328 352 0\nI 416 184 512 184 0\nM 504 312 600 312 0 2.5\nM 512 184 600 184 0 2.5\nx 81 37 97 37 0 24 A\nx 219 38 235 38 0 24 B\nx 545 169 561 169 0 16 A=B\nw 512 184 512 392 0\nw 504 312 504 408 0\n153 512 400 576 400 1 2 0.0\nw 504 408 512 408 0\nM 576 400 600 400 0 2.5\nx 546 298 562 298 0 16 A<B\nx 546 374 562 374 0 16 A>B\nw 88 144 88 248 0\nw 88 248 88 304 0\nw 88 248 304 248 0\nw 136 144 136 312 0\n"
  },
  {
    "path": "src/circuits/digsine.txt",
    "content": "$ 3 5.0E-6 10 69 5.0\n155 80 224 88 224 1 5.0\n155 144 224 152 224 1 5.0\n155 208 224 216 224 1 0.0\n155 272 224 280 224 1 0.0\n155 336 224 344 224 1 0.0\n155 400 224 416 224 1 0.0\n155 464 224 480 224 1 0.0\n155 528 224 544 224 1 0.0\nw 128 224 144 224 0\nw 192 224 208 224 0\nw 256 224 272 224 0\nw 320 224 336 224 0\nw 384 224 400 224 0\nw 448 224 464 224 0\nw 512 224 528 224 0\nw 576 256 576 280 0\nw 576 280 64 280 0\nw 64 280 64 224 0\nw 64 224 80 224 0\nw 80 240 72 240 0\nw 72 240 72 304 0\nw 144 240 136 240 0\nw 136 240 136 304 0\nw 208 240 200 240 0\nw 200 240 200 304 0\nw 272 240 264 240 0\nw 264 240 264 304 0\nw 336 240 328 240 0\nw 328 240 328 304 0\nw 400 240 392 240 0\nw 392 240 392 304 0\nw 464 240 456 240 0\nw 456 240 456 304 0\nw 528 240 520 240 0\nw 520 240 520 304 0\nw 520 304 456 304 0\nw 456 304 392 304 0\nw 392 304 328 304 0\nw 328 304 264 304 0\nw 264 304 200 304 0\nw 200 304 136 304 0\nw 136 304 72 304 0\nR 72 304 32 304 1 2 800.0 2.5 2.5\nr 128 224 128 96 0 57600.0\nr 192 224 192 96 0 30900.0\nr 256 224 256 96 0 23700.0\nr 320 224 320 96 0 22100.0\nr 384 224 384 96 0 23700.0\nr 448 224 448 96 0 30900.0\nr 512 224 512 96 0 57600.0\nw 128 96 192 96 0\nw 192 96 256 96 0\nw 256 96 320 96 0\nw 320 96 384 96 0\nw 384 96 448 96 0\nw 448 96 512 96 0\nw 512 96 552 96 0\nc 552 96 552 176 0 3.0E-7 0.33745879726352607\nO 552 96 600 96 0\ng 552 176 552 184 0\no 58 64 0 2 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/diodeclip.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 58 5.0 50\nr 272 160 320 160 0 200.0\nr 320 160 320 240 0 100.0\nd 320 240 320 288 0\nR 320 288 320 320 0 0 40.0 5.0 0.0 0.0 0.5\nO 320 160 384 160 0\nR 272 160 240 160 0 3 40.0 10.0 0.0 0.0 0.5\no 5 64 0 35 10.0 0.1 0 -1\no 4 64 0 34 10.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/diodecurve.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 2.0 50\nR 288 208 288 160 0 3 50.0 0.65 0.25 0.0 0.5\nd 288 208 288 288 0\ng 288 288 288 320 0\no 1 64 0 34 1.25 25.6 0 -1\no 1 64 0 33 0.625 51.2 0 -1\no 1 64 0 99 1.25 51.2 1 -1 I vs V\n"
  },
  {
    "path": "src/circuits/diodelimit.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 176 288 176 144 0 1 40.0 5.0 0.0\nr 176 144 272 144 0 110.0\nw 272 144 272 192 0\nw 272 192 304 192 0\nw 272 192 240 192 0\nw 176 288 240 288 0\nw 240 288 304 288 0\nd 240 192 240 288 0\nd 304 288 304 192 0\nO 272 144 368 144 0\no 0 32 0 3 5.0 0.05\no 9 64 0 2 1.25 2.44140625E-5\n"
  },
  {
    "path": "src/circuits/diodevar.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 1.0 50\n172 336 176 336 128 0 6 0.72 0.77 -1.0 0.0 0.5 Voltage\nw 336 304 336 336 1\ng 336 336 336 352 0\nd 336 176 336 304 0\n"
  },
  {
    "path": "src/circuits/divideby2.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\n155 272 96 320 96 0 0.0\nR 272 128 208 128 1 2 100.0 2.5 2.5\nw 368 160 368 64 0\nw 368 64 272 64 0\nw 272 64 272 96 0\nM 368 96 448 96 0\no 1 64 0 14 5.0 9.765625E-5 0\no 5 64 0 14 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/divideby3.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\n155 112 192 144 192 0 0.0\n155 304 192 352 192 0 0.0\nw 304 176 304 192 0\nw 304 224 304 304 0\nw 112 224 112 304 0\nw 112 304 304 304 0\nw 112 192 112 128 0\nw 400 128 400 192 0\nw 112 128 208 128 0\nw 208 128 208 160 0\nw 208 128 400 128 0\nR 112 224 48 224 1 2 150.1 2.5 2.5\nM 400 192 464 192 0\n153 208 176 304 176 0 2 0.0\no 11 32 0 14 5.0 9.765625E-5 0\no 12 32 0 14 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/dram.txt",
    "content": "$ 3 5.0E-6 5 86 5.0 50\nw 400 16 424 16 0\nc 424 16 424 48 0 1.0E-8 0\nw 368 16 344 16 0\ng 424 48 424 56 0\nf 384 72 384 16 4\nw 400 88 424 88 0\nc 424 88 424 120 0 1.0E-8 5\nw 368 88 344 88 0\ng 424 120 424 128 0\nf 384 144 384 88 4\nw 344 16 344 88 0\nw 400 160 424 160 0\nc 424 160 424 192 0 1.0E-8 0\nw 368 160 344 160 0\ng 424 192 424 200 0\nf 384 216 384 160 4\nw 400 232 424 232 0\nc 424 232 424 264 0 1.0E-8 5\nw 368 232 344 232 0\nf 384 288 384 232 4\nw 344 160 344 232 0\nw 344 88 344 160 0\nw 384 72 320 72 0\nw 384 144 320 144 0\nw 384 216 320 216 0\nw 384 288 320 288 0\n150 280 72 320 72 1 2 0.0\n150 280 144 320 144 1 2 0.0\n150 280 216 320 216 1 2 5.0\n150 280 288 320 288 1 2 0.0\nw 232 64 280 64 0\nw 232 64 232 136 0\nw 232 136 280 136 0\nw 232 136 232 152 0\nw 280 208 232 208 0\nI 232 152 232 208 0 0.5\nw 232 208 232 280 0\nw 232 280 280 280 0\nw 280 80 264 80 0\nw 264 80 264 224 0\nw 264 224 280 224 0\nw 280 152 256 152 0\nI 208 224 208 296 0 0.5\nw 208 224 264 224 0\nw 256 152 256 296 0\nw 208 296 256 296 0\nw 256 296 280 296 0\nL 208 224 160 224 2 false false 5.0 0.0\nL 232 152 160 152 2 true false 5.0 0.0\nw 344 304 408 304 0\na 408 312 456 312 3 5.0 0.0\nR 408 320 376 320 0 0 40.0 2.5 0.0\nw 456 312 456 352 0\n159 344 352 456 352 0\n159 280 352 344 352 0\nx 84 195 100 195 0 12 row select\ng 424 264 424 272 0\nw 344 232 344 304 0\nw 344 304 344 352 0\nw 280 352 280 392 0\nL 280 392 160 392 0 false false 5.0 0.0\nL 208 360 160 360 0 true true 5.0 0.0\nw 208 360 208 376 0\nw 312 376 312 368 0\nw 400 376 400 368 0\nw 208 376 312 376 0\nx 96 365 112 365 0 12 write\nx 89 430 105 430 0 12 refresh\nx 96 398 112 398 0 12 data\nM 456 312 536 312 0 2.5\nw 400 376 400 424 0\nL 400 424 160 424 0 true true 5.0 0.0\n"
  },
  {
    "path": "src/circuits/dtlinverter.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\ng 320 272 320 320 0\nr 224 176 224 96 0 4700.0\nr 320 96 320 176 0 1000.0\nw 320 176 320 240 0\nM 320 176 416 176 0\nw 224 96 320 96 0\nt 272 256 320 256 0 1 0.5852076661116874 0.622416726973117\nd 224 256 272 256 0\nd 224 256 176 256 0\nw 224 176 224 256 0\nL 176 256 128 256 0 false false\nR 224 96 128 96 0 0 40.0 5.0 0.0\n"
  },
  {
    "path": "src/circuits/dtlnand.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\ng 336 272 336 320 0\nr 240 176 240 96 0 4700.0\nr 336 96 336 176 0 1000.0\nw 336 176 336 240 0\nM 336 176 432 176 0\nw 240 96 336 96 0\nt 288 256 336 256 0 1 0.585207666112351 0.6224167269732703\nd 240 256 288 256 0\nd 240 256 192 256 0\nL 192 256 144 256 0 false false\nR 240 96 144 96 0 0 40.0 5.0 0.0\nd 240 224 192 224 0\nd 240 288 192 288 0\nw 240 176 240 224 0\nw 240 224 240 256 0\nw 240 256 240 288 0\nL 192 224 144 224 0 false false\nL 192 288 144 288 0 false false\n"
  },
  {
    "path": "src/circuits/dtlnor.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\nt 160 240 208 240 0 1 0.5852076661116881 0.6224167269731172\nr 128 160 128 80 0 4700.0\nR 128 80 64 80 0 0 40.0 5.0 0.0\nw 128 80 208 80 0\nt 320 240 368 240 0 1 0.5852076661116883 0.6224167269731175\nr 288 80 288 160 0 4700.0\nw 208 80 288 80 0\nw 288 80 368 80 0\nr 368 80 368 160 0 1000.0\nw 368 160 416 160 0\nM 416 160 480 160 0\nr 208 80 208 160 0 1000.0\nw 208 160 208 192 0\nw 368 160 368 224 0\nw 208 192 416 192 0\nw 416 192 416 160 0\nw 208 192 208 224 0\nd 128 240 160 240 0\nd 128 240 96 240 0\nd 288 240 320 240 0\nd 288 240 256 240 0\nw 128 160 128 240 0\nw 288 160 288 240 0\nL 256 240 256 288 0 false false\ng 208 256 208 320 0\ng 368 256 368 320 0\nL 96 240 96 288 0 false false\n"
  },
  {
    "path": "src/circuits/eclnor.txt",
    "content": "$ 1 5.0E-6 2.2188692582893284 54 1.5 58\nt 48 240 96 240 0 1 -1.3934257822325842 0.1535491976387855 100.0\nt 128 240 176 240 0 1 -1.3934257822325842 0.1535491976387855 100.0\nw 96 224 96 192 0\nw 96 192 176 192 0\nw 176 192 176 224 0\nw 96 256 96 288 0\nw 96 288 176 288 0\nw 176 288 176 256 0\nr 208 288 208 384 0 1180.0\nw 176 288 208 288 0\nw 208 288 240 288 0\nt 288 240 240 240 0 1 -0.20927369468138468 0.6038522693256799 100.0\nw 240 256 240 288 0\nw 240 224 240 144 0\nw 176 192 176 112 0\nr 176 112 176 48 0 217.0\nr 240 48 240 112 0 240.0\nw 240 112 240 144 0\nt 336 192 288 192 0 1 -0.3644785302182464 0.5852183980948591 100.0\nw 288 208 288 240 0\nw 288 176 288 48 0\nw 336 192 336 112 0\nr 336 48 336 112 0 250.0\nw 416 48 336 48 0\nw 336 48 288 48 0\nw 288 48 240 48 0\nw 240 48 176 48 0\nd 336 192 336 240 0\nd 336 240 336 288 0\nr 336 288 336 384 0 2460.0\nw 240 144 384 144 0\nw 176 112 448 112 0\nt 384 144 416 144 0 1 -0.7404232336317208 0.5992782584002211 100.0\nw 416 160 416 240 0\nw 416 128 416 48 0\nt 448 112 480 112 0 1 -0.00657421776741567 0.6036056663680556 100.0\nw 416 48 480 48 0\nw 480 48 480 96 0\nw 480 128 480 208 0\nr 416 288 416 384 0 1500.0\nr 480 288 480 384 0 1500.0\nw 480 384 416 384 0\nw 416 384 336 384 0\nr 288 288 288 384 0 2960.0\nw 208 384 288 384 0\nw 288 384 336 384 0\nR 208 384 160 384 0 0 40.0 -5.2 0.0 0.0 0.5\nw 176 48 128 48 0\ng 128 48 128 80 0\nL 48 240 48 144 0 0 false -0.7 -1.4\nL 128 240 128 144 0 0 false -0.7 -1.4\nM 480 208 528 208 0 -1.0\nM 416 272 528 272 0 -1.0\nx 515 191 541 194 0 12 NOR\nx 518 255 535 258 0 12 OR\nw 416 240 416 272 0\nw 288 288 288 240 0\nw 416 288 416 272 0\nw 480 208 480 288 0\nx 59 278 81 282 0 16 Q1\nx 146 278 168 281 0 16 Q2\nx 212 246 234 250 0 16 Q3\n"
  },
  {
    "path": "src/circuits/eclosc.txt",
    "content": "$ 1 5.0E-6 8.63434833026695 49 1.0 50\nl 128 192 128 256 0 0.1 0.009389546443369765\nc 192 192 192 256 0 4.9999999999999996E-5 0.39860877318423565\nt 160 144 208 144 0 1 0.39860877318423565 0.6730719429761438 100.0\nt 352 144 304 144 0 1 -0.39860877318423565 0.2744631697919081 100.0\nw 208 128 208 96 0\nw 208 96 240 96 0\ng 240 96 240 112 0\nw 208 160 208 176 0\nw 208 176 256 176 0\nw 256 176 304 176 0\nw 304 176 304 160 0\nr 256 176 256 240 0 100.0\nR 256 240 256 272 0 0 40.0 -5.2 0.0 0.0 0.5\nw 304 128 304 64 0\nw 304 64 160 64 0\nw 160 64 160 144 0\nw 160 144 160 192 0\nw 160 192 128 192 0\nw 160 192 192 192 0\nw 128 256 160 256 0\nw 160 256 192 256 0\ng 160 256 160 272 0\ng 352 144 352 160 0\nO 304 64 368 64 0\nx 213 150 235 154 0 16 Q1\nx 279 150 301 154 0 16 Q2\no 23 32 0 42 1.25 2.44140625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/edgedff.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\n151 320 272 432 272 0 2 -0.0\n151 320 144 432 144 0 2 5.0\nw 432 144 432 176 0\nw 432 176 320 240 0\nw 432 272 432 240 0\nw 432 240 320 176 0\nw 320 176 320 160 0\nw 320 240 320 256 0\n151 160 144 272 144 0 2 5.0\n151 160 48 272 48 0 2 5.0\n151 160 272 272 272 0 3 5.0\n151 160 368 272 368 0 2 -0.0\nw 160 64 160 80 0\nw 160 80 272 112 0\nw 160 128 160 112 0\nw 160 112 272 80 0\nw 272 80 272 48 0\nw 160 288 160 304 0\nw 160 304 272 336 0\nw 272 336 272 368 0\nw 160 352 160 336 0\nw 160 336 272 304 0\nw 272 128 320 128 0\nw 272 288 320 288 0\nw 272 176 160 240 0\nw 160 32 128 32 0\nw 128 416 272 416 0\nw 160 272 96 272 0\nw 96 160 160 160 0\nw 160 384 96 384 0\nL 96 384 32 384 0 false false\nR 96 272 32 272 1 2 100.0 2.5 2.5\nM 432 144 496 144 0\nM 432 272 496 272 0\nw 96 160 96 272 0\nw 160 256 160 240 0\nw 272 144 272 176 0\nw 272 368 272 416 0\nw 128 416 128 32 0\nw 272 112 272 128 0\nw 272 128 272 144 0\nw 272 272 272 288 0\nw 272 288 272 304 0\no 30 64 0 6 5.0 9.765625E-5 0 D\no 32 64 0 6 5.0 9.765625E-5 0 Q\no 31 64 0 6 5.0 9.765625E-5 0 clk\n"
  },
  {
    "path": "src/circuits/filt-hipass-l.txt",
    "content": "$ 1 5.0E-6 6.499443210467817 50 5.0 50\nO 400 160 512 160 0\ng 400 288 400 320 0\nr 240 160 400 160 0 187.0\nl 400 160 400 288 0 0.06545 0\n170 240 160 208 160 3 20.0 1000.0 5.0 0.1\no 4 16 0 34 5.0 9.765625E-5 0 -1\no 0 16 0 34 5.0 9.765625E-5 1 -1\nh 5 2 5\n"
  },
  {
    "path": "src/circuits/filt-hipass.txt",
    "content": "$ 1 5.0E-6 6.499443210467817 50 5.0 50\nc 240 160 400 160 0 1.0E-5 0\nr 400 160 400 288 0 35.0\nO 400 160 512 160 0\ng 400 288 400 320 0\n170 240 160 208 160 3 20.0 1000.0 5.0 0.1\no 4 16 0 34 5.0 9.765625E-5 0 -1 in\no 2 16 0 34 2.5 9.765625E-5 1 -1 out\nh 3 1 0\n"
  },
  {
    "path": "src/circuits/filt-lopass-l.txt",
    "content": "$ 1 5.0E-6 6.499443210467817 50 5.0 50\nr 400 160 400 288 0 35.0\nO 400 160 512 160 0\ng 400 288 400 320 0\nl 240 160 400 160 0 0.06545 0\n170 240 160 208 160 3 20.0 1000.0 5.0 0.1\no 4 32 0 34 5.0 9.765625E-5 0 -1\no 1 32 0 34 5.0 9.765625E-5 1 -1\nh 5 0 5\n"
  },
  {
    "path": "src/circuits/filt-lopass.txt",
    "content": "$ 1 5.0E-6 6.499443210467817 50 5.0 50\nO 400 160 512 160 0\ng 400 288 400 320 0\nr 240 160 400 160 0 187.0\nc 400 160 400 288 0 1.0E-5 0\n170 240 160 208 160 3 20.0 1000.0 5.0 0.1\no 4 32 0 34 5.0 9.765625E-5 0 -1\no 0 32 0 34 5.0 9.765625E-5 1 -1\nh 3 2 3\n"
  },
  {
    "path": "src/circuits/filt-vcvs-hipass.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 65 5.0 50\nr 464 192 464 256 0 5860.0\nr 464 256 464 320 0 10000.0\ng 464 320 464 336 0\nw 224 128 224 176 0\ng 304 256 304 272 0\nw 304 176 352 176 0\na 352 192 464 192 1 15.0 -15.0\nw 352 208 352 256 0\nw 352 256 464 256 0\nw 464 192 480 192 0\nw 480 192 480 128 0\nO 480 192 544 192 0\np 144 176 144 256 0\ng 144 256 144 272 0\nc 144 176 224 176 0 5.3E-8 -0.956532193261995\nc 224 176 304 176 0 5.3E-8 2.2055312375929486\nr 304 176 304 256 0 10000.0\nr 224 128 480 128 0 10000.0\n170 144 176 112 176 3 20.0 800.0 5.0 0.2\no 12 32 0 34 5.0 9.765625E-5 0 -1\no 11 32 0 34 2.5 2.44140625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/filt-vcvs-lopass.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 65 5.0 50\nr 160 176 240 176 0 10000.0\nr 240 176 320 176 0 10000.0\nr 480 192 480 256 0 5860.0\nr 480 256 480 320 0 10000.0\ng 480 320 480 336 0\nw 240 128 240 176 0\nc 320 176 320 256 0 1.59E-7 0.00526783980718932\ng 320 256 320 272 0\nw 320 176 368 176 0\na 368 192 480 192 1 15.0 -15.0\nw 368 208 368 256 0\nw 368 256 480 256 0\nw 480 192 496 192 0\nw 496 192 496 128 0\nc 496 128 240 128 0 1.59E-7 3.118399353779175\nO 496 192 560 192 0\np 160 176 160 256 0\ng 160 256 160 272 0\n170 160 176 128 176 3 20.0 800.0 5.0 0.2\no 16 64 0 34 10.0 9.765625E-5 0 -1\no 15 64 0 34 10.0 4.8828125E-5 1 -1\n"
  },
  {
    "path": "src/circuits/flashadc.txt",
    "content": "$ 3 5.0E-6 6.75 58 7.0\na 104 64 176 64 2 5.0 0.0\na 104 112 176 112 2 5.0 0.0\na 104 160 176 160 2 5.0 0.0\na 104 208 176 208 2 5.0 0.0\na 104 256 176 256 2 5.0 0.0\na 104 304 176 304 2 5.0 0.0\na 104 352 176 352 2 5.0 0.0\nr 72 8 72 56 0 500.0\nr 72 56 72 104 0 1000.0\nr 72 104 72 152 0 1000.0\nr 72 152 72 200 0 1000.0\nr 72 200 72 248 0 1000.0\nr 72 248 72 296 0 1000.0\nr 72 296 72 344 0 1000.0\nr 72 344 72 392 0 500.0\nR 72 8 32 8 0 0 40.0 7.0 0.0\nw 72 56 104 56 0\nw 72 104 104 104 0\nw 72 152 104 152 0\nw 72 200 104 200 0\nw 72 248 104 248 0\nw 72 296 104 296 0\nw 72 344 104 344 0\nw 104 72 104 120 0\nw 104 120 104 168 0\nw 104 168 104 216 0\nw 104 216 104 264 0\nw 104 264 104 312 0\nw 104 312 104 360 0\nw 104 72 104 24 0\nR 104 24 184 24 0 4 50.0 3.5 3.5\ng 72 392 72 400 0\n154 288 368 352 368 1 7 5.0\nw 176 352 176 392 0\nw 176 392 288 392 0\nw 176 304 184 304 0\nw 184 304 184 384 0\nw 184 384 288 384 0\nw 176 256 192 256 0\nw 192 256 192 376 0\nw 192 376 288 376 0\nw 176 208 200 208 0\nw 200 208 200 368 0\nw 200 368 288 368 0\nw 176 160 208 160 0\nw 208 160 208 360 0\nw 208 360 288 360 0\nw 176 112 216 112 0\nw 216 112 216 352 0\nw 216 352 288 352 0\nw 176 64 224 64 0\nw 224 64 224 344 0\nw 224 344 288 344 0\n154 280 296 352 296 1 3 5.0\nw 184 304 280 304 0\nw 280 296 248 296 0\nw 280 288 256 288 0\nw 248 296 248 208 0\nw 248 208 200 208 0\nw 256 288 256 112 0\nw 256 112 216 112 0\nw 248 208 352 208 0\nw 352 368 352 328 0\nw 352 208 352 264 0\nM 352 328 472 328 0\nM 352 296 472 296 0\nM 352 264 472 264 0\no 30 32 0 2 10.0 9.765625E-5 0\no 66 32 0 22 6.0 2.44140625E-5 1\no 65 32 0 22 6.0 9.765625E-5 1\no 64 32 0 22 6.0 9.765625E-5 1\n"
  },
  {
    "path": "src/circuits/follower.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nw 256 96 352 96 0\nr 256 96 256 192 0 800.0\nr 256 192 256 304 0 800.0\nt 256 192 352 192 0 1 -3.439010340565611 0.6536862364091407\nw 352 96 352 176 0\nr 352 208 352 304 0 40.0\nw 256 304 352 304 0\nc 208 192 256 192 0 3.0E-6 1.5823558905147017\nR 208 192 160 192 0 1 40.0 5.0 0.0\ng 256 304 256 336 0\nR 256 96 160 96 0 0 40.0 5.0 0.0\nO 352 208 416 208 0\no 2 64 0 2 5.0 0.0015625\no 11 64 0 2 5.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/freqdouble.txt",
    "content": "$ 1 5.0E-6 6.75 61 5.0\n158 416 192 448 192 0\nc 512 192 512 224 0 1.0E-7 0\nr 512 256 576 256 0 3000.0\nr 512 288 576 288 0 100000.0\nw 576 256 576 288 0\ng 576 288 576 320 0\nR 128 144 64 144 0 2 300.0 2.5 2.5\ng 304 224 304 256 0\nw 416 160 416 192 0\na 336 96 416 96 1 15.0 -15.0\nw 304 80 336 80 0\nw 336 112 336 160 0\nw 336 160 416 160 0\nw 416 160 416 96 0\n161 128 144 176 144 0\nr 224 144 304 144 0 2000.0\nw 304 80 304 144 0\nc 304 144 304 176 0 9.999999999999999E-6 0\n155 128 240 144 240 0 5.0\nw 224 240 224 208 0\nw 224 208 128 208 0\nw 128 208 128 176 0\nw 224 304 224 336 0\nw 224 336 96 336 0\nw 96 336 96 240 0\nw 96 240 128 240 0\nw 128 272 64 272 0\nw 64 272 64 352 0\nw 64 352 416 352 0\nw 416 352 416 288 0\nO 416 352 480 352 0\nr 304 176 304 224 0 1000.0\no 6 8 0 14 5.0 4.8828125E-5 0\no 30 8 0 14 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/fulladd.txt",
    "content": "$ 1 5.0E-6 1.5 50 5.0\n154 144 272 272 272 0 2 -0.0\n154 336 256 464 256 0 2 -0.0\nw 272 272 304 272 0\nw 304 272 336 272 0\nw 336 160 272 160 0\nw 336 240 272 240 0\nw 272 240 272 224 0\nw 272 224 144 224 0\nw 272 160 272 224 0\nw 288 128 464 128 0\nM 592 160 624 160 2\nw 112 288 144 288 0\nw 144 112 80 112 0\nw 80 112 80 256 0\nw 80 256 144 256 0\nL 80 256 48 256 2 true false\nL 112 288 48 288 2 true false\nL 144 224 48 224 2 true false\nw 144 144 112 144 0\nw 112 144 112 288 0\nw 464 128 464 144 0\nw 336 192 304 192 0\nw 304 192 304 272 0\nw 464 256 576 256 0\nw 576 256 576 208 0\nM 576 208 624 208 2\n150 144 128 288 128 0 2 0.0\n150 336 176 464 176 0 2 0.0\n152 464 160 592 160 0 2 0.0\n"
  },
  {
    "path": "src/circuits/fullrect.txt",
    "content": "$ 1 5.0E-6 10 53 5.0 50\nv 160 352 160 64 0 1 40.0 5.0 0.0\nw 160 64 304 64 0\nw 304 64 304 128 0\nd 304 128 368 192 0\nd 304 256 368 192 0\nd 240 192 304 128 0\nd 240 192 304 256 0\nw 304 256 304 352 0\nw 304 352 160 352 0\nw 240 192 240 288 0\nw 368 192 416 192 0\nw 240 288 416 288 0\nr 416 192 416 288 0 100.0\nx 463 248 479 248 0 20 load\no 0 64 0 3 5.0 0.05 0\no 12 64 0 3 5.0 0.05 1\n"
  },
  {
    "path": "src/circuits/fullrectf.txt",
    "content": "$ 1 5.0E-6 10 50 5.0 48\nv 96 336 96 48 0 1 40.0 5.0 0.0\nw 96 48 224 48 0\nw 224 48 224 112 0\nd 224 112 288 176 0\nd 224 240 288 176 0\nd 160 176 224 112 0\nd 160 176 224 240 0\nw 224 240 224 336 0\nw 224 336 96 336 0\nw 160 176 160 272 0\nw 288 176 336 176 0\nw 160 272 336 272 0\nc 336 176 336 272 0 1.02E-4 3.2105610440835166\nw 336 176 416 176 0\nw 336 272 416 272 0\nr 416 176 416 272 0 430.0\nx 451 232 457 232 0 16 load\no 0 32 0 2 5.0 9.765625E-5\no 15 32 0 3 5.0 0.0125\n"
  },
  {
    "path": "src/circuits/graycode.txt",
    "content": "$ 3 5.0E-6 23 50 5.0 50\nR 144 152 104 152 1 2 200.0 2.5 2.5\n154 304 152 432 152 0 2 0.0\n154 304 224 432 224 0 2 5.0\n154 304 296 432 296 0 2 0.0\nw 240 312 304 312 0\nw 304 240 304 280 0\nw 240 96 304 96 0\nw 304 96 304 136 0\nw 304 96 432 96 0\nM 432 96 472 96 0 2.5\nM 432 152 472 152 0 2.5\nM 432 224 472 224 0 2.5\nM 432 296 472 296 0 2.5\n164 144 152 224 152 0 4 0.0 5.0 0.0 0.0\nw 240 96 240 152 0\nw 240 184 304 184 0\nw 304 184 304 168 0\nw 304 184 304 208 0\nw 240 248 240 312 0\nw 240 216 264 216 0\nw 264 216 264 240 0\nw 264 240 304 240 0\nR 144 248 104 248 0 0 40.0 5.0 0.0\no 9 64 0 6 5.0 9.765625E-5 0\no 10 64 0 6 5.0 9.765625E-5 0\no 11 64 0 6 5.0 9.765625E-5 0\no 12 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/grid.txt",
    "content": "$ 17 5.0E-6 2 46 5.0 42\nR 272 64 272 16 0\ng 272 352 272 384 0\nr 176 64 176 112 0 5\nr 176 112 176 160 0 5\nr 176 160 176 208 0 5\nr 176 208 176 256 0 5\nr 176 256 176 304 0 5\nr 176 304 176 352 0 5\nr 224 64 224 112 0 5\nr 224 112 224 160 0 5\nr 224 160 224 208 0 5\nr 224 208 224 256 0 5\nr 224 256 224 304 0 5\nr 224 304 224 352 0 5\nr 272 64 272 112 0 5\nr 272 112 272 160 0 5\nr 272 160 272 208 0 5\nr 272 208 272 256 0 5\nr 272 256 272 304 0 5\nr 272 304 272 352 0 5\nr 320 64 320 112 0 5\nr 320 112 320 160 0 5\nr 320 160 320 208 0 5\nr 320 208 320 256 0 5\nr 320 256 320 304 0 5\nr 320 304 320 352 0 5\nr 368 64 368 112 0 5\nr 368 112 368 160 0 5\nr 368 160 368 208 0 5\nr 368 208 368 256 0 5\nr 368 256 368 304 0 5\nr 368 304 368 352 0 5\nr 176 64 224 64 0 5\nr 176 112 224 112 0 5\nr 176 160 224 160 0 5\nr 176 208 224 208 0 5\nr 176 256 224 256 0 5\nr 176 304 224 304 0 5\nr 176 352 224 352 0 5\nr 224 64 272 64 0 5\nr 224 112 272 112 0 5\nr 224 160 272 160 0 5\nr 224 208 272 208 0 5\nr 224 256 272 256 0 5\nr 224 304 272 304 0 5\nr 224 352 272 352 0 5\nr 272 64 320 64 0 5\nr 272 112 320 112 0 5\nr 272 160 320 160 0 5\nr 272 208 320 208 0 5\nr 272 256 320 256 0 5\nr 272 304 320 304 0 5\nr 272 352 320 352 0 5\nr 320 64 368 64 0 5\nr 320 112 368 112 0 5\nr 320 160 368 160 0 5\nr 320 208 368 208 0 5\nr 320 256 368 256 0 5\nr 320 304 368 304 0 5\nr 320 352 368 352 0 5\n"
  },
  {
    "path": "src/circuits/grid2.txt",
    "content": "$ 17 5.0E-6 2 46 5.0\nv 272 256 272 208 0 0\nr 32 64 32 112 0 10\nr 32 112 32 160 0 10\nr 32 160 32 208 0 10\nr 32 208 32 256 0 10\nr 32 256 32 304 0 10\nr 32 304 32 352 0 10\nr 32 352 32 400 0 10\nr 80 64 80 112 0 10\nr 80 112 80 160 0 10\nr 80 160 80 208 0 10\nr 80 208 80 256 0 10\nr 80 256 80 304 0 10\nr 80 304 80 352 0 10\nr 80 352 80 400 0 10\nr 128 64 128 112 0 10\nr 128 112 128 160 0 10\nr 128 160 128 208 0 10\nr 128 208 128 256 0 10\nr 128 256 128 304 0 10\nr 128 304 128 352 0 10\nr 128 352 128 400 0 10\nr 176 64 176 112 0 10\nr 176 112 176 160 0 10\nr 176 160 176 208 0 10\nr 176 208 176 256 0 10\nr 176 256 176 304 0 10\nr 176 304 176 352 0 10\nr 176 352 176 400 0 10\nr 224 64 224 112 0 10\nr 224 112 224 160 0 10\nr 224 160 224 208 0 10\nr 224 208 224 256 0 10\nr 224 256 224 304 0 10\nr 224 304 224 352 0 10\nr 224 352 224 400 0 10\nr 272 64 272 112 0 10\nr 272 112 272 160 0 10\nr 272 160 272 208 0 10\nr 272 256 272 304 0 10\nr 272 304 272 352 0 10\nr 272 352 272 400 0 10\nr 320 64 320 112 0 10\nr 320 112 320 160 0 10\nr 320 160 320 208 0 10\nr 320 208 320 256 0 10\nr 320 256 320 304 0 10\nr 320 304 320 352 0 10\nr 320 352 320 400 0 10\nr 368 64 368 112 0 10\nr 368 112 368 160 0 10\nr 368 160 368 208 0 10\nr 368 208 368 256 0 10\nr 368 256 368 304 0 10\nr 368 304 368 352 0 10\nr 368 352 368 400 0 10\nr 416 64 416 112 0 10\nr 416 112 416 160 0 10\nr 416 160 416 208 0 10\nr 416 208 416 256 0 10\nr 416 256 416 304 0 10\nr 416 304 416 352 0 10\nr 416 352 416 400 0 10\nr 464 64 464 112 0 10\nr 464 112 464 160 0 10\nr 464 160 464 208 0 10\nr 464 208 464 256 0 10\nr 464 256 464 304 0 10\nr 464 304 464 352 0 10\nr 464 352 464 400 0 10\nr 512 64 512 112 0 10\nr 512 112 512 160 0 10\nr 512 160 512 208 0 10\nr 512 208 512 256 0 10\nr 512 256 512 304 0 10\nr 512 304 512 352 0 10\nr 512 352 512 400 0 10\n\n\n\nr 32 64 80 64 0 10\nr 32 112 80 112 0 10\nr 32 160 80 160 0 10\nr 32 208 80 208 0 10\nr 32 256 80 256 0 10\nr 32 304 80 304 0 10\nr 32 352 80 352 0 10\nr 32 400 80 400 0 10\nr 80 64 128 64 0 10\nr 80 112 128 112 0 10\nr 80 160 128 160 0 10\nr 80 208 128 208 0 10\nr 80 256 128 256 0 10\nr 80 304 128 304 0 10\nr 80 352 128 352 0 10\nr 80 400 128 400 0 10\nr 128 64 176 64 0 10\nr 128 112 176 112 0 10\nr 128 160 176 160 0 10\nr 128 208 176 208 0 10\nr 128 256 176 256 0 10\nr 128 304 176 304 0 10\nr 128 352 176 352 0 10\nr 128 400 176 400 0 10\nr 176 64 224 64 0 10\nr 176 112 224 112 0 10\nr 176 160 224 160 0 10\nr 176 208 224 208 0 10\nr 176 256 224 256 0 10\nr 176 304 224 304 0 10\nr 176 352 224 352 0 10\nr 176 400 224 400 0 10\nr 224 64 272 64 0 10\nr 224 112 272 112 0 10\nr 224 160 272 160 0 10\nr 224 208 272 208 0 10\nr 224 256 272 256 0 10\nr 224 304 272 304 0 10\nr 224 352 272 352 0 10\nr 224 400 272 400 0 10\nr 272 64 320 64 0 10\nr 272 112 320 112 0 10\nr 272 160 320 160 0 10\nr 272 208 320 208 0 10\nr 272 256 320 256 0 10\nr 272 304 320 304 0 10\nr 272 352 320 352 0 10\nr 272 400 320 400 0 10\nr 320 64 368 64 0 10\nr 320 112 368 112 0 10\nr 320 160 368 160 0 10\nr 320 208 368 208 0 10\nr 320 256 368 256 0 10\nr 320 304 368 304 0 10\nr 320 352 368 352 0 10\nr 320 400 368 400 0 10\nr 368 64 416 64 0 10\nr 368 112 416 112 0 10\nr 368 160 416 160 0 10\nr 368 208 416 208 0 10\nr 368 256 416 256 0 10\nr 368 304 416 304 0 10\nr 368 352 416 352 0 10\nr 368 400 416 400 0 10\nr 416 64 464 64 0 10\nr 416 112 464 112 0 10\nr 416 160 464 160 0 10\nr 416 208 464 208 0 10\nr 416 256 464 256 0 10\nr 416 304 464 304 0 10\nr 416 352 464 352 0 10\nr 416 400 464 400 0 10\nr 464 64 512 64 0 10\nr 464 112 512 112 0 10\nr 464 160 512 160 0 10\nr 464 208 512 208 0 10\nr 464 256 512 256 0 10\nr 464 304 512 304 0 10\nr 464 352 512 352 0 10\nr 464 400 512 400 0 10\n\n\n"
  },
  {
    "path": "src/circuits/gyrator.txt",
    "content": "$ 1 5.0E-6 10.634267539816555 57 5.0 50\na 368 128 480 128 0 15.0 -15.0 1000000.0\nw 480 128 480 80 0\nw 480 80 368 80 0\nw 368 80 368 112 0\nr 368 144 368 240 0 20000.0\nr 368 112 272 112 0 1000.0\nc 272 144 368 144 0 2.5E-7 -1.9401381307764982\nw 272 144 272 128 0\nw 272 112 272 128 0\nR 272 128 208 128 0 2 20.0 5.0 0.0 0.0 0.5\ng 368 240 368 272 0\nR 272 320 208 320 0 2 20.0 5.0 0.0 0.0 0.5\nl 368 320 368 384 0 5.0 -0.0019401381307769976\ng 368 384 368 400 0\nr 368 320 272 320 0 1000.0\no 9 64 0 35 9.353610478917778 0.005846006549323612 0 -1\no 11 64 0 35 9.353610478917778 0.005846006549323612 1 -1\n"
  },
  {
    "path": "src/circuits/halfadd.txt",
    "content": "$ 1 5.0E-6 1.5 50 5.0\n154 224 240 368 240 0 2 0.0\n150 224 144 368 144 0 2 0.0\nL 128 160 80 160 2 true false\nL 128 224 80 224 2 true false\nw 128 224 160 224 0\nw 160 224 160 128 0\nw 160 128 224 128 0\nw 160 224 224 224 0\nw 128 160 192 160 0\nw 192 160 192 256 0\nw 192 256 224 256 0\nw 192 160 224 160 0\nM 368 144 416 144 2\nM 368 240 416 240 2\n"
  },
  {
    "path": "src/circuits/hartley.txt",
    "content": "$ 1 5.0E-6 3.333936307694169 54 5.0 50\nt 256 128 304 128 0 1 -5.22517933037985 -0.6454813682869913 100.0\nw 80 304 192 304 0\nw 80 128 192 128 0\nw 192 128 256 128 0\nw 192 224 304 224 0\nw 304 144 304 224 0\nw 304 112 352 112 0\nr 352 112 352 304 0 1000.0\nw 192 304 352 304 0\nr 304 112 304 48 0 100.0\nR 304 48 256 48 0 0 40.0 5.0 0.0 0.0 0.5\ng 304 224 304 256 0\nO 352 112 432 112 0\nl 192 128 192 224 0 1.5 -0.001126760367703781\nl 192 224 192 304 0 0.5 -0.005329780746696711\nc 80 128 80 304 0 6.33E-7 -1.0221589514366398\nx 157 182 176 186 0 16 L1\nx 157 273 176 277 0 16 L2\no 12 32 0 42 5.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/hfadc.txt",
    "content": "$ 3 5.0E-6 11.251013186076355 50 5.0 50\n166 360 112 384 112 1 4\nR 408 160 448 160 0 0 40.0 25.5 0.0\nw 408 112 488 112 0\nw 488 112 488 184 0\na 160 272 224 272 2 15.0 -15.0\nr 160 240 224 240 0 100000.0\nw 224 240 224 272 0\nw 488 184 160 184 0\nr 160 184 160 240 0 100000.0\nw 160 240 160 264 0\nw 120 112 120 280 0\nR 120 112 80 112 0 4 5.0 12.8 12.8\nr 120 280 160 280 0 100000.0\ng 160 352 160 368 0\nr 160 280 160 352 0 100000.0\n167 272 112 280 112 1 4\nw 120 112 272 112 0\nR 272 160 232 160 0 0 40.0 25.5 0.0\n167 272 272 296 272 1 4\nw 224 272 272 272 0\nR 272 320 232 320 0 0 40.0 1.5 0.0\nw 320 112 352 112 0\nw 320 128 344 128 0\nw 320 144 336 144 0\nw 320 160 328 160 0\nw 328 160 360 160 0\nw 336 144 360 144 0\nw 344 128 360 128 0\nw 328 160 328 256 0\nw 336 144 336 240 0\nw 344 128 344 224 0\nw 352 112 352 208 0\nw 352 112 360 112 0\nM 352 208 440 208 0 2.5\nM 344 224 456 224 0 2.5\nM 336 240 472 240 0 2.5\nM 328 256 488 256 0 2.5\nM 320 272 504 272 0 2.5\nM 320 288 520 288 0 2.5\nM 320 304 536 304 0 2.5\nM 320 320 552 320 0 2.5\no 33 64 0 6 5.0 9.765625E-5 0\no 34 64 0 6 5.0 9.765625E-5 0\no 35 64 0 6 5.0 9.765625E-5 0\no 36 64 0 6 5.0 9.765625E-5 0\no 37 64 0 6 5.0 9.765625E-5 0\no 38 64 0 6 5.0 9.765625E-5 0\no 39 64 0 6 5.0 9.765625E-5 0\no 40 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/howland.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 58 5.0 50\na 256 160 368 160 0 15.0 -15.0\nw 368 160 368 96 0\nw 368 160 368 224 0\nr 256 224 368 224 0 3000.0\nr 256 96 368 96 0 5000.0\nr 256 96 144 96 0 5000.0\nr 144 224 256 224 0 3000.0\nw 256 176 256 224 0\nR 144 96 144 48 0 0 40.0 -5.0 0.0 0.0 0.5\ng 144 224 144 256 0\nw 256 96 256 144 0\nw 256 224 256 272 0\nr 256 272 256 352 0 2000.0\ns 304 272 304 352 0 1 false\nw 256 352 304 352 0\ng 256 352 256 384 0\nw 256 272 304 272 0\nx 187 67 217 74 0 24 R1\nx 300 67 330 73 0 24 R2\nx 185 259 215 265 0 24 R3\nx 298 259 328 265 0 24 R4\nx 184 320 234 326 0 24 load\no 11 64 0 33 2.5 0.003125 0 -1\n"
  },
  {
    "path": "src/circuits/impedance.txt",
    "content": "$ 1 5.0E-6 4.798788906309526 54 5.0 48\nv 240 176 240 112 0 1 80.0 5.0 0.0 1.5707963267948966 0.5\nr 240 112 400 112 0 100.0\nw 240 176 400 176 0\nv 240 368 240 304 0 1 80.0 5.0 0.0 1.5707963267948966 0.5\nw 240 368 400 368 0\nr 240 304 400 304 0 100.0\nl 400 112 400 176 0 0.34458 3.979221357045121E-4\nc 400 304 400 368 0 1.1486E-5 2.224479357247581\nw 240 272 400 272 0\nv 240 272 240 208 0 1 80.0 5.0 0.0 1.5707963267948966 0.5\nw 240 208 400 208 0\nr 400 208 400 272 0 200.0\no 6 32 0 49 5.0 0.051 0 -1\no 11 32 0 49 5.0 0.051 0 -1\no 7 32 0 49 5.0 0.051 0 -1\n"
  },
  {
    "path": "src/circuits/indmultfreq.txt",
    "content": "$ 1 5.0E-6 10 53 5.0 46\nv 176 96 176 32 2 1 30.0 5.0 0.0\nr 176 32 336 32 0 200.0\nw 176 96 336 96 0\nv 176 192 176 128 2 1 80.0 5.0 0.0\nr 176 128 336 128 0 200.0\nw 176 192 336 192 0\nv 176 288 176 224 2 1 200.0 5.0 0.0\nw 176 288 336 288 0\nr 176 224 336 224 0 200.0\nl 336 32 336 96 0 0.4 0.012667996353689499\nl 336 128 336 192 0 0.4 0.005302775030447975\nl 336 224 336 288 0 0.4 0.009241480515348987\no 9 64 0 17 2.5 0.025\no 10 64 0 17 5.0 0.025\no 11 64 0 17 5.0 0.025\n"
  },
  {
    "path": "src/circuits/indmultind.txt",
    "content": "$ 1 5.0E-6 10 53 5.0 46\nv 224 144 224 80 2 1 80.0 5.0 0.0\nr 224 80 384 80 0 100.0\nw 224 144 384 144 0\nv 224 240 224 176 2 1 80.0 5.0 0.0\nr 224 176 384 176 0 100.0\nw 224 240 384 240 0\nv 224 336 224 272 2 1 80.0 5.0 0.0\nw 224 336 384 336 0\nr 224 272 384 272 0 100.0\nl 384 80 384 144 0 1.0 0\nl 384 176 384 240 0 0.4 0\nl 384 272 384 336 0 0.02 0\no 9 64 0 17 10.0 0.05 0\no 10 64 0 17 5.0 0.05 1\no 11 64 0 17 5.0 0.05 2\n"
  },
  {
    "path": "src/circuits/indpar.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 48 336 48 64 0 0 40.0 5.0 0.0\nS 144 144 144 64 0 false false 1\nw 240 64 240 336 0\nr 48 336 144 336 0 100.0\nr 144 336 240 336 0 100.0\nw 48 64 128 64 0\nw 160 64 240 64 0\nr 288 336 384 336 0 100.0\nr 384 336 480 336 0 100.0\nw 480 64 480 336 0\nS 384 144 384 64 0 false false 1\nw 288 64 368 64 0\nw 400 64 480 64 0\nv 288 336 288 64 0 0 40.0 5.0 0.0\nw 144 144 144 192 0\nw 144 336 144 288 0\nw 144 288 96 288 0\nw 96 192 144 192 0\nw 144 192 192 192 0\nl 96 192 96 288 0 1.0 0\nl 192 192 192 288 0 5.0 0\nl 384 144 384 336 0 .8333 0\nw 144 288 192 288 0\n"
  },
  {
    "path": "src/circuits/indseries.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 48 336 48 64 0 0 40.0 5.0 0.0\nS 144 144 144 64 0 false false 1\nw 240 64 240 336 0\nr 48 336 144 336 0 100.0\nr 144 336 240 336 0 100.0\nw 48 64 128 64 0\nw 160 64 240 64 0\nr 288 336 384 336 0 100.0\nr 384 336 480 336 0 100.0\nw 480 64 480 336 0\nS 384 144 384 64 0 false false 1\nw 288 64 368 64 0\nw 400 64 480 64 0\nv 288 336 288 64 0 0 40.0 5.0 0.0\nl 384 144 384 336 0 1.0 0\nl 144 144 144 240 0 0.1 0\nl 144 240 144 336 0 0.9 0\n"
  },
  {
    "path": "src/circuits/induct.txt",
    "content": "$ 1 5.0E-6 16 50 5.0\nv 96 336 96 64 0 0 40.0 5.0 0.0\nS 256 144 256 64 0 false false 0\nw 96 64 240 64 0\nr 96 336 256 336 0 140.0\nr 256 336 400 336 0 140.0\nw 272 64 400 64 0\nw 400 64 400 336 0\nl 256 144 256 336 0 3.0 0\no 7 128 0 3 5.0 0.05\n"
  },
  {
    "path": "src/circuits/inductac.txt",
    "content": "$ 1 5.0E-6 14.3 55 5.0\nv 176 256 176 80 0 1 40.0 5.0 0.0\nr 176 80 336 80 0 180.0\nw 176 256 336 256 0\nl 336 80 336 256 0 1.0 -0.01522759374043248\no 3 64 0 3 10.0 0.025\n"
  },
  {
    "path": "src/circuits/inductkick-block.txt",
    "content": "$ 1 5.0E-6 10 50 5.0 42\nv 176 304 176 128 0 0 40.0 5.0 0.0\nw 176 304 224 304 0\nw 336 304 288 304 0\ns 224 304 288 304 0 false false\nw 288 304 288 336 0\nw 224 304 224 336 0\nc 224 336 288 336 0 5.0E-10 -0.0\nl 176 128 336 128 0 1.0 0\nr 336 128 336 304 0 100.0\nw 176 128 176 80 0\nw 336 128 336 80 0\nd 336 80 176 80 0\n"
  },
  {
    "path": "src/circuits/inductkick-snub.txt",
    "content": "$ 1 5.0E-6 10 50 5.0 42\nv 176 304 176 128 0 0 40.0 5.0 0.0\nw 176 304 224 304 0\nw 336 304 288 304 0\ns 224 304 288 304 0 false false\nw 288 304 288 336 0\nw 224 304 224 336 0\nc 224 336 288 336 0 5.0E-10 -0.0\nl 176 128 336 128 0 1.0 0\nr 336 128 336 304 0 100.0\nw 176 128 176 80 0\nw 336 128 336 80 0\nr 256 80 176 80 0 100.0\nc 256 80 336 80 0 9.999999999999999E-6 0.04169291603818248\no 7 64 0 3 5.0 0.05\n"
  },
  {
    "path": "src/circuits/inductkick.txt",
    "content": "$ 1 5.0E-6 10 50 5.0 42\nv 176 256 176 80 0 0 40.0 5.0 0.0\nw 176 256 224 256 0\nw 336 256 288 256 0\ns 224 256 288 256 0 false false\nw 288 256 288 288 0\nw 224 256 224 288 0\nc 224 288 288 288 0 5.0E-10 -0.0\nl 176 80 336 80 0 1.0 0\nr 336 80 336 256 0 100.0\no 7 4 0 3 1.52587890625E-4 0.05\no 8 4 0 3 5.0 0.05\no 6 4 0 3 7.62939453125E-5 9.765625E-5\n"
  },
  {
    "path": "src/circuits/inv-osc.txt",
    "content": "$ 1 5.0E-6 73 50 5.0 50\nI 272 208 352 208 0 0.5\nc 352 208 352 128 0 3.9999999999999996E-5 0.3979592824367497\nr 192 128 192 208 0 4000.0\nI 192 208 272 208 0 2.0E-4\np 192 208 192 272 0\ng 192 272 192 288 0\nw 272 128 352 128 0\nr 272 128 272 208 0 400.0\nw 192 128 272 128 0\nO 352 208 432 208 0\no 9 128 0 10 10.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/invertamp.txt",
    "content": "$ 1 5.0E-6 10 53 5.0\nf 272 176 336 176 1\nf 272 272 336 272 0\nw 336 192 336 224 0\nw 336 224 336 256 0\nw 272 176 272 224 0\nw 272 224 272 272 0\nR 336 160 336 112 0 0 40.0 5.0 0.0\ng 336 288 336 320 0\nc 272 224 208 224 0 1.0E-7 2\nR 208 224 160 224 0 1 250.0 0.01 0.0\nw 336 224 416 224 0\nw 416 224 416 64 0\nr 416 64 272 64 0 1000000.0\nw 272 64 272 176 0\nO 416 224 496 224 0\no 9 32 0 2 0.01953125 1.220703125E-5\no 14 32 0 2 5.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/itov.txt",
    "content": "$ 1 5.0E-6 10 59 5.0\nr 272 112 384 112 0 1001.0\nw 272 112 272 160 0\ng 272 192 272 288 0\nS 192 240 192 160 0 true false 0\nS 192 80 192 160 0 true false 0\nw 112 80 112 160 0\nw 112 160 112 240 0\nr 112 160 176 160 0 1000.0\ni 192 80 112 80 0 0.0010\ni 192 240 112 240 0 0.0020\na 272 176 384 176 0\nw 384 112 384 176 0\nO 384 176 448 176 1\nR 112 240 112 280 0 0 40 -5 0 0 .5\nw 272 160 208 160 1\no 14 64 0 1 7.62939453125E-5 0.003125\no 12 64 0 2 5.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/jfetamp.txt",
    "content": "$ 1 5.0E-6 32 60 5.0 53\nr 272 224 272 320 0 1675.0\nj 224 208 272 208 0\nR 224 208 176 208 0 1 40.0 0.1 0.0\nR 272 80 224 80 0 0 40.0 10.0 0.0\nr 272 80 272 192 0 1675.0\nc 272 192 384 192 0 1.0E-6 7.557166811906079\nr 384 192 384 320 0 50000.0\ng 384 320 384 352 0\nO 384 192 448 192 0\nw 272 224 320 224 0\nc 320 224 320 320 0 9.999999999999999E-5 2.459186829842572\nw 272 320 320 320 0\ng 272 320 272 352 0\no 2 128 0 2 0.15625 9.765625E-5 0\no 8 128 0 2 0.625 1.220703125E-5 1\n"
  },
  {
    "path": "src/circuits/jfetcurrentsrc.txt",
    "content": "$ 1 5.0E-6 10 58 10.0\ng 256 336 256 368 0\nw 256 224 256 176 0\nw 256 176 304 176 0\nw 256 80 304 80 0\nR 256 80 256 32 0 0 40.0 10.0 0.0\ns 304 80 304 176 0 true false\nr 256 80 256 176 0 1500.0\nj 208 240 256 240 0\nw 208 240 208 336 0\nw 208 336 256 336 0\nr 256 256 256 336 0 1000.0\no 4 64 0 1 5.0 0.00625\n"
  },
  {
    "path": "src/circuits/jfetfollower-nooff.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nr 256 128 256 224 0 1100.0\nj 208 112 256 112 0\nR 208 112 160 112 0 1 40.0 2.0 0.0\nj 208 240 256 240 0\nr 256 256 256 320 0 1100.0\nw 208 240 208 320 0\nw 208 320 256 320 0\nR 256 320 256 384 0 0 40.0 -10.0 0.0\nO 256 224 352 224 0\nR 256 96 256 32 0 0 40.0 10.0 0.0\no 2 64 0 2 2.5 9.765625E-5\no 8 64 0 2 2.5 1.220703125E-5\n"
  },
  {
    "path": "src/circuits/jfetfollower.txt",
    "content": "$ 1 5.0E-6 10 60 5.0 58\nw 288 80 288 160 0\nr 288 192 288 288 0 10000.0\nO 288 192 336 192 0\nj 240 176 288 176 0\nR 240 176 192 176 0 1 40.0 2.0 0.0\ng 288 288 288 320 0\nR 288 80 240 80 0 0 40.0 10.0 0.0\no 4 64 0 2 2.5 9.765625E-5\no 2 64 0 2 10.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/jkff.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\n151 432 144 528 144 0 2 0.0\n151 432 256 528 256 0 2 5.0\nw 432 224 432 240 0\nw 432 160 432 176 0\nw 528 224 528 256 0\nw 528 224 432 176 0\nw 528 144 528 176 0\nw 528 176 432 224 0\n151 320 128 432 128 0 2 5.0\n151 320 272 432 272 0 2 0.0\nw 320 144 320 256 0\nw 320 256 320 336 0\n151 192 144 288 144 0 2 0.0\n151 192 256 288 256 0 2 5.0\nw 320 112 288 112 0\nw 288 112 288 144 0\nw 288 256 288 288 0\nw 288 288 320 288 0\nw 192 160 192 176 0\nw 192 240 192 224 0\nw 288 224 288 256 0\nw 288 224 192 176 0\nw 288 176 288 144 0\nw 288 176 192 224 0\n151 80 128 192 128 0 3 5.0\nI 64 336 320 336 0 0.5\nM 528 144 592 144 0 2.5\nM 528 256 592 256 0 2.5\nx 518 117 537 123 0 24 Q\nx 520 305 539 311 2 24 Q\nw 32 112 80 112 0\nx 30 47 37 53 0 24 J\nR 64 336 32 336 1 2 120.0 2.5 2.5 0.0 0.5\n151 80 272 192 272 0 3 5.0\nw 432 160 432 64 0\nw 432 64 80 64 0\nw 80 64 80 128 0\nL 32 256 32 224 0 1 false 5.0 0.0\nx 24 193 40 199 0 24 K\nw 64 336 64 256 0\nw 64 256 80 256 0\nw 80 144 64 144 0\nw 64 144 64 256 0\nw 32 288 32 256 0\nw 32 288 80 288 0\nw 432 240 432 368 0\nw 432 368 80 368 0\nw 80 368 80 272 0\nL 32 112 32 80 0 1 false 5.0 0.0\no 48 64 0 38 7.62939453125E-5 9.765625E-5 0 -1 J\no 37 64 0 38 5.0 9.765625E-5 0 -1 K\no 26 64 0 38 7.62939453125E-5 9.765625E-5 0 -1 Q\no 32 64 0 38 5.0 9.765625E-5 0 -1 clk\n"
  },
  {
    "path": "src/circuits/johnsonctr.txt",
    "content": "$ 3 5.0E-6 10.391409633455755 50 5.0 50\n155 88 360 104 360 1 5.0\n155 168 360 184 360 1 5.0\n155 248 360 256 360 1 5.0\n155 328 360 344 360 1 5.0\n155 408 360 424 360 1 5.0\nw 456 392 456 416 0\nw 456 416 64 416 0\nw 64 416 64 360 0\nw 64 360 88 360 0\nw 88 376 80 376 0\nw 80 376 80 440 0\nw 168 376 160 376 0\nw 160 376 160 440 0\nw 248 376 240 376 0\nw 240 376 240 440 0\nw 328 376 320 376 0\nw 320 376 320 440 0\nw 408 376 400 376 0\nw 400 376 400 440 0\nw 80 440 160 440 0\nw 160 440 240 440 0\nw 240 440 320 440 0\nw 320 440 400 440 0\nR 80 440 24 440 1 2 300.0 2.5 2.5 0.0 0.5\n150 128 312 128 256 1 2 5.0\n150 168 312 168 256 1 2 0.0\n150 208 312 208 256 1 2 0.0\n150 248 312 248 256 1 2 0.0\n150 288 312 288 256 1 2 0.0\n150 328 312 328 256 1 2 0.0\n150 368 312 368 256 1 2 0.0\n150 408 312 408 256 1 2 0.0\n150 448 312 448 256 1 2 0.0\n150 88 312 88 256 1 2 0.0\nw 64 360 64 312 0\nw 64 312 80 312 0\nw 136 392 136 344 0\nw 136 344 96 344 0\nw 96 344 96 312 0\nw 120 312 120 320 0\nw 120 320 456 320 0\nw 456 320 456 312 0\nw 136 312 160 312 0\nw 160 312 160 360 0\nw 160 360 168 360 0\nw 456 320 456 360 0\nw 216 360 216 312 0\nw 216 312 240 312 0\nw 216 392 224 392 0\nw 224 392 224 336 0\nw 224 336 176 336 0\nw 176 336 176 312 0\nw 280 312 280 336 0\nw 280 336 224 336 0\nw 296 360 296 312 0\nw 296 312 320 312 0\nw 376 360 376 312 0\nw 376 312 400 312 0\nw 200 312 200 344 0\nw 200 344 136 344 0\nw 360 312 360 328 0\nw 256 328 256 312 0\nw 296 392 304 392 0\nw 256 328 304 328 0\nw 304 328 304 392 0\nw 304 328 360 328 0\nw 336 312 336 336 0\nw 336 336 384 336 0\nw 384 336 440 336 0\nw 440 336 440 312 0\nw 384 336 384 392 0\nw 384 392 376 392 0\nw 416 312 416 328 0\nw 416 328 464 328 0\nw 464 328 464 392 0\nw 464 392 456 392 0\nw 88 256 88 40 0\nw 88 40 456 40 0\nw 168 256 168 64 0\nw 168 64 456 64 0\nw 248 256 248 88 0\nw 248 88 456 88 0\nM 456 40 488 40 0 2.5\nM 456 64 488 64 0 2.5\nM 456 88 488 88 0 2.5\nw 328 256 328 112 0\nw 328 112 456 112 0\nw 408 256 408 136 0\nw 408 136 456 136 0\nM 456 112 488 112 0 2.5\nM 456 136 488 136 0 2.5\nw 456 160 128 160 0\nw 456 184 208 184 0\nw 456 208 288 208 0\nw 456 232 368 232 0\nw 456 256 448 256 0\nw 128 160 128 256 0\nw 208 184 208 256 0\nw 288 208 288 256 0\nw 368 232 368 256 0\nM 456 160 488 160 0 2.5\nM 456 184 488 184 0 2.5\nM 456 208 488 208 0 2.5\nM 456 232 488 232 0 2.5\nM 456 256 488 256 0 2.5\nw 136 360 144 360 0\nw 144 360 144 448 0\nw 144 360 160 360 0\nw 216 360 232 360 0\nw 232 360 232 448 0\nw 232 360 248 360 0\nw 296 360 312 360 0\nw 312 360 328 360 0\nw 312 360 312 448 0\nw 376 360 392 360 0\nw 392 360 392 448 0\nw 392 360 408 360 0\nw 456 360 472 360 0\nw 472 360 472 448 0\nM 144 448 144 464 0 2.5\nM 232 448 232 464 0 2.5\nM 312 448 312 464 0 2.5\nM 392 448 392 464 0 2.5\nM 472 448 472 464 0 2.5\n"
  },
  {
    "path": "src/circuits/ladder.txt",
    "content": "$ 17 5.0E-6 3 44 5.0 35\nv 64 128 64 48 0 5 40.0 5.0 0.0\nw 64 128 112 128 0\nl 64 48 112 48 0 0.01 0.0\nl 112 48 160 48 0 0.01 0.0\nl 160 48 208 48 0 0.01 0.0\nl 208 48 256 48 0 0.01 0.0\nl 256 48 304 48 0 0.01 0.0\nl 304 48 352 48 0 0.01 0.0\nl 352 48 400 48 0 0.01 0.0\nc 112 48 112 128 0 1.0E-4 0.0\nc 160 48 160 128 0 1.0E-4 0.0\nc 208 48 208 128 0 1.0E-4 0.0\nc 256 48 256 128 0 1.0E-4 0.0\nc 304 48 304 128 0 1.0E-4 0.0\nc 352 48 352 128 0 1.0E-4 0.0\nc 400 48 400 128 0 1.0E-4 0.0\nw 112 128 160 128 0\nw 160 128 208 128 0\nw 208 128 256 128 0\nw 256 128 304 128 0\nw 304 128 352 128 0\nw 352 128 400 128 0\nl 400 48 448 48 0 0.01 0.0\nw 448 48 448 160 0\nw 400 128 432 128 0\nw 448 160 400 160 0\nc 400 160 400 240 0 1.0E-4 0.0\nl 400 160 352 160 0 0.01 0.0\nl 352 160 304 160 0 0.01 0.0\nl 304 160 256 160 0 0.01 0.0\nl 256 160 208 160 0 0.01 0.0\nl 208 160 160 160 0 0.01 0.0\nl 160 160 112 160 0 0.01 0.0\nc 352 160 352 240 0 1.0E-4 0.0\nc 304 160 304 240 0 1.0E-4 0.0\nc 256 160 256 240 0 1.0E-4 0.0\nc 208 160 208 240 0 1.0E-4 0.0\nc 160 160 160 240 0 1.0E-4 0.0\nc 112 160 112 240 0 1.0E-4 0.0\nw 432 128 432 240 0\nw 432 240 400 240 0\nw 400 240 352 240 0\nw 352 240 304 240 0\nw 304 240 256 240 0\nw 256 240 208 240 0\nw 208 240 160 240 0\nw 160 240 112 240 0\nl 112 160 64 160 0 0.01 0.0\nw 64 160 64 272 0\nw 112 240 80 240 0\nw 64 272 112 272 0\nc 112 272 112 352 0 1.0E-4 0.0\nw 80 240 80 352 0\nw 80 352 112 352 0\nl 112 272 160 272 0 0.01 0.0\nl 160 272 208 272 0 0.01 0.0\nl 208 272 256 272 0 0.01 0.0\nl 256 272 304 272 0 0.01 0.0\nl 304 272 352 272 0 0.01 0.0\nl 352 272 400 272 0 0.01 0.0\nc 160 272 160 352 0 1.0E-4 0.0\nc 208 272 208 352 0 1.0E-4 0.0\nc 256 272 256 352 0 1.0E-4 0.0\nc 304 272 304 352 0 1.0E-4 0.0\nc 352 272 352 352 0 1.0E-4 0.0\nw 112 352 160 352 0\nw 160 352 208 352 0\nw 208 352 256 352 0\nw 256 352 304 352 0\nw 304 352 352 352 0\nw 352 352 400 352 0\nc 400 272 400 352 0 1.0E-4 0.0\nw 400 272 432 272 0\nw 432 352 400 352 0\nr 432 272 432 352 0 10.0\ng 432 352 432 384 0\no 0 64 0 3 10.0 0.8\no 74 64 0 3 10.0 0.8\n"
  },
  {
    "path": "src/circuits/leadingedge.txt",
    "content": "$ 1 4.0E-9 4 54 5.0\nf 160 144 208 144 1\nf 160 240 208 240 0\nw 208 160 208 192 0\nw 208 192 208 224 0\nR 208 128 208 80 0 0 40.0 5.0 0.0\ng 208 256 208 288 0\ng 288 256 288 288 0\nw 288 192 320 192 0\nw 320 192 320 144 0\nw 320 192 320 240 0\nf 320 144 368 144 1\nf 320 240 368 240 0\nw 368 160 368 192 0\nw 368 192 368 224 0\ng 368 256 368 288 0\nR 368 128 368 80 0 0 40.0 5.0 0.0\nc 208 192 288 192 0 1.0E-9 0.22165573446504094\nr 288 192 288 256 0 1000.0\nw 160 144 160 192 0\nw 160 240 160 192 0\nw 160 192 128 192 0\nw 128 192 128 160 0\nw 128 192 128 224 0\nf 80 240 128 240 0\nf 80 144 128 144 1\nw 80 144 80 192 0\nw 80 192 80 240 0\nR 128 128 128 80 0 0 40.0 5.0 0.0\ng 128 256 128 288 0\nw 368 192 400 192 0\nw 400 192 400 144 0\nw 400 192 400 240 0\nf 400 240 448 240 0\nf 400 144 448 144 1\nw 448 160 448 192 0\nw 448 192 448 224 0\ng 448 256 448 288 0\nR 448 128 448 80 0 0 40.0 5.0 0.0\nM 448 192 496 192 0\nR 80 192 32 192 0 2 200000.0 2.5 2.5\no 39 32 0 2 5.0 9.765625E-5 0\no 38 32 0 2 5.0 9.765625E-5 0\nh 2 17 16\n"
  },
  {
    "path": "src/circuits/ledflasher.txt",
    "content": "$ 17 5.0E-6 2.183 50 5.0 50\n163 160 272 208 272 0 10 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 5.0 0.0\nL 480 336 480 368 0 false false 5.0 0.0\nR 160 304 112 304 1 2 1000.0 2.5 2.5\nw 192 240 192 112 0\n162 192 112 192 64 0 1.0 0.0 0.0\nr 192 64 112 64 0 250.0\ng 112 64 112 112 0\n162 224 112 224 64 0 1.0 0.0 0.0\n162 256 112 256 64 0 1.0 0.0 0.0\n162 288 112 288 64 0 1.0 0.0 0.0\n162 320 112 320 64 0 1.0 0.0 0.0\nw 192 64 224 64 0\nw 224 64 256 64 0\nw 256 64 288 64 0\nw 288 64 320 64 0\nw 352 240 352 112 0\nd 224 240 224 208 0\nd 256 240 256 208 0\nd 288 240 288 208 0\nd 320 240 320 208 0\n162 352 112 352 64 0 1.0 0.0 0.0\nw 352 64 320 64 0\nd 384 240 384 208 0\nd 416 240 416 208 0\nd 448 240 448 208 0\nd 480 240 480 208 0\nw 384 192 384 208 0\nw 416 176 416 208 0\nw 448 160 448 208 0\nw 320 208 320 192 0\nw 320 192 384 192 0\nw 416 176 288 176 0\nw 288 176 288 208 0\nw 448 160 256 160 0\nw 256 160 256 208 0\nw 224 208 224 144 0\nw 224 144 480 144 0\nw 480 144 480 208 0\nw 224 112 224 144 0\nw 256 112 256 160 0\nw 288 112 288 176 0\nw 320 112 320 192 0\n"
  },
  {
    "path": "src/circuits/lissa.txt",
    "content": "$ 1 5.0E-6 52.86996988945491 50 5.0 50\n118 160 208 160 80 0 1 100.0 5.0 0.0 0.0 0.5\n118 160 400 160 256 0 1 104.0 5.0 0.0 0.0 0.5\nw 160 80 208 80 0\nw 160 208 208 208 0\nw 160 256 208 256 0\nw 160 400 208 400 0\np 208 80 208 208 0\np 208 256 208 400 0\n118 288 208 288 80 0 1 40.0 5.0 0.0 0.0 0.5\n118 288 400 288 256 0 1 101.0 5.0 0.0 0.0 0.5\nw 288 80 336 80 0\nw 288 208 336 208 0\nw 288 256 336 256 0\nw 288 400 336 400 0\nw 416 256 464 256 0\nw 416 80 464 80 0\nw 416 208 464 208 0\nw 416 400 464 400 0\n118 416 208 416 80 0 1 91.0 5.0 0.0 0.0 0.5\n118 416 400 416 256 0 1 30.0 5.0 0.0 0.0 0.5\np 336 80 336 208 0\np 336 256 336 400 0\np 464 80 464 208 0\np 464 256 464 400 0\no 6 64 0 226 5.0 6.4 0 7\no 20 64 0 226 5.0 6.4 1 21\no 22 64 0 226 5.0 6.4 2 23\n"
  },
  {
    "path": "src/circuits/logconvert.txt",
    "content": "$ 1 5.0E-6 12.185319768402522 54 5.0 50\na 208 240 304 240 0 15.0 -15.0\nd 304 112 208 112 0\nw 208 144 208 112 0\nc 208 80 304 80 0 1.0E-6 0.6555203584434989\nw 304 80 304 112 0\nw 208 80 208 112 0\nw 208 144 208 224 0\nr 208 224 128 224 0 1000.0\nR 128 224 96 224 0 1 40.0 3.0 3.0 0.0 0.5\ng 208 256 208 272 0\nt 320 272 320 240 0 1 0.0 0.6332109005736126\nw 336 240 352 240 0\nw 352 240 352 272 0\nw 352 272 320 272 0\nw 352 240 384 240 0\ni 384 176 384 240 0 0.01\nR 384 176 384 144 0 0 40.0 10.0 0.0 0.0 0.5\na 384 256 480 256 1 15.0 -15.0\nr 384 320 480 320 0 15000.0\nr 384 320 384 384 0 1000.0\nw 384 272 384 320 0\nw 480 256 480 320 0\ng 384 384 384 400 0\nO 480 256 528 256 0\np 128 224 128 288 0\ng 128 288 128 304 0\nt 256 176 256 144 1 1 -6.5551380330546585E-6 0.6555138033054658\nw 208 144 240 144 0\nw 272 144 304 144 0\nw 304 112 304 144 0\nw 304 144 304 240 0\ng 256 176 256 192 0\no 8 64 0 34 10.0 0.05 0 -1 in\no 23 64 0 34 2.5 2.44140625E-5 1 -1 out\no 24 64 0 226 10.0 1.6 2 23 out vs in\n"
  },
  {
    "path": "src/circuits/longdist.txt",
    "content": "$ 1 5.0E-6 9.001713130052181 39 120.0 42\nv 64 208 64 80 0 1 60.0 120.0 0.0 0.0 0.5\nw 240 160 240 208 1\nT 160 128 240 128 0 0.5 1000.0 -1.0023486497286795 6.35743697744416E-4\nw 160 128 160 80 2\nw 160 160 160 208 1\nr 160 80 64 80 0 10.0\nw 64 208 160 208 0\nw 240 128 240 80 2\nr 240 80 432 80 0 500.0\nr 240 208 432 208 0 500.0\nw 432 80 432 128 0\nw 432 208 432 160 0\nT 432 128 496 128 0 1000000.0 0.0010 -6.357436977444156E-4 0.45338545557553267\nw 496 128 496 80 2\nw 496 80 560 80 0\nw 496 160 496 208 1\nw 496 208 560 208 0\nr 560 80 560 208 0 200.0\nv 64 384 64 256 0 1 60.0 120.0 0.0 0.0 0.5\nr 64 256 160 256 0 10.0\nr 160 256 512 256 0 500.0\nr 160 384 512 384 0 500.0\nw 64 384 160 384 0\nw 512 256 560 256 0\nw 512 384 560 384 0\nr 560 256 560 384 0 200.0\ng 432 208 432 224 0\ng 560 208 560 224 0\no 17 64 1 35 80.0 9.765625E-5 0 -1\no 25 64 1 35 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/lrc-critical.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nr 176 80 384 80 0 516.4\ns 384 80 448 80 0 true false\nw 176 80 176 352 0\nc 176 352 384 352 0 1.4999999999999999E-5 -9.860041921625609\nl 384 80 384 352 0 1.0 0.03019234785322575\nv 448 352 448 80 0 0 40.0 5.0 0.0\nr 384 352 448 352 0 100.0\no 4 64 0 3 20.0 0.05\no 3 64 0 3 10.0 0.05\no 0 64 0 3 0.625 0.05\nh 1 4 3\n"
  },
  {
    "path": "src/circuits/lrc.txt",
    "content": "$ 1 5.0E-6 10 50 5.0 43\nr 176 80 384 80 0 10\ns 384 80 448 80 0 true false\nw 176 80 176 352 0\nc 176 352 384 352 0 1.4999999999999999E-5 -9.860041921625609\nl 384 80 384 352 0 1.0 0.03019234785322575\nv 448 352 448 80 0 0 40.0 5.0 0.0\nr 384 352 448 352 0 100.0\no 4 64 0 3 20.0 0.05\no 3 64 0 3 10.0 0.05\no 0 64 0 3 0.625 0.05\nh 1 4 3\n"
  },
  {
    "path": "src/circuits/majority.txt",
    "content": "$ 1 5.0E-6 1.5 50 5.0\nL 128 144 64 144 0 true false\nL 128 208 64 208 0 true false\nL 128 272 64 272 0 false false\nw 128 208 128 176 0\nw 128 176 192 176 0\nw 128 144 144 144 0\nw 144 144 192 144 0\nw 128 208 128 224 0\nw 128 224 192 224 0\nw 144 144 144 304 0\nw 144 304 192 304 0\nw 128 272 128 256 0\nw 128 256 192 256 0\nw 128 272 128 336 0\nw 128 336 192 336 0\n151 320 240 480 240 0 3 0.0\nw 320 160 320 224 0\nw 320 256 320 320 0\n151 192 160 320 160 0 2 5.0\n151 192 240 320 240 0 2 5.0\n151 192 320 320 320 0 2 5.0\nM 480 240 544 240 0\n"
  },
  {
    "path": "src/circuits/masterslaveff.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\n151 432 160 528 160 0 2 5.0\n151 432 272 528 272 0 2 0.0\nw 432 240 432 256 0\nw 432 176 432 192 0\nw 528 240 528 272 0\nw 528 240 432 192 0\nw 528 160 528 192 0\nw 528 192 432 240 0\n151 320 144 432 144 0 2 5.0\n151 320 288 432 288 0 2 5.0\nw 320 160 320 272 0\nw 320 272 320 352 0\n151 192 160 288 160 0 2 5.0\n151 192 272 288 272 0 2 0.0\nw 320 128 288 128 0\nw 288 128 288 160 0\nw 288 272 288 304 0\nw 288 304 320 304 0\nw 192 176 192 192 0\nw 192 256 192 240 0\nw 288 240 288 272 0\nw 288 240 192 192 0\nw 288 192 288 160 0\nw 288 192 192 240 0\n151 80 144 192 144 0 2 0.0\n151 80 288 192 288 0 2 5.0\nI 80 352 320 352 0\nM 528 160 592 160 0\nM 528 272 592 272 0\nx 518 133 534 133 0 24 Q\nx 520 321 536 321 2 24 Q\nx 153 79 169 79 0 24 master\nx 399 81 415 81 0 24 slave\nw 80 160 80 304 0\nw 80 304 80 352 0\nI 48 128 48 272 0\nw 48 128 80 128 0\nw 48 272 80 272 0\nL 48 128 48 96 0 false false\nx 39 62 55 62 0 24 D\nR 80 352 48 352 1 2 120.0 2.5 2.5\no 38 64 0 6 5.0 9.765625E-5 0 D\no 27 64 0 6 5.0 9.765625E-5 0 Q\no 40 64 0 6 5.0 9.765625E-5 0 clk\n"
  },
  {
    "path": "src/circuits/mirror.txt",
    "content": "$ 1 5.0E-6 11.708435524800691 50 5.0 50\nt 256 112 192 112 0 -1 0.0 -0.625292103755946 1000.0\nt 256 112 320 112 0 -1 2.5545208310942042 -0.6252921037557799 1000.0\nw 256 112 256 160 0\nw 192 128 192 160 0\nw 192 160 256 160 0\nr 192 96 192 32 0 100.0\nr 320 96 320 32 0 100.0\nw 192 32 320 32 0\nR 192 32 128 32 0 0 40.0 5.0 0.0 0.0 0.5\nr 192 160 192 224 0 500.0\nr 320 128 320 224 0 150.0\nw 192 160 128 160 0\ns 128 160 128 224 0 1 false\nr 128 224 192 224 0 200.0\nw 320 128 384 128 0\ns 384 128 384 224 0 1 false\nr 320 224 384 224 0 10.0\nw 192 224 192 288 1\nw 320 224 320 288 1\ng 192 288 192 304 0\ng 320 288 320 304 0\nx 159 112 181 116 0 16 Q1\nx 332 113 354 117 0 16 Q2\n"
  },
  {
    "path": "src/circuits/moscurrentramp.txt",
    "content": "$ 1 5.0E-6 15.50424758475255 55 10.0 50\nr 320 304 320 352 0 10.0\ng 320 352 320 384 0\nR 256 288 208 288 0 0 40.0 2.5 0.0 0.0 0.5\nw 320 272 320 224 0\nw 320 224 416 224 0\nw 320 128 416 128 0\nR 320 128 320 80 0 0 40.0 10.0 0.0 0.0 0.5\nc 320 128 320 224 0 4.9999999999999996E-5 0\nr 416 128 416 224 0 10000.0\nw 320 128 272 128 0\nw 320 224 272 224 0\ns 272 128 272 224 0 1 true\nf 256 288 320 288 0 1.5\no 8 128 0 34 10.0 7.8125E-4 0 -1\n"
  },
  {
    "path": "src/circuits/moscurrentsrc.txt",
    "content": "$ 1 5.0E-6 11.708435524800691 50 10.0 50\nf 352 288 400 288 0 1.5\nw 400 304 400 352 1\ng 400 352 400 384 0\nR 400 112 400 80 0 0 40.0 10.0 0.0 0.0 0.5\nw 400 272 400 240 0\nr 400 112 400 240 0 300.0\nw 400 112 448 112 0\nw 400 240 448 240 0\ns 448 112 448 240 0 1 false\nR 352 288 320 288 0 0 40.0 3.0 0.0 0.0 0.5\n"
  },
  {
    "path": "src/circuits/mosfetamp.txt",
    "content": "$ 1 5.0E-6 42.05934401203833 60 5.0 53\nr 208 176 208 272 0 4000.0\nR 160 160 112 160 0 1 40.0 0.05 0.0 0.0 0.5\nR 208 32 160 32 0 0 40.0 10.0 0.0 0.0 0.5\nr 208 32 208 144 0 4000.0\nc 208 144 320 144 0 1.0E-6 1.938598649739942\nr 320 144 320 272 0 50000.0\ng 320 272 320 304 0\nO 320 144 384 144 0\nw 208 176 256 176 0\nc 256 176 256 272 0 9.999999999999999E-5 8.054803335508433\nw 208 272 256 272 0\nf 160 160 208 160 0 1.5\nR 208 272 208 304 0 0 40.0 -10.0 0.0 0.0 0.5\no 1 128 0 34 0.078125 4.8828125E-5 0 -1\no 7 128 0 34 2.5 3.0517578125E-6 1 -1\n"
  },
  {
    "path": "src/circuits/mosfollower.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 54 5.0 50\nR 208 144 176 144 0 1 40.0 5.0 0.0 0.0 0.5\nO 256 160 320 160 0\nf 208 144 256 144 0 1.5\nr 256 48 256 128 0 500.0\nR 256 48 208 48 0 0 40.0 15.0 0.0 0.0 0.5\nR 256 256 256 288 0 0 40.0 -15.0 0.0 0.0 0.5\ni 256 160 256 256 0 0.0050\no 1 64 0 34 12.0 1.220703125E-5 0 -1\n"
  },
  {
    "path": "src/circuits/mosmirror.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 50 5.0 50\nf 320 288 240 288 0 1.5\nf 320 288 400 288 0 1.5\nw 320 288 320 240 0\nw 320 240 240 240 0\nw 240 240 240 272 0\nw 240 304 240 352 1\nw 240 352 320 352 0\nw 400 304 400 352 1\nw 400 352 320 352 0\ng 320 352 320 384 0\nR 240 112 240 80 0 0 40.0 5.0 0.0 0.0 0.5\nR 400 112 400 80 0 0 40.0 5.0 0.0 0.0 0.5\nw 400 272 400 240 0\nr 400 112 400 240 0 100.0\nw 400 112 448 112 0\nw 400 240 448 240 0\ns 448 112 448 240 0 1 false\nw 240 240 192 240 0\nw 240 112 192 112 0\nr 240 112 240 240 0 500.0\nr 192 112 192 176 0 100.0\ns 192 176 192 240 0 1 false\n"
  },
  {
    "path": "src/circuits/mosswitch.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\ns 288 224 288 304 0 1 false\nw 288 128 400 128 0\nr 400 128 400 288 0 300.0\nw 400 320 400 336 0\nf 288 304 400 304 0 1.5\nw 288 128 288 224 0\nR 288 128 240 128 0 0 40.0 5.0 0.0 0.0 0.5\ng 400 336 400 352 0\n"
  },
  {
    "path": "src/circuits/mr-crossbar.txt",
    "content": "$ 1 5.0E-9 5.023272298708815 52 1.0 50\nm 208 128 256 80 0 100.0 250000.0 0 1.0E-8 1.0E-10\nm 288 128 336 80 0 100.0 250000.0 0 1.0E-8 1.0E-10\nm 208 240 256 192 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10\nm 288 240 336 192 0 100.0 250000.0 0 1.0E-8 1.0E-10\nw 208 128 288 128 0\nw 208 240 288 240 0\nw 256 80 256 192 0\nw 336 80 336 192 0\nw 256 192 256 304 0\nw 336 192 336 304 0\nw 288 240 368 240 0\nw 368 240 448 240 0\nw 288 128 368 128 0\nw 368 128 448 128 0\nm 368 128 416 80 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10\nm 448 128 496 80 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10\nm 368 240 416 192 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10\nm 448 240 496 192 0 100.0 250000.0 0 1.0E-8 1.0E-10\nw 416 80 416 192 0\nw 416 192 416 304 0\nw 496 80 496 192 0\nw 496 192 496 304 0\nS 96 176 208 176 0 0 false 0 false 0\nw 208 128 208 160 0\nw 208 192 208 240 0\nR 96 176 48 176 0 1 500000.0 1.0 0.0 0.0 0.5\nr 256 304 256 368 0 10000.0\nr 336 304 336 368 0 10000.0\nr 416 304 416 368 0 10000.0\nr 496 304 496 368 0 10000.0\ng 256 368 256 384 0\ng 336 368 336 384 0\ng 416 368 416 384 0\ng 496 368 496 384 0\nw 448 128 512 128 0\nw 448 240 512 240 0\nr 512 128 576 128 0 1000.0\nr 512 240 576 240 0 1000.0\ng 576 240 576 272 0\ng 576 128 576 160 0\no 26 32 0 54 1.1 9.765625E-5 0 -1\no 27 32 0 54 1.1 9.765625E-5 0 -1\no 28 32 0 54 1.1 9.765625E-5 0 -1\no 29 32 0 54 1.1 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/mr-sine.txt",
    "content": "$ 1 5.0E-8 9.78399845368213 72 1.0 50\ng 320 304 320 320 0\nm 320 192 320 304 0 100.0 16000.0 0 1.0E-8 1.0E-10\nR 320 192 320 160 0 1 4000.0 1.0 0.0 0.0 0.5\no 1 64 0 35 1.25 1.953125E-4 0 -1\no 1 64 2 35 20480.0 9.765625E-5 1 -1\no 1 64 0 99 2.5 1.953125E-4 2 -1\n"
  },
  {
    "path": "src/circuits/mr-sine2.txt",
    "content": "$ 1 5.0E-8 9.78399845368213 72 1.0 50\ng 320 304 320 320 0\nm 320 192 320 304 0 100.0 12500.0 0.0 1.0E-8 1.0E-10\nR 320 192 320 160 0 1 5000.0 1.0 0.0 0.0 0.5\no 1 64 0 35 1.25 0.003125 0 -1\no 1 64 2 35 20480.0 9.765625E-5 1 -1\no 1 64 0 99 1.25 0.003125 2 -1\n"
  },
  {
    "path": "src/circuits/mr-sine3.txt",
    "content": "$ 1 5.0E-8 9.78399845368213 72 1.0 50\ng 320 304 320 320 0\nm 320 192 320 304 0 100.0 5000.0 3.865479277469485E-9 1.0E-8 1.0E-10\nR 320 192 320 160 0 1 8000.0 2.0 0.0 0.0 0.5\no 1 64 0 35 2.5 0.025 0 -1\no 1 64 2 35 5120.0 2.44140625E-5 1 -1\no 1 64 0 99 2.5 0.025 2 -1\n"
  },
  {
    "path": "src/circuits/mr-square.txt",
    "content": "$ 1 5.0E-8 9.78399845368213 72 1.0 50\ng 320 304 320 320 0\nm 320 192 320 304 0 100.0 16000.0 0 1.0E-8 1.0E-10\nR 320 192 320 160 0 2 6300.0 1.0 0.0 0.0 0.5\no 1 64 0 35 1.25 7.8125E-4 0 -1\no 1 64 2 35 20480.0 9.765625E-5 1 -1\no 1 64 0 99 1.25 7.8125E-4 2 -1\n"
  },
  {
    "path": "src/circuits/mr-triangle.txt",
    "content": "$ 1 5.0E-8 9.78399845368213 72 1.0 50\ng 320 304 320 320 0\nm 320 192 320 304 0 100.0 16000.0 0 1.0E-8 1.0E-10\nR 320 192 320 160 0 3 3200.0 1.0 0.0 0.0 0.5\no 1 64 0 35 1.25 9.765625E-5 0 -1\no 1 64 2 35 20480.0 9.765625E-5 1 -1\no 1 64 0 99 1.25 9.765625E-5 2 -1\n"
  },
  {
    "path": "src/circuits/mr.txt",
    "content": "$ 1 2.0E-8 1.3804574186067096 52 5.0 50\nm 256 144 256 288 0 100.0 16000.0 0 1.0E-8 1.0E-10\ng 256 320 256 336 0\nw 256 288 256 320 1\n172 256 144 256 112 0 6 5.0 5.0 -5.0 0.0 0.5 Voltage\no 0 8 0 35 5.0 0.05 0 -1\no 0 8 2 35 640.0 9.765625E-5 1 -1 resistance\n"
  },
  {
    "path": "src/circuits/multivib-a.txt",
    "content": "$ 1 5.0E-6 8.203437568215378 50 5.0 50\nw 128 48 208 48 0\nw 208 48 288 48 0\nw 288 48 368 48 0\nr 128 48 128 176 0 330.0\nr 208 48 208 176 0 1020.0\nr 288 48 288 176 0 1020.0\nr 368 48 368 176 0 320.0\nc 128 176 208 176 0 1.8E-5 -0.1960622475177095\nc 288 176 368 176 0 1.8E-5 -3.536074488299442\nw 368 176 368 240 0\nt 288 256 368 256 0 1 0.6643052625017931 0.6776743289781562 100.0\nw 208 176 288 256 0\nw 288 176 208 256 0\nt 208 256 128 256 0 1 -4.004317503283525 -3.522705421823079 100.0\nw 128 176 128 240 0\nR 128 48 80 48 0 0 40.0 5.0 0.0 0.0 0.5\ng 128 272 128 304 0\ng 368 272 368 304 0\nx 159 212 180 216 0 16 C1\nx 317 213 338 217 0 16 C2\nx 96 260 118 264 0 16 Q1\nx 382 262 404 266 0 16 Q2\no 13 64 6 35 5.0 9.765625E-5 0 -1\no 10 64 6 35 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/multivib-bi.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 5.0 50\nr 144 32 144 128 0 100.0\nr 384 32 384 128 0 100.0\nw 384 128 384 192 0\nt 304 208 384 208 0 1 0.617227886429507 0.6759235619928714 100.0\nw 224 128 304 208 0\nw 304 128 224 208 0\nt 224 208 144 208 0 1 -4.584864481423058 0.029057265154527386 100.0\nw 144 128 144 192 0\nr 304 128 384 128 0 1020.0\nr 144 128 224 128 0 1020.0\nM 384 128 448 128 0 2.5\nw 144 32 384 32 0\nM 144 128 80 128 0 2.5\nR 144 32 80 32 0 0 40.0 5.0 0.0 0.0 0.5\nr 224 208 224 304 0 1000.0\nr 304 208 304 304 0 1000.0\nL 224 304 80 304 0 0 true 5.0 0.0\nL 304 304 448 304 0 0 true 5.0 0.0\nx 54 105 106 109 2 16 output\nx 422 100 474 104 0 16 output\nx 70 278 93 282 0 16 set\nx 429 277 468 281 0 16 reset\ng 144 224 144 256 0\ng 384 224 384 256 0\nx 106 212 128 216 0 16 Q1\nx 400 213 422 217 0 16 Q2\n"
  },
  {
    "path": "src/circuits/multivib-mono.txt",
    "content": "$ 1 5.0E-6 8.6 50 5.0 50\nw 192 32 272 32 0\nr 192 32 192 160 0 330.0\nr 272 32 272 160 0 1020.0\nr 432 32 432 160 0 320.0\nc 192 160 272 160 0 1.8E-5 4.3449566448532755\nw 432 160 432 224 0\nt 352 240 432 240 0 1 0.6277842747260773 0.6549145378729839 100.0\nw 272 160 352 240 0\nw 352 160 272 240 0\nt 272 240 192 240 0 1 -4.972740919574546 0.027130263151713234 100.0\nw 192 160 192 224 0\nr 352 160 432 160 0 100.0\nt 128 240 192 240 0 1 -4.901331660083208 0.09853952264305138 100.0\nw 128 32 192 32 0\nr 128 32 128 144 0 100.0\ns 128 144 128 240 0 1 true\nw 272 32 432 32 0\nR 128 32 64 32 0 0 40.0 5.0 0.0 0.0 0.5\ng 192 256 192 304 0\ng 432 256 432 304 0\nx 444 247 466 251 0 16 Q1\no 6 64 6 35 2.5 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/mux.txt",
    "content": "$ 1 5.0E-6 19.765835257097933 58 5.0 50\nf 256 112 256 64 0 1.5\nf 256 288 256 224 0 1.5\nf 256 176 256 224 1 1.5\nf 256 16 256 64 1 1.5\nw 256 288 192 288 0\nw 256 16 192 16 0\nR 240 64 64 64 0 1 80.0 2.5 2.5 0.0 0.5\nR 240 224 64 224 0 3 40.0 2.5 2.5 0.0 0.5\nw 272 64 368 64 0\nw 272 224 368 224 0\nw 368 64 368 224 0\nr 368 224 368 304 0 1000.0\ng 368 304 368 336 0\nO 368 224 432 224 0\nw 256 112 256 176 0\nw 192 288 192 176 0\nw 192 176 192 16 0\nI 192 176 256 176 0 0.5\nL 192 288 64 288 0 1 false 5.0 0.0\nx 43 319 88 323 0 16 select\no 13 64 0 34 5.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/mux3state.txt",
    "content": "$ 0 5.0E-6 1.5 50 5.0\n151 112 160 208 160 0 2 5.0\n150 112 288 208 288 0 2 5.0\nf 208 288 272 288 4\nf 208 160 272 160 5\nw 272 176 272 224 0\nw 272 224 272 272 0\ng 272 304 272 336 0\nR 272 144 272 112 0 0 40.0 5.0 0.0\nL 112 176 48 176 0 true false 5.0 0.0\nw 112 144 80 144 0\nw 80 144 80 304 0\nw 80 304 112 304 0\nw 272 224 320 224 0\nw 320 224 368 224 0\nw 368 224 368 272 0\nw 368 224 368 176 0\nf 432 288 368 288 4\nf 432 160 368 160 5\nR 368 144 368 112 0 0 40.0 5.0 0.0\ng 368 304 368 336 0\n150 528 288 432 288 0 2 0.0\n151 528 160 432 160 0 2 5.0\nw 576 144 528 144 0\nw 80 144 80 48 0\nw 576 48 576 144 0\nw 576 144 576 304 0\nw 576 304 528 304 0\nM 320 224 320 384 0 2.5\nI 528 176 528 272 0\nL 528 176 608 176 0 true false 5.0 0.0\nx 32 155 48 155 0 16 in 1\nx 506 358 522 358 0 16 select\nx 593 157 609 157 0 16 in 2\nx 145 95 161 95 0 16 tri-state buffer\nx 382 94 398 94 0 16 tri-state buffer\nL 576 304 576 352 0 true false 5.0 0.0\nI 576 48 80 48 0\nI 112 176 112 272 0\n"
  },
  {
    "path": "src/circuits/nandff.txt",
    "content": "$ 1 5.0E-6 1.5 50 5.0 50\n151 256 160 368 160 0 2 0.0\n151 256 288 368 288 0 2 5.0\nw 368 160 368 192 0\nw 368 192 256 256 0\nw 368 288 368 256 0\nw 368 256 256 192 0\nw 256 192 256 176 0\nw 256 256 256 272 0\nL 256 304 176 304 0 false true 5.0 0.0\nL 256 144 176 144 0 false true 5.0 0.0\nM 368 160 448 160 0 2.5\nM 368 288 448 288 0 2.5\nx 159 120 175 120 0 24 set\nx 438 138 454 138 0 24 Q\nx 147 281 163 281 0 24 reset\nx 438 266 454 266 2 24 Q\n"
  },
  {
    "path": "src/circuits/nic-r.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\na 128 144 256 144 1\nw 128 128 128 80 0\nr 128 80 256 80 0 100.0\nw 256 80 256 144 0\nw 128 160 128 208 0\nr 128 208 256 208 0 100.0\nw 256 144 256 208 0\ng 128 288 128 320 0\nR 128 128 48 128 0 1 100.0 5.0 0.0\nR 416 128 336 128 0 1 100.0 5.0 0.0\ng 416 288 416 320 0\nr 128 208 128 288 0 150.0\nr 416 208 416 288 0 150.0\nw 416 128 416 208 0\no 8 64 0 35 5.0 0.1 0 -1 nic\no 8 64 0 99 5.0 0.1 1 -1 nic I/V\no 9 64 0 35 5.0 0.1 2 -1 normal\no 9 64 0 99 5.0 0.1 3 -1 normal I/V\n"
  },
  {
    "path": "src/circuits/nmosfet.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 5.0 50\nf 304 240 352 240 0 1.5\n172 304 240 272 240 0 6 3.5 5.0 0.0 0.0 0.5 Gate Voltage\nw 352 256 352 304 0\nw 352 224 352 176 1\n172 352 176 352 144 0 6 5.0 5.0 0.0 0.0 0.5 Drain Voltage\ng 352 304 352 320 0\no 0 64 0 35 5.0 0.2 0 -1\n"
  },
  {
    "path": "src/circuits/nmosinverter.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\nR 272 128 208 128 0 0 40.0 5.0 0.0\ng 272 288 272 320 0\nL 224 224 176 224 0 false false\nr 272 128 272 208 0 5000.0\nM 272 208 352 208 0\nf 224 224 272 224 4\nw 272 240 272 288 0\n"
  },
  {
    "path": "src/circuits/nmosinverter2.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 50 5.0 50\nf 320 208 384 208 6 3.5\nf 320 288 384 288 6 1.5\nR 256 144 208 144 0 0 40.0 5.0 0.0 0.0 0.5\nw 256 144 320 144 0\nw 320 144 320 208 0\nw 320 144 384 144 0\nw 384 144 384 192 0\nw 384 224 384 272 0\ng 384 304 384 336 0\nL 320 288 272 288 0 1 false 5.0 0.0\nM 384 224 432 224 0 2.5\n"
  },
  {
    "path": "src/circuits/nmosnand.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\nf 272 224 336 224 4\nw 336 144 336 176 0\nw 336 176 336 208 0\nM 336 176 400 176 0\nf 272 288 336 288 4\nw 336 240 336 272 0\ng 336 304 336 336 0\nw 240 80 336 80 0\nw 336 80 336 112 0\nR 240 80 176 80 0 0 40.0 5.0 0.0\nw 176 288 272 288 0\nL 272 224 112 224 0 false false\nL 176 288 112 288 0 false false\nr 336 112 336 144 0 5000.0\n"
  },
  {
    "path": "src/circuits/norton.txt",
    "content": "$ 17 5.0E-6 10.8 50 5.0\nr 112 160 208 112 0 100.0\nr 208 112 224 208 0 100.0\nr 224 208 320 160 0 200.0\nr 208 112 288 128 0 100.0\nr 304 64 288 128 0 100.0\nv 288 128 384 112 0 0 40.0 5.0 0.0\nv 320 160 320 240 0 0 40.0 5.0 0.0\nv 112 160 128 224 0 0 40.0 5.0 0.0\nv 304 64 224 48 0 0 40.0 5.0 0.0\nv 224 208 224 272 0 0 40.0 5.0 0.0\nr 224 272 304 288 0 200.0\nr 128 224 64 272 0 400.0\nr 384 112 448 176 0 100.0\nr 320 240 384 256 0 100.0\nr 224 48 112 64 0 1000.0\nv 112 64 208 112 0 0 40.0 5.0 0.0\nv 64 272 224 272 0 0 40.0 2.0 0.0\nv 304 288 384 256 0 0 40.0 5.0 0.0\nr 448 176 384 256 0 100.0\nr 320 160 384 112 0 100.0\nr 112 64 112 160 0 100.0\nw 64 272 64 16 0\nw 448 16 448 176 0\ng 448 176 448 240 0\ng 384 384 384 400 0\nr 128 384 384 384 0 117.784267\ni 128 352 384 352 0 0.02383663\nw 384 320 384 352 0\nw 384 352 384 384 0\nw 128 352 128 384 0\nw 128 320 128 352 0\nv 64 16 448 16 0 1 40.0 5.0 0.0\nv 128 320 384 320 0 1 40.0 5.0 0.0\no 31 64 0 3 5.0 0.1\no 32 64 0 3 5.0 0.1\n"
  },
  {
    "path": "src/circuits/notch.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 5.0 40\nl 368 128 368 224 0 0.5 0\nc 368 224 368 320 0 3.17E-5 0\nr 256 128 368 128 0 100.0\nO 368 128 432 128 0\ng 368 320 368 352 0\n170 256 128 224 128 3 20.0 60.0 5.0 0.5\no 5 64 0 34 5.0 9.765625E-5 0 -1 in\no 3 64 0 34 5.0 9.765625E-5 1 -1 out\no 0 64 0 34 10.0 0.025 2 -1 inductor\no 1 64 0 34 10.0 0.025 2 -1 cap\nh 1 0 1\n\n"
  },
  {
    "path": "src/circuits/npn.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 43 2.0 50\n172 240 240 208 240 0 6 0.705 0.75 0.5 0.0 0.5 Base Voltage\nw 352 256 352 304 1\nw 352 224 352 176 1\n172 352 176 352 144 0 6 2.0 2.0 0.0 0.0 0.5 Collector Voltage\ng 352 304 352 320 0\nt 304 240 352 240 0 1 -4.295 0.7049999999999998 100.0\nw 240 240 304 240 1\n"
  },
  {
    "path": "src/circuits/ohms.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 5.0 50\nr 256 176 256 304 0 100.0\n172 304 176 304 128 0 6 5.0 5.0 0.0 0.0 0.5 Voltage\ng 256 336 256 352 0\nw 256 304 256 336 1\nr 352 176 352 304 0 1000.0\nw 352 304 352 336 1\ng 352 336 352 352 0\nw 304 176 352 176 0\nw 256 176 304 176 0\n"
  },
  {
    "path": "src/circuits/opamp-regulator.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\r\nr 192 160 192 208 0 10000.0\r\ng 192 272 192 288 0\r\na 240 224 336 224 1 15.0 -15.0 1000000.0\r\nw 240 208 192 208 0\r\nw 192 160 320 160 0\r\nw 336 192 336 224 0\r\nw 352 160 416 160 1\r\nw 240 240 240 272 0\r\nw 240 272 416 272 0\r\nr 416 160 416 272 0 470.0\r\nr 416 272 416 336 0 470.0\r\ng 416 336 416 352 0\r\nw 416 160 544 160 2\r\nt 336 192 336 160 1 1 0.47225771069311584 0.6621194688210963 100.0\r\nv 560 240 560 176 0 5 60.0 6.0 2.5 0.0 0.5\r\nw 560 240 560 272 1\r\ng 560 272 560 288 0\r\nz 192 272 192 208 1 0.805904783 6.14\r\nx 502 319 631 323 0 18 Simulated load\r\nx 519 332 614 335 0 12 Variable Current\r\nx 436 142 518 145 0 12 Stable Voltage\r\nR 80 160 80 256 0 3 120.0 2.0 16.0 0.0 0.5\r\nx 40 294 142 298 0 18 Variable V/I\r\n174 544 160 576 176 0 1000.0 0.5 Load Current\r\nr 80 160 192 160 0 100.0\r\no 21 64 0 35 20.0 0.05 0 -1 input\r\no 12 64 0 35 20.0 0.025 1 -1 regulated\r\no 14 64 0 35 10.0 0.025 2 -1 load\r\n"
  },
  {
    "path": "src/circuits/opamp.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 50 5.0 50\na 256 240 384 240 0 15.0 -15.0\n172 256 224 208 224 0 6 3.0 5.0 0.0 0.0 0.5 - Voltage\n172 256 256 208 256 0 6 4.0 5.0 0.0 0.0 0.5 + Voltage\nO 384 240 432 240 1\n"
  },
  {
    "path": "src/circuits/opampfeedback.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 50 5.0 50\na 192 176 320 176 0 15.0 -15.0\n172 192 192 144 192 0 6 3.3 5.0 0.0 0.0 0.5 + Voltage\nO 320 176 368 176 1\nw 320 176 320 112 0\nw 192 112 192 160 0\nw 192 112 320 112 0\n"
  },
  {
    "path": "src/circuits/opint-current.txt",
    "content": "$ 1 1.0E-5 1.5642631884188172 54 15.0 66\nt 64 160 96 160 0 1 -14.524416831323471 0.45874279140993174 100.0\nt 128 224 96 224 0 -1 13.155478365585369 -0.45874279140993174 100.0\nt 96 288 144 288 0 1 -29.07296394840523 0.45933099081733353 100.0\nt 144 352 96 352 0 1 -0.45933099081733353 0.45848552057607606 100.0\nr 96 368 96 448 0 1000.0\nr 144 352 144 448 0 50000.0\nw 144 304 144 352 0\nw 96 288 96 336 0\nw 96 288 96 240 0\nw 96 176 96 208 0\nt 240 160 208 160 0 1 -14.524389782067212 0.458756316038061 100.0\nt 176 224 208 224 0 -1 13.001245413909114 -0.4587563160380609 100.0\nw 208 176 208 208 0\nw 128 224 176 224 0\nw 176 224 176 256 0\nw 208 240 208 288 0\nt 144 352 208 352 0 1 -0.6135639424935881 0.4584855205760743 100.0\nw 208 288 208 336 0\nr 208 368 208 448 0 1000.0\nw 96 448 144 448 0\nw 144 448 208 448 0\nR 96 448 48 448 0 0 40.0 -15.0 0.0 0.0 0.5\nt 208 96 160 96 0 -1 0.0 -0.47558316867652906 100.0\nt 208 96 304 96 0 -1 15.441902414143334 -0.47558316867652906 100.0\nw 208 144 160 144 0\nw 96 144 160 144 0\nw 160 112 160 144 0\nw 208 96 208 144 0\nw 304 112 304 256 0\nw 304 256 176 256 0\nw 160 80 160 64 0\nw 160 64 304 64 0\nw 304 64 304 80 0\nw 144 272 144 64 0\nw 144 64 160 64 0\nR 144 64 48 64 0 0 40.0 15.0 0.0 0.0 0.5\nt 336 352 304 352 0 1 -13.514398472585153 0.4758368768112078 100.0\nt 336 352 368 352 0 1 0.0 0.5681159445949842 100.0\nw 304 256 304 336 0\nr 304 368 304 448 0 5000.0\nw 208 448 304 448 0\nw 304 448 368 448 0\nw 368 448 368 368 0\nw 336 352 336 304 0\nw 336 304 368 304 0\nw 368 304 368 336 0\nr 368 304 368 144 0 39000.0\nt 432 96 368 96 0 -1 0.0 -0.5678758104275285 100.0\nt 432 96 512 96 0 -1 14.673938034545353 -0.5678758104275285 100.0\nw 368 112 368 144 0\nw 432 96 432 144 0\nw 432 144 368 144 0\nw 304 64 368 64 0\nw 368 64 368 80 0\nw 368 64 512 64 0\nw 512 64 512 80 0\nw 512 112 512 144 0\nw 512 144 544 144 0\nt 544 144 592 144 0 1 -15.241813844972881 0.2605204218142353 100.0\nt 592 192 544 192 0 1 -0.2605204218142353 8.387701844192463E-8 100.0\nw 544 144 544 176 0\nw 592 160 592 192 0\nw 592 128 592 64 0\nw 592 64 512 64 0\nw 544 208 544 256 0\nr 592 192 592 256 0 25.0\nw 544 256 592 256 0\nr 592 256 592 336 0 50.0\nw 512 144 512 192 0\nw 592 368 592 448 0\nt 480 256 512 256 0 1 -0.3678986750643859 0.5648836713483172 100.0\nr 480 256 480 192 0 4500.0\nr 480 256 480 320 0 7500.0\nw 480 320 512 320 0\nw 512 320 512 272 0\nw 512 240 512 192 0\nw 512 192 480 192 0\nt 512 352 592 352 0 -1 13.825403808614416 -0.5885347729781805 100.0\nw 512 320 512 352 0\nt 480 368 512 368 0 1 -13.221109797257107 0.5677848077046654 100.0\nt 512 400 432 400 0 1 -1.0447597996183795 0.03650920365264376 100.0\nr 512 400 512 448 0 50.0\nw 480 368 480 416 0\nr 480 416 480 448 0 50000.0\nw 480 448 512 448 0\nw 512 448 592 448 0\nw 480 448 432 448 0\nw 432 448 432 416 0\nw 368 448 432 448 0\nw 512 384 512 400 0\nt 432 336 480 336 0 1 -12.744134805343393 0.47697499191371406 100.0\nw 432 336 432 384 0\nw 480 352 480 368 0\nw 208 288 432 288 0\nw 432 288 432 336 0\nw 480 192 432 192 0\nc 432 192 432 288 0 3.0E-11 13.676917151756095\nO 624 256 656 256 0\ng 64 160 64 208 0\nw 240 160 240 32 0\nr 240 32 624 32 0 300.0\nw 624 32 624 256 1\nw 624 256 592 256 0\nr 240 32 144 32 0 150.0\nR 144 32 96 32 0 1 40.0 5.0 0.0 0.0 0.5\nx 29 167 48 173 0 24 +\nx 241 195 255 201 0 24 -\no 97 16 0 34 20.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/opint-invert-amp.txt",
    "content": "$ 1 10.0E-6 1.5642631884188172 54 15.0 66\nt 48 176 80 176 0 1 -14.524416831323471 0.45873235809238094 100.0\nt 112 240 80 240 0 -1 13.155514603842647 -0.45873235809238094 100.0\nt 80 304 128 304 0 1 -29.072979320027407 0.45933003350349466 100.0\nt 128 368 80 368 0 1 -0.45933003350349466 0.4584749892202993 100.0\nr 80 384 80 464 0 1000.0\nr 128 368 128 464 0 50000.0\nw 128 320 128 368 0\nw 80 304 80 352 0\nw 80 304 80 256 0\nw 80 192 80 224 0\nt 224 176 192 176 0 1 -14.524348068778691 0.45876673936477075 100.0\nt 160 240 192 240 0 -1 13.003077911256218 -0.4587667393647708 100.0\nw 192 192 192 224 0\nw 112 240 160 240 0\nw 160 240 160 272 0\nw 192 256 192 304 0\nt 128 368 192 368 0 1 -0.6117667260899236 0.4584749892202975 100.0\nw 192 304 192 352 0\nr 192 384 192 464 0 1000.0\nw 80 464 128 464 0\nw 128 464 192 464 0\nR 80 464 32 464 0 0 40.0 -15.0 0.0 0.0 0.5\nt 192 112 144 112 0 -1 0.0 -0.47558316867652906 100.0\nt 192 112 288 112 0 -1 15.441881547508233 -0.47558316867652906 100.0\nw 192 160 144 160 0\nw 80 160 144 160 0\nw 144 128 144 160 0\nw 192 112 192 160 0\nw 288 128 288 272 0\nw 288 272 160 272 0\nw 144 96 144 80 0\nw 144 80 288 80 0\nw 288 80 288 96 0\nw 128 288 128 80 0\nw 128 80 144 80 0\nR 128 80 32 80 0 0 40.0 15.0 0.0 0.0 0.5\nt 320 368 288 368 0 1 -13.514419339220254 0.4758368768112078 100.0\nt 320 368 352 368 0 1 0.0 0.5681159445949842 100.0\nw 288 272 288 352 0\nr 288 384 288 464 0 5000.0\nw 192 464 288 464 0\nw 288 464 352 464 0\nw 352 464 352 384 0\nw 320 368 320 320 0\nw 320 320 352 320 0\nw 352 320 352 352 0\nr 352 320 352 160 0 39000.0\nt 416 112 352 112 0 -1 0.0 -0.5678758104275303 100.0\nt 416 112 496 112 0 -1 13.570461032205355 -0.5678758104275303 100.0\nw 352 128 352 160 0\nw 416 112 416 160 0\nw 416 160 352 160 0\nw 288 80 352 80 0\nw 352 80 352 96 0\nw 352 80 496 80 0\nw 496 80 496 96 0\nw 496 128 496 160 0\nw 496 160 528 160 0\nt 528 160 576 160 0 1 -14.138336842632885 0.5304968797079701 100.0\nt 576 208 528 208 0 1 -0.5304968797079701 0.004107850119627776 100.0\nw 528 160 528 192 0\nw 576 176 576 208 0\nw 576 144 576 80 0\nw 576 80 496 80 0\nw 528 224 528 272 0\nr 576 208 576 272 0 25.0\nw 528 272 576 272 0\nr 576 272 576 352 0 50.0\nw 496 160 496 208 0\nw 576 384 576 464 0\nt 464 272 496 272 0 1 -0.36778983388140857 0.5648217349170979 100.0\nr 464 272 464 208 0 4500.0\nr 464 272 464 336 0 7500.0\nw 464 336 496 336 0\nw 496 336 496 288 0\nw 496 256 496 208 0\nw 496 208 464 208 0\nt 496 368 576 368 0 -1 14.929051588568608 -0.3979658803531285 100.0\nw 496 336 496 368 0\nt 464 384 496 384 0 1 -14.326295192093617 0.5671551878197238 100.0\nt 496 416 416 416 0 1 -1.0438561639037527 0.03560120865526706 100.0\nr 496 416 496 464 0 50.0\nw 464 384 464 432 0\nr 464 432 464 464 0 50000.0\nw 464 464 496 464 0\nw 496 464 576 464 0\nw 464 464 416 464 0\nw 416 464 416 432 0\nw 352 464 416 464 0\nw 496 400 496 416 0\nt 416 352 464 352 0 1 -13.849594216009589 0.47670097608402884 100.0\nw 416 352 416 400 0\nw 464 368 464 384 0\nw 192 304 416 304 0\nw 416 304 416 352 0\nw 464 208 416 208 0\nc 416 208 416 304 0 3.0E-11 14.782205784808095\nO 608 272 640 272 0\ng 48 176 48 224 0\nw 224 176 224 48 0\nr 224 48 608 48 0 2000.0\nw 608 48 608 272 0\nw 608 272 576 272 0\nr 224 48 128 48 0 1000.0\nR 128 48 80 48 0 1 40.0 5.0 0.0 0.0 0.5\nx 13 183 32 189 0 24 +\nx 225 211 239 217 0 24 -\no 97 16 0 34 20.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/opint-slew.txt",
    "content": "$ 1 2.0E-7 1.0751013186076355 58 15.0 66\nt 64 160 96 160 0 1 -14.524416831323471 -2.506758109063678 100.0\nt 128 224 96 224 0 -1 19.913739554792024 2.5067581090636915 100.0\nt 96 288 144 288 0 1 -29.900223336664652 0.09977639416092643 100.0\nt 144 352 96 352 0 1 -0.09977639416092643 2.691253317976816E-7 100.0\nr 96 368 96 448 0 1000.0\nr 144 352 144 448 0 50000.0\nw 144 304 144 352 0\nw 96 288 96 336 0\nw 96 288 96 240 0\nw 96 176 96 208 0\nt 240 160 208 160 0 1 -8.558744145161098 0.4760782340175016 100.0\nt 176 224 208 224 0 -1 18.933020836280406 -0.4760782340175016 100.0\nw 208 176 208 208 0\nw 128 224 176 224 0\nw 176 224 176 256 0\nw 208 240 208 288 0\nt 144 352 208 352 0 1 -1.0804951126725442 2.69124420526623E-7 100.0\nw 208 288 208 336 0\nr 208 368 208 448 0 1000.0\nw 96 448 144 448 0\nw 144 448 208 448 0\nR 96 448 48 448 0 0 40.0 -15.0 0.0 0.0 0.5\nt 208 96 160 96 0 -1 0.0 -0.47558316867652906 100.0\nt 208 96 304 96 0 -1 9.510900613196101 -0.47558316867652906 100.0\nw 208 144 160 144 0\nw 96 144 160 144 0\nw 160 112 160 144 0\nw 208 96 208 144 0\nw 304 112 304 256 0\nw 304 256 176 256 0\nw 160 80 160 64 0\nw 160 64 304 64 0\nw 304 64 304 80 0\nw 144 272 144 64 0\nw 144 64 160 64 0\nR 144 64 48 64 0 0 40.0 15.0 0.0 0.0 0.5\nt 336 352 304 352 0 1 -19.445400273532385 0.475836876811206 100.0\nt 336 352 368 352 0 1 0.0 0.5681159445949842 100.0\nw 304 256 304 336 0\nr 304 368 304 448 0 5000.0\nw 208 448 304 448 0\nw 304 448 368 448 0\nw 368 448 368 368 0\nw 336 352 336 304 0\nw 336 304 368 304 0\nw 368 304 368 336 0\nr 368 304 368 144 0 39000.0\nt 432 96 368 96 0 -1 0.0 -0.5678758104275303 100.0\nt 432 96 512 96 0 -1 5.935809575255384 -0.5678758104275303 100.0\nw 368 112 368 144 0\nw 432 96 432 144 0\nw 432 144 368 144 0\nw 304 64 368 64 0\nw 368 64 368 80 0\nw 368 64 512 64 0\nw 512 64 512 80 0\nw 512 112 512 144 0\nw 512 144 544 144 0\nt 544 144 592 144 0 1 -6.503685385682914 0.5747794839304037 100.0\nt 592 192 544 192 0 1 -0.5747794839304037 0.024148064987379314 100.0\nw 544 144 544 176 0\nw 592 160 592 192 0\nw 592 128 592 64 0\nw 592 64 512 64 0\nw 544 208 544 256 0\nr 592 192 592 256 0 25.0\nw 544 256 592 256 0\nr 592 256 592 336 0 50.0\nw 512 144 512 192 0\nw 592 368 592 448 0\nt 480 256 512 256 0 1 -0.3684886259495066 0.5652176348585964 100.0\nr 480 256 480 192 0 4500.0\nr 480 256 480 320 0 7500.0\nw 480 320 512 320 0\nw 512 320 512 272 0\nw 512 240 512 192 0\nw 512 192 480 192 0\nt 512 352 592 352 0 -1 22.562608353508985 -0.33477544138584836 100.0\nw 512 320 512 352 0\nt 480 368 512 368 0 1 -21.958971011928803 0.5675170607198208 100.0\nt 512 400 432 400 0 1 -1.0443751009866045 0.03612028086036112 100.0\nr 512 400 512 448 0 50.0\nw 480 368 480 416 0\nr 480 416 480 448 0 50000.0\nw 480 448 512 448 0\nw 512 448 592 448 0\nw 480 448 432 448 0\nw 432 448 432 416 0\nw 368 448 432 448 0\nw 512 384 512 400 0\nt 432 336 480 336 0 1 -21.48211297166202 0.4768580402667837 100.0\nw 432 336 432 384 0\nw 480 352 480 368 0\nw 208 288 432 288 0\nw 432 288 432 336 0\nw 480 192 432 192 0\nc 432 192 432 288 0 3.0E-11 22.41581923247012\nO 624 256 656 256 0\ng 64 160 64 208 0\nw 240 160 240 32 0\nr 240 32 624 32 0 2000.0\nw 624 32 624 256 0\nw 624 256 592 256 0\nr 240 32 144 32 0 1000.0\nR 144 32 96 32 0 2 12000.0 5.0 0.0 0.0 0.5\nx 29 167 48 173 0 24 +\nx 241 195 255 201 0 24 -\no 104 4 0 34 5.0 0.003125 0 -1 in\no 97 2 0 290 20.0 9.765625E-5 1 -1 out\n"
  },
  {
    "path": "src/circuits/opint.txt",
    "content": "$ 1 4.9999999999999996E-6 1.5642631884188172 60 15.0 66\nt 64 128 96 128 0 1 -14.46038257128449 0.4699505311909224 100.0\nt 128 192 96 192 0 -1 13.167263810426565 -0.46995053119092234 100.0\nt 96 256 144 256 0 1 -29.043132450831923 0.4727778362899038 100.0\nt 144 320 96 320 0 1 -0.4727778362899038 0.46966901844007936 100.0\nr 96 336 96 432 0 1000.0\nr 144 320 144 432 0 50000.0\nw 144 272 144 320 0\nw 96 256 96 304 0\nw 96 256 96 208 0\nw 96 144 96 176 0\nt 240 128 208 128 0 1 -14.524414993260976 0.43793432020267864 100.0\nt 176 192 208 192 0 -1 14.106489865918032 -0.43793432020267853 100.0\nw 208 144 208 176 0\nw 128 192 176 192 0\nw 176 192 176 224 0\nw 208 208 208 256 0\nt 144 320 208 320 0 1 0.4664482192015633 0.4735715003080774 100.0\nw 208 256 208 304 0\nr 208 336 208 432 0 1000.0\nw 96 432 144 432 0\nw 144 432 208 432 0\nR 96 432 48 432 0 0 40.0 -15.0 0.0 0.0 0.5\nt 208 64 160 64 0 -1 0.0 -0.47558500673902415 100.0\nt 208 64 304 64 0 -1 15.400283633666334 -0.47558500673902415 100.0\nw 208 112 160 112 0\nw 96 112 160 112 0\nw 160 80 160 112 0\nw 208 64 208 112 0\nw 304 80 304 224 0\nw 304 224 176 224 0\nw 160 48 160 32 0\nw 160 32 304 32 0\nw 304 32 304 48 0\nw 144 240 144 32 0\nw 144 32 160 32 0\nR 144 32 48 32 0 0 40.0 15.0 0.0 0.0 0.5\nt 336 320 304 320 0 1 -13.556006792099927 0.4758387148737153 100.0\nt 336 320 368 320 0 1 0.0 0.5681245674947153 100.0\nw 304 224 304 304 0\nr 304 336 304 432 0 5000.0\nw 208 432 304 432 0\nw 304 432 368 432 0\nw 368 432 368 336 0\nw 336 320 336 272 0\nw 336 272 368 272 0\nw 368 272 368 304 0\nr 368 272 368 112 0 39000.0\nt 432 64 368 64 0 -1 0.0 -0.5579117469270845 100.0\nt 432 64 512 64 0 -1 -0.5576629644457523 -0.5579117469270845 100.0\nw 368 80 368 112 0\nw 432 64 432 112 0\nw 432 112 368 112 0\nw 304 32 368 32 0\nw 368 32 368 48 0\nw 368 32 512 32 0\nw 512 32 512 48 0\nw 512 80 512 112 0\nw 512 112 544 112 0\nt 544 112 592 112 0 1 -2.4878248133219927E-4 0.006121869393414414 100.0\nt 592 160 544 160 0 1 -0.006121869393414414 9.769962616701378E-13 100.0\nw 544 112 544 144 0\nw 592 128 592 160 0\nw 592 96 592 32 0\nw 592 32 512 32 0\nw 544 176 544 224 0\nr 592 160 592 224 0 25.0\nw 544 224 592 224 0\nr 592 224 592 304 0 50.0\nw 512 112 512 160 0\nw 592 336 592 432 0\nt 480 224 512 224 0 1 -1.58176582942815E-9 2.636269869071839E-9 100.0\nr 480 224 480 160 0 4500.0\nr 480 224 480 288 0 7500.0\nw 480 288 512 288 0\nw 512 288 512 240 0\nw 512 208 512 160 0\nw 512 160 480 160 0\nt 512 320 592 320 0 -1 29.999751213300634 0.006121865178858599 100.0\nw 512 288 512 320 0\nt 480 336 512 336 0 1 -29.999751203174743 1.0122121807398798E-8 100.0\nt 512 368 432 368 0 1 -0.0176414936728424 3.767652856367931E-12 100.0\nr 512 368 512 432 0 50.0\nw 480 336 480 384 0\nr 480 384 480 432 0 50000.0\nw 480 432 512 432 0\nw 512 432 592 432 0\nw 480 432 432 432 0\nw 432 432 432 384 0\nw 368 432 432 432 0\nw 512 352 512 368 0\nt 432 304 480 304 0 1 -29.98210971962402 0.017641483550720594 100.0\nw 432 304 432 352 0\nw 480 320 480 336 0\nw 208 256 432 256 0\nw 432 256 432 304 0\nw 480 160 432 160 0\nc 432 160 432 256 0 3.0E-11 29.982109723842058\nO 592 224 624 224 0\nR 64 128 64 176 0 1 120.0 0.1 0.0 0.0 0.5\ng 240 128 240 176 0\nx 245 105 259 111 0 24 -\nx 41 105 60 111 0 24 +\no 98 64 0 34 0.625 9.765625E-5 0 -1\no 97 16 0 34 20.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/peak-detect.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\na 128 144 256 144 1\na 304 160 432 160 1\nd 256 144 272 144 0\nw 272 144 304 144 0\nw 304 176 304 208 0\nw 304 208 432 208 0\nw 432 208 432 160 0\nw 128 160 128 192 0\nw 272 144 272 192 0\nc 272 192 272 288 0 1.0E-5 0.0026623988117427983\ng 272 288 272 320 0\ng 32 288 32 320 0\nw 128 64 128 128 0\nv 32 288 32 176 0 1 40.0 5.0 0.0\nv 32 176 32 64 0 1 110.0 3.0 0.0\nw 128 192 224 192 0\nw 224 192 272 192 0\ns 224 192 224 288 0 true true\nr 224 288 272 288 0 10.0\nw 32 64 80 64 0\nw 80 64 128 64 0\np 80 64 80 288 0\nw 32 288 80 288 0\nO 432 160 480 160 0\nx 161 247 177 247 0 20 reset\no 21 32 0 2 10.0 9.765625E-5 0 input\no 23 64 0 2 10.0 9.765625E-5 1 peak\n"
  },
  {
    "path": "src/circuits/phasecomp.txt",
    "content": "$ 1 5.0E-6 10 53 5.0\nR 272 176 208 176 0 2 105.0 2.5 2.5\nR 272 272 208 272 0 2 100.0 2.5 2.5\nw 272 176 272 208 0\n161 272 208 304 208 0\nw 368 208 416 208 0\nr 416 208 416 112 0 1000.0\nr 416 208 416 304 0 1000.0\nO 416 208 480 208 0\nR 416 112 368 112 0 0 40.0 5.0 0.0\ng 416 304 416 320 0\nw 272 240 272 272 0\no 0 64 0 6 5.0 9.765625E-5 0\no 1 64 0 6 5.0 9.765625E-5 0\no 7 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/phasecompint.txt",
    "content": "$ 1 5.0E-6 10 53 5.0\n155 128 96 144 96 2 0.0\n155 128 256 160 256 2 0.0\nw 224 96 400 96 0\nw 400 96 400 192 0\nw 224 256 400 256 0\nw 400 256 400 224 0\nf 400 256 464 256 4\nf 416 160 464 160 5\nw 224 160 416 160 0\nw 464 176 464 208 0\nw 464 208 464 240 0\ng 464 272 464 320 0\nR 464 144 464 80 0 0 40.0 5.0 0.0\nR 128 128 48 128 0 2 120.0 2.5 2.5\nR 128 288 48 288 0 2 115.0 2.5 2.5\nR 128 96 96 96 0 0 40.0 5.0 0.0\nR 128 256 96 256 0 0 40.0 5.0 0.0\nw 128 208 128 160 0\nw 304 208 304 352 0\nw 304 352 128 352 0\nw 128 352 128 320 0\nw 464 208 528 208 0\nr 528 208 528 144 0 1000.0\nr 528 208 528 272 0 1000.0\nR 528 144 528 80 0 0 40.0 5.0 0.0\ng 528 272 528 320 0\nO 528 208 576 208 0\nw 128 208 304 208 0\n150 400 208 304 208 0 2 0.0\no 13 64 0 6 5.0 9.765625E-5 0\no 14 64 0 6 5.0 9.765625E-5 0\no 26 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/phaseseq.txt",
    "content": "$ 1 2.0E-5 6.7 50 5.0\nr 112 96 176 96 0 100.0\nr 176 96 240 96 0 100.0\nr 240 96 304 96 0 100.0\nr 304 96 368 96 0 100.0\nc 176 96 112 160 0 3.9999999999999996E-5 -0.10741100884462906\nc 240 96 176 160 0 1.9999999999999998E-5 1.1133615569674231\nc 304 96 240 160 0 9.999999999999999E-6 -0.7647587214948204\nc 368 96 304 160 0 4.9999999999999996E-6 -2.06464071412291\nr 112 160 176 160 0 100.0\nr 176 160 240 160 0 100.0\nr 240 160 304 160 0 100.0\nr 304 160 368 160 0 100.0\nc 176 160 112 224 0 3.9999999999999996E-5 -2.8808489197362044\nc 240 160 176 224 0 1.9999999999999998E-5 -1.9733158385444027\nc 304 160 240 224 0 1.0E-5 -2.770585096178578\nc 368 160 304 224 0 4.9999999999999996E-6 -3.3745823741490737\nc 176 224 112 288 0 3.9999999999999996E-5 0.10741100884465973\nc 240 224 176 288 0 1.9999999999999998E-5 -1.1133615569673985\nc 304 224 240 288 0 1.0E-5 0.7647587214948486\nc 368 224 304 288 0 4.9999999999999996E-6 2.064640714122932\nr 112 224 176 224 0 100.0\nr 176 224 240 224 0 100.0\nr 240 224 304 224 0 100.0\nr 304 224 368 224 0 100.0\nr 368 288 304 288 0 100.0\nr 304 288 240 288 0 100.0\nr 240 288 176 288 0 100.0\nr 176 288 112 288 0 100.0\nc 176 288 112 352 0 3.9999999999999996E-5 2.880848919736184\nc 240 288 176 352 0 1.9999999999999998E-5 1.9733158385443441\nc 304 288 240 352 0 1.0E-5 2.770585096178546\nc 368 288 304 352 0 4.9999999999999996E-6 3.3745823741490497\nw 304 352 384 352 0\nw 384 352 384 80 0\nw 384 80 304 80 0\nw 304 80 304 96 0\nw 240 352 240 368 0\nw 240 368 400 368 0\nw 400 368 400 64 0\nw 400 64 240 64 0\nw 240 64 240 96 0\nw 176 352 176 384 0\nw 176 384 416 384 0\nw 416 384 416 48 0\nw 416 48 176 48 0\nw 176 48 176 96 0\nw 112 352 112 400 0\nw 112 400 432 400 0\nw 432 400 432 32 0\nw 432 32 112 32 0\nw 112 32 112 96 0\nw 368 96 448 96 0\nw 368 160 448 160 0\nw 368 224 448 224 0\nw 368 288 448 288 0\nO 448 96 496 96 0\nO 448 160 496 160 0\nO 448 224 496 224 0\nO 448 288 496 288 0\nw 112 96 112 128 0\nw 112 128 112 160 0\nw 112 224 112 256 0\nw 112 256 112 288 0\nv 48 192 48 128 0 1 40.0 5.0 0.0\nv 48 256 48 192 0 1 40.0 5.0 0.0\nw 48 128 112 128 0\nw 48 256 112 256 0\no 55 32 0 6 5.0 9.765625E-5 0\no 56 32 0 6 5.0 9.765625E-5 0\no 57 32 0 6 5.0 9.765625E-5 0\no 58 32 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/phaseshiftosc.txt",
    "content": "$ 1 5.0E-6 13.097415321081861 58 5.0 50\nc 128 224 192 224 0 5.0E-7 11.800776695055955\nc 192 224 256 224 0 5.0E-7 2.013884192737342\nc 256 224 320 224 0 5.0E-7 -0.3404389620445001\nr 320 224 384 224 0 1000.0\nr 192 224 192 304 0 1000.0\nr 256 224 256 304 0 1000.0\ng 192 304 192 320 0\ng 256 304 256 320 0\na 384 240 480 240 0 15.0 -15.0 1000000.0\nw 384 224 384 176 0\nr 384 176 480 176 0 29000.0\nw 480 176 480 240 0\nw 480 240 496 240 0\nw 496 240 496 144 0\nw 496 144 128 144 0\nw 128 144 128 224 0\nO 496 240 544 240 0\ng 384 256 384 304 0\no 3 64 0 34 0.625 0.0015625 0 -1\no 16 64 0 42 20.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/phasesplit.txt",
    "content": "$ 1 5.0E-6 18 64 10.0 53\nw 192 96 288 96 0\nr 192 96 192 192 0 150000.0\nr 192 192 192 304 0 56000.0\nt 192 192 288 192 0 1 -9.442348352812836 0.5777055611167752\nr 288 208 288 304 0 4700.0\nw 192 304 288 304 0\nc 144 192 192 192 0 3.0E-6 -4.905240822514835\nR 144 192 96 192 0 1 40.0 3.0 0.0\ng 192 304 192 336 0\nR 192 96 96 96 0 0 40.0 20.0 0.0\nr 288 96 288 176 0 4700.0\nc 288 208 352 208 0 3.0E-6 4.826735289331256\nr 352 208 352 304 0 10000.0\nw 288 304 352 304 0\nc 288 176 384 176 0 3.0E-6 15.221446280055797\nr 384 176 384 304 0 10000.0\nw 352 304 384 304 0\nO 384 176 448 176 0\nO 352 208 448 208 0\no 17 64 0 6 5.0 9.765625E-5 0\no 18 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/pll.txt",
    "content": "$ 1 5.0E-6 16.13108636308289 65 5.0 50\n158 432 224 464 224 0\nc 528 224 528 256 0 1.0E-6 0\nr 528 288 592 288 0 4000.0\nr 528 320 592 320 0 100000.0\nw 592 288 592 320 0\ng 592 320 592 352 0\n154 144 192 256 192 0 2 0.0\nR 144 176 80 176 0 2 60.0 2.5 2.5 0.0 0.5\nw 144 208 144 320 0\nw 144 320 432 320 0\nr 256 192 320 192 0 5000.0\nc 320 192 320 224 0 9.0E-6 0\nw 432 192 432 224 0\nO 144 320 96 320 0\na 352 128 432 128 1 15.0 -15.0 1000000.0\nw 320 192 320 112 0\nw 320 112 352 112 0\nw 352 144 352 192 0\nw 352 192 432 192 0\nw 432 192 432 128 0\nr 320 224 320 272 0 1000.0\ng 320 272 320 288 0\no 7 64 0 46 5.0 9.765625E-5 0 -1\no 13 64 0 46 5.0 9.765625E-5 0 -1\no 11 64 0 35 1.1692013098647223 0.001461501637330903 1 -1\n"
  },
  {
    "path": "src/circuits/pll2.txt",
    "content": "$ 1 5.0E-6 15.5 60 5.0\n158 416 208 448 208 0\nc 512 208 512 240 0 9.999999999999999E-7 0\nr 512 272 576 272 0 3000.0\nr 512 304 576 304 0 100000.0\nw 576 272 576 304 0\ng 576 304 576 336 0\nR 128 160 64 160 0 2 120.0 2.5 2.5\nw 128 192 128 304 0\nw 128 304 416 304 0\nw 416 176 416 208 0\nO 128 304 80 304 0\na 336 112 416 112 1 15.0 -15.0\nw 304 96 336 96 0\nw 336 128 336 176 0\nw 336 176 416 176 0\nw 416 176 416 112 0\n161 128 160 176 160 0\nr 224 160 304 160 0 500.0\nw 304 96 304 160 0\nc 304 160 304 208 0 9.0E-5 0\nr 304 208 304 256 0 1000.0\ng 304 256 304 272 0\no 6 64 0 14 5.0 9.765625E-5 0\no 10 64 0 14 5.0 9.765625E-5 0\no 19 64 0 3 0.15625 0.05 1\n"
  },
  {
    "path": "src/circuits/pll2a.txt",
    "content": "$ 1 5.0E-6 15 64 5.0\n158 416 208 448 208 0\nc 512 208 512 240 0 1.0E-8 0\nr 512 272 576 272 0 30000.0\nr 512 304 576 304 0 1000000.0\nw 576 272 576 304 0\ng 576 304 576 336 0\nR 128 160 64 160 0 2 970.0 2.5 2.5\nw 128 192 128 304 0\nw 128 304 416 304 0\ng 304 240 304 272 0\nw 416 176 416 208 0\nO 128 304 80 304 0\na 336 112 416 112 1 15.0 -15.0\nw 304 96 336 96 0\nw 336 128 336 176 0\nw 336 176 416 176 0\nw 416 176 416 112 0\n161 128 160 176 160 0\nr 224 160 304 160 0 2000.0\nw 304 96 304 160 0\nc 304 160 304 192 0 9.999999999999999E-6 0\nr 304 192 304 240 0 1000.0\no 6 16 0 14 5.0 4.8828125E-5 0\no 11 16 0 14 5.0 9.765625E-5 0\no 20 64 0 3 5.0 0.0025 1\n"
  },
  {
    "path": "src/circuits/pmosfet.txt",
    "content": "$ 1 5.0E-6 12.185319768402522 50 5.0 50\n172 304 240 272 240 0 6 2.5 5.0 0.0 0.0 0.5 Gate Voltage\nw 352 256 352 304 0\nw 352 224 352 176 1\nf 304 240 352 240 1 1.5\n172 352 304 352 320 0 6 3.0 5.0 0.0 0.0 0.5 Drain Voltage\nR 352 176 352 160 0 0 40.0 5.0 0.0 0.0 0.5\no 3 64 0 35 2.5 0.1 0 -1\n"
  },
  {
    "path": "src/circuits/pnp.txt",
    "content": "$ 1 5.0E-6 11.251013186076355 43 2.0 50\n172 208 176 176 176 0 6 1.2975 1.5 1.25 0.0 0.5 Base Voltage\nw 320 192 320 240 1\nw 320 160 320 112 1\nw 208 176 272 176 1\nt 272 176 320 176 0 -1 1.2975 -0.7024999999999999 100.0\nR 320 112 320 80 0 0 40.0 2.0 0.0 0.0 0.5\n172 320 240 320 272 0 6 0.0 2.0 0.0 0.0 0.5 Collector Voltage\n"
  },
  {
    "path": "src/circuits/pot.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\nv 208 320 208 160 0 0 40.0 5.0 0.0 0.0 0.5\nv 432 320 432 160 0 0 40.0 5.0 0.0 0.0 0.5\nw 320 224 320 160 0\nw 320 160 208 160 0\nw 320 160 432 160 0\n174 208 320 432 224 0 1000.0 0.5 Resistance\n"
  },
  {
    "path": "src/circuits/potdivide.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n174 320 352 384 96 0 1000.0 0.5 Resistance\nv 240 352 240 96 0 0 40.0 5.0 0.0 0.0 0.5\nw 240 96 320 96 0\nw 240 352 320 352 0\nO 320 96 432 96 1\nO 384 224 432 224 1\nO 320 352 432 352 1\n"
  },
  {
    "path": "src/circuits/powerfactor1.txt",
    "content": "$ 13 5.0E-6 10 47 120.0 28\nv 176 304 176 128 2 1 60.0 120.0 0.0\nr 304 128 448 128 0 10.0\nw 176 304 304 304 0\nl 448 128 448 304 0 5.0 0\nw 304 304 448 304 0\nr 176 128 304 128 0 50.0\no 5 64 1 3 0.3125 9.765625E-5 0\no 1 64 1 3 0.078125 2.44140625E-5 1\no 3 64 1 3 5.0 9.765625E-5 2\n"
  },
  {
    "path": "src/circuits/powerfactor2.txt",
    "content": "$ 13 5.0E-6 10 50 120.0 28\nv 176 304 176 128 2 1 60.0 120.0 0.0\nr 304 128 448 128 0 10.0\nw 176 304 304 304 0\nl 448 128 448 304 0 5.0 0\nw 304 304 448 304 0\nr 176 128 304 128 0 50.0\nc 304 128 304 304 0 1.4E-6 0\no 5 64 1 3 0.3125 9.765625E-5 0\no 1 64 1 3 0.078125 2.44140625E-5 1\no 3 64 1 3 5.0 9.765625E-5 2\n"
  },
  {
    "path": "src/circuits/pushpull.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 43 10.0 42\nt 256 192 320 192 0 1 -13.466578126476486 0.7195904601612297\nt 256 288 320 288 0 -1 5.091136762641694 -0.72269465072059\nw 320 208 320 240 0\nw 320 240 320 272 0\nw 320 304 320 352 0\nr 256 288 256 352 0 220.0\nr 256 192 256 128 0 220.0\nd 256 240 256 288 0\nR 256 240 192 240 0 1 40.0 5.0 0.0 0.0 0.5\nw 256 352 320 352 0\nw 256 128 320 128 0\nw 320 128 320 176 0\nR 256 128 256 80 0 0 40.0 10.0 0.0 0.0 0.5\nR 256 352 256 400 0 0 40.0 -10.0 0.0 0.0 0.5\nd 256 192 256 240 0\nw 320 240 400 240 0\nr 400 240 400 352 0 10.0\ng 400 352 400 384 0\nO 400 240 448 240 0\no 8 64 0 34 6.0 0.025 0 -1\no 18 64 0 34 6.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/pushpullxover.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 43 10.0 42\nt 256 192 320 192 0 1 -12.21942316756332 -0.7012139808257767\nt 256 288 320 288 0 -1 7.780576832436679 -0.7012139808257767\nw 320 208 320 240 0\nw 320 240 320 272 0\nw 320 304 320 352 0\nR 256 240 192 240 0 1 40.0 5.0 0.0 0.0 0.5\nw 320 128 320 176 0\nR 320 128 320 80 0 0 40.0 10.0 0.0 0.0 0.5\nR 320 352 320 400 0 0 40.0 -10.0 0.0 0.0 0.5\nw 320 240 400 240 0\nr 400 240 400 352 0 10.0\ng 400 352 400 384 0\nO 400 240 448 240 0\nw 256 240 256 288 0\nw 256 192 256 240 0\no 5 64 0 34 6.0 0.003125 0 -1\no 12 64 0 34 6.0 4.8828125E-5 1 -1\n"
  },
  {
    "path": "src/circuits/r2rladder.txt",
    "content": "$ 1 5.0E-6 10 64 5.0\n160 160 144 160 240 0\n160 240 144 240 240 0\n160 320 144 320 240 0\ng 144 240 144 288 0\ng 224 240 224 288 0\ng 304 240 304 288 0\nw 176 192 192 192 0\nw 176 240 176 256 0\nw 176 256 256 256 0\nw 256 256 256 240 0\nw 256 256 336 256 0\nw 336 256 336 240 0\nw 192 192 192 320 0\nw 256 192 272 192 0\nw 272 192 272 320 0\nw 336 192 352 192 0\nw 352 192 352 320 0\nL 192 320 192 352 0 false false\nL 272 320 272 352 0 false false\nL 352 320 352 352 0 true false\nr 160 144 160 80 0 100000.0\nr 240 144 240 80 0 100000.0\nr 320 144 320 80 0 100000.0\nr 160 80 240 80 0 50000.0\nr 240 80 320 80 0 50000.0\nr 320 80 400 80 0 100000.0\ng 400 80 400 112 0\nw 416 256 416 224 0\nw 528 224 528 272 0\nO 528 272 592 272 1\nw 336 256 416 256 0\nr 416 224 528 224 0 50100.0\ng 416 288 416 320 0\na 416 272 528 272 0 20.0 -20.0\nr 160 80 80 80 0 50000.0\nr 80 80 80 144 0 100000.0\n160 80 144 80 240 0\nw 96 192 112 192 0\nw 112 192 112 320 0\ng 64 240 64 288 0\nL 112 320 112 352 0 true false\nR 80 80 32 80 0 0 40.0 16.0 0.0\nw 96 240 96 256 0\nw 96 256 176 256 0\n"
  },
  {
    "path": "src/circuits/rectify.txt",
    "content": "$ 1 5.0E-6 13.2 55 5.0\nv 112 320 112 96 0 1 40.0 5.0 0.0\nr 416 96 416 320 0 640.0\nd 112 96 416 96 0\nw 112 320 416 320 0\no 0 64 0 3 5.0 0.0125\no 1 64 0 3 5.0 0.0125\n"
  },
  {
    "path": "src/circuits/relaxosc.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 61 10.0 50\na 288 224 416 224 0 15.0 -15.0 1000000.0\nw 288 208 288 160 0\nr 288 160 416 160 0 10000.0\nw 416 160 416 224 0\nw 416 224 416 288 0\nr 416 288 288 288 0 100000.0\nw 288 240 288 288 0\nr 288 288 192 288 0 100000.0\ng 192 288 192 320 0\nc 288 160 192 160 0 9.999999999999999E-7 6.154634481752644\ng 192 160 192 192 0\nO 416 224 480 224 0\no 9 64 0 35 10.0 0.025 0 -1\no 11 64 0 42 20.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/relay.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n178 240 176 384 176 0 1 0.2 0.04166643702749262 0.05 1000000.0 0.02 20.0\n172 240 208 176 208 0 6 5.0 5.0 0.0 0.0 0.5 Coil Voltage\ng 240 288 240 304 0\nR 240 176 240 112 0 0 40.0 5.0 0.0 0.0 0.5\nr 384 160 464 160 0 100.0\nr 384 192 464 192 0 100.0\nr 240 224 240 288 0 100.0\nw 464 160 464 192 0\nw 464 192 464 288 0\ng 464 288 464 304 0\n"
  },
  {
    "path": "src/circuits/relayand.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 44 5.0 50\n178 160 176 240 176 0 1 0.1 8.400979594570726E-14 0.05 1000000.0 0.02 50.0\n178 304 176 384 176 0 1 0.1 2.3377800273993248E-7 0.05 1000000.0 0.02 50.0\n178 448 176 528 176 0 1 0.1 1.5717284793725733E-19 0.05 1000000.0 0.02 50.0\nR 160 176 112 176 0 0 40.0 5.0 0.0 0.0 0.5\nw 240 192 304 192 0\nw 304 176 304 192 0\nw 384 192 448 192 0\nw 448 176 448 192 0\ng 160 224 160 256 0\ng 304 224 304 256 0\ng 448 224 448 256 0\nw 160 208 128 208 0\nw 304 208 272 208 0\nw 448 208 416 208 0\nL 128 208 128 288 0 0 false 5.0 0.0\nL 272 208 272 288 0 0 false 5.0 0.0\nL 416 208 416 288 0 0 false 5.0 0.0\nM 528 192 576 192 0 2.5\nr 528 192 528 272 0 100.0\ng 528 272 528 288 0\n"
  },
  {
    "path": "src/circuits/relayctr.txt",
    "content": "$ 1 1.0E-4 0.37936678946831776 42 5.0 50\n178 112 352 176 352 0 3 0.02 -0.246374098463728 0.05 1000000.0 0.02 20.0\n178 112 128 176 128 0 2 0.02 0.008998074798403165 0.05 1000000.0 0.02 20.0\nR 176 64 208 64 0 0 40.0 6.0 0.0 0.0 0.5\nw 176 112 192 112 0\nw 192 112 192 368 0\nw 192 368 176 368 0\nw 176 96 208 96 0\ng 208 96 208 112 0\nw 176 144 176 192 0\nw 176 192 112 192 0\nw 112 192 112 176 0\nw 112 160 96 160 0\nw 96 256 112 256 0\nw 176 368 176 416 0\nw 176 416 112 416 0\nw 112 416 112 400 0\nw 112 384 80 384 0\ng 80 432 80 448 0\nw 112 304 80 304 0\nw 80 304 80 48 0\nw 80 48 240 48 0\nw 240 48 240 80 0\nw 112 192 64 192 0\nw 64 192 64 352 0\nw 64 352 112 352 0\nw 240 128 240 320 0\nw 176 320 240 320 0\nw 176 272 224 272 0\n162 224 384 224 432 1 2.1024259 1.0 0.0 0.0\ng 224 432 224 448 0\nR 112 256 112 288 0 0 40.0 6.0 0.0 0.0 0.5\nw 224 272 224 304 0\nr 224 304 224 384 0 100.0\nr 432 304 432 384 0 100.0\nw 432 272 432 304 0\nR 320 256 320 288 0 0 40.0 6.0 0.0 0.0 0.5\ng 432 432 432 448 0\n162 432 384 432 432 1 2.1024259 1.0 0.0 0.0\nw 384 272 432 272 0\nw 384 320 448 320 0\nw 448 128 448 320 0\nw 496 128 448 128 0\nw 272 352 320 352 0\nw 272 192 272 352 0\nw 320 192 272 192 0\nw 496 48 496 80 0\nw 288 48 496 48 0\nw 288 304 288 48 0\nw 320 304 288 304 0\ng 288 432 288 448 0\nw 320 384 288 384 0\nw 320 416 320 400 0\nw 384 416 320 416 0\nw 384 368 384 416 0\nw 304 256 320 256 0\nw 320 160 304 160 0\nw 320 192 320 176 0\nw 384 192 320 192 0\nw 384 144 384 192 0\ng 416 96 416 112 0\nw 384 96 416 96 0\nw 400 368 384 368 0\nw 400 112 400 368 0\nw 384 112 400 112 0\nR 384 64 416 64 0 0 40.0 6.0 0.0 0.0 0.5\n178 320 128 384 128 0 2 0.02 0.0012317989769374195 0.05 1000000.0 0.02 20.0\n178 320 352 384 352 0 3 0.02 -0.24971375659971373 0.05 1000000.0 0.02 20.0\nw 240 80 320 80 0\nw 240 128 320 128 0\nr 656 304 656 384 0 100.0\nw 656 272 656 304 0\nR 544 256 544 288 0 0 40.0 6.0 0.0 0.0 0.5\ng 656 432 656 448 0\n162 656 384 656 432 1 2.1024259 1.0 0.0 0.0\nw 608 272 656 272 0\nw 496 352 544 352 0\nw 496 192 496 352 0\nw 544 192 496 192 0\nw 544 304 512 304 0\ng 512 432 512 448 0\nw 544 384 512 384 0\nw 544 416 544 400 0\nw 608 416 544 416 0\nw 608 368 608 416 0\nw 528 256 544 256 0\nw 544 160 528 160 0\nw 544 192 544 176 0\nw 608 192 544 192 0\nw 608 144 608 192 0\ng 640 96 640 112 0\nw 608 96 640 96 0\nw 624 368 608 368 0\nw 624 112 624 368 0\nw 608 112 624 112 0\nR 608 64 640 64 0 0 40.0 6.0 0.0 0.0 0.5\n178 544 128 608 128 0 2 0.02 0.001168923898353853 0.05 1000000.0 0.02 20.0\n178 544 352 608 352 0 3 0.02 -0.24487149798797075 0.05 1000000.0 0.02 20.0\nw 496 80 544 80 0\nw 496 128 544 128 0\nw 112 80 112 64 0\nw 112 64 48 64 0\nw 112 128 48 128 0\n159 48 64 48 128 0 1.0 1.0E10\nR 32 96 32 16 1 2 25.0 2.5 2.5 0.0 0.5\nw 96 160 96 256 0\nw 304 160 304 256 0\nw 528 160 528 256 0\nw 80 384 80 432 0\nw 288 384 288 432 0\nw 512 384 512 432 0\no 73 8 0 37 2.3384026197294445 0.046768052394588894 0 -1\no 37 8 0 37 2.187250724783012 0.04374501449566024 0 -1\no 28 8 0 37 2.3384026197294445 0.046768052394588894 0 -1\n"
  },
  {
    "path": "src/circuits/relayff.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 45 5.0 50\n178 224 192 336 192 1 1 0.2 0.21813393565127673 0.05 1000000.0 0.02 20.0\n178 528 192 400 192 1 1 0.2 4.99990000199996E-6 0.05 1000000.0 0.02 20.0\nw 352 176 384 224 0\nw 352 224 384 176 0\nw 224 192 224 144 0\nw 224 144 528 144 0\nw 528 144 528 192 0\nR 224 144 160 144 0 0 40.0 5.0 0.0 0.0 0.5\ns 336 240 336 320 0 0 true\ns 400 240 400 320 0 0 true\ng 336 320 336 336 0\ng 400 320 400 336 0\nx 247 286 317 290 0 16 set/reset\nw 336 176 352 176 0\nw 336 224 352 224 0\nw 384 224 400 224 0\nw 384 176 400 176 0\n"
  },
  {
    "path": "src/circuits/relaymux.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n178 128 160 208 160 0 1 0.1 0.24999999999997224 0.05 1000000.0 0.02 50.0\n178 256 192 336 192 0 2 0.1 0.24999710044544057 0.05 1000000.0 0.02 50.0\n178 384 224 464 224 0 4 0.1 0.24999999999997224 0.05 1000000.0 0.02 50.0\ng 128 208 128 240 0\ng 256 240 256 272 0\ng 384 272 384 288 0\nw 128 192 96 192 0\nw 256 224 224 224 0\nw 384 256 352 256 0\nL 96 192 96 352 0 1 false 5.0 0.0\nL 224 224 224 352 0 1 false 5.0 0.0\nL 352 256 352 352 0 1 false 5.0 0.0\nR 128 160 96 160 0 0 40.0 5.0 0.0 0.0 0.5\nw 208 144 256 144 0\nw 208 176 208 192 0\nw 208 192 256 192 0\nw 336 128 336 80 0\nw 336 80 384 80 0\nw 336 160 384 160 0\nw 384 160 384 128 0\nw 336 176 384 176 0\nw 336 208 384 208 0\nw 384 208 384 224 0\nM 464 64 512 64 4 2.5\nM 464 96 512 96 4 2.5\nM 464 112 512 112 4 2.5\nM 464 144 512 144 4 2.5\nM 464 160 512 160 4 2.5\nM 464 192 512 192 4 2.5\nM 464 208 512 208 4 2.5\nM 464 240 512 240 4 2.5\n"
  },
  {
    "path": "src/circuits/relayor.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 44 5.0 50\n178 112 176 192 176 0 1 0.1 1.4393787726652385E-9 0.05 1000000.0 0.02 50.0\n178 304 176 384 176 0 1 0.1 7.78801831882807E-17 0.05 1000000.0 0.02 50.0\n178 480 176 560 176 0 1 0.1 1.8053432778617287E-13 0.05 1000000.0 0.02 50.0\nR 112 176 80 176 0 0 40.0 5.0 0.0 0.0 0.5\ng 112 224 112 256 0\ng 304 224 304 256 0\ng 480 224 480 256 0\nw 112 208 80 208 0\nw 304 208 272 208 0\nw 480 208 448 208 0\nL 80 208 80 288 0 0 false 5.0 0.0\nL 272 208 272 288 0 0 false 5.0 0.0\nL 448 208 448 288 0 0 false 5.0 0.0\nM 592 192 640 192 0 2.5\nr 592 192 592 272 0 100.0\ng 592 272 592 288 0\nR 304 176 272 176 0 0 40.0 5.0 0.0 0.0 0.5\nR 480 176 448 176 0 0 40.0 5.0 0.0 0.0 0.5\nw 192 192 224 192 0\nw 224 192 224 128 0\nw 224 128 416 128 0\nw 416 128 416 192 0\nw 416 192 384 192 0\nw 416 128 592 128 0\nw 592 128 592 192 0\nw 560 192 592 192 0\n"
  },
  {
    "path": "src/circuits/relaytff.txt",
    "content": "$ 1 1.0E-5 18.278915558614752 50 5.0 50\n178 496 224 592 224 1 1 0.1 9.996201113724626E-6 0.05 1000000.0 0.02 20.0\nR 112 208 64 208 0 0 40.0 5.0 0.0 0.0 0.5\nw 176 208 176 368 0\nw 368 304 448 304 0\nw 176 368 368 368 0\nw 368 272 400 272 0\nw 400 320 400 368 0\nw 400 368 368 368 0\nw 368 176 624 176 0\nw 624 176 624 240 0\nw 624 240 592 240 0\ns 208 144 288 144 0 1 false\nw 288 288 208 288 0\nr 112 208 176 208 0 100.0\n178 288 288 368 288 1 2 0.1 9.996201118876302E-6 0.05 1000000.0 0.02 20.0\nw 208 288 208 144 0\nw 368 256 416 256 0\nw 416 256 416 224 0\nw 448 224 496 224 0\nw 368 224 368 176 0\nw 416 336 416 256 0\ng 448 304 448 336 0\nw 416 224 448 224 0\nw 288 144 288 240 0\nx 225 97 275 101 0 16 toggle\nw 368 336 416 336 0\nw 368 320 400 320 0\nw 400 272 400 320 0\nw 592 256 624 256 0\nw 624 240 624 256 0\ng 592 272 592 336 0\n"
  },
  {
    "path": "src/circuits/relayxor.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 47 5.0 50\n178 176 192 272 192 0 1 0.1 4.3921117436851676E-10 0.05 1000000.0 0.02 50.0\n178 400 192 304 192 0 1 0.1 1.9184076606594825E-6 0.05 1000000.0 0.02 50.0\nw 272 176 304 208 0\nw 272 208 304 176 0\nR 176 192 144 192 0 0 40.0 5.0 0.0 0.0 0.5\ng 176 240 176 256 0\ng 400 240 400 256 0\nw 176 224 144 224 0\nw 400 224 432 224 0\nL 144 224 144 304 0 0 false 5.0 0.0\nL 432 224 432 304 0 0 false 5.0 0.0\nw 400 192 480 192 0\nr 480 192 480 272 0 100.0\ng 480 272 480 288 0\nM 480 192 528 192 0 2.5\n"
  },
  {
    "path": "src/circuits/res-par.txt",
    "content": "$ 1 5.0E-6 15 53 5.0\nv 64 240 64 160 0 1 41.09 5.0 0.0\nc 448 160 448 240 0 1.4999999999999999E-5 2.5658496700882356\nw 64 160 192 160 0\nw 192 160 320 160 0\nw 320 160 448 160 0\nl 320 160 320 240 0 1.0 -0.016508821800832994\nr 192 160 192 240 0 2000.0\nw 192 240 320 240 0\nw 320 240 448 240 0\nr 64 240 192 240 0 100.0\nv 64 128 64 48 0 1 30.0 5.0 0.0\nc 448 48 448 128 0 1.4999999999999999E-5 -4.290086412851864\nw 64 48 192 48 0\nw 192 48 320 48 0\nw 320 48 448 48 0\nl 320 48 320 128 0 1.0 0.01334973082855116\nr 192 48 192 128 0 2000.0\nw 192 128 320 128 0\nw 320 128 448 128 0\nr 64 128 192 128 0 100.0\nv 64 352 64 272 0 1 50.0 5.0 0.0\nc 448 272 448 352 0 1.4999999999999999E-5 2.9322583665440085\nw 64 272 192 272 0\nw 192 272 320 272 0\nw 320 272 448 272 0\nl 320 272 320 352 0 1.0 -0.01279067133991683\nr 192 272 192 352 0 2000.0\nw 192 352 320 352 0\nw 320 352 448 352 0\nr 64 352 192 352 0 100.0\nh 1 5 1\no 10 64 0 1 2.5 0.025\no 0 64 0 1 2.5 0.003125\no 20 64 0 1 2.5 0.0125\n"
  },
  {
    "path": "src/circuits/res-series.txt",
    "content": "$ 1 5.0E-6 15 48 5.0\nv 80 112 80 32 0 1 35.0 5.0 0.0\nv 80 224 80 144 0 1 41.09 5.0 0.0\nv 80 336 80 256 0 1 45.0 5.0 0.0\nr 80 32 432 32 0 10.0\nc 432 32 432 112 0 1.5E-5 0\nl 80 112 432 112 0 1.0 0\nr 80 144 432 144 0 10.0\nc 432 144 432 224 0 1.5E-5 0\nl 80 224 432 224 0 1.0 0\nr 80 256 432 256 0 10.0\nc 432 256 432 336 0 1.5E-5 0\nl 80 336 432 336 0 1.0 0\nh 1 5 4\no 4 64 0 3 20.0 0.1\no 7 64 0 3 160.0 0.8\no 10 64 0 3 40.0 0.2\n"
  },
  {
    "path": "src/circuits/resistors.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 96 368 96 48 0 0 40.0 5.0 0.0\nw 96 48 192 48 1\nw 192 48 288 48 0\nw 288 48 384 48 0\ns 192 48 192 128 0 false false\ns 288 48 288 128 0 true false\ns 384 48 384 128 0 false false\nr 192 128 192 192 0 100.0\nr 288 128 288 192 0 400.0\nr 384 128 384 192 0 800.0\nw 192 192 288 192 0\nw 288 192 384 192 0\nw 288 224 288 192 0\nw 288 224 384 224 0\nw 288 224 192 224 0\ns 288 224 288 304 0 false false\ns 192 224 192 304 0 true false\nr 192 304 192 368 0 600.0\nr 288 304 288 368 0 200.0\ns 384 224 384 368 0 true false\nw 96 368 192 368 0\nw 192 368 288 368 0\nw 288 368 384 368 0\n"
  },
  {
    "path": "src/circuits/ringing.txt",
    "content": "$ 1 5.0E-6 4.621633621589249 50 5.0 46\nw 368 128 368 192 0\nw 368 272 368 320 0\nw 320 272 368 272 0\nw 368 272 416 272 0\nw 320 192 368 192 0\nw 368 192 416 192 0\nl 320 192 320 272 0 0.0020 0.07708318720316419\nc 416 192 416 272 0 1.264E-5 -0.22352804367929519\nr 256 128 368 128 0 100.0\nO 368 128 464 128 0\ng 368 320 368 336 0\nR 256 128 224 128 0 2 100.0 5.0 0.0 0.0 0.5\no 9 16 0 34 2.5 4.8828125E-5 0 -1\n"
  },
  {
    "path": "src/circuits/ringmod.txt",
    "content": "$ 17 5.0E-6 1.7725424121461644 41 3.0 50\nd 272 176 320 128 1 0.805904783\nd 320 128 368 176 1 0.805904783\nd 368 176 320 224 1 0.805904783\nd 320 224 272 176 1 0.805904783\n169 144 144 208 144 0 0.1 1.0 0.36188085234266 -0.10938222138187827\nw 208 144 208 128 0\n169 496 208 432 208 0 0.1 1.0 -0.33106614006595897 0.01591880270109881\nw 368 144 368 176 0\nw 432 208 432 256 0\nw 272 256 272 176 0\nw 272 256 432 256 0\nw 432 144 368 144 0\nw 208 128 320 128 0\nw 208 208 208 224 0\nw 208 224 320 224 0\nw 208 176 240 176 0\nw 240 176 240 288 0\nw 240 288 288 288 0\nw 432 176 400 176 0\nw 400 176 400 288 0\nw 400 288 336 288 0\nv 528 144 528 208 0 1 300.0 2.4 0.0 0.0 0.5\nv 112 144 112 208 0 1 200.0 2.0 0.0 0.0 0.5\nw 288 288 288 336 0\nw 336 288 336 336 0\nr 288 336 336 336 0 1.0\nw 496 208 528 208 0\nw 496 144 528 144 0\nw 112 208 144 208 0\nw 112 144 144 144 0\nr 400 288 432 256 0 1000.0\ng 528 208 528 224 0\ng 112 208 112 224 0\ng 208 224 208 240 0\no 21 8 0 38 2.5 0.4 0 -1\no 22 8 0 38 2.5 0.4 0 -1\no 25 8 0 38 1.0229345649675443 0.6546781215792284 1 -1\n"
  },
  {
    "path": "src/circuits/rossler.txt",
    "content": "$ 3 5.0E-6 2.898875293967098 66 5.0 50\na 360 304 408 304 2 15.0 -15.0\nr 360 272 408 272 0 5000000.0\nc 360 240 408 240 0 1.0E-9 3.0635621976420984\nw 408 240 408 272 0\nw 408 272 408 304 0\nw 360 272 360 296 0\nw 360 272 360 240 0\ng 360 312 360 328 0\nc 360 360 408 360 0 1.0E-9 -0.0028565435358697752\nr 360 392 408 392 0 100000.0\na 360 424 408 424 2 15.0 -15.0\nw 408 360 408 392 0\nw 408 392 408 424 0\nw 360 416 360 392 0\nw 360 392 360 360 0\ng 360 432 360 448 0\nw 408 240 408 200 0\na 352 120 408 120 2 15.0 -15.0\ng 352 128 352 144 0\nr 352 88 408 88 0 2000000.0\nc 352 56 408 56 0 1.0E-9 0.6880284746244376\nw 352 56 352 88 0\nw 352 88 352 112 0\nw 408 88 408 120 0\nw 408 56 408 88 0\nr 352 112 304 112 0 100000.0\nw 304 112 304 168 0\nw 304 168 520 168 0\nw 408 200 280 200 0\nw 280 200 280 144 0\nw 408 56 408 16 0\na 144 304 192 304 2 15.0 -15.0\na 144 424 192 424 2 15.0 -15.0\nw 192 416 192 424 0\nr 192 416 360 416 0 100000.0\nr 192 296 360 296 0 100000.0\nw 192 296 192 304 0\nw 144 296 144 256 0\nr 144 256 192 256 0 10000.0\nw 192 256 192 296 0\nr 144 296 48 296 0 10000.0\nd 96 416 144 416 0\nr 96 416 96 360 0 10000.0\nr 96 416 96 472 0 68000.0\nw 96 360 48 360 0\nw 48 360 48 296 0\nw 48 296 48 16 0\nw 48 16 408 16 0\nr 280 56 352 56 0 200000.0\nw 280 56 280 144 0\nr 280 144 144 144 0 75000.0\nw 144 144 144 256 0\ng 144 312 144 328 0\ng 144 432 144 448 0\nr 144 384 192 384 0 150000.0\nw 144 384 144 416 0\nw 192 384 192 416 0\nw 520 168 520 392 0\nw 520 392 408 392 0\nR 96 472 40 472 0 0 40.0 -15.0 0.0 0.0 0.5\np 408 304 480 304 0\np 408 424 480 424 0\np 408 120 480 120 0\ng 480 120 480 136 0\ng 480 304 480 320 0\ng 480 424 480 440 0\no 60 64 0 226 5.0 3.2 0 61 z vs y\no 62 64 0 226 5.0 6.4 1 60 y vs x\n"
  },
  {
    "path": "src/circuits/rtlinverter.txt",
    "content": "$ 1 5.0E-6 10 52 5.0\nr 240 224 320 224 0 470.0\nt 320 224 368 224 0 1 0.6381869044881298 0.6478945398933037\nr 368 208 368 112 0 640.0\nw 368 240 368 288 0\nL 240 224 192 224 0 false false 3.6 0.0\nR 368 112 320 112 0 0 40.0 3.6 0.0\nM 368 208 432 208 0\ng 368 288 368 320 0\n"
  },
  {
    "path": "src/circuits/rtlnand.txt",
    "content": "$ 1 5.0E-6 10 52 5.0\nR 368 64 320 64 0 0 40.0 3.6 0.0\ng 368 336 368 368 0\nt 320 208 368 208 0 1 0.6378429407740765 0.6475693325578884\nw 368 160 368 192 0\nr 368 160 368 64 0 640.0\nt 320 256 368 256 0 1 0.6376732762947126 0.6550300979283231\nt 320 304 368 304 0 1 0.6375679404402763 0.6608122760347422\nw 368 224 368 240 0\nw 368 272 368 288 0\nw 368 320 368 336 0\nr 320 208 240 208 0 470.0\nr 240 256 320 256 0 470.0\nr 240 304 320 304 0 470.0\nL 240 208 208 208 0 false false 3.6 0.0\nL 240 256 208 256 0 false false 3.6 0.0\nL 240 304 208 304 0 false false 3.6 0.0\nM 368 160 432 160 0\n"
  },
  {
    "path": "src/circuits/rtlnor.txt",
    "content": "$ 1 5.0E-6 10 52 5.0\nt 176 208 224 208 0 1 0.638186904488133 0.6478945398932158\nt 272 208 320 208 0 1 -0.00970763539752057 7.562178340717264E-12\nt 368 208 416 208 0 1 -0.00970763539752057 7.562178340717264E-12\nw 224 160 224 192 0\nw 320 160 320 192 0\nw 224 160 320 160 0\nw 320 160 416 160 0\nw 416 160 416 192 0\nr 176 208 176 272 0 470.0\nr 272 208 272 272 0 470.0\nr 368 208 368 272 0 470.0\nL 176 272 176 304 0 false false 3.6 0.0\nL 272 272 272 304 0 true false 3.6 0.0\nL 368 272 368 304 0 true false 3.6 0.0\nw 224 224 224 336 0\nw 320 224 320 336 0\nw 416 224 416 336 0\nw 416 336 320 336 0\nw 320 336 224 336 0\nr 416 160 416 64 0 640.0\ng 416 336 416 368 0\nR 416 64 352 64 0 0 40.0 3.6 0.0\nM 416 160 464 160 0\n"
  },
  {
    "path": "src/circuits/samplenhold.txt",
    "content": "$ 1 5.0E-6 10 74 5.0 81\nf 192 112 192 160 1\nf 192 224 192 160 0\nw 192 112 256 112 0\nw 256 112 256 224 0\nI 192 224 256 224 0 0.5\nL 192 224 192 304 0 true true 5.0 0.0\nw 208 160 304 160 0\nc 304 160 304 256 0 1.0E-7 1.9962454782690886\ng 304 256 304 304 0\na 352 160 464 160 1 15.0 -15.0\nw 304 160 304 144 0\nw 304 144 352 144 0\nw 352 176 352 224 0\nw 352 224 464 224 0\nw 464 224 464 160 0\nO 464 160 512 160 0\nR 144 160 96 160 0 1 40.0 2.5 2.5\nw 144 160 176 160 0\nx 157 341 173 341 0 20 sample\no 16 64 0 2 6.0 9.765625E-5 0\no 15 64 0 2 6.0 9.765625E-5 1\n"
  },
  {
    "path": "src/circuits/sawtooth.txt",
    "content": "$ 1 5.0E-6 10.634267539816555 63 5.0 50\na 160 224 272 224 0 15.0 -15.0 1000000.0\nw 160 240 160 304 0\nw 160 304 272 304 0\nr 272 224 272 304 0 100000.0\na 384 240 496 240 0 15.0 -15.0 1000000.0\nr 272 304 352 304 0 40000.0\nw 352 304 496 304 0\nw 496 304 496 240 0\nw 496 240 496 176 0\nc 384 176 496 176 0 5.0E-7 4.758165877822716\nw 384 176 384 224 0\ng 384 256 384 272 0\nO 496 240 560 240 0\nw 160 208 128 208 0\ng 128 208 128 240 0\nr 384 176 320 176 0 5000.0\nr 384 224 320 224 0 40000.0\nd 272 176 320 176 1 0.805904783\nd 320 224 272 224 1 0.805904783\nw 272 176 272 224 0\no 12 64 0 42 10.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/schmitt.txt",
    "content": "$ 1 5.0E-6 16.13 50 5.0 50\nr 192 32 192 96 0 500.0\nr 192 96 336 96 0 100.0\nw 336 96 336 144 0\nt 336 144 416 144 0 1 0.5820470981894252 0.631962165475968 100.0\nt 128 144 192 144 0 1 -1.8901554514017818 -0.6779682779383932 100.0\nw 192 96 192 128 0\nw 416 128 416 96 0\nw 192 32 416 32 0\nr 416 32 416 96 0 500.0\nw 192 160 192 192 0\nw 192 192 416 192 0\nw 416 160 416 192 0\nw 336 144 336 208 0\nr 336 208 336 272 0 300.0\nr 192 192 192 272 0 100.0\nw 192 272 336 272 0\nR 192 32 128 32 0 0 40.0 5.0 0.0 0.0 0.5\ng 192 272 192 320 0\nR 64 144 32 144 0 1 2000.0 0.2 0.0 0.0 0.5\np 128 144 128 272 0\nw 128 272 192 272 0\nv 64 144 128 144 0 1 40.0 2.0 2.0 0.0 0.5\nO 416 96 464 96 0\nx 201 151 223 155 0 16 Q1\nx 425 151 447 155 0 16 Q2\no 19 64 0 38 5.0 9.765625E-5 0 -1 in\no 22 64 0 34 5.0 9.765625E-5 1 -1 out\no 19 64 0 226 5.0 6.4 2 22 out vs in\n"
  },
  {
    "path": "src/circuits/scr.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\nr 384 160 384 96 0 100.0\nR 384 96 384 80 0 0 40.0 5.0 0.0 0.0 0.5\ns 384 288 384 368 0 1 false\ns 352 256 256 256 0 1 false\nr 256 176 256 256 0 100.0\nR 256 176 256 128 0 0 40.0 5.0 0.0 0.0 0.5\ng 384 368 384 384 0\n177 384 160 368 288 0 0.0 0.0\n"
  },
  {
    "path": "src/circuits/scractrig.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 49 5.0 50\n177 256 176 256 352 0 -15.051976407130628 -15.051976407130628\nr 256 176 256 112 0 50.0\nR 256 112 256 80 0 1 40.0 20.0 0.0 0.0 0.5\nd 368 288 288 288 1 0.805904783\ng 256 352 256 384 0\nw 256 176 304 176 0\nw 368 208 368 288 0\n174 368 208 304 144 0 1800.0 0.8069000000000001 Trigger Voltage\no 2 64 0 33 10.0 0.2 0 -1\n"
  },
  {
    "path": "src/circuits/sine.txt",
    "content": "$ 1 5.0E-6 10.812258501325767 53 15.0 50\na 80 128 192 128 0 15.0 -15.0\nw 80 112 32 112 0\nw 80 144 80 208 0\na 304 144 416 144 0 15.0 -15.0\nw 416 208 416 144 0\nw 416 144 416 80 0\nc 304 80 416 80 0 2.0E-6 -9.423018815839887\nw 304 80 304 128 0\nr 192 128 304 128 0 1000.0\ng 304 160 304 176 0\nO 416 144 480 144 0\nw 80 112 80 48 0\nc 80 48 192 48 0 2.0E-6 10.648649139047\nw 192 48 192 128 0\nr 80 208 192 208 0 1000.0\nw 192 208 416 208 0\nc 80 208 80 272 0 2.0E-6 -1.201945379750099\ng 80 272 80 304 0\nr 32 112 32 192 0 996.0\ng 32 192 32 224 0\nO 192 48 256 48 0\no 20 64 0 42 20.0 9.765625E-5 0 -1\no 10 64 0 34 20.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/sinediode.txt",
    "content": "$ 1 5.0E-6 3.58 58 5.0 59\nd 96 320 96 224 0\nd 112 224 112 272 0\nw 80 272 112 272 0\nr 80 272 32 272 0 100.0\nr 16 320 96 320 0 100.0\nr 112 272 160 272 0 33.0\nr 96 320 176 320 0 33.0\nw 160 272 192 272 0\nd 176 320 176 224 0\nd 192 224 192 272 0\nd 256 320 256 224 0\nd 272 224 272 272 0\nw 272 272 240 272 0\nr 176 320 256 320 0 82.0\nr 192 272 240 272 0 82.0\nr 256 320 336 320 0 47.0\nd 336 320 336 224 0\nd 352 224 352 272 0\nw 352 272 320 272 0\nr 272 272 320 272 0 47.0\nr 336 320 416 320 0 30.0\nr 416 320 496 320 0 39.0\nd 416 320 416 224 0\nd 496 320 496 224 0\nd 432 224 432 272 0\nd 512 224 512 272 0\nw 400 272 432 272 0\nw 480 272 512 272 0\nr 352 272 400 272 0 30.0\nr 432 272 480 272 0 39.0\nR 512 272 560 272 0 0 40.0 2.4 0.0\nR 496 320 560 320 0 0 40.0 -2.4 0.0\nw 96 224 112 224 0\nw 176 224 192 224 0\nw 256 224 272 224 0\nw 336 224 352 224 0\nw 416 224 432 224 0\nw 496 224 512 224 0\nr 112 224 112 144 0 2000.0\nr 192 224 192 144 0 1000.0\nr 272 224 272 144 0 470.0\nr 352 224 352 144 0 330.0\nr 432 224 432 144 0 120.0\nw 112 144 192 144 0\nw 192 144 272 144 0\nw 272 144 352 144 0\nw 352 144 432 144 0\nw 432 144 512 144 0\nr 112 144 64 144 0 200.0\nR 64 144 32 144 0 3 80.0 5.0 0.0\nO 512 144 560 144 0\nw 512 144 512 224 0\nw 16 320 16 272 0\nw 16 272 32 272 0\no 49 32 0 35 5.0 0.025 0 0\no 50 32 0 34 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/spark-marx.txt",
    "content": "$ 1 1.9999999999999998E-5 13.097415321081861 66 2000.0 50\nr 160 144 256 144 0 4000000.0\nc 256 144 256 256 0 2.4E-8 0\nr 256 144 352 144 0 1000000.0\nr 256 256 352 256 0 1000000.0\nc 352 256 352 144 0 2.4E-8 0\nr 352 144 448 144 0 1000000.0\nr 352 256 448 256 0 1000000.0\nc 448 256 448 144 0 2.4E-8 0\n187 256 144 352 256 0 1000.0 1.0E9 4000.0 0.0015\n187 352 144 448 256 0 1000.0 1.0E9 4000.0 0.0010\n187 704 144 704 208 0 1000.0 1.0E9 11000.0 0.0010\ng 704 288 704 320 0\nR 160 144 128 144 0 0 40.0 5000.0 0.0 0.0 0.5\nw 256 256 208 256 0\ng 208 256 208 320 0\nc 352 256 352 304 2 1.0E-11 0\nc 448 256 448 304 2 1.0E-11 0\ng 352 304 352 320 0\ng 448 304 448 320 0\ng 640 304 640 320 0\ng 544 304 544 320 0\nc 640 256 640 304 2 1.0E-11 0\nc 544 256 544 304 2 1.0E-11 0\n187 544 144 640 256 0 1000.0 1.0E9 4000.0 0.0010\n187 448 144 544 256 0 1000.0 1.0E9 4000.0 0.0010\nc 640 256 640 144 0 2.4E-8 0\nr 544 256 640 256 0 1000000.0\nr 544 144 640 144 0 1000000.0\nc 544 256 544 144 0 2.4E-8 0\nr 448 256 544 256 0 1000000.0\nr 448 144 544 144 0 1000000.0\nw 640 144 704 144 0\nr 704 208 704 288 0 2000000.0\no 8 64 0 35 5120.0 9.765625E-5 0 -1\no 9 64 0 35 10240.0 9.765625E-5 1 -1\no 24 64 0 35 5120.0 9.765625E-5 2 -1\no 23 64 0 35 10240.0 9.765625E-5 3 -1\no 32 64 0 35 40.0 9.765625E-5 4 -1\n"
  },
  {
    "path": "src/circuits/spark-sawtooth.txt",
    "content": "$ 1 1.0E-6 43.84883893407173 66 2000.0 50\nR 320 160 320 128 0 0 40.0 2000.0 0.0 0.0 0.5\nr 320 160 320 240 0 2000000.0\n187 320 240 320 336 0 10000.0 1.0E9 1000.0 0.0010\ng 320 336 320 352 0\nc 352 240 352 336 0 1.0E-8 954.6107492378424\nw 352 336 320 336 0\nw 320 240 352 240 0\no 4 128 0 35 1280.0 0.1 0 -1\n"
  },
  {
    "path": "src/circuits/spikegen.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 112 288 112 144 0 2 40.0 5.0 0.0\nr 240 144 240 288 0 110.0\nd 240 144 368 144 0\nw 112 288 240 288 0\nc 112 144 240 144 0 1.0E-5 4.9868403762557465\nO 368 144 432 144 0\nr 368 144 368 288 0 100.0\nw 240 288 368 288 0\no 5 64 0 3 10.0 9.765625E-5\n"
  },
  {
    "path": "src/circuits/switchedcap.txt",
    "content": "$ 1 5.0E-6 17.50203994009402 50 5.0 50\n159 160 176 256 176 0\n159 256 176 352 176 0\nc 352 176 352 240 0 4.876999999999999E-6 0\nw 352 176 416 176 0\na 416 192 512 192 1 15.0 -15.0\nw 416 208 416 240 0\nw 416 240 512 240 0\nw 512 240 512 192 0\nO 512 192 576 192 0\ng 256 240 256 256 0\ng 352 240 352 256 0\nw 304 192 304 288 0\nI 208 288 304 288 0 0.5\nw 208 192 208 288 0\nR 208 288 112 288 1 2 2000.0 2.5 2.5 0.0 0.5\nc 256 240 256 176 0 9.5123E-5 0\np 160 176 160 240 0\ng 160 240 160 256 0\n170 160 176 112 176 3 10.0 400.0 5.0 0.2\no 16 64 0 34 5.0 9.765625E-5 0 -1\no 8 64 0 34 5.0 4.8828125E-5 1 -1\n"
  },
  {
    "path": "src/circuits/switchfilter.txt",
    "content": "$ 1 1.2E-5 14 57 5.0\nf 240 176 176 176 1\nf 128 176 176 176 0\nr 176 96 176 160 0 50.0\nr 304 96 304 160 0 350.0\nw 176 192 176 224 0\nw 176 224 304 224 0\nw 304 192 304 224 0\nw 304 96 304 64 0\nw 304 64 176 64 0\nw 176 64 176 96 0\nw 304 224 416 224 0\nc 416 224 416 288 0 1.0E-5 0.4780517576155351\ng 416 288 416 320 0\nO 416 224 480 224 0\nw 240 176 240 256 0\nI 240 320 240 256 0\nw 128 176 128 320 0\nw 128 320 240 320 0\nw 240 320 352 320 0\nL 128 320 80 320 0 true false\nv 176 64 112 64 0 1 500.0 1.0 0.0\nw 304 64 416 64 0\np 416 64 416 112 0\ng 416 112 416 144 0\nR 112 64 80 64 0 1 40.0 1.0 2.5\nf 240 176 304 176 0\nf 352 176 304 176 1\nw 352 176 352 320 0\no 22 32 0 2 5.0 2.44140625E-5\no 13 32 0 2 1.25 2.44140625E-5\n"
  },
  {
    "path": "src/circuits/swtreedac.txt",
    "content": "$ 3 5.0E-6 10.391409633455755 50 5.0 50\n160 312 192 248 192 1\n160 312 272 248 272 1\n160 312 352 248 352 1\n160 312 112 248 112 1\n160 376 152 312 152 1\n160 376 312 312 312 1\n160 440 232 376 232 1\nw 376 152 376 216 0\nw 376 248 376 312 0\nw 312 272 312 296 0\nw 312 328 312 352 0\nw 312 168 312 192 0\nw 312 112 312 136 0\nO 440 232 496 232 1\nr 168 208 168 256 0 100.0\nr 168 256 168 304 0 100.0\nr 168 304 168 352 0 100.0\nr 168 352 168 400 0 100.0\nr 168 208 168 160 0 100.0\nr 168 160 168 112 0 100.0\nr 168 112 168 64 0 100.0\nw 168 64 248 64 0\nw 248 64 248 96 0\nw 168 112 216 112 0\nw 168 160 248 160 0\nw 248 160 248 176 0\nw 168 208 248 208 0\nw 168 256 248 256 0\nw 168 304 248 304 0\nw 248 304 248 288 0\nw 168 352 208 352 0\nw 208 352 208 336 0\nw 208 336 248 336 0\nw 168 400 248 400 0\nw 248 400 248 368 0\nw 216 112 216 128 0\nw 216 128 248 128 0\n82 168 64 168 32 0 0 40.0 7.001 0.0 0.0 0.5\ng 168 400 168 424 0\nw 280 128 280 208 0\nw 280 208 280 288 0\nw 280 288 280 368 0\nw 344 168 344 328 0\nw 408 248 408 368 0\nw 344 328 344 368 0\nL 408 368 464 368 0 false false 5.0 0.0\nw 344 368 344 400 0\nL 344 400 464 400 0 false false 5.0 0.0\nw 280 368 280 432 0\nL 280 432 464 432 0 false false 5.0 0.0\n"
  },
  {
    "path": "src/circuits/synccounter.txt",
    "content": "$ 3 5.0E-6 10 50 5.0\n156 80 272 128 272 0 0.0\n156 208 272 240 272 0 5.0\n156 336 272 368 272 0 0.0\n156 464 272 480 272 0 5.0\nw 464 272 448 272 0\nw 448 272 448 336 0\nw 448 336 464 336 0\nw 320 336 336 336 0\nw 320 336 320 272 0\nw 320 272 336 272 0\nw 208 272 192 272 0\nw 192 272 192 336 0\nw 192 336 208 336 0\nw 80 272 64 272 0\nw 64 272 64 336 0\nw 64 336 80 336 0\nw 560 272 560 88 0\nw 432 272 432 112 0\nw 176 272 176 160 0\nM 560 88 592 88 2 2.5\nR 64 272 32 272 0 0 40.0 5.0 0.0\nR 80 384 32 384 1 2 200.0 2.5 2.5\nw 80 304 80 384 0\nw 176 272 192 272 0\nw 80 384 208 384 0\nw 208 384 208 304 0\nw 336 304 336 384 0\nw 336 384 208 384 0\nw 336 384 464 384 0\nw 464 384 464 304 0\n150 336 200 336 272 1 2 0.0\nw 304 272 304 136 0\nw 304 136 328 136 0\nw 328 136 328 200 0\nw 344 160 344 200 0\nw 176 160 344 160 0\n150 464 200 464 272 1 3 0.0\nw 344 160 472 160 0\nw 472 160 472 200 0\nw 328 136 464 136 0\nw 464 136 464 200 0\nw 432 112 456 112 0\nw 456 112 456 200 0\nM 472 160 592 160 2 2.5\nM 464 136 592 136 2 2.5\nM 456 112 592 112 2 2.5\n"
  },
  {
    "path": "src/circuits/tdiode.txt",
    "content": "$ 1 5.0E-6 10.634267539816555 56 2.0 50\nR 320 208 320 160 0 3 50.0 0.28 0.26 0.0 0.5\ng 320 288 320 320 0\n175 320 208 320 288 0\no 2 32 0 35 0.625 0.0125 0 -1\no 2 64 0 99 0.625 0.0125 1 -1\n"
  },
  {
    "path": "src/circuits/tdosc.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 54 1.5 50\nR 160 176 128 176 0 0 40.0 1.5 0.0 0.0 0.5\nr 160 176 240 176 0 80.0\nr 240 176 240 288 0 24.0\n175 240 176 320 176 0\nr 320 176 320 288 0 75.0\nl 448 176 448 288 0 0.2 0.0014801805180037042\nO 448 176 512 176 0\ng 240 288 240 304 0\ng 320 288 320 304 0\ng 448 288 448 304 0\nw 320 176 384 176 0\nc 384 176 384 288 0 3.9999999999999996E-5 -0.0973586411333848\nw 384 176 448 176 0\ng 384 288 384 304 0\no 3 64 0 35 0.625 0.0125 0 -1 diode\no 3 64 0 99 0.625 0.00625 1 -1\no 6 64 0 34 0.3125 4.8828125E-5 2 -1 output\n"
  },
  {
    "path": "src/circuits/tdrelax.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 54 1.5 50\nR 176 176 144 176 0 0 40.0 1.5 0.0 0.0 0.5\nr 176 176 256 176 0 80.0\nr 256 176 256 288 0 24.0\n175 256 176 336 176 0\nl 336 176 336 288 0 0.7 0.002697977898647033\nO 336 176 384 176 0\ng 256 288 256 304 0\ng 336 288 336 304 0\no 3 64 0 35 0.0390625 0.00625 0 -1 diode\no 3 64 0 99 0.625 0.00625 1 -1\no 5 64 0 34 0.625 4.8828125E-5 2 -1 output\n"
  },
  {
    "path": "src/circuits/tesla.txt",
    "content": "$ 1 1.0E-8 12.235633750745258 30 120.0 50\ng 240 304 240 336 0\nr 240 256 176 256 0 10.0\nR 176 256 144 256 0 1 60.0 120.0 0.0 0.0 0.5\nT 240 256 320 304 2 10.0 100.0 4.437258653736118 -0.04413717098860063 0.999\nc 384 224 464 224 0 2.0E-8 9788.947578396032\nw 320 304 320 336 0\nw 384 336 464 336 0\nw 320 224 320 256 0\ng 320 336 320 368 0\nw 320 224 384 224 2\nw 320 336 384 336 0\nw 464 224 464 256 0\nw 464 304 464 336 0\nc 528 256 528 144 0 2.5E-11 -0.002896435768521405\nr 528 304 528 352 0 0.1\ng 528 352 528 368 0\nT 464 256 528 304 2 3.16628E-5 28.28427 0.04412738203720486 1.4084140624744444E-8 0.1\n187 384 224 384 336 0 1.0 1.0E9 10000.0 0.0010\nw 528 144 592 144 0\ng 592 144 592 368 0\no 17 64 0 35 10240.0 9.765625E-5 0 -1\no 13 32 0 34 0.0048828125 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/thevenin.txt",
    "content": "$ 17 5.0E-6 10.8 50 5.0\nr 112 176 208 128 0 100.0\nr 208 128 224 224 0 100.0\nr 224 224 320 176 0 200.0\nr 208 128 288 144 0 100.0\nr 304 80 288 144 0 100.0\nv 288 144 384 128 0 0 40.0 5.0 0.0\nv 320 176 320 256 0 0 40.0 5.0 0.0\nv 112 176 128 240 0 0 40.0 5.0 0.0\nv 304 80 224 64 0 0 40.0 5.0 0.0\nv 224 224 224 288 0 0 40.0 5.0 0.0\nr 224 288 304 304 0 200.0\nr 128 240 64 288 0 400.0\nr 384 128 448 192 0 100.0\nr 320 256 384 272 0 100.0\nr 224 64 112 80 0 1000.0\nv 112 80 208 128 0 0 40.0 5.0 0.0\nv 64 288 224 288 0 0 40.0 2.0 0.0\nv 304 304 384 272 0 0 40.0 5.0 0.0\nr 448 192 384 272 0 100.0\nr 320 176 384 128 0 100.0\nr 112 80 112 176 0 100.0\nw 64 288 64 16 0\nw 448 16 448 192 0\nr 272 384 128 384 0 117.784267\nw 128 384 128 336 0\nw 384 336 384 384 0\nv 272 384 384 384 0 0 40.0 2.80758 0.0\nv 64 16 448 16 0 1 40.0 5.0 0.0\nv 128 336 384 336 0 1 40.0 5.0 0.0\ng 448 192 448 256 0\ng 384 384 384 400 0\no 27 64 0 3 5.0 0.1\no 28 64 0 3 5.0 0.1\n"
  },
  {
    "path": "src/circuits/tl.txt",
    "content": "$ 1 5.0E-12 10.391409633455755 50 5.0 50\n171 176 240 496 240 0 0.00000003 75.0 80 0.0\nw 176 240 128 240 0\nw 128 320 176 320 0\nw 496 240 544 240 0\nw 496 320 544 320 0\nr 544 240 544 320 0 75.0\nv 128 320 128 240 0 1 40000000.0 5.0 0.0 0.0 0.5\n"
  },
  {
    "path": "src/circuits/tlfreq.txt",
    "content": "$ 1 5.0E-12 13.200821376227164 50 5.0 50\nw 496 112 544 112 0\nw 496 176 544 176 0\n170 128 112 96 112 2 1.0E8 5.0E8 5.0 4.0E-7\ng 176 176 176 192 0\nr 128 112 176 112 0 75.0\ng 544 176 544 192 0\np 544 112 544 176 0\n170 128 272 96 272 2 1.0E8 5.0E8 5.0 4.0E-7\nr 128 272 176 272 0 75.0\nw 496 272 544 272 0\nw 496 336 544 336 0\nw 544 272 544 336 0\n171 176 272 496 272 0 5.0E-9 75.0 64 0.0\n171 176 112 496 112 0 5.0E-9 75.0 64 0.0\ng 176 336 176 352 0\ng 544 336 544 352 0\no 4 64 0 34 5.1 0.05 0 -1\no 8 64 0 34 5.1 0.05 1 -1\n"
  },
  {
    "path": "src/circuits/tllight.txt",
    "content": "$ 1 1.0E-11 25.237822143832553 37 120.0 50\n171 128 176 384 176 0 6.000000000000001E-8 300.0 64 0.0\nr 128 176 80 176 0 10.0\nw 80 240 128 240 0\nw 512 176 544 176 0\nw 512 240 544 240 0\nr 544 176 544 240 0 70.0\nv 80 240 80 176 0 1 60.0 120.0 0.0 1.5707963267948966 0.03\ng 384 240 384 256 0\ng 432 240 432 256 0\ng 512 240 512 256 0\n171 432 176 512 176 0 1.0E-8 300.0 64 0.0\ns 384 176 432 176 0 0 false\no 6 256 0 35 160.0 1.6 0 -1\no 5 256 0 35 160.0 1.6 1 -1\n"
  },
  {
    "path": "src/circuits/tllopass.txt",
    "content": "$ 1 5.0E-13 11.708435524800691 50 5.0 50\n170 64 80 32 80 2 2.0E9 8.0E9 5.0 1.0E-8\n171 144 176 256 176 0 3.125E-11 64.9 48 0.0\n171 144 80 256 80 0 3.125E-11 217.5 48 0.0\nw 128 128 128 224 0\nw 128 224 144 224 0\nw 128 128 144 128 0\n171 304 80 400 80 0 3.125E-11 217.5 48 0.0\n171 304 176 400 176 0 3.125E-11 70.3 48 0.0\n171 448 176 544 176 0 3.125E-11 64.9 48 0.0\nw 256 80 272 80 0\nw 272 80 272 176 0\nw 272 176 304 176 0\nw 256 128 288 128 0\nw 288 128 288 224 0\nw 288 224 304 224 0\nw 272 80 304 80 0\nw 288 128 304 128 0\nw 400 80 416 80 0\nw 416 80 416 176 0\nw 416 176 448 176 0\nw 400 128 432 128 0\nw 432 128 432 224 0\nw 432 224 448 224 0\ng 256 224 256 240 0\ng 400 224 400 240 0\ng 544 224 544 240 0\nw 416 80 464 80 0\nw 432 128 464 128 0\nr 464 80 464 128 0 50.0\ng 256 128 256 144 0\ng 144 224 144 240 0\nr 64 80 112 80 0 50.0\nw 112 80 112 176 0\nw 112 176 144 176 0\nw 112 80 144 80 0\no 28 64 0 35 5.0 0.1 0 -1\n"
  },
  {
    "path": "src/circuits/tlmatch1.txt",
    "content": "$ 1 1.0E-11 25.237822143832553 52 4.0 50\n171 128 128 256 128 0 2.0E-8 75.0 64 0.0\n171 400 128 528 128 0 2.0E-8 300.0 64 0.0\nr 128 128 80 128 0 75.0\nw 80 192 128 192 0\nw 528 128 560 128 0\nw 528 192 560 192 0\nr 560 128 560 192 0 300.0\nv 80 192 80 128 0 1 9.0E7 5.0 0.0 0.0 0.03\ng 256 192 256 208 0\ng 400 192 400 208 0\ng 528 192 528 208 0\nl 256 128 336 128 0 2.5E-7 -0.00932931614162717\nc 336 128 336 192 0 1.06E-11 -4.843602086224591\nw 336 192 400 192 0\nw 336 128 400 128 0\nv 80 256 80 320 0 1 9.0E7 5.0 0.0 0.0 0.5\nr 80 256 128 256 0 75.0\nw 80 320 128 320 0\n171 128 256 256 256 0 2.0E-8 75.0 64 0.0\n171 400 256 528 256 0 2.0E-8 300.0 64 0.0\nw 256 256 400 256 0\nw 256 320 400 320 0\nw 528 256 560 256 0\nw 528 320 560 320 0\ng 256 320 256 336 0\ng 528 320 528 336 0\ng 128 192 128 208 0\ng 128 320 128 336 0\nr 560 256 560 320 0 300.0\no 6 64 1 51 0.15625 1.220703125E-5 0 -1 matched\no 28 64 1 51 0.15625 2.44140625E-5 1 -1 mismatched\n"
  },
  {
    "path": "src/circuits/tlmatch2.txt",
    "content": "$ 1 1.0E-11 12.682493960703473 52 4.0 50\n171 48 112 192 112 0 1.0E-8 75.0 64 0.0\nr 48 112 0 112 0 75.0\nw 0 176 48 176 0\nw 464 112 496 112 0\nw 464 176 496 176 0\nr 496 112 496 176 0 300.0\nv 0 176 0 112 0 1 1.0E8 5.0 0.0 0.0 0.03\ng 192 176 192 192 0\nv 0 240 0 304 0 1 1.0E8 5.0 0.0 0.0 0.5\nr 0 240 48 240 0 75.0\nw 0 304 48 304 0\n171 48 240 192 240 0 1.17621E-8 75.0 64 0.0\nw 464 240 496 240 0\nw 464 304 496 304 0\ng 192 304 192 320 0\ng 48 176 48 192 0\ng 48 304 48 320 0\nr 496 240 496 304 0 300.0\nw 192 112 192 32 0\nw 192 32 208 32 0\nw 192 176 208 176 0\nw 208 176 208 96 0\nw 192 112 224 112 0\nw 208 176 224 176 0\ng 336 96 336 112 0\n171 224 112 288 112 0 1.7621000000000001E-9 75.0 64 0.0\ng 288 176 288 192 0\n171 208 32 336 32 0 3.4358E-9 75.0 64 0.0\n171 304 112 464 112 0 1.0E-8 300.0 64 0.0\n171 304 240 464 240 0 1.0E-8 300.0 64 0.0\nw 288 176 304 176 0\nw 288 112 304 112 0\nw 192 240 304 240 0\nw 192 304 304 304 0\ng 464 304 464 320 0\ng 464 176 464 192 0\no 5 64 1 51 0.15625 1.220703125E-5 0 -1 matched\no 17 64 1 51 0.15625 2.44140625E-5 1 -1 mismatched\n"
  },
  {
    "path": "src/circuits/tlmis1.txt",
    "content": "$ 0 5.0E-12 23.25989509352673 50 5.0 50\n171 128 192 304 192 0 1.0E-8 75.0 64 0.0\nr 128 192 80 192 0 75.0\nw 80 256 128 256 0\nw 512 192 544 192 0\nw 512 256 544 256 0\nr 544 192 544 256 0 500.0\nv 80 256 80 192 0 1 1.87E8 5.0 0.0 0.0 0.03\ng 304 256 304 272 0\ng 336 256 336 272 0\ng 512 256 512 272 0\n171 336 192 512 192 0 1.0E-8 500.0 64 0.0\nw 304 192 336 192 0\no 1 64 0 34 4.0 0.025 0 -1\no 5 64 0 34 5.0 0.00625 1 -1\n"
  },
  {
    "path": "src/circuits/tlmismatch.txt",
    "content": "$ 1 5.0E-12 12.682493960703473 50 5.0 50\n171 112 192 256 192 0 1.0E-8 75.0 64 0.0\n171 256 192 384 192 0 1.0E-8 500.0 64 0.0\n171 384 192 512 192 0 1.0E-8 75.0 64 0.0\nr 112 192 64 192 0 75.0\nw 64 256 112 256 0\nw 512 192 544 192 0\nw 512 256 544 256 0\nr 544 192 544 256 0 75.0\nv 64 256 64 192 0 2 1.0E7 2.5 2.5 0.0 0.03\ng 256 256 256 272 0\ng 384 256 384 272 0\ng 512 256 512 272 0\n"
  },
  {
    "path": "src/circuits/tlstand.txt",
    "content": "$ 1 1.0E-12 2.7070718156067044 50 5.0 50\n171 176 192 496 192 0 0.0000000020 300.0 80 0.0\nw 128 272 176 272 0\nw 496 192 544 192 0\nw 496 272 544 272 0\nr 128 192 176 192 0 300.0\ng 544 272 544 288 0\ng 128 272 128 288 0\nR 128 192 96 192 0 1 1500000000.0 5.0 0.0 0.0 0.5\nw 544 192 544 272 0\no 4 16 0 34 5.0 0.025 0 -1\n"
  },
  {
    "path": "src/circuits/tlterm.txt",
    "content": "$ 1 5.0E-12 14.304574186067095 50 5.0 50\n171 112 32 528 32 0 1.0E-8 75.0 64 0.0\nr 112 32 64 32 0 75.0\nw 64 96 112 96 0\nw 528 32 560 32 0\nw 528 96 560 96 0\nr 560 32 560 96 0 75.0\nv 64 96 64 32 0 2 1.0E7 2.5 2.5 0.0 0.03\ng 528 96 528 112 0\n171 112 144 528 144 0 1.0E-8 75.0 64 0.0\nr 112 144 64 144 0 75.0\nw 64 208 112 208 0\nw 528 144 560 144 0\nw 528 208 560 208 0\nr 560 144 560 208 0 10000.0\nv 64 208 64 144 0 2 1.0E7 2.5 2.5 0.0 0.03\ng 528 208 528 224 0\n171 112 256 528 256 0 1.0E-8 75.0 64 0.0\nr 112 256 64 256 0 75.0\nw 64 320 112 320 0\nw 528 256 560 256 0\nw 528 320 560 320 0\nr 560 256 560 320 0 10.0\nv 64 320 64 256 0 2 1.0E7 2.5 2.5 0.0 0.03\ng 528 320 528 336 0\n171 112 368 528 368 0 1.0E-8 75.0 64 0.0\nr 112 368 64 368 0 10.0\nw 64 432 112 432 0\nw 528 368 560 368 0\nw 528 432 560 432 0\nr 560 368 560 432 0 10000.0\nv 64 432 64 368 0 2 1.0E7 2.5 2.5 0.0 0.03\ng 528 432 528 448 0\n"
  },
  {
    "path": "src/circuits/traffic.txt",
    "content": "$ 3 0.0012 3.84 50 5.0 50\n163 296 336 320 336 1 10 0.0 0.0 0.0 0.0 0.0 0.0 5.0 0.0 0.0 0.0\nR 456 368 456 392 0 0 40.0 5.0 0.0\n152 336 296 336 232 1 4 0.0\nw 320 296 312 296 0\nw 312 296 312 320 0\nw 328 296 328 320 0\nw 344 296 344 320 0\nw 352 296 360 296 0\nw 360 296 360 320 0\nw 408 296 408 320 0\nw 424 296 424 320 0\nw 400 296 392 296 0\nw 392 296 392 320 0\nw 432 296 440 296 0\nw 440 296 440 320 0\n152 416 296 416 232 1 4 5.0\n162 480 88 528 88 0 1.0 0.0 0.0\n162 480 120 528 120 0 1.0 1.0 0.0\n162 480 152 528 152 0 0.0 1.0 0.0\nw 376 320 376 216 0\n162 304 88 256 88 0 1.0 0.0 0.0\n162 304 120 256 120 0 1.0 1.0 0.0\n162 304 152 256 152 0 0.0 1.0 0.0\nw 336 232 336 152 0\nw 456 320 456 120 0\nw 456 120 480 120 0\nw 416 232 416 152 0\nw 416 152 480 152 0\nw 416 96 416 152 0\nw 416 80 432 80 0\nw 432 80 432 120 0\nw 432 120 456 120 0\nw 336 152 336 40 0\nw 360 88 304 88 0\nw 376 216 352 216 0\nw 336 152 304 152 0\nw 352 216 352 120 0\nw 352 120 304 120 0\nw 352 120 352 56 0\n152 352 48 480 48 1 2 0.0\nw 336 40 352 40 0\nw 480 48 480 88 0\nw 528 88 528 120 0\nw 528 120 528 152 0\nw 256 88 256 120 0\nw 256 120 256 152 0\nr 528 152 528 216 0 200.0\nr 256 152 256 216 0 200.0\ng 256 216 256 232 0\ng 528 216 528 232 0\n152 416 88 360 88 1 2 5.0\nR 152 176 152 136 0 0 40.0 5.0 0.0\nw 152 176 64 176 0\nr 64 240 64 304 0 47000.0\nr 64 176 64 240 0 10000.0\nw 216 272 216 352 0\nw 216 352 296 352 0\n165 88 208 152 208 0 0.0\nw 64 304 64 336 0\nc 64 336 64 368 0 9.999999999999999E-6 2.4856719240739658\ng 64 368 64 384 0\nw 64 240 88 240 0\nw 64 304 88 304 0\nw 64 336 88 336 0\n"
  },
  {
    "path": "src/circuits/trans-diffamp-common.txt",
    "content": "$ 1 5.0E-6 5.6 68 15.0 60\nt 176 224 208 224 0 1 -15.316178939790538 0.5164877485159067\nt 400 224 336 224 0 1 -8.349791529425255 0.516487748515907\nw 208 240 208 272 0\nw 336 240 336 272 0\nr 208 272 272 272 0 1000.0\nr 272 272 336 272 0 1000.0\nr 272 272 272 352 0 75000.0\nr 336 144 336 64 0 75000.0\nw 208 64 336 64 0\nR 208 64 176 64 0 0 40.0 15.0 0.0\nR 272 352 208 352 0 0 40.0 -15.0 0.0\nR 176 224 128 224 0 1 40.0 1.0 0.0\nR 400 224 432 224 0 1 40.0 1.0 0.0\np 400 224 400 288 0\ng 400 288 400 320 0\nw 336 144 336 208 0\nw 208 64 208 208 0\nO 336 144 416 144 0\nx 154 206 170 206 0 14 in 1\nx 377 207 393 207 0 14 in 2\no 11 32 0 2 0.15625 9.765625E-5 0\no 13 32 0 2 0.3125 9.765625E-5 0\no 17 32 0 2 20.0 9.765625E-5 1 output\n"
  },
  {
    "path": "src/circuits/trans-diffamp-cursrc.txt",
    "content": "$ 1 5.0E-6 5.6 60 15.0 52\nt 208 192 240 192 0 1 -12.552345476990716 0.5746836796974437\nt 432 192 368 192 0 1 -5.407801804527631 0.5746836796974437\nw 240 208 240 240 0\nw 368 208 368 240 0\nr 368 128 368 48 0 7500.0\nw 240 48 368 48 0\nR 240 48 208 48 0 0 40.0 15.0 0.0\nR 208 192 160 192 0 1 40.0 4.0 0.0\nR 496 192 528 192 0 1 40.0 4.0 0.0\np 432 192 432 256 0\ng 432 256 432 288 0\nw 368 128 368 176 0\nw 240 48 240 176 0\nO 368 128 448 128 0\nx 186 174 202 174 0 14 in 1\nx 409 175 425 175 0 14 in 2\nw 240 240 304 240 0\nw 304 240 368 240 0\nt 256 288 304 288 0 1 -14.336812066191886 0.5922636176064682\nw 304 240 304 272 1\nw 304 368 256 368 0\nr 256 288 256 368 0 2700.0\nr 304 304 304 368 0 1000.0\nr 256 288 176 288 0 13000.0\ng 176 288 176 304 0\nR 256 368 176 368 0 0 40.0 -15.0 0.0\nv 432 192 496 192 0 5 300.0 0.4 0.0\no 7 32 0 2 0.15625 9.765625E-5 0\no 9 32 0 2 0.3125 9.765625E-5 0\no 13 32 0 2 20.0 9.765625E-5 1\n"
  },
  {
    "path": "src/circuits/trans-diffamp.txt",
    "content": "$ 1 5.0E-6 5.6 68 15.0 60\nt 144 208 176 208 0 1 -15.095449051751599 0.5174493144866628\nt 368 208 304 208 0 1 -8.193950382547882 0.5162742583726527\nw 176 224 176 256 0\nw 304 224 304 256 0\nr 176 256 240 256 0 1000.0\nr 240 256 304 256 0 1000.0\nr 240 256 240 336 0 75000.0\nr 304 128 304 48 0 75000.0\nw 176 48 304 48 0\nR 176 48 144 48 0 0 40.0 15.0 0.0\nR 240 336 176 336 0 0 40.0 -15.0 0.0\nR 144 208 96 208 0 1 40.0 0.1 0.0\nv 368 208 432 208 0 1 40.0 -0.1 0.0\nR 432 208 464 208 0 1 200.0 0.1 0.0\np 368 208 368 272 0\ng 368 272 368 304 0\nw 304 128 304 192 0\nw 176 48 176 192 0\nO 304 128 384 128 0\nx 122 190 138 190 0 14 in 1\nx 345 191 361 191 0 14 in 2\no 11 32 0 2 0.15625 9.765625E-5 0\no 14 32 0 2 0.3125 9.765625E-5 0\no 18 32 0 2 12.0 9.765625E-5 1 output\n"
  },
  {
    "path": "src/circuits/transformer.txt",
    "content": "$ 1 5.0E-6 9 54 5.0\nv 176 272 176 144 0 1 60.0 10.0 0.0\nw 352 224 352 272 0\nT 272 192 352 192 0 100.0 1.0 -0.003935272598777283 0.004618353276268098\nw 272 192 272 144 0\nw 272 224 272 272 0\nr 272 144 176 144 0 0.1\nw 176 272 272 272 0\nw 352 272 448 272 0\nw 352 144 448 144 0\nr 448 144 448 272 0 1000.0\nw 352 192 352 144 0\no 0 64 0 3 10.0 0.0125 2\no 9 64 0 3 10.0 0.0125 1\n"
  },
  {
    "path": "src/circuits/transformerdc.txt",
    "content": "$ 1 5.0E-6 10 50 5.0 42\nv 176 272 176 144 0 0 60.0 10.0 0.0\nw 352 224 352 272 0\nT 272 192 352 192 0 10.0 1.0 0 0\nw 272 192 272 144 0\nw 272 224 272 272 0\nr 272 144 176 144 0 100.0\nw 176 272 272 272 0\nw 352 272 448 272 0\nw 352 144 448 144 0\nr 448 144 448 272 0 300.0\nw 352 192 352 144 0\no 0 64 0 3 10.0 0.1 0\no 9 64 0 3 10.0 0.025 1\n\n"
  },
  {
    "path": "src/circuits/transformerdown.txt",
    "content": "$ 1 5.0E-6 9 47 5.0 30\nv 176 272 176 144 2 1 60.0 120.0 0.0\nw 352 224 352 272 0\nT 272 192 352 192 0 1000.0 0.1 0 0\nw 272 192 272 144 1\nw 272 224 272 272 0\nr 272 144 176 144 0 20.0\nw 176 272 272 272 0\nw 352 272 448 272 0\nw 352 144 448 144 0\nr 448 144 448 272 0 300.0\nw 352 192 352 144 1\no 0 64 0 3 160.0 0.4 0\no 9 64 0 3 20.0 0.05 1\n"
  },
  {
    "path": "src/circuits/transformerup.txt",
    "content": "$ 1 5.0E-6 9 43 5.0 42\nv 176 272 176 144 0 1 60.0 10.0 0.0\nw 352 224 352 272 0\nT 272 192 352 192 0 1.0 10.0 0.14177509724862508 -0.008963174444486828\nw 272 192 272 144 1\nw 272 224 272 272 0\nr 272 144 176 144 0 0.1\nw 176 272 272 272 0\nw 352 272 448 272 0\nw 352 144 448 144 0\nr 448 144 448 272 0 2000.0\nw 352 192 352 144 1\no 0 64 0 3 10.0 0.8 0\no 9 64 0 3 160.0 0.05 1\n"
  },
  {
    "path": "src/circuits/transswitch.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nv 144 352 144 80 0 0 40.0 5.0 0.0\nw 144 80 256 80 0\nt 256 256 368 256 0 1 0.5597337598267538 0.646589672025579\nr 256 80 256 176 0 10000.0\ns 256 176 256 256 0 true false\nw 256 80 368 80 0\nr 368 80 368 240 0 300.0\nw 368 272 368 352 0\nw 368 352 144 352 0\n"
  },
  {
    "path": "src/circuits/triangle.txt",
    "content": "$ 1 4.9999999999999996E-6 10.20027730826997 60 6.0 50\na 160 224 272 224 0 15.0 -15.0 1000000.0\nw 160 240 160 304 0\nw 160 304 272 304 0\nr 272 224 272 304 0 10000.0\na 384 240 496 240 0 15.0 -15.0 1000000.0\nr 272 304 352 304 0 4000.0\nw 352 304 496 304 0\nw 496 304 496 240 0\nw 496 240 496 176 0\nc 384 176 496 176 0 1.0E-6 4.7736574744107685\nw 384 176 384 224 0\nr 272 224 384 224 0 10000.0\ng 384 256 384 272 0\nO 496 240 560 240 0\nw 160 208 128 208 0\ng 128 208 128 240 0\no 13 64 0 42 10.0 9.765625E-5 0 -1\n"
  },
  {
    "path": "src/circuits/triode.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 50 5.0 50\n172 304 240 272 240 0 6 0.0 0.0 -8.0 0.0 0.5 Grid Voltage\nw 352 272 352 320 0\nw 368 208 368 160 1\n172 368 160 368 128 0 6 500.0 500.0 0.0 0.0 0.5 Plate Voltage\ng 352 320 352 336 0\n173 304 240 368 240 0 93.0 680.0\no 3 64 0 35 640.0 0.1 0 -1\n"
  },
  {
    "path": "src/circuits/triodeamp.txt",
    "content": "$ 1 5.0E-6 11.086722712598126 60 3.0 53\nw 272 64 368 64 0\nr 272 224 272 368 0 10000.0\nw 272 368 352 368 0\ng 272 368 272 400 0\nR 272 64 176 64 0 0 40.0 160.0 0.0 0.0 0.5\nr 368 64 368 192 0 10000.0\nr 352 256 352 368 0 3000.0\nc 272 224 192 224 0 4.9999999999999996E-6 -0.011918466765635682\nR 192 224 144 224 0 1 80.0 0.5 0.0 0.0 0.5\nc 368 192 448 192 0 4.9999999999999996E-6 156.41283175374522\nO 448 192 496 192 0\nr 448 192 448 288 0 100000.0\ng 448 288 448 320 0\n173 272 224 368 224 0 93.0 1360.0\nw 352 256 400 256 0\nc 400 256 400 368 0 4.9999999999999996E-6 1.2120701747074232\nw 352 368 400 368 0\no 8 64 0 34 0.625 9.765625E-5 0 -1\no 10 64 0 34 5.0 2.44140625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/ttlinverter.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\nt 224 192 224 272 0 1 0.5875584150944089 -3.7844516501481884\nt 240 272 320 272 0 1 0.6035944264912844 0.6279899347574025\ng 320 288 320 336 0\nL 208 272 144 272 0 false false\nr 224 192 224 112 0 4700.0\nr 320 112 320 192 0 1000.0\nw 320 192 320 256 0\nM 320 192 416 192 0\nR 224 112 144 112 0 0 40.0 5.0 0.0\nw 224 112 320 112 0\n"
  },
  {
    "path": "src/circuits/ttlnand.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\nR 192 112 112 112 0 0 40.0 5.0 0.0\nr 352 112 352 192 0 1000.0\nw 352 192 352 224 0\nt 192 192 192 240 0 1 0.5735476679612052 -4.40887239412782\nt 240 192 240 288 0 1 0.5735476679612052 0.5911276058721799\nt 288 240 352 240 0 1 -4.982420061888025 0.01757993791097478\nw 208 240 288 240 0\nw 256 288 288 288 0\nw 288 288 288 240 0\nw 192 192 240 192 0\nL 176 240 128 240 0 false false\nL 224 288 128 288 0 true false\ng 352 256 352 336 0\nw 192 112 352 112 0\nr 192 112 192 192 0 4700.0\nM 352 192 416 192 0\n"
  },
  {
    "path": "src/circuits/ttlnor.txt",
    "content": "$ 1 5.0E-6 10 54 5.0\nt 144 192 144 272 0 1 0.5874809043486446 -3.7727363939084873\nt 160 272 208 272 0 1 0.602697396937354 0.6397827017428683\nL 128 272 64 272 0 false false\nr 144 192 144 112 0 4700.0\nR 144 112 64 112 0 0 40.0 5.0 0.0\nw 144 112 208 112 0\nt 304 192 304 272 0 1 0.5908763474738555 0.5911276058707033\nt 320 272 368 272 0 1 -0.03683404640866654 2.512583968477912E-4\nr 304 112 304 192 0 4700.0\nw 208 112 304 112 0\nw 304 112 368 112 0\nr 368 112 368 192 0 1000.0\nw 368 192 432 192 0\nM 432 192 480 192 0\nL 288 272 240 272 0 true false\nr 208 112 208 192 0 1000.0\nw 208 192 208 224 0\nw 368 192 368 256 0\nw 208 224 432 224 0\nw 432 224 432 192 0\nw 208 224 208 256 0\ng 208 288 208 320 0\ng 368 288 368 320 0\n"
  },
  {
    "path": "src/circuits/twint.txt",
    "content": "$ 1 5.0E-6 10.391409633455755 50 5.0 50\nr 192 112 304 112 0 100.0\nr 304 112 416 112 0 100.0\nc 192 272 304 272 0 2.6524999999999998E-5 0\nc 304 272 416 272 0 2.6524999999999998E-5 0\nc 304 112 304 176 0 5.3049999999999995E-5 0\ng 304 176 304 208 0\nr 304 272 304 336 0 50.0\ng 304 336 304 368 0\nw 416 112 416 192 0\nw 416 192 416 272 0\nw 192 112 192 192 0\nw 192 192 192 272 0\nO 416 192 480 192 0\n170 192 192 144 192 3 40.0 80.0 5.0 0.5\no 13 32 0 34 5.0 0.025 0 -1\no 12 32 0 34 5.0 9.765625E-5 1 -1\n"
  },
  {
    "path": "src/circuits/vco.txt",
    "content": "$ 1 5.0E-6 8.872897488127265 75 5.0 50\na 176 160 272 160 0 5.0 0.0\na 368 176 464 176 0 5.0 0.0\nw 272 160 304 160 0\nw 304 160 368 160 0\nw 368 192 368 224 0\nw 464 176 464 224 0\nr 368 224 464 224 0 100000.0\nr 368 224 368 288 0 100000.0\ng 368 288 368 304 0\nr 176 176 176 240 0 49900.0\ng 176 240 176 256 0\nw 176 144 176 96 0\nw 176 144 144 144 0\nr 144 144 64 144 0 100000.0\nw 64 144 64 160 0\nw 64 160 64 176 0\nr 64 176 160 176 0 49900.0\nw 160 176 176 176 0\nw 144 144 144 272 0\nr 144 272 144 320 0 49900.0\ng 144 352 144 368 0\nf 192 336 144 336 0\nw 192 336 464 336 0\nw 464 336 464 224 0\nc 176 96 272 96 0 1.0E-8 -2.248578405619046\nw 272 96 272 160 0\nw 368 192 368 128 0\nr 368 128 368 80 0 100000.0\nR 368 80 416 80 0 0 40.0 5.0 0.0\nR 64 160 32 160 0 4 10.0 2.0 3.0\nO 464 176 512 176 0\nO 304 160 304 48 0\no 29 64 0 2 5.0 9.765625E-5 0 control\no 30 32 0 2 10.0 4.8828125E-5 1\no 31 32 0 2 5.0 9.765625E-5 2\n"
  },
  {
    "path": "src/circuits/voltdivide.txt",
    "content": "$ 1 5.0E-6 10 63 10.0 62\nv 112 368 112 48 0 0 40.0 10.0 0.0\nw 112 48 240 48 0\nr 240 48 240 208 0 10000\nr 240 208 240 368 0 10000\nw 112 368 240 368 0\nO 240 208 304 208 1\nw 240 48 432 48 0\nw 240 368 432 368 0\nr 432 48 432 128 0 10000\nr 432 128 432 208 0 10000\nr 432 208 432 288 0 10000\nr 432 288 432 368 0 10000\nO 432 128 496 128 1\nO 432 208 496 208 1\nO 432 288 496 288 1\n"
  },
  {
    "path": "src/circuits/voltdouble.txt",
    "content": "$ 1 5.0E-6 10 53 15.0 45\nv 160 208 160 112 0 1 40.0 15.0 0.0\nw 160 112 224 112 0\nd 224 112 336 112 0\nc 336 112 336 208 0 9.999999999999999E-5 0\nc 336 208 336 304 0 9.999999999999999E-5 0\nw 160 208 336 208 0\nw 224 112 224 304 0\nd 336 304 224 304 0\nw 336 112 432 112 0\nw 336 304 432 304 0\nr 432 112 432 304 0 10000.0\no 0 64 0 3 5.0 0.2\no 10 64 0 2 10.0 7.8125E-4\n"
  },
  {
    "path": "src/circuits/voltdouble2.txt",
    "content": "$ 1 5.0E-6 10 50 15.0 45\nR 224 176 192 176 0 1 40.0 15.0 0.0\nc 224 176 304 176 0 9.999999999999999E-5 0\nd 304 288 304 176 0\nd 304 176 400 176 0\nc 400 176 400 288 0 9.999999999999999E-5 0\ng 304 288 304 304 0\ng 400 288 400 304 0\nw 400 176 464 176 0\nr 464 176 464 288 0 20000.0\ng 464 288 464 304 0\no 0 64 0 3 20.0 0.4\no 8 64 0 3 40.0 0.025\n"
  },
  {
    "path": "src/circuits/voltinvert.txt",
    "content": "$ 1 5.0E-6 3.5 62 5.0\n159 176 112 272 112 0\n159 272 112 368 112 0\nc 272 112 272 208 0 1.0E-5 0\n159 176 208 272 208 0\n159 272 208 368 208 0\ng 368 112 368 144 0\nc 368 208 368 304 0 1.0E-5 0\ng 368 304 368 320 0\ng 176 208 176 240 0\nR 176 112 128 112 0 0 40.0 5.0 0.0\nw 224 128 224 224 0\nw 320 128 320 224 0\nw 224 224 224 288 0\nw 320 224 320 288 0\nI 224 288 320 288 0\nR 224 288 128 288 1 2 400.0 2.5 2.5\nw 368 208 432 208 0\nr 432 208 432 304 0 30000.0\ng 432 304 432 320 0\nO 432 208 496 208 1\n"
  },
  {
    "path": "src/circuits/voltquad.txt",
    "content": "$ 1 5.0E-6 10 53 15.0 45\nd 208 256 288 256 0\nc 208 160 288 160 0 9.999999999999999E-5 0\nd 288 160 368 160 0\nc 368 160 368 336 0 9.999999999999999E-5 0\nw 368 160 432 160 0\nr 432 160 432 336 0 50000.0\ng 208 336 208 352 0\ng 368 336 368 352 0\ng 432 336 432 352 0\nR 208 160 160 160 0 1 120.0 15.0 0.0\nd 208 336 208 256 0\nd 288 256 288 160 0\nc 288 256 288 336 0 9.999999999999999E-5 0\ng 288 336 288 352 0\nc 208 160 208 256 0 9.999999999999999E-5 0\no 9 64 0 3 80.0 0.00625\no 5 64 0 3 80.0 0.00625\n"
  },
  {
    "path": "src/circuits/volttriple.txt",
    "content": "$ 1 5.0E-6 10 53 15.0 45\nd 208 160 208 256 0\nd 208 256 288 256 0\nw 288 256 288 160 0\nc 208 160 288 160 0 9.999999999999999E-5 0\nc 208 256 208 336 0 9.999999999999999E-5 0\nd 288 160 368 160 0\nc 368 160 368 336 0 9.999999999999999E-5 0\nw 368 160 432 160 0\nr 432 160 432 336 0 40000.0\ng 208 336 208 352 0\ng 368 336 368 352 0\ng 432 336 432 352 0\nR 208 160 160 160 0 1 120.0 15.0 0.0\no 12 64 0 3 80.0 0.00625\no 8 64 0 3 80.0 0.00625\n"
  },
  {
    "path": "src/circuits/volume.txt",
    "content": "$ 1 5.0E-6 10 67 5.0 64\nj 304 240 352 240 0\nr 304 240 304 176 0 100000.0\nr 304 240 240 240 0 100000.0\nw 304 176 352 176 0\nw 352 176 352 224 0\ng 352 256 352 304 0\nw 352 176 352 128 0\nr 352 128 240 128 0 6000.0\nO 352 128 416 128 0\nR 240 128 192 128 0 1 200.0 5.0 0.0\nR 240 240 192 240 0 3 10.0 3.0 -8.0\no 10 64 0 6 20.0 9.765625E-5 0\no 8 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/wheatstone.txt",
    "content": "v 176 352 176 64 0 0 40.0 5.0 0.0\nw 320 64 320 128 0\nw 320 256 320 352 0\nw 320 352 176 352 0\nr 256 192 320 128 0 200.0\nr 320 128 384 192 0 400.0\nr 256 192 320 256 0 100.0\nr 320 256 384 192 0 200.0\nw 176 64 320 64 0\nw 256 192 384 192 0\n"
  },
  {
    "path": "src/circuits/xor.txt",
    "content": "$ 1 5.0E-6 1.5 50 5.0\n151 96 240 208 240 0 2 0\n151 208 192 320 192 0 2 0\n151 208 288 320 288 0 2 0\nw 208 240 208 272 0\nw 208 240 208 208 0\n151 320 240 432 240 0 2 0\nw 320 192 320 224 0\nw 320 256 320 288 0\nw 96 176 96 224 0\nw 96 176 208 176 0\nw 96 256 96 304 0\nw 96 304 208 304 0\nM 432 240 480 240 0\nL 96 176 48 176 0 true false\nL 96 304 48 304 0 true false\n"
  },
  {
    "path": "src/circuits/xorphasedet.txt",
    "content": "$ 1 5.0E-6 10 50 5.0\nR 192 128 128 128 0 2 100.0 2.5 2.5\nR 192 224 128 224 0 2 105.0 2.5 2.5\n154 192 176 336 176 0 2 0.0\nO 336 176 416 176 0\nw 192 128 192 160 0\nw 192 192 192 224 0\no 0 64 0 6 5.0 9.765625E-5 0\no 1 64 0 6 5.0 9.765625E-5 0\no 3 64 0 6 5.0 9.765625E-5 0\n"
  },
  {
    "path": "src/circuits/zeneriv.txt",
    "content": "$ 1 5.0E-6 10.634267539816555 40 2.0 50\nR 320 208 320 160 0 3 50.0 3.55 -2.56 0.0 0.5\ng 320 288 320 320 0\nz 320 208 320 288 1 0.805904783 5.6\no 2 64 0 99 10.0 25.6 0 -1\no 2 64 0 35 10.0 25.6 1 -1\n"
  },
  {
    "path": "src/circuits/zenerref.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 54 5.0 50\nR 272 160 224 160 0 1 40.0 1.0 6.7 0.0 0.5\nz 336 288 336 160 1 0.805904783 5.6\ng 336 288 336 304 0\nw 336 160 416 160 0\nr 416 160 416 288 0 10000.0\ng 416 288 416 304 0\nr 272 160 336 160 0 500.0\no 0 64 0 34 10.0 0.003125 0 -1 in\no 4 64 0 34 10.0 3.90625E-4 1 -1 out\no 1 64 0 35 10.0 0.00625 2 -1 zener\n"
  },
  {
    "path": "src/circuits/zenerreffollow.txt",
    "content": "$ 1 5.0E-6 10.20027730826997 56 5.0 50\nR 240 128 192 128 0 1 40.0 2.0 8.8 0.0 0.5\nw 240 128 320 128 0\nr 320 128 320 208 0 10000.0\nt 320 208 400 208 0 1 -3.046294556431631 0.6320971159170448 100.0\nr 400 128 400 192 0 100.0\nw 320 128 400 128 0\nz 320 320 320 208 1 0.805904783 5.6\nw 400 224 400 256 0\nw 400 256 448 256 0\nr 448 256 448 320 0 500.0\ng 448 320 448 336 0\ng 320 320 320 336 0\no 0 64 0 34 12.0 0.00625 0 -1 in\no 9 64 0 35 5.0 0.0125 1 -1 out\no 6 64 0 35 10.0 7.8125E-4 2 -1 zener\n"
  },
  {
    "path": "src/setuplist.txt",
    "content": "### setuplist.txt first line must be a comment\n+Basics\nohms.txt Ohm's Law\nresistors.txt Resistors\ncap.txt Capacitor\ninduct.txt Inductor\n>lrc.txt LRC Circuit\nvoltdivide.txt Voltage Divider\npot.txt Potentiometer\npotdivide.txt Potentiometer Divider\nthevenin.txt Thevenin's Theorem\nnorton.txt Norton's Theorem\n-\n+A/C Circuits\ncapac.txt Capacitor\ninductac.txt Inductor\ncapmultcaps.txt Caps of Various Capacitances\ncapmultfreq.txt Caps w/ Various Frequencies\nindmultind.txt Inductors of Various Inductances\nindmultfreq.txt Inductors w/ Various Frequencies\nimpedance.txt Impedances of Same Magnitude\nres-series.txt Series Resonance\nres-par.txt Parallel Resonance\n-\n+Passive Filters\nfilt-hipass.txt High-Pass Filter (RC)\nfilt-lopass.txt Low-Pass Filter (RC)\nfilt-hipass-l.txt High-Pass Filter (RL)\nfilt-lopass-l.txt Low-Pass Filter (RL)\nbandpass.txt Band-pass Filter\nnotch.txt Notch Filter\ntwint.txt Twin-T Filter\ncrossover.txt Crossover\nbutter10lo.txt Butterworth Low-Pass (10 pole)\nbesselbutter.txt Bessel vs Butterworth\nringing.txt Band-pass with Ringing\n-\n+Other Passive Circuits\n+Series/Parallel\nindseries.txt Inductors in Series\nindpar.txt Inductors in Parallel\ncapseries.txt Caps in Series\ncappar.txt Caps in Parallel\n-\n+Transformers\ntransformer.txt Transformer\ntransformerdc.txt Transformer w/ DC\ntransformerup.txt Step-Up Transformer\ntransformerdown.txt Step-Down Transformer\nlongdist.txt Long-Distance Power Transmission\n-\n+Relays\nrelay.txt Relay\nrelayand.txt Relay AND\nrelayor.txt Relay OR\nrelayxor.txt Relay XOR\nrelaymux.txt Relay Mux\nrelayff.txt Relay Flip-Flop\nrelaytff.txt Relay Toggle Flip-Flop\nrelayctr.txt Relay Counter\n-\n3way.txt 3-Way Light Switches\n4way.txt 3- and 4-Way Light Switches\ndiff.txt Differentiator\nwheatstone.txt Wheatstone Bridge\nlrc-critical.txt Critically Damped LRC\ncurrentsrcelm.txt Current Source\ninductkick.txt Inductive Kickback\ninductkick-snub.txt Blocking Inductive Kickback\npowerfactor1.txt Power Factor\npowerfactor2.txt Power Factor Correction\ngrid.txt Resistor Grid\ngrid2.txt Resistor Grid 2\ncube.txt Resistor Cube\n+Coupled LC's\ncoupled1.txt LC Modes (2)\ncoupled2.txt Weak Coupling\ncoupled3.txt LC Modes (3)\nladder.txt LC Ladder\n-\nphaseseq.txt Phase-Sequence Network\nlissa.txt Lissajous Figures\n-\n+Diodes\ndiodevar.txt Diode\ndiodecurve.txt Diode I/V Curve\nrectify.txt Half-Wave Rectifier\nfullrect.txt Full-Wave Rectifier\nfullrectf.txt Full-Wave Rectifier w/ Filter\ndiodelimit.txt Diode Limiter\n+Zener Diodes\nzeneriv.txt I/V Curve\nzenerref.txt Voltage Reference\nzenerreffollow.txt Voltage Reference w/ Follower\n-\ndcrestoration.txt DC Restoration\ninductkick-block.txt Blocking Inductive Kickback\nspikegen.txt Spike Generator\n+Voltage Multipliers\nvoltdouble.txt Voltage Doubler\nvoltdouble2.txt Voltage Doubler 2\nvolttriple.txt Voltage Tripler\nvoltquad.txt Voltage Quadrupler\n-\namdetect.txt AM Detector\ndiodeclip.txt Waveform Clipper\nsinediode.txt Triangle-to-Sine Converter\nringmod.txt Ring Modulator\n-\n+Op-Amps\nopamp.txt Op-Amp\nopampfeedback.txt Op-Amp Feedback\n+Amplifiers\namp-invert.txt Inverting Amplifier\namp-noninvert.txt Noninverting Amplifier\namp-follower.txt Follower\namp-diff.txt Differential Amplifier\namp-sum.txt Summing Amplifier\nlogconvert.txt Log Amplifier\nclassd.txt Class-D Amplifier\n-\n+Oscillators\nrelaxosc.txt Relaxation Oscillator\nphaseshiftosc.txt Phase-Shift Oscillator\ntriangle.txt Triangle Wave Generator\nsine.txt Sine Wave Generator\nsawtooth.txt Sawtooth Wave Generator\nvco.txt Voltage-Controlled Oscillator\nrossler.txt Rossler Circuit\n-\namp-rect.txt Half-Wave Rectifier (inverting)\namp-fullrect.txt Full-Wave Rectifier\npeak-detect.txt Peak Detector\namp-integ.txt Integrator\namp-dfdx.txt Differentiator\namp-schmitt.txt Schmitt Trigger\nnic-r.txt Negative Impedance Converter\ngyrator.txt Gyrator\ncapmult.txt Capacitance Multiplier\nhowland.txt Howland Current Source\nitov.txt I-to-V Converter\nopamp-regulator.txt Voltage Regulator\nopint.txt 741 Internals\nopint-invert-amp.txt 741 (inverting amplifier)\nopint-slew.txt 741 Slew Rate\nopint-current.txt 741 Current Limits\n-\n+Transistors\nnpn.txt NPN Transistor\npnp.txt PNP Transistor\ntransswitch.txt Switch\nfollower.txt Emitter Follower\n+Multivibrators\nmultivib-a.txt Astable Multivib\nmultivib-bi.txt Bistable Multivib (Flip-Flop)\nmultivib-mono.txt Monostable Multivib (One-Shot)\n-\nceamp.txt Common-Emitter Amplifier\nphasesplit.txt Unity-Gain Phase Splitter\nschmitt.txt Schmitt Trigger\ncurrentsrc.txt Current Source\ncurrentsrcramp.txt Current Source Ramp\nmirror.txt Current Mirror\ndarlington.txt Darlington Pair\n+Differential Amplifiers\ntrans-diffamp.txt Differential Input\ntrans-diffamp-common.txt Common-Mode Input\ntrans-diffamp-cursrc.txt Common-Mode w/Current Source\n-\n+Push-Pull Follower\npushpullxover.txt Simple, with distortion\npushpull.txt Improved\n-\n+Oscillators\ncolpitts.txt Colpitts Oscillator\nhartley.txt Hartley Oscillator\neclosc.txt Emitter-Coupled LC Oscillator\n-\n-\n+MOSFETs\nnmosfet.txt n-MOSFET\npmosfet.txt p-MOSFET\nmosswitch.txt Switch\nmosfollower.txt Source Follower\nmoscurrentsrc.txt Current Source\nmoscurrentramp.txt Current Ramp\nmosmirror.txt Current Mirror\nmosfetamp.txt Common-Source Amplifier\ncmosinverter.txt CMOS Inverter\ncmosinvertercap.txt CMOS Inverter (w/capacitance)\ncmosinverterslow.txt CMOS Inverter (slow transition)\ncmostransgate.txt CMOS Transmission Gate\nmux.txt CMOS Multiplexer\nsamplenhold.txt Sample-and-Hold\ndelayrc.txt Delayed Buffer\nleadingedge.txt Leading-Edge Detector\nswitchfilter.txt Switchable Filter\nvoltinvert.txt Voltage Inverter\ninvertamp.txt Inverter Amplifier\ninv-osc.txt Inverter Oscillator\n-\n+555 Timer Chip\n555square.txt Square Wave Generator\n555int.txt Internals\n555saw.txt Sawtooth Oscillator\n555lowduty.txt Low-duty-cycle Oscillator\n555monostable.txt Monostable Multivibrator\n555pulsemod.txt Pulse Width Modulator\n555sequencer.txt Pulse Sequencer\n555schmitt.txt Schmitt Trigger (inverting)\n555missing.txt Missing Pulse Detector\n-\n+Active Filters\nfilt-vcvs-lopass.txt VCVS Low-Pass Filter\nfilt-vcvs-hipass.txt VCVS High-Pass Filter\nswitchedcap.txt Switched-Capacitor Filter\nallpass1.txt Allpass\nallpass2.txt Allpass w/ Square\n-\n+Logic Families\n+RTL\nrtlinverter.txt RTL Inverter\nrtlnor.txt RTL NOR\nrtlnand.txt RTL NAND\n-\n+DTL\ndtlinverter.txt DTL Inverter\ndtlnand.txt DTL NAND\ndtlnor.txt DTL NOR\n-\n+TTL\nttlinverter.txt TTL Inverter\nttlnand.txt TTL NAND\nttlnor.txt TTL NOR\n-\n+NMOS\nnmosinverter.txt NMOS Inverter\nnmosinverter2.txt NMOS Inverter 2\nnmosnand.txt NMOS NAND\n-\n+CMOS\ncmosinverter.txt CMOS Inverter\ncmosnand.txt CMOS NAND\ncmosnor.txt CMOS NOR\ncmosxor.txt CMOS XOR\ncmosff.txt CMOS Flip-Flop\ncmosmsff.txt CMOS Master-Slave Flip-Flop\n-\n+ECL\neclnor.txt ECL NOR/OR\n-\n+Ternary\n3-cgand.txt CGAND\n3-cgor.txt CGOR\n3-invert.txt Complement (F210)\n3-f211.txt F211\n3-f220.txt F220\n3-f221.txt F221\n-\n-\n+Combinational Logic\nxor.txt Exclusive OR\nhalfadd.txt Half Adder\nfulladd.txt Full Adder\ndecoder.txt 1-of-4 Decoder\nmux3state.txt 2-to-1 Mux\nmajority.txt Majority Logic\ndigcompare.txt 2-Bit Comparator\n7segdecoder.txt 7-Segment LED Decoder\n-\n+Sequential Logic\n+Flip-Flops\nnandff.txt SR Flip-Flop\nclockedsrff.txt Clocked SR Flip-Flop\nmasterslaveff.txt Master-Slave Flip-Flop\nedgedff.txt Edge-Triggered D Flip-Flop\njkff.txt JK Flip-Flop\n-\n+Counters\ncounter.txt 4-Bit Ripple Counter\ncounter8.txt 8-Bit Ripple Counter\nsynccounter.txt Synchronous Counter\ndeccounter.txt Decimal Counter\ngraycode.txt Gray Code Counter\njohnsonctr.txt Johnson Counter\n-\ndivideby2.txt Divide-by-2\ndivideby3.txt Divide-by-3\nledflasher.txt LED Flasher\ntraffic.txt Traffic Light\ndram.txt Dynamic RAM\n-\n+Analog/Digital\nflashadc.txt Flash ADC\ndeltasigma.txt Delta-Sigma ADC\nhfadc.txt Half-Flash (Subranging) ADC\ndac.txt Binary-Weighted DAC\nr2rladder.txt R-2R Ladder DAC\nswtreedac.txt Switch-Tree DAC\ndigsine.txt Digital Sine Wave\n-\n+Phase-Locked Loops\nxorphasedet.txt XOR Phase Detector\npll.txt Type I PLL\nphasecomp.txt Phase Comparator (Type II)\nphasecompint.txt Phase Comparator Internals\npll2.txt Type II PLL\npll2a.txt Type II PLL (fast)\nfreqdouble.txt Frequency Doubler\n-\n+Transmission Lines\ntl.txt Simple TL\ntlstand.txt Standing Wave\ntlterm.txt Termination\ntlmismatch.txt Mismatched lines (Pulse)\ntlmis1.txt Mismatched lines (Standing Wave)\ntlmatch1.txt Impedance Matching (L-Section)\ntlmatch2.txt Impedance Matching (Shunt Stub)\ntlfreq.txt Stub Frequency Response\ntllopass.txt Low-Pass Filter\ntllight.txt Light Switch\n-\n+Misc Devices\n+JFETs\njfetcurrentsrc.txt JFET Current Source\njfetfollower.txt JFET Follower\njfetfollower-nooff.txt JFET Follower w/zero offset\njfetamp.txt Common-Source Amplifier\nvolume.txt Volume Control\n-\n+Tunnel Diodes\ntdiode.txt I/V Curve\ntdosc.txt LC Oscillator\ntdrelax.txt Relaxation Oscillator\n-\n+Memristors\nmr.txt Memristor\nmr-sine.txt Sine Wave\nmr-square.txt Square Wave\nmr-triangle.txt Triangle Wave\nmr-sine2.txt Hard-Switching 1\nmr-sine3.txt Hard-Switching 2\nmr-crossbar.txt Crossbar Memory\n-\n+Triodes\ntriode.txt Triode\ntriodeamp.txt Amplifier\n-\n+Silicon-Controlled Rectifiers\nscr.txt SCR\nscractrig.txt AC Trigger\n-\n+Current Conveyor\ncc2.txt CCII+\ncc2n.txt CCII-\nccinductor.txt Inductor Simulator\ncc2imp.txt CCII+ Implementation\ncc2impn.txt CCII- Implementation\ncciamp.txt Current Amplifier\nccvccs.txt VCCS\nccdiff.txt Current Differentiator\nccint.txt Current Integrator\nccitov.txt Current-Controlled Voltage Source\n-\n+Spark Gap\nspark-sawtooth.txt Sawtooth Generator\ntesla.txt Tesla Coil\nspark-marx.txt Marx Generator\n-\n-\nblank.txt Blank Circuit\n"
  }
]