Author:赵志乾
Date:2024-06-22
Declaration:All Right Reserved!!!
1. 类图
2. 代码解析
//************************核心字段*************************
// Network所属的level
private transient Level level;
// Network的绘制模式
private ShapeDrawMode drawMode;
// Network的z轴坐标
private double z;
//************************构造函数*************************
// Network的构造函数需要指定其所属的owner(即空间坐标基准),以及名称
public Network(Agent owner, String name) {
super(owner, name);
drawMode = ShapeDrawMode.SHAPE_DRAW_2D3D;
z=0;
}
//****************************Network的绘制模式*************************
// 设置绘制模式;绘制模式只能设置一次,设置后不允许变更
public void setDrawMode(ShapeDrawMode drawMode) {
if (drawMode != this.drawMode&&this.drawMode!=null) {
error("绘制模式不允许变更");
}
this.drawMode = drawMode ;
}
// 获取Network的绘制模式
public ShapeDrawMode getDrawMode() {
// 当Network位于level上时,其绘制模式被level的绘制模式覆盖
if (this.level != null) {
return this.level.getDrawMode();
}
return this.drawMode;
}
//**************************Network的Z向高度*****************************
// 设置Network的Z向高度
public void setZ(double z) {
// 检查是否可以变更,当Network完成initialize后,将不再允许变更Z向高度
this.checkForModify();
this.z = z;
}
// 获取Network的Z向高度
public double getZ() {
return this.z;
}
//**************************Network所属的Level**************************
// 获取Network所属的Level
public Level getLevel() {
return this.level;
}
// 设置Network所属的Level
public void setLevel(Level level) {
// 检查是否可以变更level,当Network完成initialize后,将不再允许设置level
this.checkForModify();
// 只能设置一次level
if (this.level != null) {
error("This space markup element is already contained in some level");
}
this.level = level;
}