首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JHotDraw的IO有关问题

2012-12-19 
JHotDraw的IO问题您好!请教一个问题:jhotdraw7.6中samples中draw实例中有个file菜单中有个“open”的功能,可

JHotDraw的IO问题

您好!请教一个问题:jhotdraw7.6中samples中draw实例中有个file菜单中有个“open”的功能,可以根据xml文件生成图形,请问这个功能的代码在哪儿?谢谢

?

?

你好,我用的是7.5的版本,我想应该是一样的。

实现机制:
draw的存储接口是DOMStorable,负责drawing的IO操作;所有继承或实现该接口的子类都必须实现了read和write方法,即实现具体类的读入和写出责任。AbstractAttributedFigure和Drawing都继承该接口。

读取文件的顺序为:

    openAction读入文件,调用DrawView的read方法读取该文件;DrawView中维护多个inputFormat,每个inputFormat负责读取特定的Figure;当调用read方法时,DrawView尝试让所有的inputFormat读取该文件,但只要有一个inputFormat读取成功就停止。
至于DrawView装载了多少InputFromat,可以参考org.jhotdraw.samples.draw.DrawView.createDrawing():

?

?

?

- <a>
- <fontFace>
  <font id="1" name="宋体" style="0" size="20" />
  </fontFace>
- <fontSize>
  <double id="2">20.0</double>
  </fontSize>
  </a>
  <transition name="到拟稿" to="拟稿" />
  </start-state>
- <task-node id="3" x="42" y="148" w="60" h="40" name="拟稿">
- <a>
- <text>
  <string id="4">拟稿</string>
  </text>
- <fontFace>
  <font ref="1" />
  </fontFace>
- <fontSize>
  <double ref="2" />
  </fontSize>
  </a>
  <transition name="到审批" to="审批" />
- <task name="拟稿">
  <description>draft</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  </task-node>
- <task-node id="5" x="40" y="238" w="60" h="40" name="审批">
- <a>
- <text>
  <string id="6">审批</string>
  </text>
- <fontFace>
  <font ref="1" />
  </fontFace>
- <fontSize>
  <double ref="2" />
  </fontSize>
  </a>
  <transition name="到判断" to="判断" />
- <task name="审批">
  <description>examine</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  </task-node>
- <task-node id="7" x="40" y="346" w="60" h="40" name="成文">
- <a>
- <text>
  <string id="8">成文</string>
  </text>
- <fontFace>
  <font ref="1" />
  </fontFace>
- <fontSize>
  <double ref="2" />
  </fontSize>
  </a>
  <transition name="到传阅" to="传阅" />
- <task name="成文">
  <description>write</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  </task-node>
- <task-node id="9" x="187" y="344" w="60" h="40" name="传阅">
- <a>
- <text>
  <string id="a">传阅</string>
  </text>
- <fontFace>
  <font ref="1" />
  </fontFace>
- <fontSize>
  <double ref="2" />
  </fontSize>
  </a>
  <transition name="到归档" to="归档" />
- <task name="传阅">
  <description>read</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  </task-node>
- <decision id="b" x="179" y="232" w="60" h="40" name="判断">
- <a>
- <fillColor>
  <color id="c" rgba="#ffffff00" />
  </fillColor>
- <fontFace>
  <font ref="1" />
  </fontFace>
- <fontSize>
  <double ref="2" />
  </fontSize>
  </a>
  <transition name="同意" to="成文" />
  <transition name="不同意" to="拟稿" />
  <handler />
  </decision>
- <end-state id="d" x="462" y="337" w="60" h="40" name="结束">
- <a>
- <fillColor>
  <color id="e" rgba="#ffff0000" />
  </fillColor>
- <fontFace>
  <font ref="1" />
  </fontFace>
- <fontSize>
  <double ref="2" />
  </fontSize>
  </a>
  </end-state>
- <task-node id="f" x="313" y="343" w="60" h="40" name="归档">
- <a>
- <text>
  <string id="10">归档</string>
  </text>
- <fontFace>
  <font ref="1" />
  </fontFace>
- <fontSize>
  <double ref="2" />
  </fontSize>
  </a>
  <transition name="到结束" to="结束" />
- <task name="归档">
  <description>file</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  </task-node>
- <transition id="11">
- <points>
  <p colinear="true" x="70.41414141414141" y="89.5" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="71.58585858585859" y="147.5" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="12">
- <Owner>
  <start-state ref="0" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="13">
- <Owner>
  <task-node ref="3" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color id="14" rgba="#ff000000" />
  </strokeColor>
- <strokeWidth>
  <double id="15">1.0</double>
  </strokeWidth>
  </a>
  </transition>
- <transition id="16">
- <points>
  <p colinear="true" x="71.54444444444445" y="188.5" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="70.45555555555555" y="237.5" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="17">
- <Owner>
  <task-node ref="3" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="18">
- <Owner>
  <task-node ref="5" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color ref="14" />
  </strokeColor>
- <strokeWidth>
  <double ref="15" />
  </strokeWidth>
  </a>
  </transition>
- <transition id="19">
- <points>
  <p colinear="true" x="100.5" y="256.68345323741005" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="178.5" y="253.31654676258992" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="1a">
- <Owner>
  <task-node ref="5" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="1b">
- <Owner>
  <decision ref="b" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color ref="14" />
  </strokeColor>
- <strokeWidth>
  <double ref="15" />
  </strokeWidth>
  </a>
  </transition>
- <transition id="1c">
- <points>
  <p colinear="true" x="178.5" y="233.2992700729927" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="102.5" y="186.7007299270073" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="1d">
- <Owner>
  <decision ref="b" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="1e">
- <Owner>
  <task-node ref="3" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color ref="14" />
  </strokeColor>
- <strokeWidth>
  <double ref="15" />
  </strokeWidth>
  </a>
  </transition>
- <transition id="1f">
- <points>
  <p colinear="true" x="184.00438596491227" y="272.5" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="94.99561403508773" y="345.5" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="20">
- <Owner>
  <decision ref="b" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="21">
- <Owner>
  <task-node ref="7" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color ref="14" />
  </strokeColor>
- <strokeWidth>
  <double ref="15" />
  </strokeWidth>
  </a>
  </transition>
- <transition id="22">
- <points>
  <p colinear="true" x="100.5" y="365.5850340136054" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="186.5" y="364.4149659863946" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="23">
- <Owner>
  <task-node ref="7" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="24">
- <Owner>
  <task-node ref="9" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color ref="14" />
  </strokeColor>
- <strokeWidth>
  <double ref="15" />
  </strokeWidth>
  </a>
  </transition>
- <transition id="25">
- <points>
  <p colinear="true" x="247.5" y="363.7579365079365" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="312.5" y="363.2420634920635" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="26">
- <Owner>
  <task-node ref="9" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="27">
- <Owner>
  <task-node ref="f" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color ref="14" />
  </strokeColor>
- <strokeWidth>
  <double ref="15" />
  </strokeWidth>
  </a>
  </transition>
- <transition id="28">
- <points>
  <p colinear="true" x="373.5" y="361.7718120805369" c1x="0" c1y="0" c2x="0" c2y="0" />
  <p colinear="true" x="461.5" y="358.2281879194631" c1x="0" c1y="0" c2x="0" c2y="0" />
  </points>
- <startConnector>
- <rConnector id="29">
- <Owner>
  <task-node ref="f" />
  </Owner>
  </rConnector>
  </startConnector>
- <endConnector>
- <rConnector id="2a">
- <Owner>
  <end-state ref="d" />
  </Owner>
  </rConnector>
  </endConnector>
- <a>
- <strokeColor>
  <color ref="14" />
  </strokeColor>
- <strokeWidth>
  <double ref="15" />
  </strokeWidth>
  </a>
  </transition>
  </figures>
  </drawing>

修改成文一下形式的xml文件
  <?xml version="1.0" encoding="UTF-8" ?>
- <process-definition xmlns="" name="document">
- <start-state name="开始">
  <transition to="拟稿" />
  </start-state>
- <task-node name="拟稿">
- <task name="拟稿">
  <description>draft</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  <transition to="审批" />
  </task-node>
- <task-node name="归档">
- <task name="归档">
  <description>file</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  <transition to="结束" />
  </task-node>
- <task-node name="传阅">
- <task name="传阅">
  <description>read</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  <transition to="归档" />
  </task-node>
- <task-node name="成文">
- <task name="成文">
  <description>write</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  <transition to="传阅" />
  </task-node>
- <task-node name="审批">
- <task name="审批">
  <description>examine</description>
  <assignment />
- <controller>
  <variable access="read,write" name="documentId" />
  </controller>
  </task>
  <transition to="判断" />
  </task-node>
- <decision name="判断">
  <handler />
  <transition to="成文" name="同意" />
  <transition to="拟稿" name="不同意" />
  </decision>
  <end-state name="结束" />
  </process-definition>

请问需要修改哪些文件啊?
我也在整,不过过程中还有不少的问题

热点排行