修改代码
This commit is contained in:
parent
bdf42ae492
commit
540dc4e346
@ -6,42 +6,48 @@ class ESigPass extends Group {
|
||||
constructor(model) {
|
||||
super();
|
||||
this.model = model;
|
||||
this._create();
|
||||
this.isNew = false;
|
||||
}
|
||||
|
||||
_create() {
|
||||
const model = this.model;
|
||||
const style = this.model.style;
|
||||
const rotation = model.drict != 1? 0 : Math.PI;
|
||||
const point = arrows(model.x, model.y, style.Signal.signalAutoWidth, style.Signal.lamp.signalR * 0.8);
|
||||
this.arrows = new Polygon({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
rotation: rotation,
|
||||
shape: {
|
||||
points: point
|
||||
},
|
||||
style: {
|
||||
stroke: model.stroke,
|
||||
lineWidth: model.lineWidth,
|
||||
fill: model.fill
|
||||
}
|
||||
});
|
||||
this.add(this.arrows);
|
||||
if (!this.isNew) {
|
||||
const model = this.model;
|
||||
const style = this.model.style;
|
||||
const rotation = model.drict != 1? 0 : Math.PI;
|
||||
const point = arrows(model.x, model.y, style.Signal.signalAutoWidth, style.Signal.lamp.signalR * 0.8);
|
||||
this.arrows = new Polygon({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
rotation: rotation,
|
||||
shape: {
|
||||
points: point
|
||||
},
|
||||
style: {
|
||||
stroke: model.stroke,
|
||||
lineWidth: model.lineWidth,
|
||||
fill: model.fill
|
||||
}
|
||||
});
|
||||
this.add(this.arrows);
|
||||
this.isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 停止动画
|
||||
animationRecover() {
|
||||
this._create();
|
||||
this.arrows.stopAnimation(false);
|
||||
}
|
||||
|
||||
// 箭头颜色
|
||||
setColor(color) {
|
||||
this._create();
|
||||
this.arrows.setStyle('fill', color);
|
||||
}
|
||||
|
||||
// 箭头闪烁
|
||||
arrowsAnimation() {
|
||||
this._create();
|
||||
const style = this.model.style;
|
||||
const fill = this.arrows.style.Signal.fill;
|
||||
this.arrows.animate(true)
|
||||
@ -54,11 +60,13 @@ class ESigPass extends Group {
|
||||
|
||||
// 隐藏
|
||||
hide() {
|
||||
this._create();
|
||||
this.arrows.hide();
|
||||
}
|
||||
|
||||
// 显示
|
||||
show() {
|
||||
this._create();
|
||||
this.arrows.show();
|
||||
}
|
||||
}
|
||||
|
@ -8,97 +8,99 @@ class ESigButton extends Group {
|
||||
constructor(model) {
|
||||
super();
|
||||
this.model = model;
|
||||
this._create();
|
||||
this.isNew = false;
|
||||
}
|
||||
|
||||
_create() {
|
||||
const model = this.model;
|
||||
const style = this.model.style;
|
||||
const padding = 1;
|
||||
const r = style.Signal.lamp.signalR * 0.8;
|
||||
if (!this.isNew) {
|
||||
const model = this.model;
|
||||
const style = this.model.style;
|
||||
const padding = 1;
|
||||
const r = style.Signal.lamp.signalR * 0.8;
|
||||
|
||||
this.style = style;
|
||||
this._subType = 'SignalButton';
|
||||
this.sigNormalButtom = new Rect({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
_subType: 'SignalButton',
|
||||
_val: '1',
|
||||
shape: {
|
||||
x: model.x - style.Signal.lamp.signalR,
|
||||
y: model.y - r + r * model.posit,
|
||||
width: style.Signal.lamp.signalR * 2,
|
||||
height: style.Signal.lamp.signalR * 2
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0.2,
|
||||
stroke: style.Signal.button.signalButtonDashColor,
|
||||
fill: style.Signal.button.signalButtonColor
|
||||
}
|
||||
});
|
||||
|
||||
this.sigNormalButtom = new Rect({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
_subType: this._subType,
|
||||
_val: '1',
|
||||
shape: {
|
||||
x: model.x - style.Signal.lamp.signalR,
|
||||
y: model.y - r + r * model.posit,
|
||||
width: style.Signal.lamp.signalR * 2,
|
||||
height: style.Signal.lamp.signalR * 2
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0.2,
|
||||
stroke: style.Signal.button.signalButtonDashColor,
|
||||
fill: style.Signal.button.signalButtonColor
|
||||
}
|
||||
});
|
||||
this.sigReentryButton = new Circle({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
_subType: 'SignalButton',
|
||||
_val: '2', // 折返按钮
|
||||
shape: {
|
||||
cx: model.x,
|
||||
cy: model.y - 5 / 2 * r * model.posit,
|
||||
r: style.Signal.lamp.signalR
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0.2,
|
||||
stroke: style.Signal.button.signalButtonDashColor,
|
||||
fill: style.Signal.button.signalButtonColor
|
||||
}
|
||||
});
|
||||
|
||||
this.sigReentryButton = new Circle({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
_subType: this._subType,
|
||||
_val: '2', // 折返按钮
|
||||
shape: {
|
||||
cx: model.x,
|
||||
cy: model.y - 5 / 2 * r * model.posit,
|
||||
r: style.Signal.lamp.signalR
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0.2,
|
||||
stroke: style.Signal.button.signalButtonDashColor,
|
||||
fill: style.Signal.button.signalButtonColor
|
||||
}
|
||||
});
|
||||
this.sigNormalButtomDown = new Polyline({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
silent: true,
|
||||
shape: { points: [
|
||||
[model.x - padding + r, this.sigNormalButtom.shape.y + padding],
|
||||
[model.x + padding - r, this.sigNormalButtom.shape.y + padding],
|
||||
[model.x + padding - r, this.sigNormalButtom.shape.y + padding * 2 + r]
|
||||
] },
|
||||
style: {
|
||||
lineWidth: 0.8,
|
||||
stroke: style.backgroundColor
|
||||
}
|
||||
});
|
||||
|
||||
this.sigNormalButtomDown = new Polyline({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
silent: true,
|
||||
shape: { points: [
|
||||
[model.x - padding + r, this.sigNormalButtom.shape.y + padding],
|
||||
[model.x + padding - r, this.sigNormalButtom.shape.y + padding],
|
||||
[model.x + padding - r, this.sigNormalButtom.shape.y + padding * 2 + r]
|
||||
] },
|
||||
style: {
|
||||
lineWidth: 0.8,
|
||||
stroke: style.backgroundColor
|
||||
}
|
||||
});
|
||||
this.sigReentryButtonDown = new Arc({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
silent: true,
|
||||
shape: {
|
||||
cx: this.sigReentryButton.shape.cx,
|
||||
cy: this.sigReentryButton.shape.cy,
|
||||
r: this.sigReentryButton.shape.r - padding,
|
||||
startAngle: Math.PI * 8 / 5,
|
||||
endAngle: Math.PI * 4 / 5,
|
||||
clockwise: false
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0.8,
|
||||
stroke: style.backgroundColor
|
||||
}
|
||||
});
|
||||
|
||||
this.sigReentryButtonDown = new Arc({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
silent: true,
|
||||
shape: {
|
||||
cx: this.sigReentryButton.shape.cx,
|
||||
cy: this.sigReentryButton.shape.cy,
|
||||
r: this.sigReentryButton.shape.r - padding,
|
||||
startAngle: Math.PI * 8 / 5,
|
||||
endAngle: Math.PI * 4 / 5,
|
||||
clockwise: false
|
||||
},
|
||||
style: {
|
||||
lineWidth: 0.8,
|
||||
stroke: style.backgroundColor
|
||||
}
|
||||
});
|
||||
|
||||
this.add(this.sigNormalButtom);
|
||||
this.add(this.sigReentryButton);
|
||||
this.hide();
|
||||
this.add(this.sigNormalButtom);
|
||||
this.add(this.sigReentryButton);
|
||||
this.hide();
|
||||
this.isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
hide() {
|
||||
this._create();
|
||||
this.sigNormalButtom.hide();
|
||||
this.sigReentryButton.hide();
|
||||
}
|
||||
|
||||
show() {
|
||||
this._create();
|
||||
this.sigNormalButtom.show();
|
||||
this.sigReentryButton.show();
|
||||
}
|
||||
|
@ -5,43 +5,50 @@ class ESigDelay extends Group {
|
||||
constructor(model) {
|
||||
super();
|
||||
this.model = model;
|
||||
this._create();
|
||||
this.isNew = false;
|
||||
}
|
||||
|
||||
_create() {
|
||||
const model = this.model;
|
||||
this.name = new Text({
|
||||
_subType: model._subType,
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
silent: model.silent || false,
|
||||
style: {
|
||||
x: model.x,
|
||||
y: model.y,
|
||||
text: model.text,
|
||||
textFont: model.textFont,
|
||||
textFill: model.textFill,
|
||||
textAlign: model.textAlign,
|
||||
textPosition: model.textPosition || 'inside',
|
||||
textVerticalAlign: model.textVerticalAlign || null
|
||||
}
|
||||
});
|
||||
this.add(this.name);
|
||||
if (!this.isNew) {
|
||||
const model = this.model;
|
||||
this.name = new Text({
|
||||
_subType: model._subType,
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
silent: model.silent || false,
|
||||
style: {
|
||||
x: model.x,
|
||||
y: model.y,
|
||||
text: model.text,
|
||||
textFont: model.textFont,
|
||||
textFill: model.textFill,
|
||||
textAlign: model.textAlign,
|
||||
textPosition: model.textPosition || 'inside',
|
||||
textVerticalAlign: model.textVerticalAlign || null
|
||||
}
|
||||
});
|
||||
this.add(this.name);
|
||||
this.isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
setStyle(model) {
|
||||
this._create();
|
||||
this.name.setStyle(model);
|
||||
}
|
||||
|
||||
setColor(color) {
|
||||
this._create();
|
||||
this.name.setStyle('textFill', color);
|
||||
}
|
||||
|
||||
hide() {
|
||||
this._create();
|
||||
this.name.hide();
|
||||
}
|
||||
|
||||
show() {
|
||||
this._create();
|
||||
this.name.show();
|
||||
}
|
||||
}
|
||||
|
@ -6,34 +6,40 @@ class ESigDrict extends Group {
|
||||
constructor(model) {
|
||||
super();
|
||||
this.model = model;
|
||||
this._create();
|
||||
this.isNew = false;
|
||||
}
|
||||
|
||||
_create() {
|
||||
const model = this.model;
|
||||
const style = this.model.style;
|
||||
this.sigDrict = new Polygon({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
shape: {
|
||||
points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR)
|
||||
},
|
||||
style: {
|
||||
stroke: style.backgroundColor,
|
||||
lineWidth: 0.5,
|
||||
fill: style.Signal.route.signalRouteColor
|
||||
}
|
||||
});
|
||||
this.add(this.sigDrict);
|
||||
if (!this.isNew) {
|
||||
const model = this.model;
|
||||
const style = this.model.style;
|
||||
this.sigDrict = new Polygon({
|
||||
zlevel: model.zlevel,
|
||||
z: model.z,
|
||||
shape: {
|
||||
points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR)
|
||||
},
|
||||
style: {
|
||||
stroke: style.backgroundColor,
|
||||
lineWidth: 0.5,
|
||||
fill: style.Signal.route.signalRouteColor
|
||||
}
|
||||
});
|
||||
|
||||
this.add(this.sigDrict);
|
||||
this.isNew = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏
|
||||
hide() {
|
||||
this._create();
|
||||
this.sigDrict.hide();
|
||||
}
|
||||
|
||||
// 显示
|
||||
show() {
|
||||
this._create();
|
||||
this.sigDrict.show();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user