JAVAC.JP
HOSHI TETSUYA 星鉄矢
2005/07/26
hossy@javac.jp
http://www.javac.jp
Google
WWW を検索 WWW.JAVAC.JP を検索

3-1 実際の分子データを用いよう。またXMLに追加する情報について

実際の分子のデータを扱って見ましょう。
以下に載せるのはMethotrexateの3次元立体構造データです。
xml/001.xml
---
<?xml version="1.0" encoding="UTF-8" ?>
<model>
    <config scale="500" cx="0" cy="0" cz="20" length="1" />
    <pointlist>
        <point id="1" x="2.7898" y="-6.1913" z="2.3184" note="N" comment="This is atom N" />
        <point id="2" x="4.0435" y="-4.3264" z="0.7798" note="N" comment="This is atom N" />
        <point id="3" x="4.4193" y="-7.7793" z="1.7673" note="N" comment="This is atom N" />
        <point id="4" x="6.1893" y="-7.2188" z="0.3435" note="N" comment="This is atom N" />
        <point id="5" x="5.5483" y="-8.1214" z="1.1148" note="C" comment="This is atom C" />
        <point id="6" x="3.922" y="-6.5293" z="1.6588" note="C" comment="This is atom C" />
        <point id="7" x="4.5616" y="-5.577" z="0.8732" note="C" comment="This is atom C" />
        <point id="8" x="5.7212" y="-5.9586" z="0.2095" note="C" comment="This is atom C" />
        <point id="9" x="2.2619" y="-4.9487" z="2.2123" note="C" comment="This is atom C" />
        <point id="10" x="2.8957" y="-3.9996" z="1.4197" note="C" comment="This is atom C" />
        <point id="11" x="-1.2797" y="-1.9769" z="1.7988" note="C" comment="This is atom C" />
        <point id="12" x="-2.1139" y="-1.0669" z="2.4372" note="C" comment="This is atom C" />
        <point id="13" x="0.0702" y="-1.6984" z="1.6021" note="C" comment="This is atom C" />
        <point id="14" x="0.556" y="-0.4725" z="2.0478" note="C" comment="This is atom C" />
        <point id="15" x="-1.6148" y="0.1452" z="2.8994" note="C" comment="This is atom C" />
        <point id="16" x="-0.2721" y="0.4381" z="2.6898" note="C" comment="This is atom C" />
        <point id="17" x="-0.6679" y="6.2707" z="3.8384" note="C" comment="This is atom C" />
        <point id="18" x="0.0486" y="6.8229" z="2.8328" note="O" comment="This is atom O" />
        <point id="19" x="-0.6945" y="6.8264" z="4.9453" note="O" comment="This is atom O" />
        <point id="20" x="-1.419" y="4.9953" z="3.6028" note="C" comment="This is atom C" />
        <point id="21" x="-2.1588" y="4.5721" z="4.8711" note="C" comment="This is atom C" />
        <point id="22" x="-2.9276" y="3.2582" z="4.7205" note="C" comment="This is atom C" />
        <point id="23" x="-2.0523" y="2.1957" z="4.2874" note="N" comment="This is atom N" />
        <point id="24" x="-2.5265" y="1.114" z="3.6116" note="C" comment="This is atom C" />
        <point id="25" x="-3.7199" y="0.9336" z="3.5875" note="O" comment="This is atom O" />
        <point id="26" x="-3.5338" y="3.0112" z="6.0744" note="C" comment="This is atom C" />
        <point id="27" x="-2.9543" y="2.2964" z="6.9037" note="O" comment="This is atom O" />
        <point id="28" x="-4.7203" y="3.5804" z="6.3964" note="O" comment="This is atom O" />
        <point id="29" x="0.9009" y="-2.6029" z="0.9869" note="N" comment="This is atom N" />
        <point id="30" x="0.379" y="-3.5634" z="0.0407" note="C" comment="This is atom C" />
        <point id="31" x="2.3229" y="-2.6201" z="1.2671" note="C" comment="This is atom C" />
        <point id="32" x="6.413" y="-5.0996" z="-0.5816" note="N" comment="This is atom N" />
        <point id="33" x="6.0379" y="-9.3734" z="1.2353" note="N" comment="This is atom N" />
        <point id="34" x="1.3779" y="-4.7048" z="2.725" note="H" comment="" />
        <point id="35" x="-1.6812" y="-2.8877" z="1.4656" note="H" comment="" />
        <point id="36" x="-3.1296" y="-1.3005" z="2.5719" note="H" comment="" />
        <point id="37" x="1.5635" y="-0.2189" z="1.9002" note="H" comment="" />
        <point id="38" x="0.1331" y="1.351" z="3.0112" note="H" comment="" />
        <point id="39" x="0.4296" y="7.6241" z="3.1743" note="H" comment="" />
        <point id="40" x="-2.1206" y="5.1442" z="2.7956" note="H" comment="" />
        <point id="41" x="-0.7054" y="4.2369" z="3.3176" note="H" comment="" />
        <point id="42" x="-1.4345" y="4.4592" z="5.6665" note="H" comment="" />
        <point id="43" x="-2.8535" y="5.3539" z="5.1475" note="H" comment="" />
        <point id="44" x="-3.7314" y="3.393" z="4.0087" note="H" comment="" />
        <point id="45" x="-1.1062" y="2.2516" z="4.4858" note="H" comment="" />
        <point id="46" x="-4.9602" y="3.2546" z="7.2564" note="H" comment="" />
        <point id="47" x="-0.4495" y="-3.1517" z="-0.5175" note="H" comment="" />
        <point id="48" x="1.1422" y="-3.855" z="-0.6674" note="H" comment="" />
        <point id="49" x="0.0434" y="-4.4458" z="0.5671" note="H" comment="" />
        <point id="50" x="2.5471" y="-2.1128" z="2.1942" note="H" comment="" />
        <point id="51" x="2.844" y="-2.1139" z="0.4669" note="H" comment="" />
        <point id="52" x="7.2199" y="-5.4007" z="-1.0275" note="H" comment="" />
        <point id="53" x="6.1072" y="-4.187" z="-0.705" note="H" comment="" />
        <point id="54" x="6.8486" y="-9.622" z="0.7665" note="H" comment="" />
        <point id="55" x="5.5765" y="-10.0197" z="1.7908" note="H" comment="" />
    </pointlist>
    <linelist>
        <line id="1" point1="1" point2="9" note="double" comment="" />
        <line id="2" point1="1" point2="6" note="single" comment="" />
        <line id="3" point1="2" point2="10" note="double" comment="" />
        <line id="4" point1="2" point2="7" note="single" comment="" />
        <line id="5" point1="3" point2="5" note="single" comment="" />
        <line id="6" point1="3" point2="6" note="double" comment="" />
        <line id="7" point1="4" point2="8" note="single" comment="" />
        <line id="8" point1="4" point2="5" note="double" comment="" />
        <line id="9" point1="5" point2="33" note="single" comment="" />
        <line id="10" point1="6" point2="7" note="single" comment="" />
        <line id="11" point1="7" point2="8" note="double" comment="" />
        <line id="12" point1="8" point2="32" note="single" comment="" />
        <line id="13" point1="9" point2="10" note="single" comment="" />
        <line id="14" point1="9" point2="34" note="single" comment="" />
        <line id="15" point1="10" point2="31" note="single" comment="" />
        <line id="16" point1="11" point2="13" note="double" comment="" />
        <line id="17" point1="11" point2="12" note="single" comment="" />
        <line id="18" point1="11" point2="35" note="single" comment="" />
        <line id="19" point1="12" point2="15" note="double" comment="" />
        <line id="20" point1="12" point2="36" note="single" comment="" />
        <line id="21" point1="13" point2="29" note="single" comment="" />
        <line id="22" point1="13" point2="14" note="single" comment="" />
        <line id="23" point1="14" point2="16" note="double" comment="" />
        <line id="24" point1="14" point2="37" note="single" comment="" />
        <line id="25" point1="15" point2="24" note="single" comment="" />
        <line id="26" point1="15" point2="16" note="single" comment="" />
        <line id="27" point1="16" point2="38" note="single" comment="" />
        <line id="28" point1="17" point2="18" note="single" comment="" />
        <line id="29" point1="17" point2="19" note="double" comment="" />
        <line id="30" point1="17" point2="20" note="single" comment="" />
        <line id="31" point1="18" point2="39" note="single" comment="" />
        <line id="32" point1="20" point2="21" note="single" comment="" />
        <line id="33" point1="20" point2="40" note="single" comment="" />
        <line id="34" point1="20" point2="41" note="single" comment="" />
        <line id="35" point1="21" point2="22" note="single" comment="" />
        <line id="36" point1="21" point2="42" note="single" comment="" />
        <line id="37" point1="21" point2="43" note="single" comment="" />
        <line id="38" point1="22" point2="23" note="single" comment="" />
        <line id="39" point1="22" point2="26" note="single" comment="" />
        <line id="40" point1="22" point2="44" note="single" comment="" />
        <line id="41" point1="23" point2="24" note="single" comment="" />
        <line id="42" point1="23" point2="45" note="single" comment="" />
        <line id="43" point1="24" point2="25" note="double" comment="" />
        <line id="44" point1="26" point2="28" note="single" comment="" />
        <line id="45" point1="26" point2="27" note="double" comment="" />
        <line id="46" point1="28" point2="46" note="single" comment="" />
        <line id="47" point1="29" point2="31" note="single" comment="" />
        <line id="48" point1="29" point2="30" note="single" comment="" />
        <line id="49" point1="30" point2="47" note="single" comment="" />
        <line id="50" point1="30" point2="48" note="single" comment="" />
        <line id="51" point1="30" point2="49" note="single" comment="" />
        <line id="52" point1="31" point2="50" note="single" comment="" />
        <line id="53" point1="31" point2="51" note="single" comment="" />
        <line id="54" point1="32" point2="52" note="single" comment="" />
        <line id="55" point1="32" point2="53" note="single" comment="" />
        <line id="56" point1="33" point2="54" note="single" comment="" />
        <line id="57" point1="33" point2="55" note="single" comment="" />
    </linelist>
