javascript - 如何用 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;
}
但它不起作用。先感谢您。
解决方案
Java解决方案:
graph.getView().getState(cell).getStyle().replace(mxConstants.STYLE_IMAGE, new ImageIcon( GraphViewer.class.getResource("/com/mxgraph/examples/swing/images/cube_green.png")));
推荐阅读
- java - 如何快速找到给出最大值的点?请使用 Java 或 C++ 代码
- octave - Octave:根据向量设置矩阵值
- r - R如何累积总和直到条件,包括条件改变的行
- vba - 如何防止用户在 MS 项目中查看 VB 代码,但允许他们通过自定义 UI 运行代码?
- assembly - 如何写ARMGNU汇编代码写C = A + B?
- react-native - TypeError:null 不是评估“_reactNative.NativeModules.RNDateTimePickerManager.getDefaultDisplayValue”的对象
- c - fprintf() 函数不起作用(它没有写入文件)
- c++ - CLion 代码补全仅适用于点/句点
- javascript - Setter 和扩展属性同名
- windows - 停止 Vmmem 使用 RAM