// To compile this code:
//    Run "Command prompt"
//    cd "E:\DevelE\Electric\lib\java\COM\staticfreesoft"
//    type "javac electric.java"

package COM.staticfreesoft;


public class electric
{
	final static public int vdisplay = 64;

	int address;

	public class nodeinst extends electric {}
	public class nodeproto extends electric {}
	public class portarcinst extends electric {}
	public class portexpinst extends electric {}
	public class portproto extends electric {}
	public class arcinst extends electric {}
	public class arcproto extends electric {}
	public class geom extends electric {}
	public class library extends electric {}
	public class technology extends electric {}
	public class aid extends electric {}
	public class rtnode extends electric {}
	public class network extends electric {}
	public class cell extends electric {}
	public class view extends electric {}
	public class windowpart extends electric {}
	public class windowframe extends electric {}
	public class graphics extends electric {}
	public class constraint extends electric {}
	public class polygon extends electric {}
	public class xarray
	{
		public int[]               v;
	}

	public class eout extends java.io.PrintStream
	{
		public eout() { super(System.out); }
		public void takeover() { System.setOut(this); System.setErr(this); }

		public native void ewrite(String s);
		public native void write(int b);

		public boolean checkError()  { return(false); }
		public void flush()          {}
		public void print(boolean b) { ewrite(b ? "true" : "false"); }
		public void print(char c)    { ewrite(String.valueOf(c)); }
		public void print(int i)     { ewrite(String.valueOf(i)); }
		public void print(long l)    { ewrite(String.valueOf(l)); }
		public void print(float f)   { ewrite(String.valueOf(f)); }
		public void print(double d)  { ewrite(String.valueOf(d)); }
		public void print(char s[])  { for (int i = 0; i < s.length; i++) write(s[i]); }
		public void print(String s)  { if (s == null) s = "null"; ewrite(s); }
		public void print(Object o)  { ewrite(String.valueOf(o)); }
		public void println()          {           write('\n'); }
		public void println(boolean x) { print(x); write('\n'); }
		public void println(char x)    { print(x); write('\n'); }
		public void println(int x)     { print(x); write('\n'); }
		public void println(long x)    { print(x); write('\n'); }
		public void println(float x)   { print(x); write('\n'); }
		public void println(double x)  { print(x); write('\n'); }
		public void println(char x[])  { print(x); write('\n'); }
		public void println(String x)  { print(x); write('\n'); }
		public void println(Object x)  { print(x); write('\n'); }
		public void write(byte[] s, int off, int len)
			{ for (int i = 0; i < len; i++) write(s[i+off]); }
	}

	public boolean isNull() { return(address == -1); }
	public static boolean isEqual(electric a1, electric a2) { return(a1.address == a2.address); }

	/***************** DATABASE EXAMINATION ROUTINES *****************/
	public static native library curLib();
	public static native technology curTech();
	public static native Object getVal(nodeinst obj, String name);
	public static native Object getVal(nodeproto obj, String name);
	public static native Object getVal(portarcinst obj, String name);
	public static native Object getVal(portexpinst obj, String name);
	public static native Object getVal(portproto obj, String name);
	public static native Object getVal(arcinst obj, String name);
	public static native Object getVal(arcproto obj, String name);
	public static native Object getVal(geom obj, String name);
	public static native Object getVal(library obj, String name);
	public static native Object getVal(technology obj, String name);
	public static native Object getVal(aid obj, String name);
	public static native Object getVal(rtnode obj, String name);
	public static native Object getVal(network obj, String name);
	public static native Object getVal(cell obj, String name);
	public static native Object getVal(view obj, String name);
	public static native Object getVal(windowpart obj, String name);
	public static native Object getVal(windowframe obj, String name);
	public static native Object getVal(graphics obj, String name);
	public static native Object getVal(constraint obj, String name);
	public static native Object getVal(polygon obj, String name);
	public static native void setVal(Object obj, String name, Object attr, int bits);
	public static native void setInd(Object obj, String name, int index, Object attr);
	public static native void delVal(Object obj, String name);
	public static native int initSearch(int lx, int hx, int ly, int hy, nodeproto facet);
	public static native Object nextObject(int search);
	public static native void termSearch(int search);

	/***************** AID ROUTINES *****************/
	public static native aid getAid(String name);
	public static native int maxAid();
	public static native aid indexAid(int index);
	public static native void aidTurnOn(aid a, int noCatchUp);
	public static native void aidTurnOff(aid a);
	public static native void tellAid(aid a, int argc, String[] argv);

	/***************** LIBRARY ROUTINES *****************/
	public static native library getLibrary(String name);
	public static native library newLibrary(String libname, String libfile);
	public static native void killLibrary(library lib);
	public static native void eraseLibrary(library lib);
	public static native void selectLibrary(library lib);

	/***************** NODEPROTO ROUTINES *****************/
	public static native nodeproto getNodeProto(String name);
	public static native nodeproto newNodeProto(String name, library lib);
	public static native int killNodeProto(nodeproto facet);
	public static native nodeproto copyNodeProto(nodeproto facet, library tolibrary,
		String toname);
	public static native nodeproto iconView(nodeproto facet);
	public static native nodeproto contentsView(nodeproto facet);

	/***************** NODEINST ROUTINES *****************/
	public static native nodeinst newNodeInst(nodeproto proto, int lx, int hx,
		int ly, int hy, int trans, int rot, nodeproto facet);
	public static native void modifyNodeInst(nodeinst node, int dlx, int dly,
		int dhx, int dhy, int drot, int dtrans);
	public static native int killNodeInst(nodeinst node);
	public static native nodeinst replaceNodeInst(nodeinst node, nodeproto newproto);
	public static native int nodeFunction(nodeinst node);
	public static native int nodePolys(nodeinst node);
	public static native electric.polygon shapeNodePoly(nodeinst node, int index);
	public static native int nodeEPolys(nodeinst node);
	public static native electric.polygon shapeENodePoly(nodeinst node, int index);
	public static native electric.xarray makeRot(nodeinst node);
	public static native electric.xarray makeTrans(nodeinst node);

	/***************** ARCINST ROUTINES *****************/
	public static native arcinst newArcInst(arcproto proto, int wid, int bits,
		nodeinst node1, portproto port1, int x1, int y1,
		nodeinst node2, portproto port2, int x2, int y2, nodeproto facet);
	public static native int modifyArcInst(arcinst arc, int dwid, int dx1, int dy1,
		int dx2, int dy2);
	public static native int killArcInst(arcinst arc);
	public static native arcinst replaceArcInst(arcinst arc, arcproto newproto);
	public static native int arcPolys(arcinst arc);
	public static native electric.polygon shapeArcPoly(arcinst arc, int index);

	/***************** PORTPROTO ROUTINES *****************/
	public static native portproto newPortProto(nodeproto facet, nodeinst node,
		portproto port, String name);
	public static native Integer[] portPosition(nodeinst node, portproto port);
	public static native portproto getPortProto(nodeproto facet, String name);
	public static native int killPortProto(nodeproto facet, portproto port);
	public static native int movePortProto(nodeproto facet, portproto oldport,
		nodeinst newnode, portproto newport);

	/***************** CHANGE CONTROL ROUTINES *****************/
	public static native int undoABatch();
	public static native void noUndoAllowed();

	/***************** VIEW ROUTINES *****************/
	public static native view getView(String name);
	public static native view newView(String name, String shortname);
	public static native int killView(view v);

	/***************** MISCELLANEOUS ROUTINES *****************/
	public static native arcproto getArcProto(String name);
	public static native cell getCell(String name);
	public static native technology getTechnology(String name);
	public static native nodeproto getPinProto(arcproto arctype);
	public static native network getNetwork(String name, nodeproto facet);
	public static native String layerName(technology tech, int layer);
	public static native int layerFunction(technology tech, int layer);
	public static native int maxDRCSurround(technology tech, library lib, int layer);
	public static native int DRCMinDistance(technology tech, library lib, int layer1,
		int layer2, int connected);
	public static native int DRCMinWidth(technology tech, library lib, int layer);
	public static native void xformPoly(polygon poly, xarray trans);
	public static native void freePolygon(polygon poly);
	public static native electric.nodeinst[] getTraversalPath();
}