</model>
さて、このデータですが、実際に前のXMLファイルと置き換えてみれば分かるのですが、表示がおかしくなってしまいます。
前述したように、ParamControlにおけるパラメータを決め打ちにしていることや、CubeControlでノードのサイズを決め打ちにしているためです。
使用するデータが変わる度に再コンパイルすることは馬鹿げていますので、上記001.xmlファイルでは、configタグを使って、パラメータの指定をしています。

また、読み込むファイル名が決め打ちなのも困ります。config.xmlというものを用意して、ここで読み込むファイル名を指定できるようにしましょう。
config.xml
---
<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <model dirname="xml/" filename="001.xml" />
    <pointnotelist>
        <pointnote note="C" size="0.5" col_r="50" col_g="50" col_b="50" col_a="100" />
        <pointnote note="O" size="0.5" col_r="100" col_g="100" col_b="0" col_a="100" />
        <pointnote note="H" size="0.3" col_r="100" col_g="100" col_b="100" col_a="100" />
        <pointnote note="N" size="0.5" col_r="100" col_g="0" col_b="100" col_a="100" />
        <pointnote note="S" size="0.7" col_r="0" col_g="0" col_b="100" col_a="100" />
        <pointnote note="Cl" size="0.7" col_r="0" col_g="100" col_b="0" col_a="100" />
        <pointnote note="Br" size="0.7" col_r="100" col_g="50" col_b="0" col_a="100" />
    </pointnotelist>
    <linenotelist>
        <linenote note="single" size="1" col_r="0" col_g="0" col_b="0" col_a="100" />
        <linenote note="double" size="4" col_r="20" col_g="20" col_b="20" col_a="100" />
        <linenote note="triple" size="10" col_r="40" col_g="40" col_b="40" col_a="100" />
    </linenotelist>
</config>
ここで変な属性『note』というものを設定しています。(他に妥当な名前が見つからなかったです。)
このコンテンツの目的は分子を描画するものなので、note属性でカテゴリー分けして、config.xmlに記載されたサイズと色を、各々のノード・エッジに反映させる、ということにより、データ量を小さくしています。(『分子』であることにこだわらなければ、pointタグ・lineタグにサイズと色を持たせることが正しいと思いますが、分子においては、同じ原子をまとめて扱いたいので、このような仕様にしています。)



BACKTOPNEXT




All Contents Copyright (C) 2005 HOSHI Tetsuya
Home