rt-sim-training-client/src/jmapNew/shape/StationStand/ETime.js

72 lines
2.0 KiB
JavaScript
Raw Normal View History

2019-11-29 12:51:58 +08:00
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
class ETime extends Group {
2020-03-27 17:26:17 +08:00
constructor(model) {
super();
this.model = model;
this.isNew = false;
}
create() {
if (!this.isNew) {
2020-09-09 13:55:42 +08:00
const model = this.model.modelData;
2020-03-27 17:26:17 +08:00
const style = this.model.style;
2020-09-09 13:55:42 +08:00
const timeDrict = model.right ? 1 : -1;
const timeX = model.position.x + style.StationStand.stopTime.position * timeDrict * (style.StationStand.stopTime.offset.x - model.width / 2);
const timeY = model.position.y + timeDrict * (style.StationStand.stopTime.offset.y - model.height / 2);
2020-03-27 17:26:17 +08:00
this.isNew = true;
this.time = new Text({
2020-09-09 13:55:42 +08:00
zlevel: this.model.zlevel,
z: this.model.z,
2020-03-27 17:26:17 +08:00
style: {
2020-09-09 13:55:42 +08:00
x: timeX,
y: timeY,
2020-03-27 17:26:17 +08:00
fontWeight: style.textStyle.fontWeight,
2020-09-09 13:55:42 +08:00
fontSize: style.StationStand.stopTime.textFontSize,
2020-03-27 17:26:17 +08:00
fontFamily: style.fontFamily,
2020-09-09 13:55:42 +08:00
text: model.parkingTime || '30',
2020-03-27 17:26:17 +08:00
textFill: style.StationStand.stopTime.textColor,
textAlign: style.textStyle.textAlign,
textVerticalAlign: style.textStyle.textVerticalAlign
}
});
this.add(this.time);
}
}
setName(val) {
this.time.setStyle('text', val);
}
setColor(color) {
this.create();
this.time.setStyle('textFill', color);
}
hideMode() {
this.time && this.time.hide();
2020-03-27 17:26:17 +08:00
}
showMode() {
this.create();
this.time && this.time.show();
2020-03-27 17:26:17 +08:00
}
2020-09-09 13:55:42 +08:00
recover() {
this.hideMode();
}
2020-09-15 17:08:28 +08:00
setState(model) {
2020-09-15 18:28:32 +08:00
// 停站时间
2020-09-15 17:08:28 +08:00
if (Number(model.parkingTime) > 0) {
this.showMode();
this.setName(model.parkingTime);
}
}
2019-11-29 12:51:58 +08:00
}
export default ETime;