rt-sim-training-client/src/jmapNew/shape/Station/index.js

113 lines
3.6 KiB
JavaScript
Raw Normal View History

2019-11-29 12:51:58 +08:00
/*
* 车站
*/
import Group from 'zrender/src/container/Group';
import ETextName from '../element/ETextName';
import EHighlight from '../element/EHighlight'; // 名称文字 (共有)
2019-12-04 14:59:04 +08:00
import EturnBack from './EturnBack';
2019-11-29 12:51:58 +08:00
export default class Station extends Group {
constructor(model, style) {
super();
this._code = model.code;
this._type = model._type;
this.zlevel = model.zlevel;
this.z = 40;
this.model = model;
this.style = style;
this.create();
2019-12-04 14:59:04 +08:00
this.createPullBack(); // 创建按图折返
this.setState(model);
this.checkIsDrawMap();
}
2019-11-29 12:51:58 +08:00
create() {
const model = this.model;
const style = this.style;
2019-11-29 12:51:58 +08:00
if (model.visible) {
// 公里标名称是否显示
this.stationText = new ETextName({
zlevel: this.zlevel,
z: this.z,
position: [0, 0],
x: model.position.x,
y: model.position.y,
fontWeight: model.fontWeight,
fontSize: model.nameFont || 18,
fontFamily: style.fontFamily,
text: model.name,
textAlign: 'middle',
textVerticalAlign: 'top',
textFill: model.nameFontColor
});
this.add(this.stationText);
const path = window.location.href;
if (style.Station.kmPostShow || path.includes('/map/draw')) {
// 公里标是否显示
let direction = 1;
if (this.style.Station.kilometerPosition == 'up') {
direction = -1;
}
this.mileageText = new ETextName({
zlevel: this.zlevel,
z: this.z,
position: [0, 0],
x: model.position.x,
y: model.position.y + ((parseInt(model.nameFont) + 2) * direction),
fontWeight: model.fontWeight,
fontSize: model.kmPostFont || 18,
fontFamily: style.fontFamily,
text: model.kmPost,
textAlign: 'middle',
textVerticalAlign: 'top',
textFill: model.kmPostFontColor
});
this.add(this.mileageText);
}
}
}
2019-12-04 14:59:04 +08:00
createPullBack() {
const model = this.model;
const style = this.style;
if (model.visible && model.isCreateTurnBack) {
2019-12-04 14:59:04 +08:00
this.turnBack = new EturnBack({
zlevel: this.zlevel,
z: this.z,
position: [0, 0],
x: model.position.x,
y: model.position.y,
fontWeight: model.fontWeight,
fontSize: model.kmPostFont || 18,
fontFamily: style.fontFamily,
text: model.kmPost,
textAlign: 'middle',
textVerticalAlign: 'top',
textFill: model.kmPostFontColor
});
this.add(this.turnBack);
}
}
2019-11-29 12:51:58 +08:00
// eslint-disable-next-line no-unused-vars
setState(model) {
}
2019-11-29 12:51:58 +08:00
getShapeTipPoint() {
return null;
}
drawSelected(selected) {
this.highlight && this.highlight.drawSelected(selected);
}
checkIsDrawMap() {
const path = window.location.href;
if (path.includes('/map/draw')) {
this.highlight = new EHighlight(this);
this.add(this.highlight);
this.on('mouseout', () => { this.highlight.mouseout(); });
this.on('mouseover', () => { this.highlight.mouseover(); });
}
}
2019-11-29 12:51:58 +08:00
}