@armyc2.c5isr.renderer/mil-sym-ts-web 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +57 -0
  3. package/buildNode.bat +2 -0
  4. package/buildWeb.bat +2 -0
  5. package/dist/C5Ren.d.ts +6970 -0
  6. package/dist/C5Ren.js +2 -0
  7. package/dist/C5Ren.js.map +1 -0
  8. package/dist/LICENSE +201 -0
  9. package/dist/README.md +57 -0
  10. package/dist/armyc2.c5isr.renderer-mil-sym-ts-web-2.2.0.tgz +0 -0
  11. package/dist/manifest.json +4 -0
  12. package/dist/package.json +16 -0
  13. package/index.ts +169 -0
  14. package/package.bak +50 -0
  15. package/package.json +40 -0
  16. package/package.node.json +43 -0
  17. package/package.pack.json +19 -0
  18. package/package.packWeb.json +16 -0
  19. package/package.web.json +40 -0
  20. package/src/main/ts/android/graphics/Bitmap.ts +7 -0
  21. package/src/main/ts/android/graphics/Paint.ts +26 -0
  22. package/src/main/ts/android/graphics/Path.ts +78 -0
  23. package/src/main/ts/android/graphics/PointF.ts +14 -0
  24. package/src/main/ts/android/graphics/Rect.ts +18 -0
  25. package/src/main/ts/android/graphics/RectF.ts +50 -0
  26. package/src/main/ts/android/graphics/Region.ts +36 -0
  27. package/src/main/ts/android/graphics/Typeface.ts +11 -0
  28. package/src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes.ts +99 -0
  29. package/src/main/ts/armyc2/c5isr/JavaLineArray/CChannelPoints2.ts +34 -0
  30. package/src/main/ts/armyc2/c5isr/JavaLineArray/CELineArray.ts +193 -0
  31. package/src/main/ts/armyc2/c5isr/JavaLineArray/Channels.ts +2971 -0
  32. package/src/main/ts/armyc2/c5isr/JavaLineArray/DISMSupport.ts +4008 -0
  33. package/src/main/ts/armyc2/c5isr/JavaLineArray/POINT2.ts +93 -0
  34. package/src/main/ts/armyc2/c5isr/JavaLineArray/Shape2.ts +89 -0
  35. package/src/main/ts/armyc2/c5isr/JavaLineArray/TacticalLines.ts +515 -0
  36. package/src/main/ts/armyc2/c5isr/JavaLineArray/arraysupport.ts +5403 -0
  37. package/src/main/ts/armyc2/c5isr/JavaLineArray/countsupport.ts +1084 -0
  38. package/src/main/ts/armyc2/c5isr/JavaLineArray/flot.ts +2173 -0
  39. package/src/main/ts/armyc2/c5isr/JavaLineArray/lineutility.ts +4934 -0
  40. package/src/main/ts/armyc2/c5isr/JavaLineArray/ref.ts +7 -0
  41. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/Modifier2.ts +5601 -0
  42. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/P1.ts +14 -0
  43. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/TGLight.ts +648 -0
  44. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsChannelUtility.ts +647 -0
  45. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsMETOC.ts +2994 -0
  46. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsUtility.ts +2663 -0
  47. package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/mdlGeodesic.ts +669 -0
  48. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipPolygon2.ts +971 -0
  49. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipQuad.ts +871 -0
  50. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer.ts +3507 -0
  51. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer2.ts +500 -0
  52. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtility.ts +1089 -0
  53. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityCPOF.ts +2656 -0
  54. package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityGE.ts +1419 -0
  55. package/src/main/ts/armyc2/c5isr/data/genc.json +1407 -0
  56. package/src/main/ts/armyc2/c5isr/data/msd.json +17311 -0
  57. package/src/main/ts/armyc2/c5isr/data/mse.json +18500 -0
  58. package/src/main/ts/armyc2/c5isr/data/svgd.json +31214 -0
  59. package/src/main/ts/armyc2/c5isr/data/svge.json +30558 -0
  60. package/src/main/ts/armyc2/c5isr/graphics2d/AffineTransform.ts +10 -0
  61. package/src/main/ts/armyc2/c5isr/graphics2d/Area.ts +437 -0
  62. package/src/main/ts/armyc2/c5isr/graphics2d/BasicStroke.ts +429 -0
  63. package/src/main/ts/armyc2/c5isr/graphics2d/BasicTypes.ts +7 -0
  64. package/src/main/ts/armyc2/c5isr/graphics2d/BufferedImage.ts +35 -0
  65. package/src/main/ts/armyc2/c5isr/graphics2d/Font.ts +111 -0
  66. package/src/main/ts/armyc2/c5isr/graphics2d/FontMetrics.ts +29 -0
  67. package/src/main/ts/armyc2/c5isr/graphics2d/FontRenderContext.ts +18 -0
  68. package/src/main/ts/armyc2/c5isr/graphics2d/GeneralPath.ts +211 -0
  69. package/src/main/ts/armyc2/c5isr/graphics2d/Graphics2D.ts +80 -0
  70. package/src/main/ts/armyc2/c5isr/graphics2d/IPathIterator.ts +33 -0
  71. package/src/main/ts/armyc2/c5isr/graphics2d/ImageIO.ts +16 -0
  72. package/src/main/ts/armyc2/c5isr/graphics2d/Line2D.ts +726 -0
  73. package/src/main/ts/armyc2/c5isr/graphics2d/PathIterator.ts +141 -0
  74. package/src/main/ts/armyc2/c5isr/graphics2d/Point.ts +112 -0
  75. package/src/main/ts/armyc2/c5isr/graphics2d/Point2D.ts +261 -0
  76. package/src/main/ts/armyc2/c5isr/graphics2d/Polygon.ts +391 -0
  77. package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle.ts +567 -0
  78. package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D.ts +445 -0
  79. package/src/main/ts/armyc2/c5isr/graphics2d/Shape.ts +31 -0
  80. package/src/main/ts/armyc2/c5isr/graphics2d/Stroke.ts +18 -0
  81. package/src/main/ts/armyc2/c5isr/graphics2d/TextLayout.ts +45 -0
  82. package/src/main/ts/armyc2/c5isr/graphics2d/TexturePaint.ts +25 -0
  83. package/src/main/ts/armyc2/c5isr/renderer/IIconRenderer.ts +15 -0
  84. package/src/main/ts/armyc2/c5isr/renderer/IconRenderer.ts +22 -0
  85. package/src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer.ts +269 -0
  86. package/src/main/ts/armyc2/c5isr/renderer/ModifierRenderer.ts +9882 -0
  87. package/src/main/ts/armyc2/c5isr/renderer/PatternFillRenderer.ts +146 -0
  88. package/src/main/ts/armyc2/c5isr/renderer/SinglePointSVGRenderer.ts +1265 -0
  89. package/src/main/ts/armyc2/c5isr/renderer/shapes/arc.ts +64 -0
  90. package/src/main/ts/armyc2/c5isr/renderer/shapes/bcurve.ts +95 -0
  91. package/src/main/ts/armyc2/c5isr/renderer/shapes/ellipse.ts +93 -0
  92. package/src/main/ts/armyc2/c5isr/renderer/shapes/line.ts +114 -0
  93. package/src/main/ts/armyc2/c5isr/renderer/shapes/path.ts +555 -0
  94. package/src/main/ts/armyc2/c5isr/renderer/shapes/pathiterator.ts +62 -0
  95. package/src/main/ts/armyc2/c5isr/renderer/shapes/point.ts +120 -0
  96. package/src/main/ts/armyc2/c5isr/renderer/shapes/rectangle.ts +431 -0
  97. package/src/main/ts/armyc2/c5isr/renderer/shapes/roundedrectangle.ts +99 -0
  98. package/src/main/ts/armyc2/c5isr/renderer/shapes/types.ts +25 -0
  99. package/src/main/ts/armyc2/c5isr/renderer/shapes/utilities.ts +203 -0
  100. package/src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors.ts +104 -0
  101. package/src/main/ts/armyc2/c5isr/renderer/utilities/Color.ts +481 -0
  102. package/src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit.ts +40 -0
  103. package/src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules.ts +1323 -0
  104. package/src/main/ts/armyc2/c5isr/renderer/utilities/EntityCode.ts +51 -0
  105. package/src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger.ts +736 -0
  106. package/src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup.ts +106 -0
  107. package/src/main/ts/armyc2/c5isr/renderer/utilities/GeoPixelConversion3D.ts +84 -0
  108. package/src/main/ts/armyc2/c5isr/renderer/utilities/IMultiPointRenderer.ts +87 -0
  109. package/src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion.ts +34 -0
  110. package/src/main/ts/armyc2/c5isr/renderer/utilities/ImageInfo.ts +324 -0
  111. package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUCache.ts +127 -0
  112. package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUEntry.ts +18 -0
  113. package/src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel.ts +111 -0
  114. package/src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules.ts +219 -0
  115. package/src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo.ts +1008 -0
  116. package/src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup.ts +882 -0
  117. package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes.ts +380 -0
  118. package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol.ts +797 -0
  119. package/src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers.ts +1699 -0
  120. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversion.ts +178 -0
  121. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversionDummy.ts +45 -0
  122. package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D.ts +126 -0
  123. package/src/main/ts/armyc2/c5isr/renderer/utilities/RectUtilities.ts +118 -0
  124. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererException.ts +11 -0
  125. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings.ts +1201 -0
  126. package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities.ts +591 -0
  127. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo.ts +29 -0
  128. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup.ts +753 -0
  129. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo.ts +137 -0
  130. package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGTextInfo.ts +438 -0
  131. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEvent.ts +19 -0
  132. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEventListener.ts +10 -0
  133. package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsEventListener.ts +5 -0
  134. package/src/main/ts/armyc2/c5isr/renderer/utilities/Shape2SVG.ts +404 -0
  135. package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo.ts +525 -0
  136. package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeUtilities.ts +55 -0
  137. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolDimensionInfo.ts +36 -0
  138. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID.ts +1055 -0
  139. package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities.ts +2085 -0
  140. package/src/main/ts/armyc2/c5isr/renderer/utilities/TextInfo.ts +157 -0
  141. package/src/main/ts/armyc2/c5isr/web/render/GeoPixelConversion.ts +86 -0
  142. package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandler.ts +3798 -0
  143. package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandlerSVG.ts +412 -0
  144. package/src/main/ts/armyc2/c5isr/web/render/PointConverter.ts +124 -0
  145. package/src/main/ts/armyc2/c5isr/web/render/SymbolModifiers.ts +26 -0
  146. package/src/main/ts/armyc2/c5isr/web/render/WebRenderer.ts +677 -0
  147. package/src/main/ts/armyc2/c5isr/web/render/utilities/JavaRendererUtilities.ts +484 -0
  148. package/src/main/ts/armyc2/c5isr/web/render/utilities/LineInfo.ts +62 -0
  149. package/src/main/ts/armyc2/c5isr/web/render/utilities/SymbolInfo.ts +46 -0
  150. package/src/main/ts/armyc2/c5isr/web/render/utilities/TextInfo.ts +51 -0
  151. package/src/main/ts/org/gavaghan/geodesy/Angle.ts +31 -0
  152. package/src/main/ts/org/gavaghan/geodesy/Ellipsoid.ts +71 -0
  153. package/src/main/ts/org/gavaghan/geodesy/GeodeticCalculator.ts +200 -0
  154. package/src/main/ts/org/gavaghan/geodesy/GeodeticCurve.ts +55 -0
  155. package/src/main/ts/org/gavaghan/geodesy/GeodeticMeasurement.ts +68 -0
  156. package/src/main/ts/org/gavaghan/geodesy/GlobalCoordinates.ts +103 -0
  157. package/src/main/ts/org/gavaghan/geodesy/GlobalPosition.ts +90 -0
  158. package/test/ExportSPImages.js +692 -0
  159. package/test/MPWW.html +556 -0
  160. package/test/MPWorker.js +318 -0
  161. package/test/SPWorker.js +233 -0
  162. package/test/SVGWW.html +363 -0
  163. package/test/singlePointTester3.html +751 -0
  164. package/tsconfig.json +54 -0
  165. package/typedoc.json +30 -0
  166. package/updateVersion.js +21 -0
  167. package/webpack.config.js +34 -0
  168. package/webpackn.config.js +28 -0
  169. package/webpackr.config.js +47 -0
  170. package/webpackw.config.js +23 -0
