User 870ab5b546
19-04-2012 02:33:29
Hello,
See the attached image. The three figures differ in the size of the atom captions. I want them all to be the same. My code always sets the scale to 30, and it reports the atom size to be 0.4 in every case. We're using the dimensions that we get from the MolPrinter to set the size of the MarvinView applet window. We're using JChem 5.9 and MarvinView 5.4.
final MolPrinter printer = new MolPrinter(mol);
printer.setRendering(WIREFRAME_RENDERING_S);
printer.setImplicitH(isLewis ? IMPLICITH_ALL_S : IMPLICITH_HETEROTERM_S);
printer.setScale(MAX_SCALE); // = 30
final Rectangle boundingRect =
printer.getBoundingRectangle(
mol.getDocument().getAllMolecules());
debugPrint(SELF + "for ", molStruct, "\nimage at scale ",
MAX_SCALE, " has width ", boundingRect.width,
" and height ", boundingRect.height, "; atom size is ",
printer.getAtomSize()); /**/
Here's the log:
ChemUtils.getBestAppletSize: for <?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28"
elementType="C H N N H H N H H H H C H O H H H C O C O C H H H H H H"
formalCharge="0 0 0 -1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
mrvAlias="C 0 0 0 0 0 0 0 0 0 0 C 0 0 0 0 0 C 0 C 0 C 0 0 0 0 0 0"
x2="-6.063750982284546 -7.603750982284545 -4.523750982284547 -6.689374923706055 -8.229374923706054 -5.149374923706055 -0.8181250095367432 -2.3581250095367423 0.7218749904632569 -0.818125009536743 -0.818125009536743 4.8125 3.272500000000001 6.3525 4.8125 4.8125 7.8925 2.1401576674991176 2.1401576674991176 0.6001576674991185 3.6801576674991185 5.220157667499119 -0.9398423325008807 0.6001576674991185 0.6001576674991185 5.220157667499119 6.760157667499119 5.220157667499119"
y2="-0.8181251883506775 -0.8181251883506775 -0.8181251883506775 4.331250190734863 4.331250190734863 4.331250190734863 4.331250190734863 4.331250190734863 4.331250190734863 2.7912501907348632 5.871250190734863 4.331250190734863 4.331250190734863 4.331250190734863 2.7912501907348632 5.871250190734863 4.331250190734863 -0.8822625248352696 0.6577374751647307 -0.8822625248352693 -0.8822625248352696 -0.8822625248352696 -0.8822625248352696 0.6577374751647307 -2.4222625248352694 0.6577374751647307 -0.8822625248352696 -2.4222625248352694"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a1 a3" order="3" />
<bond atomRefs2="a4 a5" order="1" />
<bond atomRefs2="a4 a6" order="1" />
<bond atomRefs2="a7 a8" order="1" />
<bond atomRefs2="a7 a9" order="1" />
<bond atomRefs2="a7 a10" order="1" />
<bond atomRefs2="a7 a11" order="1" />
<bond atomRefs2="a12 a13" order="1" />
<bond atomRefs2="a12 a14" order="1" />
<bond atomRefs2="a12 a15" order="1" />
<bond atomRefs2="a12 a16" order="1" />
<bond atomRefs2="a14 a17" order="1" />
<bond atomRefs2="a18 a19" order="2" />
<bond atomRefs2="a18 a20" order="1" />
<bond atomRefs2="a18 a21" order="1" />
<bond atomRefs2="a21 a22" order="1" />
<bond atomRefs2="a20 a23" order="1" />
<bond atomRefs2="a20 a24" order="1" />
<bond atomRefs2="a20 a25" order="1" />
<bond atomRefs2="a22 a26" order="1" />
<bond atomRefs2="a22 a27" order="1" />
<bond atomRefs2="a22 a28" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>
image at scale 30 has width 326 and height 188; atom size is 0.4
ChemUtils.getBestAppletSize: for <?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11"
elementType="C N C H H H O N O O H"
formalCharge="0 1 -1 0 0 0 0 1 0 -1 0"
x2="-7.21875 -5.67875 -4.13875 -7.21875 -8.75875 -7.21875 0.33687499165534973 1.8768749916553498 2.6468749916553502 2.6468749916553502 -0.43312500834464995"
y2="1.2512500286102295 1.2512500286102295 1.2512500286102295 2.7912500286102295 1.2512500286102297 -0.28874997138977054 1.347499966621399 1.347499966621399 2.6811790884494346 0.01382084479336343 2.6811790884494346"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="3" />
<bond atomRefs2="a1 a4" order="1" />
<bond atomRefs2="a1 a5" order="1" />
<bond atomRefs2="a1 a6" order="1" />
<bond atomRefs2="a7 a8" order="1" />
<bond atomRefs2="a8 a9" order="2" />
<bond atomRefs2="a8 a10" order="1" />
<bond atomRefs2="a7 a11" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>
image at scale 30 has width 247 and height 88; atom size is 0.4
ChemUtils.getBestAppletSize: for <?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10"
elementType="B F F F F Al H H H H"
formalCharge="-1 0 0 0 0 -1 0 0 0 0"
x2="-4.668125152587891 -5.757069595615174 -3.5791807095606076 -5.757069595615174 -3.5791807095606076 1.2512500286102295 0.16230558558294628 2.3401944716375125 0.16230558558294628 2.3401944716375125"
y2="0.9143750071525574 2.0033194501798404 2.0033194501798404 -0.17456943587472584 -0.17456943587472584 0.9624999761581421 2.051444419185425 2.051444419185425 -0.12644446686914113 -0.12644446686914113"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a1 a3" order="1" />
<bond atomRefs2="a1 a4" order="1" />
<bond atomRefs2="a1 a5" order="1" />
<bond atomRefs2="a6 a7" order="1" />
<bond atomRefs2="a6 a8" order="1" />
<bond atomRefs2="a6 a9" order="1" />
<bond atomRefs2="a6 a10" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>
image at scale 30 has width 169 and height 69; atom size is 0.4
Is there a way to set the atom size relative to an absolute scale?