⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlparam.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        public final List<DistanceRule> terms = new ArrayList<DistanceRule>();        public void assign(Distance d) {            k = d.k;            lambdaValue = d.lambdaValue;            for (DistanceRule term: d.terms)                terms.add(term.clone());        }        public void assign(com.sun.electric.technology.Technology.Distance d) {            k = d.k;            lambdaValue = d.lambdaValue;            for (com.sun.electric.technology.Technology.DistanceRule term: d.terms)                terms.add(new DistanceRule(term));        }        public Distance clone() {            Distance d = new Distance();            d.assign(this);            return d;        }        public double getLambda(DistanceContext context) {            double value = lambdaValue;            for (DistanceRule term: terms)                value += term.getLambda(context);            return value;        }        private void writeXml(Writer writer, boolean multiLine) {            for (DistanceRule term: terms) {                term.writeXml(writer);                if (multiLine)                    writer.l();            }            if (lambdaValue != 0) {                writer.bcpe(XmlKeyword.lambda, lambdaValue);                if (multiLine)                    writer.l();            }        }        public void addLambda(double value) {            lambdaValue += value;        }        public void addRule(String ruleName, double k) {            addRule(ruleName, null, k);        }        public void addRule(String ruleName, Layer layer, double k) {            addRule(ruleName, layer, null, k);        }        public void addRule(String ruleName, Layer layer, Layer layer2, double k) {            terms.add(new DistanceRule(ruleName, layer, layer2, k));        }        public boolean isEmpty() { return lambdaValue == 0 && terms.isEmpty(); }    }    public static interface DistanceContext {        public double getRule(String ruleName);    }    public static class DistanceRule implements Serializable, Cloneable {        final String ruleName;        final Layer layer;        final Layer layer2;        final double k;        public DistanceRule(com.sun.electric.technology.Technology.DistanceRule oldRule) {            this(oldRule.ruleName, null, null, oldRule.k);        }                private DistanceRule(String ruleName, Layer layer, Layer layer2, double k) {            this.ruleName = ruleName;            this.layer = layer;            this.layer2 = layer2;            this.k = k;        }                public DistanceRule clone() {            try {                return (DistanceRule)super.clone();            } catch (CloneNotSupportedException e) {                throw new AssertionError();            }        }        private void writeXml(Writer writer) {            writer.b(XmlKeyword.rule);            writer.a("ruleName", ruleName);            if (layer != null) {                writer.a("layer", layer.name);                if (layer2 != null)                    writer.a("layer2", layer2.name);            }            if (k != 1)                writer.a("k", k);            writer.e();        }        private double getLambda(DistanceContext context) {            return context.getRule(ruleName)*k;        }    }        public static class RuleSet implements Serializable {        public final String name;        public final Map<String,Map<Layer,Distance>> layerRules = new LinkedHashMap<String,Map<Layer,Distance>>();                private RuleSet(String name) {            this.name = name;        }                public Map<Layer,Distance> newLayerRule(String ruleName) {            if (ruleName == null)                throw new NullPointerException();            if (layerRules.containsKey(ruleName))                throw new IllegalArgumentException("Duplicate LayerRule " + ruleName);            Map<Layer,Distance> layerRule = new LinkedHashMap<Layer,Distance>();            layerRules.put(ruleName, layerRule);            return layerRule;        }    }    public static class Foundry implements Serializable {        public String name;        public final Map<String,String> layerGds = new LinkedHashMap<String,String>();        public final List<DRCTemplate> rules = new ArrayList<DRCTemplate>();    }    private XmlParam() {}    private static enum XmlKeyword {        technology,        shortName(true),        description(true),        numMetals,        scale,        defaultFoundry,        minResistance,        minCapacitance,        layer,        display3D,        cifLayer,        skillLayer,        parasitics,        pureLayerNode,        arcProto,        oldName(true),        wipable,        curvable,        special,        notUsed,        skipSizeInPalette,        extended(true),        fixedAngle(true),        angleIncrement(true),        antennaRatio(true),        elibWidthOffset(true),        arcLayer,        arcPin,        primitiveNode,        //oldName(true),        shrinkArcs,        square,        canBeZeroSize,        wipes,        lockable,        edgeSelect,//        skipSizeInPalette,//        notUsed,        lowVt,        highVt,        nativeBit,        od18,        od25,        od33,        diskOffset,        defaultWidth,        defaultHeight,        nodeBase,        nodeLayer,        box,        multicutbox,        serpbox,        lambdaBox,        points,        techPoint,        primitivePort,        portAngle,        portTopology(true),//        techPoint,        portArc(true),        polygonal,        serpTrans,        specialValue(true),        minSizeRule,        spiceTemplate,        spiceHeader,        spiceLine,                displayStyle,        transparentLayer,        r(true),        g(true),        b(true),        transparentColor,        opaqueColor,        patternedOnDisplay(true),        patternedOnPrinter(true),        pattern(true),        outlined(true),        opacity(true),        foreground(true),                menuPalette,        menuBox,        menuArc(true),        menuNode(true),        menuCell,        menuText(true),        menuNodeInst,        menuNodeText,        lambda(true),        rule,                ruleSet,        layerRule,        Foundry,        layerGds,        LayerRule,        LayersRule,        NodeLayersRule,        NodeRule;        private final boolean hasText;        private XmlKeyword() {            hasText = false;        };        private XmlKeyword(boolean hasText) {            this.hasText = hasText;        }    };    private static final HashMap<String,XmlKeyword> xmlKeywords = new HashMap<String,XmlKeyword>();    static {        for (XmlKeyword k: XmlKeyword.class.getEnumConstants())            xmlKeywords.put(k.name(), k);    }    private static Schema schema = null;    private static synchronized void loadTechnologySchema() throws SAXException {        if (schema != null) return;        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);        URL technologySchemaUrl = Technology.class.getResource("xml/TechnologyParam.xsd");        if (technologySchemaUrl != null)            schema = schemaFactory.newSchema(technologySchemaUrl);        else        {            System.err.println("Schema file TechnologyParam.xsd, working without XML schema");            System.out.println("Schema file TechnologyParam.xsd, working without XML schema");        }    }    public static Technology parseTechnology(URL fileURL) {//        System.out.println("Memory usage " + Main.getMemoryUsage() + " bytes");        SAXParserFactory factory = SAXParserFactory.newInstance();        factory.setNamespaceAware(true);        try {            if (schema == null)                loadTechnologySchema();            factory.setSchema(schema);    //        factory.setValidating(true);    //        System.out.println("Memory usage " + Main.getMemoryUsage() + " bytes");            // create the parser            long startTime = System.currentTimeMillis();            SAXParser parser = factory.newSAXParser();            URLConnection urlCon = fileURL.openConnection();            InputStream inputStream = urlCon.getInputStream();            XMLReader handler = new XMLReader();            parser.parse(inputStream, handler);            if (Job.getDebug())            {                long stopTime = System.currentTimeMillis();                System.out.println("Loading technology " + fileURL + " ... " + (stopTime - startTime) + " msec");            }            return handler.tech;        } catch (SAXParseException e) {            String msg = "Error parsing Xml technology:\n" +                    e.getMessage() + "\n" +                    " Line " + e.getLineNumber() + " column " + e.getColumnNumber() + " of " + fileURL;            msg = msg.replaceAll("\"http://electric.sun.com/Technology\":", "");            System.out.println(msg);            Job.getUserInterface().showErrorMessage(msg, "Error parsing Xml technology");        } catch (Exception e) {            String msg = "Error loading Xml technology " + fileURL + " :\n"                   + e.getMessage() + "\n";            System.out.println(msg);            Job.getUserInterface().showErrorMessage(msg, "Error loading Xml technology");        }        return null;    }    /**     * Method to parse a string of XML that describes the component menu in a Technology Editing context.     * Normal parsing of XML returns objects in the Xml class, but     * this method returns objects in a given Technology-Editor world.     * @param xml the XML string     * @param nodes the PrimitiveNode objects describing nodes in the technology.     * @param arcs the ArcProto objects describing arcs in the technology.     * @return the MenuPalette describing the component menu.     */    public static MenuPalette parseComponentMenuXMLTechEdit(String xml, List<PrimitiveNode> nodes, List<ArcProto> arcs)    {        SAXParserFactory factory = SAXParserFactory.newInstance();        factory.setNamespaceAware(true);        try        {            SAXParser parser = factory.newSAXParser();            InputSource is = new InputSource(new StringReader(xml));            XMLReader handler = new XMLReader(nodes, arcs);            parser.parse(is, handler);            return handler.tech.menuPalette;        } catch (Exception e)        {            System.out.println("Error parsing XML component menu data");            e.printStackTrace();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -