首页 > 解决方案 > 如何用 mxgraph 替换图像

问题描述

我是一个新的 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;
}

但它不起作用。先感谢您。

标签: javascriptmxgraph

解决方案


Java解决方案:

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

推荐阅读