User 870ab5b546
01-10-2014 17:24:33
I can see the following structure in MarvinView, but when I try to convert it to an inline PNG image, I get an exception (below).
<?xml version="1.0" encoding="windows-1252"?>
<cml xmlns="http://www.chemaxon.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.chemaxon.com/marvin/schema/mrvSchema_14_8_4.xsd" version="ChemAxon file format v14.8.4, generated by v14.9.8.0">
<MDocument>
<MElectronContainer id="o1" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a8" difLoc="-0.2187899858542952 -0.37895540435502006 0.0"/>
<MElectron atomRefs="m1.a8" difLoc="1.633405322110093E-8 -0.4375800000000005 0.0"/>
</MElectronContainer>
<MElectronContainer id="o2" occupation="1 1" radical="0">
<MElectron atomRefs="m1.a8" difLoc="0.30941580841144756 -0.3094157622117706 0.0"/>
<MElectron atomRefs="m1.a8" difLoc="0.42266983152269777 -0.1132540062009948 0.0"/>
</MElectronContainer>
<MElectronContainer id="o3" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a8" difLoc="-0.05711567548311791 0.4338364392419187 0.0"/>
<MElectron atomRefs="m1.a8" difLoc="-0.2663818455436475 0.3471555397293269 0.0"/>
</MElectronContainer>
<MRectangle id="o4">
<MPoint x="-8.359999656677246" y="6.776000022888184"/>
<MPoint x="3.740000009536743" y="6.776000022888184"/>
<MPoint x="3.740000009536743" y="-1.187999963760376"/>
<MPoint x="-8.359999656677246" y="-1.187999963760376"/>
</MRectangle>
<MElectronContainer id="o5" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a6" difLoc="0.0 -0.43757999999999964 0.0"/>
<MElectron atomRefs="m1.a6" difLoc="0.21879000000000026 -0.378955396187993 0.0"/>
</MElectronContainer>
<MElectronContainer id="o6" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a6" difLoc="-0.30941578531160907 0.3094157853116082 0.0"/>
<MElectron atomRefs="m1.a6" difLoc="-0.4226698230675705 0.11325403775596232 0.0"/>
</MElectronContainer>
<MEFlow id="o7" arcAngle="-140.0" headSkip="0.25" headLength="0.5" headWidth="0.4" tailSkip="0.25" baseElectronContainerIndex="1" baseElectronIndexInContainer="-1">
<MEFlowBasePoint atomRef="m1.a8"/>
<MAtomSetPoint atomRefs="m1.a8 m1.a9" weights="0.25 0.75"/>
</MEFlow>
<MElectronContainer id="o8" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a15" difLoc="-0.11325403775596099 -0.4226698230675705 0.0"/>
<MElectron atomRefs="m1.a15" difLoc="0.11325403775596188 -0.4226698230675705 0.0"/>
</MElectronContainer>
<MElectronContainer id="o9" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a15" difLoc="0.42266982306757095 0.11325403775596143 0.0"/>
<MElectron atomRefs="m1.a15" difLoc="0.3094157853116113 0.30941578531160996 0.0"/>
</MElectronContainer>
<MElectronContainer id="o10" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a17" difLoc="1.7763568394002505E-15 -0.43757999999999875 0.0"/>
<MElectron atomRefs="m1.a17" difLoc="0.21879000000000381 -0.3789553961879939 0.0"/>
</MElectronContainer>
<MElectronContainer id="o11" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a17" difLoc="-0.3094157853116073 0.30941578531160996 0.0"/>
<MElectron atomRefs="m1.a17" difLoc="-0.42266982306756873 0.11325403775596143 0.0"/>
</MElectronContainer>
<MRectangle id="o12">
<MPoint x="-7.171999931335449" y="-2.2880001068115234"/>
<MPoint x="8.359999656677246" y="-2.2880001068115234"/>
<MPoint x="8.359999656677246" y="-9.239999771118164"/>
<MPoint x="-7.171999931335449" y="-9.239999771118164"/>
</MRectangle>
<MEFlow id="o13" arcAngle="-257.0544339526754" headSkip="0.38" headLength="0.5" headWidth="0.4" tailSkip="0.38" baseElectronContainerIndex="1" baseElectronIndexInContainer="1">
<MAtomSetPoint atomRefs="m1.a15 m1.a16"/>
<MAtomSetPoint atomRefs="m1.a16"/>
</MEFlow>
<MElectronContainer id="o14" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a26" difLoc="-0.42599941903451466 0.10000375684071017 0.0"/>
<MElectron atomRefs="m1.a26" difLoc="-0.418928197301657 -0.126393915619321 0.0"/>
</MElectronContainer>
<MElectronContainer id="o15" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a26" difLoc="-0.06030679019069041 0.4334043694483203 0.0"/>
<MElectron atomRefs="m1.a26" difLoc="-0.26892939704999597 0.34518579895807555 0.0"/>
</MElectronContainer>
<MChemicalStruct>
<molecule molID="m1">
<atomArray>
<atom id="a1" elementType="C" x2="-6.423999786376953" y2="4.136000156402588"/>
<atom id="a2" elementType="C" x2="-5.090320664548917" y2="4.9060001564025875"/>
<atom id="a3" elementType="C" x2="-3.756641542720882" y2="4.136000156402587"/>
<atom id="a4" elementType="C" x2="-2.422962420892846" y2="4.906000156402587"/>
<atom id="a5" elementType="C" x2="-1.0892832990648103" y2="4.136000156402587"/>
<atom id="a6" elementType="O" x2="0.24439582276322547" y2="4.906000156402587"/>
<atom id="a7" elementType="R" sgroupRef="sg1" x2="-3.256000041961670" y2="2.1559998989105225"/>
<atom id="a8" elementType="O" formalCharge="-1" x2="-1.7160000419616699" y2="2.1559998989105225"/>
<atom id="a9" elementType="H" x2="1.7843958227632255" y2="4.906000156402587"/>
<atom id="a10" elementType="C" x2="-5.015999794006348" y2="-5.015999794006348"/>
<atom id="a11" elementType="C" x2="-3.682320672178312" y2="-4.245999794006348"/>
<atom id="a12" elementType="C" x2="-2.348641550350276" y2="-5.015999794006348"/>
<atom id="a13" elementType="C" x2="-1.0149624285222405" y2="-4.245999794006348"/>
<atom id="a14" elementType="C" x2="0.3187166933057952" y2="-5.015999794006348"/>
<atom id="a15" elementType="O" x2="1.6523958151338305" y2="-4.245999794006347"/>
<atom id="a16" elementType="H" x2="2.9860749369618667" y2="-5.015999794006347"/>
<atom id="a17" elementType="O" x2="4.319754058789902" y2="-4.245999794006347"/>
<atom id="a18" elementType="R" sgroupRef="sg2" x2="5.859754058789902" y2="-4.245999794006347"/>
<atom id="a19" elementType="C" x2="-3.695999860763550" y2="-14.651999473571777"/>
<atom id="a20" elementType="C" x2="-2.362320738935514" y2="-13.881999473571778"/>
<atom id="a21" elementType="H" x2="-5.0296789825915855" y2="-13.881999473571778"/>
<atom id="a22" elementType="C" x2="-3.649418529398319" y2="-16.271525215539363"/>
<atom id="a23" elementType="H" x2="-4.960408498060644" y2="-17.079550773344778"/>
<atom id="a24" elementType="C" x2="-2.2941528851005746" y2="-17.002863053604800"/>
<atom id="a25" elementType="C" x2="-1.9637394094776317" y2="-12.394473701086612"/>
<atom id="a26" elementType="O" formalCharge="-1" x2="-3.2042135328035473" y2="-11.335892524216622"/>
<atom id="a27" elementType="C" x2="2.4639999866485596" y2="-14.960000038146973"/>
<atom id="a28" elementType="C" x2="3.7976791084765953" y2="-14.190000038146973"/>
<atom id="a29" elementType="C" x2="5.131358230304631" y2="-14.960000038146973"/>
<atom id="a30" elementType="C" x2="3.7976791084765953" y2="-12.650000038146974"/>
<atom id="a31" elementType="R" sgroupRef="sg3" x2="5.131358230304631" y2="-11.880000038146974"/>
<atom id="a32" elementType="C" x2="2.4639999866485596" y2="-16.500000038146972"/>
</atomArray>
<bondArray>
<bond id="b1" atomRefs2="a1 a2" order="2"/>
<bond id="b2" atomRefs2="a2 a3" order="1"/>
<bond id="b3" atomRefs2="a3 a4" order="2"/>
<bond id="b4" atomRefs2="a4 a5" order="1"/>
<bond id="b5" atomRefs2="a5 a6" order="1"/>
<bond id="b6" atomRefs2="a7 a8" order="1"/>
<bond id="b7" atomRefs2="a6 a9" order="1"/>
<bond id="b8" atomRefs2="a10 a11" order="2"/>
<bond id="b9" atomRefs2="a11 a12" order="1"/>
<bond id="b10" atomRefs2="a12 a13" order="2"/>
<bond id="b11" atomRefs2="a13 a14" order="1"/>
<bond id="b12" atomRefs2="a14 a15" order="1"/>
<bond id="b13" atomRefs2="a15 a16" order="1"/>
<bond id="b14" atomRefs2="a16 a17" order="1"/>
<bond id="b15" atomRefs2="a17 a18" order="1"/>
<bond id="b16" atomRefs2="a19 a20" order="2"/>
<bond id="b17" atomRefs2="a19 a21" order="1"/>
<bond id="b18" atomRefs2="a19 a22" order="1"/>
<bond id="b19" atomRefs2="a22 a23" order="1"/>
<bond id="b20" atomRefs2="a22 a24" order="2"/>
<bond id="b21" atomRefs2="a20 a25" order="1"/>
<bond id="b22" atomRefs2="a25 a26" order="1"/>
<bond id="b23" atomRefs2="a27 a28" order="1"/>
<bond id="b24" atomRefs2="a28 a29" order="1"/>
<bond id="b25" atomRefs2="a28 a30" order="2"/>
<bond id="b26" atomRefs2="a30 a31" order="1"/>
<bond id="b27" atomRefs2="a27 a32" order="1"/>
</bondArray>
<molecule id="sg1" role="SuperatomSgroup" title="tBu" molID="m2">
<atomArray atomID="a33 a34 a35 a36" elementType="C C C C" attachmentPoint="1 0 0 0" sgroupAttachmentPoint="1 0 0 0" x2="-0.17600004196166985 0.5939999580383297 0.5939999580383306 -1.7160000419616699" y2="2.1559998989105225 3.489679020738558 0.8223207770824872 2.1559998989105225"/>
<bondArray>
<bond id="b28" atomRefs2="a33 a34" order="1"/>
<bond id="b29" atomRefs2="a33 a35" order="1"/>
<bond id="b30" atomRefs2="a33 a36" order="1"/>
</bondArray>
<SgroupAtom>
<scalar title="graphicalMarvinProperty::FormattedLabel" convention="atomprop" dataType="xsd:string">\i\St\n Bu</scalar>
</SgroupAtom>
<AttachmentPointArray>
<attachmentPoint atom="a33" order="1" bond="b6"/>
</AttachmentPointArray>
</molecule>
<molecule id="sg2" role="SuperatomSgroup" title="tBu" molID="m3">
<atomArray atomID="a37 a38 a39 a40" elementType="C C C C" attachmentPoint="1 0 0 0" sgroupAttachmentPoint="1 0 0 0" x2="9.064000205993652 9.834000205993652 9.834000205993654 7.524000205993652" y2="-4.355999946594238 -3.0223208247662026 -5.689679068422274 -4.355999946594238"/>
<bondArray>
<bond id="b31" atomRefs2="a37 a38" order="1"/>
<bond id="b32" atomRefs2="a37 a39" order="1"/>
<bond id="b33" atomRefs2="a37 a40" order="1"/>
</bondArray>
<SgroupAtom>
<scalar title="graphicalMarvinProperty::FormattedLabel" convention="atomprop" dataType="xsd:string">\i\St\n Bu</scalar>
</SgroupAtom>
<AttachmentPointArray>
<attachmentPoint atom="a37" order="1" bond="b15"/>
</AttachmentPointArray>
</molecule>
<molecule id="sg3" role="SuperatomSgroup" title="CO2Me" leftName="MeO2C" molID="m4">
<atomArray atomID="a41 a42 a43 a44" elementType="C O C O" attachmentPoint="1 0 0 0" sgroupAttachmentPoint="1 0 0 0" x2="8.569000091552734 9.339000091552734 10.879000091552733 7.029000091552734" y2="-12.59083934729097 -13.924518469119008 -13.924518469119008 -12.59083934729097"/>
<bondArray>
<bond id="b34" atomRefs2="a43 a42" order="1"/>
<bond id="b35" atomRefs2="a42 a41" order="1"/>
<bond id="b36" atomRefs2="a41 a44" order="2"/>
</bondArray>
<AttachmentPointArray>
<attachmentPoint atom="a41" order="1" bond="b26"/>
</AttachmentPointArray>
</molecule>
</molecule>
</MChemicalStruct>
<MElectronContainer id="o17" occupation="0 0" radical="0">
<MElectron atomRefs="m1.a26" difLoc="-0.24686340775967475 -0.36129588194342865 0.0"/>
<MElectron atomRefs="m1.a26" difLoc="-0.03314204141296084 -0.43632311592554984 0.0"/>
</MElectronContainer>
<MEFlow id="o18" arcAngle="-140.0" headSkip="0.25" headLength="0.5" headWidth="0.4" tailSkip="0.25" baseElectronContainerIndex="1" baseElectronIndexInContainer="1">
<MAtomSetPoint atomRefs="m1.a28 m1.a30"/>
<MAtomSetPoint atomRefs="m1.a30 m1.a20" weights="0.25 0.75"/>
</MEFlow>
<MEFlow id="o19" arcAngle="181.79999999999998" headSkip="0.25" headLength="0.5" headWidth="0.4" tailSkip="0.25" baseElectronContainerIndex="1" baseElectronIndexInContainer="1">
<MAtomSetPoint atomRefs="m1.a19 m1.a20"/>
<MAtomSetPoint atomRefs="m1.a19 m1.a22"/>
</MEFlow>
<MEFlow id="o20" arcAngle="140.0" headSkip="0.25" headLength="0.5" headWidth="0.4" tailSkip="0.25" baseElectronContainerIndex="1" baseElectronIndexInContainer="1">
<MAtomSetPoint atomRefs="m1.a22 m1.a24"/>
<MAtomSetPoint atomRefs="m1.a24 m1.a32" weights="0.25 0.75"/>
</MEFlow>
<MRectangle id="o21">
<MPoint x="-6.556000232696533" y="-10.076000213623047"/>
<MPoint x="8.62399959564209" y="-10.076000213623047"/>
<MPoint x="8.62399959564209" y="-18.43600082397461"/>
<MPoint x="-6.556000232696533" y="-18.43600082397461"/>
</MRectangle>
</MDocument>
</cml>
Oct 1, 2014 12:55:11 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: Attribute compressionFlag must be 'true' or 'false'!
javax.imageio.metadata.IIOInvalidTreeException: Attribute compressionFlag must be 'true' or 'false'!
at com.sun.imageio.plugins.png.PNGMetadata.fatal(PNGMetadata.java:1083)
at com.sun.imageio.plugins.png.PNGMetadata.getBooleanAttribute(PNGMetadata.java:1155)
at com.sun.imageio.plugins.png.PNGMetadata.getBooleanAttribute(PNGMetadata.java:1163)
at com.sun.imageio.plugins.png.PNGMetadata.mergeNativeTree(PNGMetadata.java:1411)
at com.sun.imageio.plugins.png.PNGMetadata.mergeTree(PNGMetadata.java:1224)
at javax.imageio.metadata.IIOMetadata.setFromTree(IIOMetadata.java:742)
at chemaxon.marvin.io.image.encoder.PngEncoder.createIIOMetaData(PngEncoder.java:104)
at chemaxon.marvin.io.image.encoder.ImageEncoder.getIIOImage(ImageEncoder.java:228)
at chemaxon.marvin.io.image.encoder.ImageEncoder.encode(ImageEncoder.java:68)
at chemaxon.marvin.io.image.exporter.PngExport.encodeImage(PngExport.java:109)
at chemaxon.marvin.io.image.exporter.PngExport.convert(PngExport.java:65)
at chemaxon.marvin.io.image.exporter.PngExport.convert(PngExport.java:49)
at chemaxon.formats.MolExporter.exportToObject(MolExporter.java:1348)
at chemaxon.formats.MolExporter.exportToObject(MolExporter.java:1308)
at chemaxon.formats.MolExporter.exportToObject(MolExporter.java:1048)
at chemaxon.formats.MolExporter.exportToBinFormat(MolExporter.java:1139)
at com.epoch.chem.MolString.toBinFormat(MolString.java:219)
at com.epoch.chem.MolString.getImage(MolString.java:437)
Here's the code:
private static String getImage(String format, String molStr, long qFlags) {
final String SELF = "MolString.getImage: ";
String imageData = "";
if (!Utils.isEmpty(molStr)) try {
debugPrint(SELF + "molStr:\n", molStr);
final boolean isLewis = molStr.contains("Lewis ");
final Molecule mol = MolImporter.importMol(molStr);
final int[] dims = getBestAppletSize(mol, isLewis);
final String opts =
getImageOpts(format, dims, qFlags, isLewis);
MDocument mDoc = mol.getDocument();
if (mDoc == null) mDoc = new MDocument(mol);
imageData = (PNG.equals(format)
? new StringBuilder().append("data:image/")
.append(PNG).append(";base64,")
.append(Base64Coder.encode(toBinFormat(mDoc, opts)))
.toString()
: Utils.bytesToString(toBinFormat(mDoc, opts))
.replaceAll("\"clipPath1\"", "\"clipPath2\""));
debugPrint(SELF + "generated image src URI with options ", opts,
"; isLewis = ", isLewis);
debugPrintMRV(SELF + "image data:\n", imageData);
} catch (MolFormatException e) {
Utils.alwaysPrint(SELF + "caught MolFormatException converting "
+ "to format ", format, " on:\n", molStr);
e.printStackTrace();
} // try
return imageData;
} // getImage(String, String, long)
public static byte[] toBinFormat(MDocument mDoc, String format) {
try {
return MolExporter.exportToBinFormat(mDoc, format);
} catch (IOException e) {
// do nothing
}
return new byte[0];
} // toBinFormat(MDocument, String)