我的供应链模型中有两种类型的边:demand_links 和 supply_links。所有链接的默认颜色为灰色。但是我想在每次更改 demand_link 的属性时将 demand_links 的颜色更改为红色(注意:边缘是通过边缘创建者自定义的边缘代理)。这该怎么做?
下面是我的简单测试代码,它没有用。
public class EdgeStyle2D extends DefaultStyleOGL2D {
@Override
public Color getColor(Object o){
// if (((CustomEdge) o).getCurrent_dl() == 1) {
// return Color.RED;
// }
// else {
// return Color.BLACK;
// }
if (o instanceof Distributor)
return Color.YELLOW;
return null;
}
}
初始化时出现错误。
Caused by: java.lang.ClassCastException: class supplyChainSystem.EdgeStyle2D cannot be cast to class repast.simphony.visualizationOGL2D.EdgeStyleOGL2D (supplyChainSystem.EdgeStyle2D and repast.simphony.visualizationOGL2D.EdgeStyleOGL2D are in unnamed module of loader repast.simphony.plugin.ExtendablePluginClassLoader @61af1510)