车站固定元素更换,圆点固定
This commit is contained in:
parent
e855b7f85f
commit
925ce62a9c
@ -21,13 +21,12 @@ const stationConsts = {
|
||||
borderWidth: 1,
|
||||
borderColor: '0xff0000',
|
||||
fillColor: '0xff0000',
|
||||
circleOffsetY: -20,
|
||||
transferRadius: 3.5,
|
||||
transferWidth: 0.2,
|
||||
transferColor: '0x0fe81f',
|
||||
codeColor: '0xF48815',
|
||||
codeFontSize: 22,
|
||||
lineWidth: 3,
|
||||
codeOffsetY: 20,
|
||||
};
|
||||
//子元素--圆点
|
||||
class circleGraphic extends Container {
|
||||
@ -54,7 +53,6 @@ class circleGraphic extends Container {
|
||||
circle.beginFill(stationConsts.fillColor, 1);
|
||||
circle.drawCircle(0, 0, stationConsts.radius);
|
||||
circle.endFill;
|
||||
circle.position.set(0, stationConsts.circleOffsetY);
|
||||
const arcGraphicUp = this.arcUp;
|
||||
const arcGraphicDown = this.arcDown;
|
||||
const arrowUpGraphic = this.arrowUp;
|
||||
@ -67,11 +65,8 @@ class circleGraphic extends Container {
|
||||
this.drawTransfer(arcGraphicUp, arrowUpGraphic);
|
||||
this.drawTransfer(arcGraphicDown, arrowDownGraphic);
|
||||
arcGraphicDown.rotation = Math.PI;
|
||||
arrowDownGraphic.rotation = Math.PI - (Math.PI * 1) / 25;
|
||||
arrowDownGraphic.position.set(
|
||||
stationConsts.transferRadius,
|
||||
stationConsts.circleOffsetY
|
||||
);
|
||||
arrowDownGraphic.rotation = (Math.PI * 24) / 25;
|
||||
arrowDownGraphic.position.set(stationConsts.transferRadius, 0);
|
||||
}
|
||||
}
|
||||
drawTransfer(transferGraphic: Graphics, arrowGraphic: Graphics): void {
|
||||
@ -87,7 +82,6 @@ class circleGraphic extends Container {
|
||||
Math.PI,
|
||||
false
|
||||
);
|
||||
transferGraphic.position.set(0, stationConsts.circleOffsetY);
|
||||
arrowGraphic.lineStyle(
|
||||
stationConsts.transferWidth,
|
||||
new Color(stationConsts.transferColor)
|
||||
@ -96,35 +90,39 @@ class circleGraphic extends Container {
|
||||
arrowGraphic.lineTo(1, 1);
|
||||
arrowGraphic.moveTo(0, 0);
|
||||
arrowGraphic.lineTo(-1, 1);
|
||||
arrowGraphic.position.set(
|
||||
-stationConsts.transferRadius,
|
||||
stationConsts.circleOffsetY
|
||||
);
|
||||
arrowGraphic.position.set(-stationConsts.transferRadius, 0);
|
||||
arrowGraphic.pivot = new Point(0, 0);
|
||||
arrowGraphic.rotation = -(Math.PI * 1) / 25;
|
||||
}
|
||||
}
|
||||
export class StationLine extends JlGraphic {
|
||||
static Type = 'stationLine';
|
||||
codeGraph: VectorText = new VectorText(''); //车站名
|
||||
circleGraphic: circleGraphic = new circleGraphic();
|
||||
codeGraph: VectorText = new VectorText(''); //车站名
|
||||
|
||||
constructor() {
|
||||
super(StationLine.Type);
|
||||
this.addChild(this.codeGraph);
|
||||
this.addChild(this.circleGraphic);
|
||||
this.circleGraphic.name = 'circle';
|
||||
this.codeGraph.name = 'trainLineCode';
|
||||
}
|
||||
|
||||
get datas(): IStationLineData {
|
||||
return this.getDatas<IStationLineData>();
|
||||
}
|
||||
doRepaint(): void {
|
||||
this.circleGraphic.draw(this.datas);
|
||||
const codeGraph = this.codeGraph;
|
||||
codeGraph.text = this.datas?.code || '车站StationLine';
|
||||
codeGraph.style.fill = stationConsts.codeColor;
|
||||
codeGraph.setVectorFontSize(stationConsts.codeFontSize);
|
||||
codeGraph.anchor.set(0.5);
|
||||
this.circleGraphic.draw(this.datas);
|
||||
if (this.datas.childTransforms?.length) {
|
||||
const pos = this.datas.childTransforms[0].transform.position;
|
||||
codeGraph.position.set(pos.x, pos.y);
|
||||
} else {
|
||||
codeGraph.position.set(0, stationConsts.codeOffsetY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,19 +82,19 @@ export class stationLineInteraction extends GraphicInteractionPlugin<StationLine
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
g.circleGraphic.eventMode = 'static';
|
||||
g.circleGraphic.cursor = 'pointer';
|
||||
g.circleGraphic.draggable = true;
|
||||
g.circleGraphic.selectable = true;
|
||||
g.circleGraphic.transformSave = true;
|
||||
g.codeGraph.eventMode = 'static';
|
||||
g.codeGraph.cursor = 'pointer';
|
||||
g.codeGraph.draggable = true;
|
||||
g.codeGraph.selectable = true;
|
||||
g.codeGraph.transformSave = true;
|
||||
}
|
||||
unbind(g: StationLine): void {
|
||||
g.eventMode = 'none';
|
||||
g.scalable = false;
|
||||
g.rotatable = false;
|
||||
g.circleGraphic.eventMode = 'none';
|
||||
g.circleGraphic.draggable = false;
|
||||
g.circleGraphic.selectable = false;
|
||||
g.circleGraphic.transformSave = false;
|
||||
g.codeGraph.eventMode = 'none';
|
||||
g.codeGraph.draggable = false;
|
||||
g.codeGraph.selectable = false;
|
||||
g.codeGraph.transformSave = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user