@@ -0,0 +1,647 @@
1
+ import { type int, type double } from "../graphics2d/BasicTypes";
2
+
3
+ import { BasicStroke } from "../graphics2d/BasicStroke"
4
+ import { Rectangle2D } from "../graphics2d/Rectangle2D"
5
+ import { arraysupport } from "../JavaLineArray/arraysupport"
6
+ import { CELineArray } from "../JavaLineArray/CELineArray"
7
+ import { Channels } from "../JavaLineArray/Channels"
8
+ import { lineutility } from "../JavaLineArray/lineutility"
9
+ import { POINT2 } from "../JavaLineArray/POINT2"
10
+ import { ref } from "../JavaLineArray/ref"
11
+ import { Shape2 } from "../JavaLineArray/Shape2"
12
+ import { TacticalLines } from "../JavaLineArray/TacticalLines"
13
+ import { P1 } from "../JavaTacticalRenderer/P1"
14
+ import { TGLight } from "../JavaTacticalRenderer/TGLight"
15
+ import { Color } from "../renderer/utilities/Color"
16
+ import { EntityCode } from "../renderer/utilities/EntityCode"
17
+ import { ErrorLogger } from "../renderer/utilities/ErrorLogger"
18
+ import { IPointConversion } from "../renderer/utilities/IPointConversion"
19
+ import { RendererException } from "../renderer/utilities/RendererException"
20
+ import { SymbolID } from "../renderer/utilities/SymbolID"
21
+ import { clsRenderer2 } from "../RenderMultipoints/clsRenderer2"
22
+ import { clsUtility } from "./clsUtility";
23
+
24
+ /**
25
+ * A class to process channel types.
26
+ *
27
+ *
28
+ */
29
+ export class clsChannelUtility {
30
+
31
+ private static readonly _className: string = "clsChannelUtility";
32
+
33
+ /**
34
+ * Gets partitions from the client points based on the segments generated by
35
+ * GetSegments. Partitions are used handle double-backed segments. Each
36
+ * partition is a continuous sequence of points for a channel.
37
+ *
38
+ * @param segments
39
+ * @param partitions OUT the partitions
40
+ * @return
41
+ */
42
+ private static GetPartitions(segments: boolean[],
43
+ partitions: Array<P1>): int {
44
+ try {
45
+ let j: int = 0;
46
+ let nextSegment: boolean = false;
47
+ //worst case is every segment is a separate partition
48
+ //caller must deallocate partitions
49
+ let p1: P1 = new P1();
50
+ //first segment will always be true,
51
+ //there are no bad one-segment channels
52
+ if (segments[0] === false) {
53
+ return 0;
54
+ }
55
+
56
+ if (partitions != null) {
57
+ partitions.length = 0; // partitions.clear()
58
+ } else {
59
+ return 0;
60
+ }
61
+
62
+ p1.start = 0;
63
+ //only add the partitions after p1.end has been set
64
+ let n: int = segments.length;
65
+ //for (j = 0; j < segments.length - 1; j++)
66
+ for (j = 0; j < n - 1; j++) {
67
+ nextSegment = segments[j + 1];
68
+ if (nextSegment === false) {
69
+ //the end of the current partition is the last good segment
70
+ p1.end_Renamed = j;
71
+ partitions.push(p1);
72
+ //beginning of the next partition
73
+ p1 = new P1();
74
+ p1.start = j + 1;
75
+ }
76
+ }
77
+ p1.end_Renamed = j;
78
+ partitions.push(p1);
79
+ } catch (exc) {
80
+ if (exc instanceof Error) {
81
+ //console.log(e.message);
82
+ //clsUtility.WriteFile("error in clsChanneUtility.GetPartitions");
83
+ ErrorLogger.LogException(clsChannelUtility._className, "GetPartitions",
84
+ new RendererException("Failed inside GetPartitions", exc));
85
+ } else {
86
+ throw exc;
87
+ }
88
+ }
89
+ return partitions.length;
90
+ }
91
+
92
+ /**
93
+ * Draws a partition to the shapes array and stores the calculated channel
94
+ * points
95
+ *
96
+ * @param fromSegment
97
+ * @param toSegment
98
+ * @param pixels
99
+ * @param channelWidth
100
+ * @param bolLastSegment
101
+ * @param shapes
102
+ * @param channelPoints
103
+ * @param distanceToChannelPoint
104
+ * @return
105
+ */
106
+ private static DrawGoodChannel2(tg: TGLight,
107
+ fromSegment: int,
108
+ toSegment: int,
109
+ pixels: number[],
110
+ channelWidth: int,
111
+ bolLastSegment: boolean,
112
+ shapes: Array<Shape2>,
113
+ channelPoints: Array<POINT2>,
114
+ distanceToChannelPoint: double): int {
115
+ let returnValue: int = 0; // Had to initialize to something
116
+ try {
117
+ let lineType: int = tg.get_LineType();
118
+ let lineType2: int = 0;
119
+ let channelPixels: number[];
120
+ switch (lineType) {
121
+ case TacticalLines.LC:
122
+ case TacticalLines.UNSP:
123
+ case TacticalLines.DFENCE:
124
+ case TacticalLines.SFENCE:
125
+ case TacticalLines.DOUBLEA:
126
+ case TacticalLines.LWFENCE:
127
+ case TacticalLines.HWFENCE:
128
+ case TacticalLines.BBS_LINE:
129
+ case TacticalLines.SINGLEC:
130
+ case TacticalLines.DOUBLEC:
131
+ case TacticalLines.TRIPLE: {
132
+ lineType2 = lineType;
133
+ break;
134
+ }
135
+
136
+ case TacticalLines.SPT: {
137
+ if (fromSegment === 0) {
138
+ lineType2 = TacticalLines.CHANNEL_FLARED;
139
+ } else {
140
+ lineType2 = TacticalLines.CHANNEL;
141
+ }
142
+ break;
143
+ }
144
+
145
+ case TacticalLines.MAIN: {
146
+ if (fromSegment === 0) {
147
+ lineType2 = TacticalLines.CHANNEL_FLARED;
148
+ } else {
149
+ lineType2 = TacticalLines.CHANNEL;
150
+ }
151
+ break;
152
+ }
153
+
154
+ case TacticalLines.CATK: {
155
+ lineType2 = TacticalLines.CHANNEL_DASHED;
156
+ break;
157
+ }
158
+
159
+ case TacticalLines.CATKBYFIRE: {
160
+ lineType2 = TacticalLines.CHANNEL_DASHED;
161
+ break;
162
+ }
163
+
164
+ default: {
165
+ lineType2 = TacticalLines.CHANNEL;
166
+ break;
167
+ }
168
+
169
+ }
170
+ if (bolLastSegment === true) {
171
+ if (fromSegment !== 0) {
172
+ switch (lineType) {
173
+ case TacticalLines.SPT: {
174
+ lineType2 = TacticalLines.SPT_STRAIGHT;
175
+ break;
176
+ }
177
+
178
+ case TacticalLines.MAIN: {
179
+ lineType2 = TacticalLines.MAIN_STRAIGHT;
180
+ break;
181
+ }
182
+
183
+ default: {
184
+ lineType2 = lineType as int;
185
+ break;
186
+ }
187
+
188
+ }
189
+ } else {
190
+ lineType2 = lineType as int;
191
+ }
192
+ }
193
+
194
+ if (fromSegment < 0) {
195
+ return returnValue;
196
+ }
197
+ if (toSegment < 0) {
198
+ return returnValue;
199
+ }
200
+ if (toSegment < fromSegment) {
201
+ return returnValue;
202
+ }
203
+ let j: int = 0;
204
+ let lineCount: int = 0;
205
+ let numPoints: int = 0;
206
+ let counter: int = 0;
207
+ let goodUpperPixels: number[];
208
+ let goodLowerPixels: number[];
209
+ numPoints = toSegment - fromSegment + 2;
210
+ goodUpperPixels = new Array<number>(2 * numPoints);
211
+ goodLowerPixels = new Array<number>(2 * numPoints);
212
+
213
+ counter = 0;
214
+ for (j = fromSegment; j < toSegment + 2; j++) {
215
+ goodUpperPixels[counter] = pixels[2 * j];
216
+ goodUpperPixels[counter + 1] = pixels[2 * j + 1];
217
+ goodLowerPixels[counter] = pixels[2 * j];
218
+ goodLowerPixels[counter + 1] = pixels[2 * j + 1];
219
+ counter = counter + 2;
220
+ }
221
+
222
+ tg.set_LineType(lineType2);
223
+ lineCount = CELineArray.CGetLineCountDouble(tg, goodUpperPixels, numPoints, channelWidth);
224
+ channelPixels = new Array<number>(3 * lineCount);
225
+ let pt: POINT2;
226
+ lineCount = Channels.GetChannel1Double(tg, goodUpperPixels, goodLowerPixels, channelPixels, numPoints, numPoints, channelWidth / 2, distanceToChannelPoint as int, shapes);
227
+ tg.set_LineType(lineType);
228
+
229
+ //if shapes is null then it is not a CPOF client
230
+ if (shapes == null && channelPixels != null) {
231
+ //do not clear channelPoints first because the function gets successive calls
232
+ let n: int = channelPixels.length;
233
+ //for (j = 0; j < channelPixels.length / 3; j++)
234
+ for (j = 0; j < n / 3; j++) {
235
+ pt = new POINT2(channelPixels[3 * j], channelPixels[3 * j + 1], channelPixels[3 * j + 2] as int);
236
+ if (j === channelPixels.length / 3 - 1) {
237
+ pt.style = 5;
238
+ }
239
+ channelPoints.push(pt);
240
+ }
241
+ }
242
+
243
+ if (lineCount > 0) {
244
+ //DrawChannelPixels2(lineCount, channelPixels, (int)lineType);
245
+ returnValue = channelPixels.length;
246
+ } else {
247
+ returnValue = 0;
248
+ }
249
+ //channelPixels[channelPixels.length - 1] = 5;
250
+ if (lineCount > 0) {
251
+ channelPixels[lineCount - 1] = 5;
252
+ }
253
+ //clean up
254
+ goodUpperPixels = null;
255
+ goodLowerPixels = null;
256
+ } catch (exc) {
257
+ if (exc instanceof Error) {
258
+ //clsUtility.WriteFile("error in clsChanneUtility.DrawGoodChannel2");
259
+ ErrorLogger.LogException(clsChannelUtility._className, "DrawGoodChannel2",
260
+ new RendererException("Failed inside DrawGoodChannel2", exc));
261
+ } else {
262
+ throw exc;
263
+ }
264
+ }
265
+ return returnValue;
266
+ }
267
+
268
+ /**
269
+ * Draws the channel partitions to the shapes array
270
+ *
271
+ * @param pixels
272
+ * @param partitions
273
+ * @param channelWidth channel width in pixels
274
+ * @param shapes
275
+ * @param channelPoints
276
+ * @param distanceToChannelPoint distance in pixels from the tip to the back
277
+ * of the arrow
278
+ */
279
+ private static DrawSegments(tg: TGLight,
280
+ pixels: number[],
281
+ partitions: Array<P1>,
282
+ channelWidth: int,
283
+ shapes: Array<Shape2>,
284
+ channelPoints: Array<POINT2>,
285
+ distanceToChannelPoint: double): void {
286
+ try {
287
+ let j: int = 0;
288
+ let n: int = 0;
289
+ let t: int = partitions.length;
290
+ //for (j = 0; j < partitions.length - 1; j++)
291
+ for (j = 0; j < t - 1; j++) {
292
+ n = clsChannelUtility.DrawGoodChannel2(tg, partitions[j].start, partitions[j].end_Renamed, pixels, channelWidth, false, shapes, channelPoints, distanceToChannelPoint);
293
+
294
+ }
295
+ //draw the last partition using linetype
296
+ n = clsChannelUtility.DrawGoodChannel2(tg, partitions[j].start, partitions[j].end_Renamed, pixels, channelWidth, true, shapes, channelPoints, distanceToChannelPoint);
297
+ } catch (exc) {
298
+ if (exc instanceof Error) {
299
+ //clsUtility.WriteFile("error in clsChanneUtility.DrawSegments");
300
+ ErrorLogger.LogException(clsChannelUtility._className, "DrawSegments",
301
+ new RendererException("Failed inside DrawSegments", exc));
302
+ } else {
303
+ throw exc;
304
+ }
305
+ }
306
+ }
307
+
308
+ private static DrawLCSingleLineSegments(tg: TGLight,
309
+ pixels2: number[],
310
+ singleLinePartitions: Array<P1>,
311
+ shapes: Array<Shape2>,
312
+ clipBounds: Rectangle2D,
313
+ converter: IPointConversion): void {
314
+ try {
315
+ for (let flotPartition of singleLinePartitions) {
316
+ let vblSaveCounter: int = flotPartition.end_Renamed - flotPartition.start + 1;
317
+ let flotPixels: Array<POINT2> = new Array();
318
+ for (let i: int = 0; i < vblSaveCounter; i++) {
319
+
320
+ flotPixels.push(new POINT2(pixels2[2 * (i + flotPartition.start)], pixels2[2 * (i + flotPartition.start) + 1]));
321
+ }
322
+
323
+
324
+ let flotID: string = tg.get_SymbolId();
325
+ flotID = SymbolID.setAffiliation(flotID, SymbolID.StandardIdentity_Affiliation_Hostile_Faker);
326
+ flotID = SymbolID.setEntityCode(flotID, EntityCode.EntityCode_FLOT);
327
+ let flotTG: TGLight = new TGLight();
328
+ flotTG.set_LineType(TacticalLines.FLOT);
329
+ flotTG.set_Pixels(flotPixels);
330
+ flotTG.set_SymbolId(flotID);
331
+ flotTG.set_LineThickness(tg.get_LineThickness());
332
+
333
+ let flotShapes: Array<Shape2> | null = clsRenderer2.GetLineArray(flotTG, converter, false, clipBounds);
334
+
335
+ if (flotShapes != null) {
336
+ for (let shape of flotShapes) {
337
+
338
+ shape.setLineColor(Color.RED);
339
+ }
340
+
341
+ shapes.push(...flotShapes);
342
+ }
343
+ }
344
+ } catch (exc) {
345
+ if (exc instanceof Error) {
346
+ ErrorLogger.LogException(clsChannelUtility._className, "DrawLCFlotSegments",
347
+ new RendererException("Failed inside DrawLCFlotSegments", exc));
348
+ } else {
349
+ throw exc;
350
+ }
351
+ }
352
+ }
353
+
354
+ /**
355
+ * Handle symbol too small for line of contact
356
+ * @param tg
357
+ * @param pixels
358
+ * @return
359
+ */
360
+ private static getLCPixels(tg: TGLight, pixels: Array<POINT2>): Array<POINT2> {
361
+ let pixels2: Array<POINT2>;
362
+ try {
363
+ if (tg.get_LineType() !== TacticalLines.LC) {
364
+
365
+ return pixels;
366
+ }
367
+
368
+ let pts: POINT2[] = tg.Pixels;
369
+ let ul: POINT2 = new POINT2();
370
+ let lr: POINT2 = new POINT2();
371
+ lineutility.CalcMBRPoints(pts as POINT2[], pts.length, ul, lr);
372
+ let flotDiameter: double = arraysupport.getScaledSize(21, tg.get_LineThickness(), tg.get_patternScale());
373
+ if (lr.x - ul.x >= flotDiameter) {
374
+
375
+ return pixels;
376
+ }
377
+
378
+ else {
379
+ if (lr.y - ul.y >= flotDiameter) {
380
+
381
+ return pixels;
382
+ }
383
+
384
+ }
385
+
386
+ //at this point the mbr is too small for a meaningful LC symbol
387
+ let x0: double = pts[0].x;
388
+ let y0: double = pts[0].y;
389
+ let x1: double = pts[1].x;
390
+ let y1: double = pts[1].y;
391
+ if (x0 <= x1) {
392
+
393
+ x1 = x0 + flotDiameter;
394
+ }
395
+
396
+ else {
397
+
398
+ x1 = x0 - flotDiameter;
399
+ }
400
+
401
+ y1 = y0;
402
+ let pt0: POINT2 = new POINT2(x0, y0);
403
+ let pt1: POINT2 = new POINT2(x1, y1);
404
+ pixels2 = new Array();
405
+ pixels2.push(pt0);
406
+ pixels2.push(pt1);
407
+ } catch (exc) {
408
+ if (exc instanceof Error) {
409
+ //clsUtility.WriteFile("error in clsChanneUtility.DrawSegments");
410
+ ErrorLogger.LogException(clsChannelUtility._className, "getLCPixels",
411
+ new RendererException("Failed inside getLCPixels", exc));
412
+ } else {
413
+ throw exc;
414
+ }
415
+ }
416
+ return pixels2;
417
+ }
418
+
419
+ /**
420
+ * The main interface to clsChannelUtility calls DrawChannel2 after stuffing
421
+ * the points into an array of 2-tuples x,y
422
+ *
423
+ * @param pixels the client points
424
+ * @param linetype the line type
425
+ * @param tg the tactical graphic
426
+ * @param shapes
427
+ * @param channelPoints
428
+ */
429
+ public static DrawChannel(pixels: Array<POINT2>,
430
+ linetype: int,
431
+ tg: TGLight,
432
+ shapes: Array<Shape2>,
433
+ channelPoints: Array<POINT2> | null,
434
+ clipBounds: Rectangle2D,
435
+ converter: IPointConversion): void {
436
+ try {
437
+ pixels = clsChannelUtility.getLCPixels(tg, pixels);
438
+ //we must do this because the rotary arrow tip now has to match the
439
+ //anchor point, i.e. the rotary feature can no longer stick out past the anchor point
440
+ //45 pixels shift here matches the 45 pixels shift for catkbyfire found in Channels.GetAXADDouble
441
+ lineutility.adjustCATKBYFIREControlPoint(linetype, pixels, 45);
442
+
443
+ let j: int = 0;
444
+ let pixels2: number[] = new Array<number>(pixels.length * 2);
445
+ let n: int = pixels.length;
446
+ //for (j = 0; j < pixels.length; j++)
447
+ for (j = 0; j < n; j++) {
448
+ pixels2[2 * j] = pixels[j].x;
449
+ pixels2[2 * j + 1] = pixels[j].y;
450
+ }
451
+ clsChannelUtility.DrawChannel2(pixels2, linetype, tg, shapes, channelPoints, clipBounds, converter);
452
+ } catch (exc) {
453
+ if (exc instanceof Error) {
454
+ //clsUtility.WriteFile("error in clsChanneUtility.DrawSegments");
455
+ ErrorLogger.LogException(clsChannelUtility._className, "DrawChannel",
456
+ new RendererException("Failed inside DrawChannel", exc));
457
+ } else {
458
+ throw exc;
459
+ }
460
+ }
461
+ }
462
+
463
+ /**
464
+ * utility for clsMETOC to handle double-backed segments
465
+ *
466
+ * @param tg the tactical graphic object
467
+ */
468
+ public static GetPartitions2(tg: TGLight): Array<P1> | null {
469
+ let partitions: Array<P1>;
470
+ try {
471
+ let pixels: number[] = new Array<number>(tg.Pixels.length * 2);
472
+ let n: int = tg.Pixels.length;
473
+ //for(int j=0;j<tg.Pixels.length;j++)
474
+ for (let j: int = 0; j < n; j++) {
475
+ pixels[2 * j] = tg.Pixels[j].x;
476
+ pixels[2 * j + 1] = tg.Pixels[j].y;
477
+ }
478
+
479
+ let segments: boolean[] = new Array<boolean>(pixels.length / 2 - 1);
480
+ if (segments.length === 0) {
481
+ return null;
482
+ }
483
+
484
+ let factor: double = arraysupport.getScaledSize(3, tg.get_LineThickness(), tg.get_patternScale());
485
+
486
+ clsUtility.GetSegments(pixels, segments, factor);
487
+ partitions = new Array<P1>();
488
+ clsChannelUtility.GetPartitions(segments, partitions);
489
+ } catch (exc) {
490
+ if (exc instanceof Error) {
491
+ ErrorLogger.LogException(clsChannelUtility._className, "GetPartitions2",
492
+ new RendererException("Failed inside GetPartitions2", exc));
493
+ } else {
494
+ throw exc;
495
+ }
496
+ }
497
+ return partitions;
498
+ }
499
+
500
+ /**
501
+ * The main function for processing channel types. Gets segments, then gets
502
+ * partitions from the segments and then draws the partitions.
503
+ *
504
+ * @param pixels the client points as an array of 2-tuples x,y
505
+ * @param linetype the line type
506
+ * @param tg the tactical graphic object
507
+ * @param shapes
508
+ * @param channelPoints
509
+ */
510
+ private static DrawChannel2(pixels: number[],
511
+ linetype: int,
512
+ tg: TGLight,
513
+ shapes: Array<Shape2>,
514
+ channelPoints: Array<POINT2> | null,
515
+ clipBounds: Rectangle2D,
516
+ converter: IPointConversion): void {
517
+ try {
518
+ let distanceToChannelPoint: ref<number[]> = new ref();
519
+ let j: int = 0;
520
+ let pixels2: number[];
521
+ let channelWidth: int = 0;
522
+ let partitions: Array<P1>;
523
+ let n: int = pixels.length;
524
+ let numPoints: int = 0;
525
+ //LC and others do not call clsUtility.ChannelWidth, but the
526
+ //value array still needs to be allocated or there is a
527
+ //null pointer exception in DrawGoodChannel2
528
+ distanceToChannelPoint.value = new Array<number>(1);
529
+ distanceToChannelPoint.value[0] = arraysupport.getScaledSize(20, tg.get_LineThickness(), tg.get_patternScale());
530
+
531
+ switch (linetype) {
532
+ case TacticalLines.MAIN:
533
+ case TacticalLines.CATK:
534
+ case TacticalLines.CATKBYFIRE:
535
+ case TacticalLines.AIRAOA:
536
+ case TacticalLines.AAAAA:
537
+ case TacticalLines.SPT: {
538
+ clsUtility.ReorderPixels(pixels);
539
+ numPoints = pixels.length / 2;
540
+
541
+ if (numPoints < 3) {
542
+ return;
543
+ }
544
+ //moved this to be prior to stuffing pixels2
545
+ channelWidth = clsUtility.ChannelWidth(pixels, distanceToChannelPoint) / 2;
546
+ //ValidateChannelPixels2(ref pixels, ref channelWidth, ref distanceToChannelPoint);
547
+
548
+ numPoints = pixels.length / 2;
549
+ pixels2 = new Array<number>(pixels.length - 2);
550
+
551
+ for (j = 0; j < numPoints; j++) {
552
+ if (j < numPoints - 1) {
553
+ pixels2[2 * j] = pixels[2 * j];
554
+ pixels2[2 * j + 1] = pixels[2 * j + 1];
555
+ }
556
+ }
557
+ break;
558
+ }
559
+
560
+ case TacticalLines.LC: {
561
+ channelWidth = arraysupport.getScaledSize(40, tg.get_LineThickness(), tg.get_patternScale()) as int;// was 20;
562
+ pixels2 = new Array<number>(pixels.length);
563
+ n = pixels.length;
564
+ //for (j = 0; j < pixels.length; j++)
565
+ for (j = 0; j < n; j++) {
566
+ pixels2[j] = pixels[j];
567
+ }
568
+ break;
569
+ }
570
+
571
+ case TacticalLines.UNSP:
572
+ case TacticalLines.DFENCE:
573
+ case TacticalLines.SFENCE:
574
+ case TacticalLines.DOUBLEA:
575
+ case TacticalLines.LWFENCE:
576
+ case TacticalLines.HWFENCE:
577
+ case TacticalLines.SINGLEC:
578
+ case TacticalLines.DOUBLEC:
579
+ case TacticalLines.TRIPLE: {
580
+ tg.set_lineCap(BasicStroke.CAP_BUTT);
581
+ channelWidth = arraysupport.getScaledSize(30, tg.get_LineThickness(), tg.get_patternScale()) as int;
582
+ if (Channels.getShiftLines()) {
583
+ channelWidth = arraysupport.getScaledSize(60, tg.get_LineThickness(), tg.get_patternScale()) as int;
584
+ }
585
+ pixels2 = new Array<number>(pixels.length);
586
+ n = pixels.length;
587
+ //for (j = 0; j < pixels.length; j++)
588
+ for (j = 0; j < n; j++) {
589
+ pixels2[j] = pixels[j];
590
+ }
591
+ break;
592
+ }
593
+
594
+ case TacticalLines.BBS_LINE: {
595
+ channelWidth = 8 * tg.Pixels[0].style; //was 20 1-10-13
596
+ let pixels2: double[] = [];
597
+ n = pixels.length;
598
+ //for (j = 0; j < pixels.length; j++)
599
+ for (j = 0; j < n; j++) {
600
+ pixels2[j] = pixels[j];
601
+ }
602
+ break;
603
+ }
604
+
605
+ default: {
606
+
607
+ break;
608
+ }
609
+
610
+ }
611
+
612
+ //we require new partitions because pixels are dirty
613
+ let segments: boolean[] = new Array<boolean>(Math.trunc(pixels2.length / 2) - 1);
614
+ if (segments.length === 0) {
615
+ return;
616
+ }
617
+
618
+ // Line of contact looks bad with small channel corners extending out
619
+ if (linetype === TacticalLines.LC) {
620
+ partitions = new Array();
621
+ let singleLinePartitions: Array<P1> = new Array();
622
+ clsUtility.GetLCPartitions(pixels2, arraysupport.getScaledSize(40, tg.get_LineThickness(), tg.get_patternScale()), partitions, singleLinePartitions);
623
+ clsChannelUtility.DrawSegments(tg, pixels2, partitions, channelWidth, shapes, channelPoints, distanceToChannelPoint.value[0]);
624
+
625
+ if (singleLinePartitions.length > 0) {
626
+ // Render any small angles that only have side (not channel) as FLOT
627
+ clsChannelUtility.DrawLCSingleLineSegments(tg, pixels2, singleLinePartitions, shapes, clipBounds, converter);
628
+ }
629
+ } else {
630
+ let factor: double = 3;
631
+
632
+ clsUtility.GetSegments(pixels2, segments, factor);
633
+ partitions = new Array();
634
+ clsChannelUtility.GetPartitions(segments, partitions);
635
+
636
+ clsChannelUtility.DrawSegments(tg, pixels2, partitions, channelWidth, shapes, channelPoints, distanceToChannelPoint.value[0]);
637
+ }
638
+ } catch (exc) {
639
+ if (exc instanceof Error) {
640
+ ErrorLogger.LogException(clsChannelUtility._className, "DrawChannel2",
641
+ new RendererException("Failed inside DrawChannel2", exc));
642
+ } else {
643
+ throw exc;
644
+ }
645
+ }
646
+ }
647
+ }