83
83
public String defaultFoundry;
84
84
public double minResistance;
85
85
public double minCapacitance;
86
private final LinkedHashMap<String,Layer> layers = new LinkedHashMap<String,Layer>();
86
public final List<Color> transparentLayers = new ArrayList<Color>();
87
public final List<Layer> layers = new ArrayList<Layer>();
87
88
public final List<ArcProto> arcs = new ArrayList<ArcProto>();
88
89
public final List<PrimitiveNode> nodes = new ArrayList<PrimitiveNode>();
89
90
public final List<SpiceHeader> spiceHeaders = new ArrayList<SpiceHeader>();
90
public final List<DisplayStyle> displayStyles = new ArrayList<DisplayStyle>();
91
91
public MenuPalette menuPalette;
92
public final LinkedHashMap<String,RuleSet> ruleSets = new LinkedHashMap<String,RuleSet>();
93
92
public final List<Foundry> foundries = new ArrayList<Foundry>();
95
public Layer newLayer(String name) {
97
throw new NullPointerException();
98
if (layers.containsKey(name))
99
throw new IllegalArgumentException("Duplicate Layer " + name);
100
Layer layer = new Layer(name);
101
layers.put(name, layer);
105
public RuleSet newRuleSet(String name) {
107
throw new NullPointerException();
108
if (ruleSets.containsKey(name))
109
throw new IllegalArgumentException("Duplicate RuleSet " + name);
110
RuleSet ruleSet = new RuleSet(name);
111
ruleSets.put(name, ruleSet);
115
94
public Layer findLayer(String name) {
116
return layers.get(name);
95
for (Layer layer: layers) {
96
if (layer.name.equals(name))
119
102
public ArcProto findArc(String name) {
132
public static class Version implements Serializable {
133
public int techVersion;
134
public com.sun.electric.database.text.Version electricVersion;
149
137
public static class Layer implements Serializable {
150
public final String name;
151
139
public com.sun.electric.technology.Layer.Function function;
152
140
public int extraFunction;
141
public EGraphics desc;
142
public double thick3D;
143
public double height3D;
144
public String mode3D;
145
public double factor3D;
153
146
public String cif;
154
147
public String skill;
155
148
public double resistance;
156
149
public double capacitance;
157
150
public double edgeCapacitance;
158
151
public PureLayerNode pureLayerNode;
160
private Layer(String name) {
165
154
public static class PureLayerNode implements Serializable {
166
155
public String name;
167
156
public String oldName;
157
public Poly.Type style;
169
158
public String port;
159
public final Distance size = new Distance();
170
160
public final List<String> portArcs = new ArrayList<String>();
180
170
public boolean notUsed;
181
171
public boolean skipSizeInPalette;
173
public final TreeMap<Integer,Double> diskOffset = new TreeMap<Integer,Double>();
174
public final Distance defaultWidth = new Distance();
183
175
public boolean extended;
184
176
public boolean fixedAngle;
185
177
public int angleIncrement;
186
178
public double antennaRatio;
187
public double elibWidthOffset;
188
179
public final List<ArcLayer> arcLayers = new ArrayList<ArcLayer>();
189
public ArcPin arcPin;
192
public static class ArcPin implements Serializable {
194
public String portName;
195
public double elibSize;
196
public final List<String> portArcs = new ArrayList<String>();
199
182
public static class ArcLayer implements Serializable {
200
183
public String layer;
201
184
public final Distance extend = new Distance();
185
public Poly.Type style;
205
188
public static class PrimitiveNode implements Serializable {
273
255
public final List<String> spiceLines = new ArrayList<String>();
276
public static class DisplayStyle implements Serializable {
278
public final List<Color> transparentLayers = new ArrayList<Color>();
279
private final LinkedHashMap<Layer,LayerDisplayStyle> layerStylesInternal = new LinkedHashMap<Layer,LayerDisplayStyle>();
280
public final Map<Layer,LayerDisplayStyle> layerStyles = Collections.unmodifiableMap(layerStylesInternal);
282
public LayerDisplayStyle newLayer(Layer layer) {
283
LayerDisplayStyle lds = new LayerDisplayStyle(layer);
284
LayerDisplayStyle old = layerStylesInternal.put(layer, lds);
290
public static class LayerDisplayStyle implements Serializable {
291
public final Layer layer;
292
public EGraphics desc;
293
public String mode3D;
294
public double factor3D;
296
private LayerDisplayStyle(Layer layer) {
301
258
public static class MenuPalette implements Serializable {
302
259
public int numColumns;
303
260
public List<List<Object>> menuBoxes = new ArrayList<List<Object>>();
315
272
public static class MenuNodeInst implements Serializable {
316
public String protoName;
317
public com.sun.electric.technology.PrimitiveNode.Function function;
319
public double fontSize;
323
public static class MenuCell implements Serializable {
324
public String cellName;
325
// public String text;
326
// public double fontSize;
273
/** the name of the prototype in the menu */ public String protoName;
274
/** the function of the prototype */ public com.sun.electric.technology.PrimitiveNode.Function function;
275
/** label to draw in the menu entry (may be null) */ public String text;
276
/** the size of the menu entry label */ public double fontSize;
277
/** the rotation of the node in the menu entry */ public int rotation;
329
280
public static class Distance implements Serializable {
331
public double lambdaValue;
332
public final List<DistanceRule> terms = new ArrayList<DistanceRule>();
334
public void assign(Distance d) {
336
lambdaValue = d.lambdaValue;
337
for (DistanceRule term: d.terms)
338
terms.add(term.clone());
341
public void assign(com.sun.electric.technology.Technology.Distance d) {
343
lambdaValue = d.lambdaValue;
344
for (com.sun.electric.technology.Technology.DistanceRule term: d.terms)
345
terms.add(new DistanceRule(term));
348
public Distance clone() {
349
Distance d = new Distance();
354
public double getLambda(DistanceContext context) {
355
double value = lambdaValue;
356
for (DistanceRule term: terms)
357
value += term.getLambda(context);
360
private void writeXml(Writer writer, boolean multiLine) {
361
for (DistanceRule term: terms) {
362
term.writeXml(writer);
366
if (lambdaValue != 0) {
367
writer.bcpe(XmlKeyword.lambda, lambdaValue);
372
public void addLambda(double value) {
373
lambdaValue += value;
375
public void addRule(String ruleName, double k) {
376
addRule(ruleName, null, k);
378
public void addRule(String ruleName, Layer layer, double k) {
379
addRule(ruleName, layer, null, k);
381
public void addRule(String ruleName, Layer layer, Layer layer2, double k) {
382
terms.add(new DistanceRule(ruleName, layer, layer2, k));
384
public boolean isEmpty() { return lambdaValue == 0 && terms.isEmpty(); }
387
public static interface DistanceContext {
388
public double getRule(String ruleName);
391
public static class DistanceRule implements Serializable, Cloneable {
392
final String ruleName;
397
public DistanceRule(com.sun.electric.technology.Technology.DistanceRule oldRule) {
398
this(oldRule.ruleName, null, null, oldRule.k);
401
private DistanceRule(String ruleName, Layer layer, Layer layer2, double k) {
402
this.ruleName = ruleName;
404
this.layer2 = layer2;
408
public DistanceRule clone() {
410
return (DistanceRule)super.clone();
411
} catch (CloneNotSupportedException e) {
412
throw new AssertionError();
416
private void writeXml(Writer writer) {
417
writer.b(XmlKeyword.rule);
418
writer.a("ruleName", ruleName);
420
writer.a("layer", layer.name);
422
writer.a("layer2", layer2.name);
429
private double getLambda(DistanceContext context) {
430
return context.getRule(ruleName)*k;
434
public static class RuleSet implements Serializable {
435
public final String name;
436
public final Map<String,Map<Layer,Distance>> layerRules = new LinkedHashMap<String,Map<Layer,Distance>>();
438
private RuleSet(String name) {
442
public Map<Layer,Distance> newLayerRule(String ruleName) {
443
if (ruleName == null)
444
throw new NullPointerException();
445
if (layerRules.containsKey(ruleName))
446
throw new IllegalArgumentException("Duplicate LayerRule " + ruleName);
447
Map<Layer,Distance> layerRule = new LinkedHashMap<Layer,Distance>();
448
layerRules.put(ruleName, layerRule);
284
public void addLambda(double lambdaValue) {
285
value += lambdaValue;
586
414
private static synchronized void loadTechnologySchema() throws SAXException {
587
415
if (schema != null) return;
588
416
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
589
URL technologySchemaUrl = Technology.class.getResource("xml/Technology807.xsd");
417
URL technologySchemaUrl = Technology.class.getResource("Technology.xsd");
590
418
if (technologySchemaUrl != null)
591
419
schema = schemaFactory.newSchema(technologySchemaUrl);
594
System.err.println("Schema file Technology807.xsd, working without XML schema");
595
System.out.println("Schema file Technology807.xsd, working without XML schema");
422
System.err.println("Schema file Technology.xsd, working without XML schema");
423
System.out.println("Schema file Technology.xsd, working without XML schema");
668
495
private static boolean DEBUG = false;
669
496
private Locator locator;
671
private Technology tech = new Technology();
672
private Layer curLayer;
673
private ArcProto curArc;
674
private PrimitiveNode curNode;
675
private NodeLayer curNodeLayer;
676
private PrimitivePort curPort;
677
private int curSpecialValueIndex;
678
private ArrayList<Object> curMenuBox;
679
private MenuNodeInst curMenuNodeInst;
680
private MenuCell curMenuCell;
681
private Distance curDistance;
682
private SpiceHeader curSpiceHeader;
684
private DisplayStyle curDisplayStyle;
498
private Xml807.Technology tech = new Xml807.Technology();
685
499
private int curTransparent = 0;
686
500
private int curR;
687
501
private int curG;
688
502
private int curB;
689
private LayerDisplayStyle curLayerDisplayStyle;
503
private Layer curLayer;
690
504
private boolean patternedOnDisplay;
691
505
private boolean patternedOnPrinter;
692
506
private final int[] pattern = new int[16];
694
508
private EGraphics.Outline outline;
695
509
private double opacity;
696
510
private boolean foreground;
698
private RuleSet curRuleSet;
699
private Map<Layer,Distance> curLayerRule;
511
private ArcProto curArc;
512
private PrimitiveNode curNode;
513
private NodeLayer curNodeLayer;
514
private PrimitivePort curPort;
515
private int curSpecialValueIndex;
516
private ArrayList<Object> curMenuBox;
517
private MenuNodeInst curMenuNodeInst;
518
private Distance curDistance;
519
private SpiceHeader curSpiceHeader;
700
520
private Foundry curFoundry;
702
522
private boolean acceptCharacters;
971
797
case minCapacitance:
972
798
tech.minCapacitance = Double.parseDouble(a("value"));
800
case transparentLayer:
801
curTransparent = Integer.parseInt(a("transparent"));
802
curR = curG = curB = 0;
975
if (curDisplayStyle != null) {
976
curLayerDisplayStyle = curDisplayStyle.newLayer(tech.findLayer(a("name")));
978
curR = curG = curB = 0;
979
patternedOnDisplay = false;
980
patternedOnPrinter = false;
981
Arrays.fill(pattern, 0);
983
// EGraphics.Outline outline = null;
984
} else if (curLayerRule != null) {
985
curDistance = new Distance();
986
Distance old = curLayerRule.put(tech.findLayer(a("name")), curDistance);
988
throw new IllegalArgumentException("Duplicate layer " + a("name"));
990
curLayer = tech.newLayer(a("name"));
991
curLayer.function = com.sun.electric.technology.Layer.Function.valueOf(a("fun"));
992
String extraFunStr = a_("extraFun");
993
if (extraFunStr != null) {
994
if (extraFunStr.equals("depletion_heavy"))
995
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.DEPLETION|com.sun.electric.technology.Layer.Function.HEAVY;
996
else if (extraFunStr.equals("depletion_light"))
997
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.DEPLETION|com.sun.electric.technology.Layer.Function.LIGHT;
998
else if (extraFunStr.equals("enhancement_heavy"))
999
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.ENHANCEMENT|com.sun.electric.technology.Layer.Function.HEAVY;
1000
else if (extraFunStr.equals("enhancement_light"))
1001
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.ENHANCEMENT|com.sun.electric.technology.Layer.Function.LIGHT;
1003
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.parseExtraName(extraFunStr);
805
curLayer = new Layer();
806
curLayer.name = a("name");
807
curLayer.function = com.sun.electric.technology.Layer.Function.valueOf(a("fun"));
808
String extraFunStr = a_("extraFun");
809
if (extraFunStr != null) {
810
if (extraFunStr.equals("depletion_heavy"))
811
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.DEPLETION|com.sun.electric.technology.Layer.Function.HEAVY;
812
else if (extraFunStr.equals("depletion_light"))
813
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.DEPLETION|com.sun.electric.technology.Layer.Function.LIGHT;
814
else if (extraFunStr.equals("enhancement_heavy"))
815
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.ENHANCEMENT|com.sun.electric.technology.Layer.Function.HEAVY;
816
else if (extraFunStr.equals("enhancement_light"))
817
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.ENHANCEMENT|com.sun.electric.technology.Layer.Function.LIGHT;
819
curLayer.extraFunction = com.sun.electric.technology.Layer.Function.parseExtraName(extraFunStr);
822
curR = curG = curB = 0;
823
patternedOnDisplay = false;
824
patternedOnPrinter = false;
825
Arrays.fill(pattern, 0);
827
// EGraphics.Outline outline = null;
829
case transparentColor:
830
curTransparent = Integer.parseInt(a("transparent"));
831
if (curTransparent > 0) {
832
Color color = tech.transparentLayers.get(curTransparent - 1);
833
curR = color.getRed();
834
curG = color.getGreen();
835
curB = color.getBlue();
839
curR = Integer.parseInt(a("r"));
840
curG = Integer.parseInt(a("g"));
841
curB = Integer.parseInt(a("b"));
844
curLayer.thick3D = Double.parseDouble(a("thick"));
845
curLayer.height3D = Double.parseDouble(a("height"));
846
curLayer.mode3D = a_("mode");
847
String factor3DStr = a_("factor");
848
curLayer.factor3D = factor3DStr != null ? Double.parseDouble(factor3DStr) : 0;
1008
851
curLayer.cif = a("cif");
1048
892
if (curNode != null)
1049
893
curNode.skipSizeInPalette = true;
897
curArc.diskOffset.put(Integer.parseInt(a("untilVersion")), Double.parseDouble(a("width")));
899
curNode.diskOffset.put(Integer.parseInt(a("untilVersion")), EPoint.fromLambda(Double.parseDouble(a("x")), Double.parseDouble(a("y"))));
903
curDistance = curArc.defaultWidth;
905
curDistance = curNode.defaultWidth;
1052
ArcLayer arcLay = new ArcLayer();
1053
arcLay.layer = a("layer");
1054
curDistance = arcLay.extend;
1055
arcLay.style = Type.valueOf(a("style"));
1056
curArc.arcLayers.add(arcLay);
1059
curArc.arcPin = new ArcPin();
1060
curArc.arcPin.name = a("name");
1061
curArc.arcPin.portName = a("port");
1062
curArc.arcPin.elibSize = Double.valueOf(a("elibSize"));
908
ArcLayer arcLayer = new ArcLayer();
909
arcLayer.layer = a("layer");
910
curDistance = arcLayer.extend;
911
arcLayer.style = Poly.Type.valueOf(a("style"));
912
curArc.arcLayers.add(arcLayer);
1064
914
case primitiveNode:
1065
915
curNode = new PrimitiveNode();
1103
953
curNode.od33 = true;
1106
curNode.diskOffset = EPoint.fromLambda(Double.parseDouble(a("x")), Double.parseDouble(a("y")));
1109
curDistance = curNode.defaultWidth;
1111
955
case defaultHeight:
1112
956
curDistance = curNode.defaultHeight;
1115
959
double lx = Double.parseDouble(a("lx"));
1116
960
double hx = Double.parseDouble(a("hx"));
1117
961
double ly = Double.parseDouble(a("ly"));
1118
962
double hy = Double.parseDouble(a("hy"));
1119
curNode.nodeBase = ERectangle.fromLambda(lx, ly, hx - lx, hy - ly);
963
curNode.sizeOffset = new SizeOffset(lx, hx, ly, hy);
1122
966
curNodeLayer = new NodeLayer();
1123
967
curNodeLayer.layer = a("layer");
1124
curNodeLayer.style = Type.valueOf(a("style"));
968
curNodeLayer.style = Poly.Type.valueOf(a("style"));
1125
969
String portNum = a_("portNum");
1126
970
if (portNum != null)
1127
971
curNodeLayer.portNum = Integer.parseInt(portNum);
1177
1022
case lambdaBox:
1178
1023
if (curNodeLayer != null) {
1179
curNodeLayer.lx.addLambda(Double.parseDouble(a("klx")));
1180
curNodeLayer.hx.addLambda(Double.parseDouble(a("khx")));
1181
curNodeLayer.ly.addLambda(Double.parseDouble(a("kly")));
1182
curNodeLayer.hy.addLambda(Double.parseDouble(a("khy")));
1024
curNodeLayer.lx.value = Double.parseDouble(a("klx"));
1025
curNodeLayer.hx.value = Double.parseDouble(a("khx"));
1026
curNodeLayer.ly.value = Double.parseDouble(a("kly"));
1027
curNodeLayer.hy.value = Double.parseDouble(a("khy"));
1184
1029
if (curPort != null) {
1185
curPort.lx.addLambda(Double.parseDouble(a("klx")));
1186
curPort.hx.addLambda(Double.parseDouble(a("khx")));
1187
curPort.ly.addLambda(Double.parseDouble(a("kly")));
1188
curPort.hy.addLambda(Double.parseDouble(a("khy")));
1030
curPort.lx.value = Double.parseDouble(a("klx"));
1031
curPort.hx.value = Double.parseDouble(a("khx"));
1032
curPort.ly.value = Double.parseDouble(a("kly"));
1033
curPort.hy.value = Double.parseDouble(a("khy"));
1191
1036
case techPoint:
1230
1075
case spiceLine:
1231
1076
curSpiceHeader.spiceLines.add(a("line"));
1235
curDisplayStyle = new DisplayStyle();
1236
curDisplayStyle.name = a("name");
1237
tech.displayStyles.add(curDisplayStyle);
1239
case transparentLayer:
1240
curTransparent = Integer.parseInt(a("transparent"));
1241
curR = curG = curB = 0;
1243
case transparentColor:
1244
curTransparent = Integer.parseInt(a("transparent"));
1245
if (curTransparent > 0) {
1246
Color color = curDisplayStyle.transparentLayers.get(curTransparent - 1);
1247
curR = color.getRed();
1248
curG = color.getGreen();
1249
curB = color.getBlue();
1253
curR = Integer.parseInt(a("r"));
1254
curG = Integer.parseInt(a("g"));
1255
curB = Integer.parseInt(a("b"));
1258
curLayerDisplayStyle.mode3D = a("mode");
1259
curLayerDisplayStyle.factor3D = Double.parseDouble(a("factor"));
1262
1078
case menuPalette:
1263
1079
tech.menuPalette = new MenuPalette();
1264
1080
tech.menuPalette.numColumns = Integer.parseInt(a("numColumns"));
1411
1234
case antennaRatio:
1412
1235
curArc.antennaRatio = Double.parseDouble(text);
1414
case elibWidthOffset:
1415
curArc.elibWidthOffset = Double.parseDouble(text);
1417
1237
case portTopology:
1418
1238
curPort.portTopology = Integer.parseInt(text);
1421
1241
if (curLayer != null && curLayer.pureLayerNode != null)
1422
1242
curLayer.pureLayerNode.portArcs.add(text);
1423
if (curArc != null && curArc.arcPin != null)
1424
curArc.arcPin.portArcs.add(text);
1425
1243
if (curPort != null)
1426
1244
curPort.portArcs.add(text);
1428
1246
case specialValue:
1429
1247
curNode.specialValues[curSpecialValueIndex++] = Double.parseDouble(text);
1433
curR = Integer.parseInt(text);
1436
curG = Integer.parseInt(text);
1439
curB = Integer.parseInt(text);
1441
case patternedOnDisplay:
1442
patternedOnDisplay = Boolean.parseBoolean(text);
1444
case patternedOnPrinter:
1445
patternedOnPrinter = Boolean.parseBoolean(text);
1449
assert text.length() == 16;
1450
for (int j = 0; j < text.length(); j++) {
1451
if (text.charAt(text.length() - j - 1) != ' ')
1454
pattern[curPatternIndex++] = p;
1457
outline = EGraphics.Outline.valueOf(text);
1460
opacity = Double.parseDouble(text);
1463
foreground = Boolean.parseBoolean(text);
1467
1250
curMenuBox.add(tech.findArc(text));
1485
1268
case technology:
1270
case transparentLayer:
1271
while (curTransparent > tech.transparentLayers.size())
1272
tech.transparentLayers.add(null);
1273
Color oldColor = tech.transparentLayers.set(curTransparent - 1, new Color(curR, curG, curB));
1274
assert oldColor == null;
1488
if (curDisplayStyle != null) {
1489
assert curPatternIndex == pattern.length;
1490
curLayerDisplayStyle.desc = new EGraphics(patternedOnDisplay, patternedOnPrinter, outline, curTransparent,
1277
assert curPatternIndex == pattern.length;
1278
curLayer.desc = new EGraphics(patternedOnDisplay, patternedOnPrinter, outline, curTransparent,
1491
1279
curR, curG, curB, opacity, foreground, pattern.clone());
1492
curLayerDisplayStyle = null;
1493
} else if (curLayerRule != null) {
1280
assert tech.findLayer(curLayer.name) == null;
1281
tech.layers.add(curLayer);
1500
1285
tech.arcs.add(curArc);
1832
1590
b(XmlKeyword.technology); a("name", t.techName); a("class", t.className); l();
1833
1591
a("xmlns", "http://electric.sun.com/Technology"); l();
1834
1592
a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); l();
1835
a("xsi:schemaLocation", "http://electric.sun.com/Technology ../../technology/xml/Technology807.xsd"); cl();
1593
a("xsi:schemaLocation", "http://electric.sun.com/Technology ../../technology/Technology.xsd"); cl();
1838
1596
bcpel(XmlKeyword.shortName, t.shortTechName);
1839
1597
bcpel(XmlKeyword.description, t.description);
1598
for (Version version: t.versions) {
1599
b(XmlKeyword.version); a("tech", version.techVersion); a("electric", version.electricVersion); el();
1840
1601
b(XmlKeyword.numMetals); a("min", t.minNumMetals); a("max", t.maxNumMetals); a("default", t.defaultNumMetals); el();
1841
1602
b(XmlKeyword.scale); a("value", t.scaleValue); a("relevant", t.scaleRelevant); el();
1842
1603
b(XmlKeyword.defaultFoundry); a("value", t.defaultFoundry); el();
1847
1608
// printlnAttribute(" groundNetInclusion", gi.includeGround);
1611
if (t.transparentLayers.size() != 0) {
1612
comment("Transparent layers");
1613
for (int i = 0; i < t.transparentLayers.size(); i++) {
1614
Color color = t.transparentLayers.get(i);
1615
b(XmlKeyword.transparentLayer); a("transparent", i + 1); cl();
1616
bcpel(XmlKeyword.r, color.getRed());
1617
bcpel(XmlKeyword.g, color.getGreen());
1618
bcpel(XmlKeyword.b, color.getBlue());
1619
el(XmlKeyword.transparentLayer);
1850
1624
comment("**************************************** LAYERS ****************************************");
1851
for (Layer li: t.layers.values()) {
1625
for (Xml807.Layer li: t.layers) {
1855
1629
comment("******************** ARCS ********************");
1856
for (ArcProto ai: t.arcs) {
1630
for (Xml807.ArcProto ai: t.arcs) {
1861
1635
comment("******************** NODES ********************");
1862
for (PrimitiveNode ni: t.nodes) {
1636
for (Xml807.PrimitiveNode ni: t.nodes) {
1867
for (SpiceHeader spiceHeader: t.spiceHeaders)
1641
for (Xml807.SpiceHeader spiceHeader: t.spiceHeaders)
1868
1642
writeSpiceHeaderXml(spiceHeader);
1870
for (DisplayStyle displayStyle: t.displayStyles)
1871
writeDisplayStyleXml(displayStyle);
1873
1644
writeMenuPaletteXml(t.menuPalette);
1875
for (RuleSet ruleSet: t.ruleSets.values())
1878
for (Foundry foundry: t.foundries)
1646
for (Xml807.Foundry foundry: t.foundries)
1879
1647
writeFoundryXml(foundry);
1881
1649
el(XmlKeyword.technology);
1884
private void writeXml(Layer li) {
1652
private void writeXml(Xml807.Layer li) {
1653
EGraphics desc = li.desc;
1885
1654
String funString = null;
1886
1655
int funExtra = li.extraFunction;
1887
1656
if (funExtra != 0) {
1898
1667
b(XmlKeyword.layer); a("name", li.name); a("fun", li.function.name()); a("extraFun", funString); cl();
1669
if (desc.getTransparentLayer() > 0) {
1670
b(XmlKeyword.transparentColor); a("transparent", desc.getTransparentLayer()); el();
1672
Color color = desc.getColor();
1673
b(XmlKeyword.opaqueColor); a("r", color.getRed()); a("g", color.getGreen()); a("b", color.getBlue()); el();
1676
bcpel(XmlKeyword.patternedOnDisplay, desc.isPatternedOnDisplay());
1677
bcpel(XmlKeyword.patternedOnPrinter, desc.isPatternedOnPrinter());
1679
int [] pattern = desc.getPattern();
1680
for(int j=0; j<16; j++) {
1682
for(int k=0; k<16; k++)
1683
p += (pattern[j] & (1 << (15-k))) != 0 ? 'X' : ' ';
1684
bcpel(XmlKeyword.pattern, p);
1687
if (li.desc.getOutlined() != null)
1688
bcpel(XmlKeyword.outlined, desc.getOutlined().getConstName());
1689
bcpel(XmlKeyword.opacity, desc.getOpacity());
1690
bcpel(XmlKeyword.foreground, desc.getForeground());
1692
// write the 3D information
1693
if (li.thick3D != 0 || li.height3D != 0 || li.mode3D != null) {
1694
b(XmlKeyword.display3D); a("thick", li.thick3D); a("height", li.height3D);
1695
if (li.mode3D != null) {
1696
a("mode", li.mode3D); a("factor", li.factor3D);
1900
1701
if (li.cif != null && li.cif.length() > 0) {
1901
1702
b(XmlKeyword.cifLayer); a("cif", li.cif); el();
1911
1712
if (li.pureLayerNode != null) {
1912
1713
String nodeName = li.pureLayerNode.name;
1913
Type style = li.pureLayerNode.style;
1914
String styleStr = style == Type.FILLED ? null : style.name();
1714
Poly.Type style = li.pureLayerNode.style;
1715
String styleStr = style == Poly.Type.FILLED ? null : style.name();
1915
1716
String portName = li.pureLayerNode.port;
1916
b(XmlKeyword.pureLayerNode); a("name", nodeName); a("style", styleStr); a("port", portName);
1917
if (li.pureLayerNode.oldName == null && li.pureLayerNode.portArcs.isEmpty()) {
1921
bcpel(XmlKeyword.oldName, li.pureLayerNode.oldName);
1922
for (String portArc: li.pureLayerNode.portArcs)
1923
bcpel(XmlKeyword.portArc, portArc);
1924
el(XmlKeyword.pureLayerNode);
1717
b(XmlKeyword.pureLayerNode); a("name", nodeName); a("style", styleStr); a("port", portName); cl();
1718
bcpel(XmlKeyword.oldName, li.pureLayerNode.oldName);
1719
bcpel(XmlKeyword.lambda, li.pureLayerNode.size.value);
1720
for (String portArc: li.pureLayerNode.portArcs)
1721
bcpel(XmlKeyword.portArc, portArc);
1722
el(XmlKeyword.pureLayerNode);
1927
1724
el(XmlKeyword.layer);
1931
private void writeXml(ArcProto ai) {
1728
private void writeXml(Xml807.ArcProto ai) {
1932
1729
b(XmlKeyword.arcProto); a("name", ai.name); a("fun", ai.function.getConstantName()); cl();
1933
1730
bcpel(XmlKeyword.oldName, ai.oldName);
1947
1744
bcpel(XmlKeyword.angleIncrement, ai.angleIncrement);
1948
1745
if (ai.antennaRatio != 0)
1949
1746
bcpel(XmlKeyword.antennaRatio, ai.antennaRatio);
1950
if (ai.elibWidthOffset != 0)
1951
bcpel(XmlKeyword.elibWidthOffset, ai.elibWidthOffset);
1953
for (ArcLayer al: ai.arcLayers) {
1954
String style = al.style == Type.FILLED ? "FILLED" : "CLOSED";
1748
for (Map.Entry<Integer,Double> e: ai.diskOffset.entrySet()) {
1749
b(XmlKeyword.diskOffset); a("untilVersion", e.getKey()); a("width", e.getValue()); el();
1752
if (ai.defaultWidth.value != 0) {
1753
bcl(XmlKeyword.defaultWidth);
1754
bcpel(XmlKeyword.lambda, ai.defaultWidth.value);
1755
el(XmlKeyword.defaultWidth);
1758
for (Xml807.ArcLayer al: ai.arcLayers) {
1759
String style = al.style == Poly.Type.FILLED ? "FILLED" : "CLOSED";
1955
1760
b(XmlKeyword.arcLayer); a("layer", al.layer); a("style", style);
1956
if (al.extend.isEmpty()) {
1761
double extend = al.extend.value;
1960
writeDistance(al.extend);
1766
bcpel(XmlKeyword.lambda, extend);
1961
1767
el(XmlKeyword.arcLayer);
1964
if (ai.arcPin != null) {
1965
b(XmlKeyword.arcPin); a("name", ai.arcPin.name); a("port", ai.arcPin.portName); a("elibSize", ai.arcPin.elibSize);
1966
if (ai.arcPin.portArcs.isEmpty()) {
1970
for (String portArc: ai.arcPin.portArcs)
1971
bcpel(XmlKeyword.portArc, portArc);
1972
el(XmlKeyword.arcPin);
1975
1770
el(XmlKeyword.arcProto);
1978
private void writeXml(PrimitiveNode ni) {
1773
private void writeXml(Xml807.PrimitiveNode ni) {
1979
1774
b(XmlKeyword.primitiveNode); a("name", ni.name); a("fun", ni.function.name()); cl();
1980
1775
bcpel(XmlKeyword.oldName, ni.oldName);
2009
1804
bel(XmlKeyword.od33);
2011
if (ni.diskOffset != null) {
2012
b(XmlKeyword.diskOffset); a("x", ni.diskOffset.getLambdaX()); a("y", ni.diskOffset.getLambdaY()); el();
1806
for (Map.Entry<Integer,EPoint> e: ni.diskOffset.entrySet()) {
1807
EPoint p = e.getValue();
1808
b(XmlKeyword.diskOffset); a("untilVersion", e.getKey()); a("x", p.getLambdaX()); a("y", p.getLambdaY()); el();
2015
if (!ni.defaultWidth.isEmpty()) {
1811
if (ni.defaultWidth.value != 0) {
2016
1812
bcl(XmlKeyword.defaultWidth);
2017
writeDistance(ni.defaultWidth);
1813
bcpel(XmlKeyword.lambda, ni.defaultWidth.value);
2018
1814
el(XmlKeyword.defaultWidth);
2021
if (!ni.defaultHeight.isEmpty()) {
1817
if (ni.defaultHeight.value != 0) {
2022
1818
bcl(XmlKeyword.defaultHeight);
2023
writeDistance(ni.defaultHeight);
1819
bcpel(XmlKeyword.lambda, ni.defaultHeight.value);
2024
1820
el(XmlKeyword.defaultHeight);
2027
if (ni.nodeBase != null) {
2028
double lx = ni.nodeBase.getLambdaMinX();
2029
double hx = ni.nodeBase.getLambdaMaxX();
2030
double ly = ni.nodeBase.getLambdaMinY();
2031
double hy = ni.nodeBase.getLambdaMaxY();
2032
b(XmlKeyword.nodeBase); a("lx", lx); a("hx", hx); a("ly", ly); a("hy", hy); el();
1823
if (ni.sizeOffset != null) {
1824
double lx = ni.sizeOffset.getLowXOffset();
1825
double hx = ni.sizeOffset.getHighXOffset();
1826
double ly = ni.sizeOffset.getLowYOffset();
1827
double hy = ni.sizeOffset.getHighYOffset();
1828
b(XmlKeyword.sizeOffset); a("lx", lx); a("hx", hx); a("ly", ly); a("hy", hy); el();
2035
1831
for(int j=0; j<ni.nodeLayers.size(); j++) {
2036
NodeLayer nl = ni.nodeLayers.get(j);
1832
Xml807.NodeLayer nl = ni.nodeLayers.get(j);
2037
1833
b(XmlKeyword.nodeLayer); a("layer", nl.layer); a("style", nl.style.name());
2038
1834
if (nl.portNum != 0) a("portNum", Integer.valueOf(nl.portNum));
2039
1835
if (!(nl.inLayers && nl.inElectricalLayers))
2044
1840
if (ni.specialType == com.sun.electric.technology.PrimitiveNode.SERPTRANS) {
2045
1841
writeBox(XmlKeyword.serpbox, nl.lx, nl.hx, nl.ly, nl.hy);
2046
1842
a("lWidth", nl.lWidth); a("rWidth", nl.rWidth); a("tExtent", nl.tExtent); a("bExtent", nl.bExtent); cl();
2047
writeLambdaBox(nl.lx, nl.hx, nl.ly, nl.hy);
1843
b(XmlKeyword.lambdaBox); a("klx", nl.lx.value); a("khx", nl.hx.value); a("kly", nl.ly.value); a("khy", nl.hy.value); el();
2048
1844
el(XmlKeyword.serpbox);
2050
1846
writeBox(XmlKeyword.box, nl.lx, nl.hx, nl.ly, nl.hy); cl();
2051
writeLambdaBox(nl.lx, nl.hx, nl.ly, nl.hy);
1847
b(XmlKeyword.lambdaBox); a("klx", nl.lx.value); a("khx", nl.hx.value); a("kly", nl.ly.value); a("khy", nl.hy.value); el();
2052
1848
el(XmlKeyword.box);
2058
1854
case com.sun.electric.technology.Technology.NodeLayer.MULTICUTBOX:
2059
1855
writeBox(XmlKeyword.multicutbox, nl.lx, nl.hx, nl.ly, nl.hy);
2060
a("sizeRule", nl.sizeRule); a("sepRule", nl.sepRule); a("sepRule2D", nl.sepRule2D);
2061
if (nl.lx.isEmpty() && nl.hx.isEmpty() && nl.ly.isEmpty() && nl.hy.isEmpty()) {
2065
writeLambdaBox(nl.lx, nl.hx, nl.ly, nl.hy);
2066
el(XmlKeyword.multicutbox);
1856
a("sizex", nl.sizex); a("sizey", nl.sizey); a("sep1d", nl.sep1d); a("sep2d", nl.sep2d); cl();
1857
b(XmlKeyword.lambdaBox); a("klx", nl.lx.value); a("khx", nl.hx.value); a("kly", nl.ly.value); a("khy", nl.hy.value); el();
1858
el(XmlKeyword.multicutbox);
2070
1861
for (TechPoint tp: nl.techPoints) {
2077
1868
el(XmlKeyword.nodeLayer);
2079
1870
for (int j = 0; j < ni.ports.size(); j++) {
2080
PrimitivePort pd = ni.ports.get(j);
1871
Xml807.PrimitivePort pd = ni.ports.get(j);
2081
1872
b(XmlKeyword.primitivePort); a("name", pd.name); cl();
2082
1873
b(XmlKeyword.portAngle); a("primary", pd.portAngle); a("range", pd.portRange); el();
2083
1874
bcpel(XmlKeyword.portTopology, pd.portTopology);
2085
1876
writeBox(XmlKeyword.box, pd.lx, pd.hx, pd.ly, pd.hy); cl();
2086
writeLambdaBox(pd.lx, pd.hx, pd.ly, pd.hy);
1877
b(XmlKeyword.lambdaBox); a("klx", pd.lx.value); a("khx", pd.hx.value); a("kly", pd.ly.value); a("khy", pd.hy.value); el();
2087
1878
el(XmlKeyword.box);
2089
1880
for (String portArc: pd.portArcs)
2126
1913
if (hy.k != 1) a("khy", hy.k);
2129
private void writeLambdaBox(Distance lx, Distance hx, Distance ly, Distance hy) {
2130
double lxv = lx.getLambda(EMPTY_CONTEXT);
2131
double hxv = hx.getLambda(EMPTY_CONTEXT);
2132
double lyv = ly.getLambda(EMPTY_CONTEXT);
2133
double hyv = hy.getLambda(EMPTY_CONTEXT);
2134
// if (lxv == 0 && hxv == 0 && lyv == 0 && hyv == 0) return;
2135
b(XmlKeyword.lambdaBox); a("klx", lxv); a("khx", hxv); a("kly", lyv); a("khy", hyv); el();
2138
private void writeSpiceHeaderXml(SpiceHeader spiceHeader) {
1916
private void writeSpiceHeaderXml(Xml807.SpiceHeader spiceHeader) {
2139
1917
b(XmlKeyword.spiceHeader); a("level", spiceHeader.level); cl();
2140
1918
for (String line: spiceHeader.spiceLines) {
2141
1919
b(XmlKeyword.spiceLine); a("line", line); el();
2143
1921
el(XmlKeyword.spiceHeader);
2147
private void writeDisplayStyleXml(DisplayStyle displayStyle) {
2148
b(XmlKeyword.displayStyle); a("name", displayStyle.name); cl();
2150
if (displayStyle.transparentLayers.size() != 0) {
2151
comment("Transparent layers");
2152
for (int i = 0; i < displayStyle.transparentLayers.size(); i++) {
2153
Color color = displayStyle.transparentLayers.get(i);
2154
b(XmlKeyword.transparentLayer); a("transparent", i + 1); cl();
2155
bcpel(XmlKeyword.r, color.getRed());
2156
bcpel(XmlKeyword.g, color.getGreen());
2157
bcpel(XmlKeyword.b, color.getBlue());
2158
el(XmlKeyword.transparentLayer);
2163
for (LayerDisplayStyle l: displayStyle.layerStyles.values()) {
2164
b(XmlKeyword.layer); a("name", l.layer.name); cl();
2165
EGraphics desc = l.desc;
2166
if (desc.getTransparentLayer() > 0) {
2167
b(XmlKeyword.transparentColor); a("transparent", desc.getTransparentLayer()); el();
2169
Color color = desc.getColor();
2170
b(XmlKeyword.opaqueColor); a("r", color.getRed()); a("g", color.getGreen()); a("b", color.getBlue()); el();
2173
bcpel(XmlKeyword.patternedOnDisplay, desc.isPatternedOnDisplay());
2174
bcpel(XmlKeyword.patternedOnPrinter, desc.isPatternedOnPrinter());
2176
int [] pattern = desc.getPattern();
2177
for(int j=0; j<16; j++) {
2179
for(int k=0; k<16; k++)
2180
p += (pattern[j] & (1 << (15-k))) != 0 ? 'X' : ' ';
2181
bcpel(XmlKeyword.pattern, p);
2184
if (desc.getOutlined() != null)
2185
bcpel(XmlKeyword.outlined, desc.getOutlined().getConstName());
2186
bcpel(XmlKeyword.opacity, desc.getOpacity());
2187
bcpel(XmlKeyword.foreground, desc.getForeground());
2189
// write the 3D information
2190
if (l.mode3D != null) {
2191
b(XmlKeyword.display3D); a("mode", l.mode3D); a("factor", l.factor3D); el();
2194
el(XmlKeyword.layer);
2197
el(XmlKeyword.displayStyle);
2201
public void writeMenuPaletteXml(MenuPalette menuPalette) {
1925
public void writeMenuPaletteXml(Xml807.MenuPalette menuPalette) {
2202
1926
if (menuPalette == null) return;
2203
1927
b(XmlKeyword.menuPalette); a("numColumns", menuPalette.numColumns); cl();
2204
1928
for (int i = 0; i < menuPalette.menuBoxes.size(); i++) {
2221
1945
for (Object o: list) {
2222
if (o instanceof ArcProto) {
2223
bcpel(XmlKeyword.menuArc, ((ArcProto)o).name);
2224
} else if (o instanceof PrimitiveNode) {
2225
bcpel(XmlKeyword.menuNode, ((PrimitiveNode)o).name);
2226
} else if (o instanceof MenuCell) {
2227
MenuCell cell = (MenuCell)o;
2228
b(XmlKeyword.menuCell); a("cellName", cell.cellName); el();
2229
} else if (o instanceof MenuNodeInst) {
2230
MenuNodeInst ni = (MenuNodeInst)o;
1946
if (o instanceof Xml807.ArcProto) {
1947
bcpel(XmlKeyword.menuArc, ((Xml807.ArcProto)o).name);
1948
} else if (o instanceof Xml807.PrimitiveNode) {
1949
bcpel(XmlKeyword.menuNode, ((Xml807.PrimitiveNode)o).name);
1950
} else if (o instanceof Xml807.MenuNodeInst) {
1951
Xml807.MenuNodeInst ni = (Xml807.MenuNodeInst)o;
2231
1952
b(XmlKeyword.menuNodeInst); a("protoName", ni.protoName); a("function", ni.function.name());
2232
1953
if (ni.rotation != 0) a("rotation", ni.rotation);
2233
1954
if (ni.text == null) {
2245
1966
el(XmlKeyword.menuBox);
2248
private void writeXml(RuleSet ruleSet) {
2249
b(XmlKeyword.ruleSet); a("name", ruleSet.name); cl();
2250
for (Map.Entry<String,Map<Layer,Distance>> e: ruleSet.layerRules.entrySet())
2251
writeLayerRuleXml(e.getKey(), e.getValue());
2252
el(XmlKeyword.ruleSet);
2256
private void writeLayerRuleXml(String ruleName, Map<Layer,Distance> sizes) {
2257
if (sizes.isEmpty()) return;
2258
b(XmlKeyword.layerRule); a("ruleName", ruleName); cl();
2259
int maxNameLength = 0;
2260
for (Layer l: sizes.keySet())
2261
maxNameLength = Math.max(maxNameLength, l.name.length());
2262
for (Map.Entry<Layer,Distance> e: sizes.entrySet()) {
2263
String layerName = e.getKey().name;
2264
Distance d = e.getValue();
2265
b(XmlKeyword.layer); a("name", layerName); c();
2266
s(maxNameLength - layerName.length());
2267
d.writeXml(this, false);
2268
el(XmlKeyword.layer);
2270
el(XmlKeyword.layerRule);
2273
private void writeFoundryXml(Foundry foundry) {
1969
private void writeFoundryXml(Xml807.Foundry foundry) {
2274
1970
b(XmlKeyword.Foundry); a("name", foundry.name); cl();
2276
1972
for (Map.Entry<String,String> e: foundry.layerGds.entrySet()) {