mxGraphを使用して、Webページに描画可能領域を作成しています。mxGraphはグリッドを表示しますが、画像は表示されません。
これはレガシーコードであり、グリッド以外に画像が表示されないため、これを理解しようとしています。ここで
は簡単な図を示すために私のjavascriptのコード
//define a window to show the image and put a grid as background
container.style.background = 'url("js/src/images/grid.gif")';
//some other definitions here
var model = new mxGraphModel();
var graph = new mxGraph(container, model);
var id = _GET("id");
mxUtils.post("../Diagram",
"action=get&id="+id,
function(req)
{
var node = req.getDocumentElement();
var dec = new mxCodec(node.ownerDocument);
dec.decode(node, graph.getModel());
},
function(error){
console.log("Error in the design area");
console.log(error);
});
../Diagram
であるあなたは以下を参照することができますサーブレットのJavaです:
try {
BufferedReader buffRead = new BufferedReader(new FileReader("/home/glassfish/mySite/Repository/"+getId()+"/"+getName()+".txt"));
String line = "";
while (true) {
if (line != null) {
file = line;
} else {
break;
}
line = buffRead.readLine();
}
buffRead.close();
} catch(Exception e) {
System.out.println("File not found");
}
return file;
返されたXML(ファイル)は、以下のようなものです:
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" parent="1" style="shape=ellipse;fillColor=#33CCFF" value="Objective" vertex="1">
<mxGeometry as="geometry" height="40" width="100" x="262" y="90"/>
</mxCell>
</root>
ただし、画面の結果は常にグリッドのみです
私は私は、Javaで返される情報を含むXMLオブジェクトを持っnode
値を見るために行dec.decode(node, graph.getModel());
をデバッグします。
Chromeでは、コンソールにメッセージは表示されませんが、Firefoxでテストすると、「graph.propertiesファイルにXML解析エラーがあります」という警告が表示されますが、このファイルはありませんXML(実際には、私はこのファイルが何であるか分かりません)。また、私はまだ問題を解決していないが、私は新たな証拠を持ってここに
graph.properties
alreadyConnected=Nodes already connected
containsValidationErrors=Contains validation errors
updatingDocument=Updating Document. Please wait...
updatingSelection=Updating Selection. Please wait...
collapse-expand=Collapse/Expand
doubleClickOrientation=Doubleclick to change orientation
close=Close
error=Error
done=Done
cancel=Cancel
ok=OK
UPDATE
をファイルを貼り付けています。
dec.decode(node, graph.getModel());
行をデバッグすると、dec
変数の2つのプロパティがあります。 XMLDocumentと空の配列。問題はエンコード部分にある可能性がありますが、私はpage about mxCodecにヒントが見つかりませんでした。