站台详细信息

This commit is contained in:
joylink_zhaoerwei 2023-05-30 18:06:52 +08:00
parent 0a0cb0a77a
commit 618752e037
2 changed files with 99 additions and 13 deletions

View File

@ -3,6 +3,7 @@ import {
GraphicData,
JlGraphic,
JlGraphicTemplate,
VectorText,
getRectangleCenter,
} from 'src/jlgraphic';
@ -28,43 +29,94 @@ export interface IPlatformData extends GraphicData {
eq(other: IPlatformData): boolean;
}
//站台颜色
export enum PlatformColorEnum {
blue = '0x0fe81f', //站台的颜色
lightBlue = '0x55d15d',
yellow = '0xfbff00',
white = '0xffffff',
lozengeRed = '0xff0000', //站台旁的菱形图标
whiteNumbers = '0xffffff', //站台旁白色数字
HCharYellow = '0xfbff00', //站台旁的H字符
HCharWhite = '0xffffff',
HCharRed = '0xff0000',
doorBlue = '0x008000', //屏蔽门的颜色
doorRed = '0xff0000',
}
const platformConsts = {
width: 60,
height: 20,
lineWidth: 3,
besideFontSize: 12,
doorOpenSpacing: 5,
doorPlatformSpacing: 10,
besideSpacing: 10,
};
export class Platform extends JlGraphic {
static Type = 'Platform';
platformGraphic: Graphics;
doorGraphic: Graphics;
besideGraphic: Graphics;
codeGraph: VectorText = new VectorText(''); //站台旁数字、字符
constructor() {
super(Platform.Type);
this.platformGraphic = new Graphics();
this.doorGraphic = new Graphics();
this.besideGraphic = new Graphics();
this.addChild(this.platformGraphic);
this.addChild(this.doorGraphic);
this.addChild(this.besideGraphic);
this.addChild(this.codeGraph);
this.codeGraph.setVectorFontSize(platformConsts.besideFontSize);
}
get datas(): IPlatformData {
return this.getDatas<IPlatformData>();
}
doRepaint(): void {
const width = this.datas.width;
const height = this.datas.height;
//屏蔽门
const doorGraphic = this.doorGraphic;
doorGraphic.clear();
if (this.datas.hasdoor) {
doorGraphic.clear();
doorGraphic.lineStyle(
this.datas.lineWidth,
new Color(this.datas.lineColorDoor)
);
const width = this.datas.width;
const height = this.datas.height;
doorGraphic.moveTo(
-width / 2 - this.datas.lineWidth / 2,
-height / 2 - 10
);
doorGraphic.lineTo(
width / 2 + this.datas.lineWidth / 2,
-height / 2 - 10
);
//屏蔽门打开
if (this.datas.hasdoor) {
doorGraphic.lineTo(
-platformConsts.doorOpenSpacing,
-height / 2 - platformConsts.doorPlatformSpacing
);
doorGraphic.moveTo(
platformConsts.doorOpenSpacing,
-height / 2 - platformConsts.doorPlatformSpacing
);
doorGraphic.lineTo(
width / 2 + this.datas.lineWidth / 2,
-height / 2 - platformConsts.doorPlatformSpacing
);
} else {
doorGraphic.lineTo(
width / 2 + this.datas.lineWidth / 2,
-height / 2 - platformConsts.doorPlatformSpacing
);
}
}
/* doorGraphic.position.set(
0,
height + platformConsts.doorPlatformSpacing * 2
); */
//站台
const platformGraphic = this.platformGraphic;
platformGraphic.clear();
platformGraphic.lineStyle(
@ -77,6 +129,39 @@ export class Platform extends JlGraphic {
const rect = new Rectangle(0, 0, this.datas.width, this.datas.height);
platformGraphic.pivot = getRectangleCenter(rect);
this.position.set(this.datas.point.x, this.datas.point.y);
//站台旁菱形图标
const besideGraphic = this.besideGraphic;
besideGraphic.clear();
if (this.datas.hasdoor) {
besideGraphic.lineStyle(1, new Color(PlatformColorEnum.lozengeRed));
besideGraphic.drawRect(
0,
0,
this.datas.height / 4,
this.datas.height / 4
);
const rect = new Rectangle(
0,
0,
this.datas.height / 4,
this.datas.height / 4
);
besideGraphic.pivot = getRectangleCenter(rect);
besideGraphic.rotation = Math.PI / 4;
besideGraphic.position.set(
-width / 2 - this.datas.lineWidth / 2 - platformConsts.besideSpacing,
0
);
}
//站台旁的数字、字符
const codeGraph = this.codeGraph;
codeGraph.text = 'H';
codeGraph.anchor.set(0.5);
codeGraph.position.set(
-width / 2 - this.datas.lineWidth / 2 - platformConsts.besideSpacing,
0
);
codeGraph.style.fill = PlatformColorEnum.HCharYellow;
}
}
@ -89,12 +174,12 @@ export class PlatformTemplate extends JlGraphicTemplate<Platform> {
height: number;
constructor() {
super(Platform.Type);
this.lineWidth = 2;
this.lineColor = '#000000';
this.lineColorDoor = '0x008000';
this.lineWidth = platformConsts.lineWidth;
this.lineColor = PlatformColorEnum.yellow;
this.lineColorDoor = PlatformColorEnum.doorBlue;
this.hasdoor = true;
this.width = 100;
this.height = 30;
this.width = platformConsts.width;
this.height = platformConsts.height;
}
new(): Platform {
return new Platform();

View File

@ -14,7 +14,7 @@ import {
import { IPlatformData, Platform, PlatformTemplate } from './Platform';
export interface ILinkDrawOptions {
export interface IPlatformDrawOptions {
newData: () => IPlatformData;
}
@ -85,6 +85,7 @@ export class PlatformDraw extends GraphicDrawAssistant<
const height = template.height;
doorGraphic.moveTo(-width / 2 - template.lineWidth / 2, -height / 2 - 10);
doorGraphic.lineTo(width / 2 + template.lineWidth / 2, -height / 2 - 10);
doorGraphic.position.set(p.x, p.y);
}
//站台