2020-08-21 14:14:26 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import Rect from 'zrender/src/graphic/shape/Rect';
|
|
|
|
import Stop_Route from '@/assets/stop_route.png';
|
|
|
|
import Pattern from 'zrender/src/graphic/Pattern';
|
|
|
|
import JTriangle from '../../utils/JTriangle';
|
|
|
|
|
|
|
|
export default class EStopRouteImg extends Group {
|
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
|
|
|
this.zlevel = model.zlevel;
|
|
|
|
this.z = model.z;
|
|
|
|
this.stopRouteImgList = [];
|
|
|
|
this.create();
|
|
|
|
}
|
|
|
|
create() {
|
2020-09-15 17:40:57 +08:00
|
|
|
const model = this.model.modelData;
|
|
|
|
const style = this.model.style;
|
|
|
|
const modelPoints = model.points;
|
|
|
|
if (model.type !== '04') {
|
|
|
|
const image = new Image(5, 8);
|
|
|
|
image.src = Stop_Route;
|
|
|
|
image.decode()
|
|
|
|
.then(() => {
|
|
|
|
const pattern = new Pattern(image, 'repeat');
|
|
|
|
for (let i = 1; i < modelPoints.length; i++) {
|
|
|
|
const triangle = new JTriangle(modelPoints[i - 1], modelPoints[i]);
|
|
|
|
this.stopRouteImgList.push(new Rect({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z + 1,
|
|
|
|
origin: [modelPoints[i - 1].x, modelPoints[i - 1].y],
|
|
|
|
rotation: -triangle.getRotation(),
|
|
|
|
shape: {
|
|
|
|
x: modelPoints[i - 1].x,
|
|
|
|
y: modelPoints[i - 1].y - style.Section.line.width / 2,
|
|
|
|
width: triangle.getLength(),
|
|
|
|
height: style.Section.line.width
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
fill: pattern
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
this.stopRouteImgList.forEach(item => {
|
|
|
|
this.add(item);
|
|
|
|
item.hide();
|
|
|
|
});
|
2020-08-21 14:14:26 +08:00
|
|
|
});
|
2020-09-15 17:40:57 +08:00
|
|
|
}
|
2020-08-21 14:14:26 +08:00
|
|
|
}
|
|
|
|
setModel(dx, dy) {
|
|
|
|
}
|
|
|
|
setCursor(mouseStyle) {
|
|
|
|
this.imageBg.attr('cursor', mouseStyle);
|
|
|
|
}
|
2020-09-15 17:40:57 +08:00
|
|
|
|
|
|
|
recover() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setState() {
|
|
|
|
|
|
|
|
}
|
2020-08-21 14:14:26 +08:00
|
|
|
}
|