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

📄 cmlcoremodule.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    elsym.add(value);                } // this is supported in CML 2.0                 else if (att.equals("title")) {                    eltitles.add(value);                } // this is supported in CML 2.0                 else if (att.equals("x2")) {                    x2.add(value);                } // this is supported in CML 2.0                 else if (att.equals("xy2")) {                    StringTokenizer tokenizer = new StringTokenizer(value);                    x2.add(tokenizer.nextToken());                    y2.add(tokenizer.nextToken());                } // this is supported in CML 2.0                 else if (att.equals("xyzFract")) {                    StringTokenizer tokenizer = new StringTokenizer(value);                    xfract.add(tokenizer.nextToken());                    yfract.add(tokenizer.nextToken());                    zfract.add(tokenizer.nextToken());                } // this is supported in CML 2.0                 else if (att.equals("xyz3")) {                    StringTokenizer tokenizer = new StringTokenizer(value);                    x3.add(tokenizer.nextToken());                    y3.add(tokenizer.nextToken());                    z3.add(tokenizer.nextToken());                } // this is supported in CML 2.0                 else if (att.equals("y2")) {                    y2.add(value);                } // this is supported in CML 2.0                 else if (att.equals("x3")) {                    x3.add(value);                } // this is supported in CML 2.0                 else if (att.equals("y3")) {                    y3.add(value);                } // this is supported in CML 2.0                 else if (att.equals("z3")) {                    z3.add(value);                } // this is supported in CML 2.0                 else if (att.equals("xFract")) {                    xfract.add(value);                } // this is supported in CML 2.0                 else if (att.equals("yFract")) {                    yfract.add(value);                } // this is supported in CML 2.0                 else if (att.equals("zFract")) {                    zfract.add(value);                } // this is supported in CML 2.0                 else if (att.equals("formalCharge")) {                    formalCharges.add(value);                } // this is supported in CML 2.0                 else if (att.equals("hydrogenCount")) {                    hCounts.add(value);                }                else if (att.equals("isotope")) {                    isotope.add(value);                }                else if (att.equals("dictRef")) {                	                    logger.debug("ocupaccy: "+value);                    atomDictRefs.add(value);                }                 else if (att.equals("spinMultiplicity")) {                    spinMultiplicities.add(value);                }                else if (att.equals("occupancy")) {                    occupancies.add(value);                }                                  else {                    logger.warn("Unparsed attribute: " + att);                }            }        } else if ("atomArray".equals(name) &&        		   !xpath.endsWith("formula", "atomArray")) {            boolean atomsCounted = false;            for (int i = 0; i < atts.getLength(); i++) {                String att = atts.getQName(i);                int count = 0;                if (att.equals("atomID")) {                    count = addArrayElementsTo(elid, atts.getValue(i));                } else if (att.equals("elementType")) {                    count = addArrayElementsTo(elsym, atts.getValue(i));                } else if (att.equals("x2")) {                    count = addArrayElementsTo(x2, atts.getValue(i));                } else if (att.equals("y2")) {                    count = addArrayElementsTo(y2, atts.getValue(i));                } else if (att.equals("x3")) {                    count = addArrayElementsTo(x3, atts.getValue(i));                } else if (att.equals("y3")) {                    count = addArrayElementsTo(y3, atts.getValue(i));                } else if (att.equals("z3")) {                    count = addArrayElementsTo(z3, atts.getValue(i));                } else if (att.equals("xFract")) {                    count = addArrayElementsTo(xfract, atts.getValue(i));                } else if (att.equals("yFract")) {                    count = addArrayElementsTo(yfract, atts.getValue(i));                } else if (att.equals("zFract")) {                    count = addArrayElementsTo(zfract, atts.getValue(i));                } else {                    logger.warn("Unparsed attribute: " + att);                }                if (!atomsCounted) {                    atomCounter += count;                    atomsCounted = true;                }            }        } else if ("bond".equals(name)) {            bondCounter++;            for (int i = 0; i < atts.getLength(); i++) {                String att = atts.getQName(i);                logger.debug("B2 ", att, "=", atts.getValue(i));                                if (att.equals("id")) {                    bondid.add(atts.getValue(i));                    logger.debug("B3 ", bondid);                } else if (att.equals("atomRefs") || // this is CML 1.x support                           att.equals("atomRefs2")) { // this is CML 2.0 support                                        // expect exactly two references                    try {                        StringTokenizer st = new StringTokenizer(                            atts.getValue(i)                        );                        bondARef1.add((String)st.nextElement());                        bondARef2.add((String)st.nextElement());                    } catch (Exception e) {                        logger.error("Error in CML file: ", e.getMessage());                        logger.debug(e);                    }                } else if (att.equals("order")) { // this is CML 2.0 support                    order.add(atts.getValue(i).trim());                } else if (att.equals("dictRef")) {                    bondDictRefs.add(atts.getValue(i).trim());                }            }                        stereoGiven = false;            curRef = 0;        } else if ("bondArray".equals(name)) {            boolean bondsCounted = false;            for (int i = 0; i < atts.getLength(); i++) {                String att = atts.getQName(i);                int count = 0;                if (att.equals("bondID")) {                    count = addArrayElementsTo(bondid, atts.getValue(i));                } else if (att.equals("atomRefs1")) {                    count = addArrayElementsTo(bondARef1, atts.getValue(i));                } else if (att.equals("atomRefs2")) {                    count = addArrayElementsTo(bondARef2, atts.getValue(i));                } else if (att.equals("atomRef1")) {                    count = addArrayElementsTo(bondARef1, atts.getValue(i));                } else if (att.equals("atomRef2")) {                    count = addArrayElementsTo(bondARef2, atts.getValue(i));                } else if (att.equals("order")) {                    count = addArrayElementsTo(order, atts.getValue(i));                } else {                    logger.warn("Unparsed attribute: " + att);                }                if (!bondsCounted) {                    bondCounter += count;                    bondsCounted = true;                }            }            curRef = 0;        } else if ("bondStereo".equals(name)) {            for (int i = 0; i < atts.getLength(); i++) {                if (atts.getQName(i).equals("dictRef")) {                	if (atts.getValue(i).startsWith("cml:"))                	bondStereo.add(atts.getValue(i).substring(4));                    stereoGiven=true;                }            }        } else if ("bondType".equals(name)) {            for (int i = 0; i < atts.getLength(); i++) {                if (atts.getQName(i).equals("dictRef")) {                	if (atts.getValue(i).equals("cdk:aromaticBond"))                		bondAromaticity.add(Boolean.TRUE);                }            }        } else if ("molecule".equals(name)) {            newMolecule();            BUILTIN = "";//            cdo.startObject("Molecule");            if (currentChemModel == null) currentChemModel = currentChemFile.getBuilder().newChemModel();            if (currentMoleculeSet == null) currentMoleculeSet = currentChemFile.getBuilder().newMoleculeSet();            currentMolecule = currentChemFile.getBuilder().newMolecule();            for (int i = 0; i < atts.getLength(); i++) {                if (atts.getQName(i).equals("id")) {//                    cdo.setObjectProperty("Molecule", "id", atts.getValue(i));                	currentMolecule.setID(atts.getValue(i));                } else if (atts.getQName(i).equals("dictRef")) {//                	cdo.setObjectProperty("Molecule", "dictRef", atts.getValue(i));                	currentMolecule.setProperty(new DictRef(DICTREF, atts.getValue(i)), atts.getValue(i));                }            }        } else if ("crystal".equals(name)) {            newCrystalData();//            cdo.startObject("Crystal");            currentMolecule = currentChemFile.getBuilder().newCrystal(currentMolecule);            for (int i = 0; i < atts.getLength(); i++) {                String att = atts.getQName(i);                if (att.equals("z")) {//                    cdo.setObjectProperty("Crystal", "z", atts.getValue(i));                	((ICrystal)currentMolecule).setZ(Integer.parseInt(atts.getValue(i)));                }            }        } else if ("symmetry".equals(name)) {            for (int i = 0; i < atts.getLength(); i++) {                String att = atts.getQName(i);                if (att.equals("spaceGroup")) {//                    cdo.setObjectProperty("Crystal", "spacegroup", atts.getValue(i));                	((ICrystal)currentMolecule).setSpaceGroup(atts.getValue(i));                }            }        } else if ("identifier".equals(name)) {        	if (atts.getValue("convention") != null &&         		atts.getValue("convention").equals("iupac:inchi") &&        		atts.getValue("value") != null) {//                cdo.setObjectProperty("Molecule", "inchi", atts.getValue("value"));        		currentMolecule.setProperty(CDKConstants.INCHI, atts.getValue("value"));            }        } else if ("scalar".equals(name)) {            if (xpath.endsWith("crystal", "scalar"))                crystalScalar++;        } else if ("label".equals(name)) {            if (xpath.endsWith("atomType", "label")) {//            	cdo.setObjectProperty("Atom", "atomTypeLabel", atts.getValue("value"));            	currentAtom.setAtomTypeName(atts.getValue("value"));            }        } else if ("list".equals(name)) {//            cdo.startObject("MoleculeSet");        	if (DICTREF.equals("cdk:model")) {        		currentChemModel = currentChemFile.getBuilder().newChemModel();        	} else if (DICTREF.equals("cdk:moleculeSet")) {        		currentMoleculeSet = currentChemFile.getBuilder().newMoleculeSet();        		currentMolecule = currentChemFile.getBuilder().newMolecule();        	} else {        		// the old default        		currentMoleculeSet = currentChemFile.getBuilder().newMoleculeSet();        		currentMolecule = currentChemFile.getBuilder().newMolecule();        	}        }    }    public void endElement(CMLStack xpath, String uri, String name, String raw) {        logger.debug("EndElement: ", name);        String cData = currentChars;        if ("bond".equals(name)) {        	if (!stereoGiven)                bondStereo.add("");            if (bondStereo.size() > bondDictRefs.size())                bondDictRefs.add(null);            if (bondAromaticity.size() > bondDictRefs.size())            	bondAromaticity.add(null);        } else if ("atom".equals(name)) {            if (atomCounter > eltitles.size()) {                eltitles.add(null);            }            if (atomCounter > hCounts.size()) {                /* while strictly undefined, assume zero                 implicit hydrogens when no number is given */                hCounts.add("0");            }            if (atomCounter > atomDictRefs.size()) {                atomDictRefs.add(null);            }            if (atomCounter > isotope.size()) {                isotope.add(null);            }            if (atomCounter > spinMultiplicities.size()) {                spinMultiplicities.add(null);            }            if (atomCounter > occupancies.size()) {                occupancies.add(null);            }            if (atomCounter > formalCharges.size()) {                /* while strictly undefined, assume zero                 implicit hydrogens when no number is given */                formalCharges.add("0");            }            /* It may happen that not all atoms have            associated 2D or 3D coordinates. accept that */            if (atomCounter > x2.size() && x2.size() != 0) {                /* apparently, the previous atoms had atomic                coordinates, add 'null' for this atom */                x2.add(null);                y2.add(null);            }            if (atomCounter > x3.size() && x3.size() != 0) {                /* apparently, the previous atoms had atomic                coordinates, add 'null' for this atom */                x3.add(null);                y3.add(null);                z3.add(null);            }                        if (atomCounter > xfract.size() && xfract.size() != 0) {                /* apparently, the previous atoms had atomic                coordinates, add 'null' for this atom */                xfract.add(null);                yfract.add(null);                zfract.add(null);            }        } else if ("molecule".equals(name)) {            storeData();//            cdo.endObject("Molecule");            if (currentMolecule instanceof IMolecule) {                logger.debug("Adding molecule to set");                currentMoleculeSet.addMolecule((IMolecule)currentMolecule);                logger.debug("#mols in set: " + currentMoleculeSet.getMoleculeCount());            } else if (currentMolecule instanceof ICrystal) {                logger.debug("Adding crystal to chemModel");                currentChemModel.setCrystal((ICrystal)currentMolecule);                currentChemSequence.addChemModel(currentChemModel);            }        } else if ("crystal".equals(name)) {            if (crystalScalar > 0) {                // convert unit cell parameters to cartesians                Vector3d[] axes = CrystalGeometryTools.notionalToCartesian(                    unitcellparams[0], unitcellparams[1], unitcellparams[2],                    unitcellparams[3], unitcellparams[4], unitcellparams[5]                );                cartesianAxesSet = true;//                cdo.startObject("a-axis");//                cdo.setObjectProperty("a-axis", "x", new Double(aAxis.x).toString());//                cdo.setObjectProperty("a-axis", "y", new Double(aAxis.y).toString());//                cdo.setObjectProperty("a-axis", "z", new Double(aAxis.z).toString());//                cdo.endObject("a-axis");//                cdo.startObject("b-axis");//                cdo.setObjectProperty("b-axis", "x", new Double(bAxis.x).toString());//                cdo.setObjectProperty("b-axis", "y", new Double(bAxis.y).toString());//                cdo.setObjectProperty("b-axis", "z", new Double(bAxis.z).toString());//                cdo.endObject("b-axis");//                cdo.startObject("c-axis");//                cdo.setObjectProperty("c-axis", "x", new Double(cAxis.x).toString());//                cdo.setObjectProperty("c-axis", "y", new Double(cAxis.y).toString());//                cdo.setObjectProperty("c-axis", "z", new Double(cAxis.z).toString());//                cdo.endObject("c-axis");                ((ICrystal)currentMolecule).setA(axes[0]);                ((ICrystal)currentMolecule).setB(axes[1]);                ((ICrystal)currentMolecule).setC(axes[2]);            } else {                logger.error("Could not find crystal unit cell parameters");            }//            cdo.endObject("Crystal");        } else if ("list".equals(name)) {//            cdo.endObject("MoleculeSet");        	// FIXME: I really should check the DICTREF, but there is currently        	// no mechanism for storing these for use with endTag() :(        	// So, instead, for now, just see if it already has done the setting        	// to work around duplication        	if (currentChemModel.getMoleculeSet() != currentMoleculeSet) {        		currentChemModel.setMoleculeSet(currentMoleculeSet);        		currentChemSequence.addChemModel(currentChemModel);        	}        } else if ("coordinate3".equals(name)) {            if (BUILTIN.equals("xyz3")) {

⌨️ 快捷键说明

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