Javascript 如何用mxgraph替换图像

Javascript 如何用mxgraph替换图像,javascript,mxgraph,Javascript,Mxgraph,我是一个新的mxgraph用户,所以我对mxgraph的了解很差。我将尽可能清楚地解释我的问题:我想使用mxgraph将一个图像替换为一个新图像。有没有办法用mxgraph做到这一点?我尝试了graph.setCellStyles函数,或者这样: mxGraph.prototype.getImage = function(state) { if (state != null && state.style != null) { return state.style[

我是一个新的mxgraph用户,所以我对mxgraph的了解很差。我将尽可能清楚地解释我的问题:我想使用mxgraph将一个图像替换为一个新图像。有没有办法用mxgraph做到这一点?我尝试了
graph.setCellStyles
函数,或者这样:

mxGraph.prototype.getImage = function(state)
{
  if (state != null && state.style != null)
  {
    return state.style[mxConstants.STYLE_IMAGE];
  }
  return null;
}
但它不起作用。提前感谢您。

Java解决方案:

graph.getView().getState(cell).getStyle().replace(mxConstants.STYLE_IMAGE, new ImageIcon( GraphViewer.class.getResource("/com/mxgraph/examples/swing/images/cube_green.png")));