| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import WithContextLoader from "./WithContextLoader" | 
					
						
							|  |  |  | import TagRenderingConfig from "./TagRenderingConfig" | 
					
						
							|  |  |  | import LineRenderingConfigJson from "./Json/LineRenderingConfigJson" | 
					
						
							| 
									
										
										
										
											2024-02-12 12:39:35 +01:00
										 |  |  | import { TagUtils } from "../../Logic/Tags/TagUtils" | 
					
						
							|  |  |  | import { TagsFilter } from "../../Logic/Tags/TagsFilter" | 
					
						
							| 
									
										
										
										
											2021-10-20 02:01:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class LineRenderingConfig extends WithContextLoader { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     public readonly color: TagRenderingConfig | 
					
						
							|  |  |  |     public readonly width: TagRenderingConfig | 
					
						
							| 
									
										
										
										
											2024-04-01 01:39:04 +02:00
										 |  |  |     public readonly dashArray: string | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     public readonly lineCap: TagRenderingConfig | 
					
						
							|  |  |  |     public readonly offset: TagRenderingConfig | 
					
						
							|  |  |  |     public readonly fill: TagRenderingConfig | 
					
						
							|  |  |  |     public readonly fillColor: TagRenderingConfig | 
					
						
							| 
									
										
										
										
											2021-10-22 01:42:44 +02:00
										 |  |  |     public readonly leftRightSensitive: boolean | 
					
						
							| 
									
										
										
										
											2024-02-20 13:33:38 +01:00
										 |  |  |     public readonly imageAlongWay: { if?: TagsFilter; then: string }[] | 
					
						
							| 
									
										
										
										
											2021-10-28 03:15:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-20 02:01:27 +02:00
										 |  |  |     constructor(json: LineRenderingConfigJson, context: string) { | 
					
						
							|  |  |  |         super(json, context) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this.color = this.tr("color", "#0000ff") | 
					
						
							|  |  |  |         this.width = this.tr("width", "7") | 
					
						
							| 
									
										
										
										
											2024-04-01 01:39:04 +02:00
										 |  |  |         this.dashArray = json.dashArray | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this.lineCap = this.tr("lineCap", "round") | 
					
						
							|  |  |  |         this.fill = this.tr("fill", undefined) | 
					
						
							|  |  |  |         this.fillColor = this.tr("fillColor", undefined) | 
					
						
							| 
									
										
										
										
											2024-02-12 12:39:35 +01:00
										 |  |  |         this.imageAlongWay = [] | 
					
						
							|  |  |  |         if (json.imageAlongWay) { | 
					
						
							|  |  |  |             if (typeof json.imageAlongWay === "string") { | 
					
						
							|  |  |  |                 this.imageAlongWay.push({ | 
					
						
							|  |  |  |                     then: json.imageAlongWay, | 
					
						
							|  |  |  |                 }) | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 for (let i = 0; i < json.imageAlongWay.length; i++) { | 
					
						
							|  |  |  |                     const imgAlong = json.imageAlongWay[i] | 
					
						
							|  |  |  |                     const ctx = context + ".imageAlongWay[" + i + "]" | 
					
						
							| 
									
										
										
										
											2024-02-20 13:33:38 +01:00
										 |  |  |                     if (!imgAlong.then.endsWith(".png")) { | 
					
						
							| 
									
										
										
										
											2024-02-12 12:39:35 +01:00
										 |  |  |                         throw "An imageAlongWay should always be a PNG image" | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2024-02-20 13:33:38 +01:00
										 |  |  |                     this.imageAlongWay.push({ | 
					
						
							|  |  |  |                         if: TagUtils.Tag(imgAlong.if, ctx), | 
					
						
							|  |  |  |                         then: imgAlong.then, | 
					
						
							|  |  |  |                     }) | 
					
						
							| 
									
										
										
										
											2024-02-12 12:39:35 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-10-28 03:15:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-23 16:51:31 +01:00
										 |  |  |         if (typeof json.offset === "string") { | 
					
						
							|  |  |  |             json.offset = parseFloat(json.offset) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.leftRightSensitive = json.offset !== undefined && json.offset !== 0 | 
					
						
							| 
									
										
										
										
											2021-10-28 03:15:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this.offset = this.tr("offset", "0") | 
					
						
							| 
									
										
										
										
											2021-10-20 02:01:27 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |