@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.
- package/LICENSE +201 -0
- package/README.md +57 -0
- package/buildNode.bat +2 -0
- package/buildWeb.bat +2 -0
- package/dist/C5Ren.d.ts +6970 -0
- package/dist/C5Ren.js +2 -0
- package/dist/C5Ren.js.map +1 -0
- package/dist/LICENSE +201 -0
- package/dist/README.md +57 -0
- package/dist/armyc2.c5isr.renderer-mil-sym-ts-web-2.2.0.tgz +0 -0
- package/dist/manifest.json +4 -0
- package/dist/package.json +16 -0
- package/index.ts +169 -0
- package/package.bak +50 -0
- package/package.json +40 -0
- package/package.node.json +43 -0
- package/package.pack.json +19 -0
- package/package.packWeb.json +16 -0
- package/package.web.json +40 -0
- package/src/main/ts/android/graphics/Bitmap.ts +7 -0
- package/src/main/ts/android/graphics/Paint.ts +26 -0
- package/src/main/ts/android/graphics/Path.ts +78 -0
- package/src/main/ts/android/graphics/PointF.ts +14 -0
- package/src/main/ts/android/graphics/Rect.ts +18 -0
- package/src/main/ts/android/graphics/RectF.ts +50 -0
- package/src/main/ts/android/graphics/Region.ts +36 -0
- package/src/main/ts/android/graphics/Typeface.ts +11 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes.ts +99 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CChannelPoints2.ts +34 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CELineArray.ts +193 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Channels.ts +2971 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/DISMSupport.ts +4008 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/POINT2.ts +93 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Shape2.ts +89 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/TacticalLines.ts +515 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/arraysupport.ts +5403 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/countsupport.ts +1084 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/flot.ts +2173 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/lineutility.ts +4934 -0
- package/src/main/ts/armyc2/c5isr/JavaLineArray/ref.ts +7 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/Modifier2.ts +5601 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/P1.ts +14 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/TGLight.ts +648 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsChannelUtility.ts +647 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsMETOC.ts +2994 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsUtility.ts +2663 -0
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/mdlGeodesic.ts +669 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipPolygon2.ts +971 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipQuad.ts +871 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer.ts +3507 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer2.ts +500 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtility.ts +1089 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityCPOF.ts +2656 -0
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityGE.ts +1419 -0
- package/src/main/ts/armyc2/c5isr/data/genc.json +1407 -0
- package/src/main/ts/armyc2/c5isr/data/msd.json +17311 -0
- package/src/main/ts/armyc2/c5isr/data/mse.json +18500 -0
- package/src/main/ts/armyc2/c5isr/data/svgd.json +31214 -0
- package/src/main/ts/armyc2/c5isr/data/svge.json +30558 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/AffineTransform.ts +10 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Area.ts +437 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicStroke.ts +429 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicTypes.ts +7 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/BufferedImage.ts +35 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Font.ts +111 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/FontMetrics.ts +29 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/FontRenderContext.ts +18 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/GeneralPath.ts +211 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Graphics2D.ts +80 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/IPathIterator.ts +33 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/ImageIO.ts +16 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Line2D.ts +726 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/PathIterator.ts +141 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Point.ts +112 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Point2D.ts +261 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Polygon.ts +391 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle.ts +567 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D.ts +445 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Shape.ts +31 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/Stroke.ts +18 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/TextLayout.ts +45 -0
- package/src/main/ts/armyc2/c5isr/graphics2d/TexturePaint.ts +25 -0
- package/src/main/ts/armyc2/c5isr/renderer/IIconRenderer.ts +15 -0
- package/src/main/ts/armyc2/c5isr/renderer/IconRenderer.ts +22 -0
- package/src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer.ts +269 -0
- package/src/main/ts/armyc2/c5isr/renderer/ModifierRenderer.ts +9882 -0
- package/src/main/ts/armyc2/c5isr/renderer/PatternFillRenderer.ts +146 -0
- package/src/main/ts/armyc2/c5isr/renderer/SinglePointSVGRenderer.ts +1265 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/arc.ts +64 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/bcurve.ts +95 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/ellipse.ts +93 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/line.ts +114 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/path.ts +555 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/pathiterator.ts +62 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/point.ts +120 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/rectangle.ts +431 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/roundedrectangle.ts +99 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/types.ts +25 -0
- package/src/main/ts/armyc2/c5isr/renderer/shapes/utilities.ts +203 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors.ts +104 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Color.ts +481 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit.ts +40 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules.ts +1323 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/EntityCode.ts +51 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger.ts +736 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup.ts +106 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GeoPixelConversion3D.ts +84 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IMultiPointRenderer.ts +87 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion.ts +34 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ImageInfo.ts +324 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUCache.ts +127 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUEntry.ts +18 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel.ts +111 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules.ts +219 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo.ts +1008 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup.ts +882 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes.ts +380 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol.ts +797 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers.ts +1699 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversion.ts +178 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversionDummy.ts +45 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D.ts +126 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RectUtilities.ts +118 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererException.ts +11 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings.ts +1201 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities.ts +591 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo.ts +29 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup.ts +753 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo.ts +137 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGTextInfo.ts +438 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEvent.ts +19 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEventListener.ts +10 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsEventListener.ts +5 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Shape2SVG.ts +404 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo.ts +525 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeUtilities.ts +55 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolDimensionInfo.ts +36 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID.ts +1055 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities.ts +2085 -0
- package/src/main/ts/armyc2/c5isr/renderer/utilities/TextInfo.ts +157 -0
- package/src/main/ts/armyc2/c5isr/web/render/GeoPixelConversion.ts +86 -0
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandler.ts +3798 -0
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandlerSVG.ts +412 -0
- package/src/main/ts/armyc2/c5isr/web/render/PointConverter.ts +124 -0
- package/src/main/ts/armyc2/c5isr/web/render/SymbolModifiers.ts +26 -0
- package/src/main/ts/armyc2/c5isr/web/render/WebRenderer.ts +677 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/JavaRendererUtilities.ts +484 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/LineInfo.ts +62 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/SymbolInfo.ts +46 -0
- package/src/main/ts/armyc2/c5isr/web/render/utilities/TextInfo.ts +51 -0
- package/src/main/ts/org/gavaghan/geodesy/Angle.ts +31 -0
- package/src/main/ts/org/gavaghan/geodesy/Ellipsoid.ts +71 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCalculator.ts +200 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCurve.ts +55 -0
- package/src/main/ts/org/gavaghan/geodesy/GeodeticMeasurement.ts +68 -0
- package/src/main/ts/org/gavaghan/geodesy/GlobalCoordinates.ts +103 -0
- package/src/main/ts/org/gavaghan/geodesy/GlobalPosition.ts +90 -0
- package/test/ExportSPImages.js +692 -0
- package/test/MPWW.html +556 -0
- package/test/MPWorker.js +318 -0
- package/test/SPWorker.js +233 -0
- package/test/SVGWW.html +363 -0
- package/test/singlePointTester3.html +751 -0
- package/tsconfig.json +54 -0
- package/typedoc.json +30 -0
- package/updateVersion.js +21 -0
- package/webpack.config.js +34 -0
- package/webpackn.config.js +28 -0
- package/webpackr.config.js +47 -0
- package/webpackw.config.js +23 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
//import { RendererUtilities } from "../../renderer/utilities/RendererUtilities"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Integer based Color class with utility functions
|
|
6
|
+
*/
|
|
7
|
+
export class Color {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The color white. In the default sRGB space.
|
|
11
|
+
*/
|
|
12
|
+
public static readonly white: Color = new Color(255, 255, 255);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The color white. In the default sRGB space.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
public static readonly WHITE: Color = Color.white;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The color light gray. In the default sRGB space.
|
|
22
|
+
*/
|
|
23
|
+
public static readonly lightGray: Color = new Color(192, 192, 192);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The color light gray. In the default sRGB space.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
public static readonly LIGHT_GRAY: Color = Color.lightGray;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The color gray. In the default sRGB space.
|
|
33
|
+
*/
|
|
34
|
+
public static readonly gray: Color = new Color(128, 128, 128);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The color gray. In the default sRGB space.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
public static readonly GRAY: Color = Color.gray;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The color dark gray. In the default sRGB space.
|
|
44
|
+
*/
|
|
45
|
+
public static readonly darkGray: Color = new Color(64, 64, 64);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The color dark gray. In the default sRGB space.
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
public static readonly DARK_GRAY: Color = Color.darkGray;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The color black. In the default sRGB space.
|
|
55
|
+
*/
|
|
56
|
+
public static readonly black: Color = new Color(0, 0, 0);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The color black. In the default sRGB space.
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
public static readonly BLACK: Color = Color.black;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The color red. In the default sRGB space.
|
|
66
|
+
*/
|
|
67
|
+
public static readonly red: Color = new Color(255, 0, 0);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The color red. In the default sRGB space.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
public static readonly RED: Color = Color.red;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The color pink. In the default sRGB space.
|
|
77
|
+
*/
|
|
78
|
+
public static readonly pink: Color = new Color(255, 175, 175);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The color pink. In the default sRGB space.
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
public static readonly PINK: Color = Color.pink;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The color orange. In the default sRGB space.
|
|
88
|
+
*/
|
|
89
|
+
public static readonly orange: Color = new Color(255, 128, 0);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The color orange. In the default sRGB space.
|
|
93
|
+
*
|
|
94
|
+
*/
|
|
95
|
+
public static readonly ORANGE: Color = Color.orange;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The color yellow. In the default sRGB space.
|
|
99
|
+
*/
|
|
100
|
+
public static readonly yellow: Color = new Color(255, 255, 0);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The color yellow. In the default sRGB space.
|
|
104
|
+
*
|
|
105
|
+
*/
|
|
106
|
+
public static readonly YELLOW: Color = Color.yellow;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The color green. In the default sRGB space.
|
|
110
|
+
*/
|
|
111
|
+
public static readonly green: Color = new Color(0, 255, 0);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The color green. In the default sRGB space.
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
117
|
+
public static readonly GREEN: Color = Color.green;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The color magenta. In the default sRGB space.
|
|
121
|
+
*/
|
|
122
|
+
public static readonly magenta: Color = new Color(255, 0, 255);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The color magenta. In the default sRGB space.
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
public static readonly MAGENTA: Color = Color.magenta;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The color cyan. In the default sRGB space.
|
|
132
|
+
*/
|
|
133
|
+
public static readonly cyan: Color = new Color(0, 255, 255);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The color cyan. In the default sRGB space.
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
public static readonly CYAN: Color = Color.cyan;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The color blue. In the default sRGB space.
|
|
143
|
+
*/
|
|
144
|
+
public static readonly blue: Color = new Color(0, 0, 255);
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The color blue. In the default sRGB space.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
public static readonly BLUE: Color = Color.blue;
|
|
151
|
+
|
|
152
|
+
private _A: number = 255;
|
|
153
|
+
private _R: number = 0;
|
|
154
|
+
private _G: number = 0;
|
|
155
|
+
private _B: number = 0;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
* @param hexValue - String representing hex value (formatted "0xRRGGBB"
|
|
160
|
+
* i.e. "0xFFFFFF") OR formatted "0xAARRGGBB" i.e. "0x00FFFFFF" for a color
|
|
161
|
+
* with an alpha value I will also put up with "RRGGBB" and "AARRGGBB"
|
|
162
|
+
* without the starting "0x" or "#"
|
|
163
|
+
* @return
|
|
164
|
+
*/
|
|
165
|
+
private getColorsFromHexString(hexValue: string): Array<number> | null
|
|
166
|
+
{
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
if (hexValue == null || hexValue.length === 0) {
|
|
170
|
+
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let hexOriginal: string = hexValue;
|
|
175
|
+
|
|
176
|
+
let hexAlphabet: string = "0123456789ABCDEF";
|
|
177
|
+
|
|
178
|
+
if (hexValue.charAt(0) === '#') {
|
|
179
|
+
hexValue = hexValue.substring(1);
|
|
180
|
+
}
|
|
181
|
+
if (hexValue.substring(0, 2) === "0x" || hexValue.substring(0, 2) === "0X") {
|
|
182
|
+
hexValue = hexValue.substring(2);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
hexValue = hexValue.toUpperCase();
|
|
186
|
+
|
|
187
|
+
let count: number = hexValue.length;
|
|
188
|
+
let value: number[];
|
|
189
|
+
let k: number = 0;
|
|
190
|
+
let int1: number = 0;
|
|
191
|
+
let int2: number = 0;
|
|
192
|
+
|
|
193
|
+
if (count === 8 || count === 6) {
|
|
194
|
+
value = new Array<number>((count / 2));
|
|
195
|
+
for (let i: number = 0; i < count; i += 2) {
|
|
196
|
+
int1 = hexAlphabet.indexOf(hexValue.charAt(i));
|
|
197
|
+
int2 = hexAlphabet.indexOf(hexValue.charAt(i + 1));
|
|
198
|
+
|
|
199
|
+
if (int1 === -1 || int2 === -1) {
|
|
200
|
+
throw Error("Bad hex value: " + hexOriginal);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
value[k] = (int1 * 16) + int2;
|
|
204
|
+
k++;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return value;
|
|
208
|
+
}
|
|
209
|
+
else
|
|
210
|
+
{
|
|
211
|
+
throw Error("Bad hex value: " + hexValue);
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
} catch (exc) {
|
|
215
|
+
if (exc instanceof Error) {
|
|
216
|
+
throw Error("Bad hex value: " + hexValue);
|
|
217
|
+
} else {
|
|
218
|
+
throw exc;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public constructor();
|
|
225
|
+
public constructor(color: Color);
|
|
226
|
+
|
|
227
|
+
public constructor(color: number);
|
|
228
|
+
|
|
229
|
+
public constructor(hexString: string);
|
|
230
|
+
|
|
231
|
+
public constructor(R: number, G: number, B: number);
|
|
232
|
+
|
|
233
|
+
public constructor(R: number, G: number, B: number, A: number);
|
|
234
|
+
public constructor(...args: unknown[]) {
|
|
235
|
+
switch (args.length)
|
|
236
|
+
{
|
|
237
|
+
case 1:
|
|
238
|
+
{
|
|
239
|
+
if(args[0] instanceof Color)
|
|
240
|
+
{
|
|
241
|
+
const [color] = args as [Color];
|
|
242
|
+
|
|
243
|
+
if (color != null) {
|
|
244
|
+
this._A = color.getAlpha();
|
|
245
|
+
this._R = color.getRed();
|
|
246
|
+
this._G = color.getGreen();
|
|
247
|
+
this._B = color.getBlue();
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this._A = 255;
|
|
251
|
+
this._R = 0;
|
|
252
|
+
this._G = 0;
|
|
253
|
+
this._B = 0;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else if(typeof args[0] === 'string')
|
|
257
|
+
{
|
|
258
|
+
const [hexString] = args as [string];
|
|
259
|
+
|
|
260
|
+
let arr:Array<number> | null = this.getColorsFromHexString(hexString);
|
|
261
|
+
|
|
262
|
+
if(arr != null && (arr.length === 4 || arr.length === 3) )
|
|
263
|
+
{
|
|
264
|
+
if(arr.length === 4)
|
|
265
|
+
{
|
|
266
|
+
this._A = arr[0];
|
|
267
|
+
this._R = arr[1];
|
|
268
|
+
this._G = arr[2];
|
|
269
|
+
this._B = arr[3];
|
|
270
|
+
}
|
|
271
|
+
else
|
|
272
|
+
{
|
|
273
|
+
this._A = 255;
|
|
274
|
+
this._R = arr[0];
|
|
275
|
+
this._G = arr[1];
|
|
276
|
+
this._B = arr[2];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else if(typeof args[0] === 'number')
|
|
282
|
+
{
|
|
283
|
+
const [color] = args as [number];
|
|
284
|
+
|
|
285
|
+
this._A = this.getAlphaFromColor(color);
|
|
286
|
+
this._R = this.getRedFromColor(color);
|
|
287
|
+
this._G = this.getGreenFromColor(color);
|
|
288
|
+
this._B = this.getBlueFromColor(color);
|
|
289
|
+
}
|
|
290
|
+
else
|
|
291
|
+
{
|
|
292
|
+
this._A = 255;
|
|
293
|
+
this._R = 0;
|
|
294
|
+
this._G = 0;
|
|
295
|
+
this._B = 0;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
case 3: {
|
|
302
|
+
const [R, G, B] = args as [number, number, number];
|
|
303
|
+
|
|
304
|
+
this._A = 255;
|
|
305
|
+
this._R = R;
|
|
306
|
+
this._G = G;
|
|
307
|
+
this._B = B;
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
case 4: {
|
|
314
|
+
const [R, G, B, A] = args as [number, number, number, number];
|
|
315
|
+
|
|
316
|
+
this._A = A;
|
|
317
|
+
this._R = R;
|
|
318
|
+
this._G = G;
|
|
319
|
+
this._B = B;
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
case 0: {
|
|
326
|
+
|
|
327
|
+
this._A = 255;
|
|
328
|
+
this._R = 0;
|
|
329
|
+
this._G = 0;
|
|
330
|
+
this._B = 0;
|
|
331
|
+
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
default: {
|
|
336
|
+
throw new Error("Color() - Invalid number of arguments");//java.lang.IllegalArgumentException(S`Invalid number of arguments`);
|
|
337
|
+
}//*/
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
public static makeColor(r:number,g:number,b:number):Color
|
|
342
|
+
{
|
|
343
|
+
let color:Color = null;
|
|
344
|
+
try
|
|
345
|
+
{
|
|
346
|
+
color = new Color(r,g,b);
|
|
347
|
+
}
|
|
348
|
+
catch(e)
|
|
349
|
+
{
|
|
350
|
+
console.log(e.message);
|
|
351
|
+
}
|
|
352
|
+
return color;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
public toRGB():number
|
|
356
|
+
{
|
|
357
|
+
return (this._R*65536) + (this._G*256) + this._B;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
public toARGB(): number {
|
|
361
|
+
let returnVal: number = 0;
|
|
362
|
+
returnVal = (this._A << 24) + ((this._R & 0xFF) << 16) + ((this._G & 0xFF) << 8) + (this._B & 0xFF);
|
|
363
|
+
return returnVal;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private convert(integer:number):string
|
|
367
|
+
{
|
|
368
|
+
//Simpler
|
|
369
|
+
//var str = integer.toString(16);
|
|
370
|
+
//return str.length === 1 ? "0" + str : str;
|
|
371
|
+
|
|
372
|
+
//Much Faster
|
|
373
|
+
var hexAlphabet = "0123456789ABCDEF";
|
|
374
|
+
return isNaN(integer) ? "00" : hexAlphabet.charAt((integer - integer % 16)/16) + hexAlphabet.charAt(integer % 16);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* A hex string in the format of AARRGGBB
|
|
379
|
+
* @param {Boolean} withAlpha Optional, default is true. If set to false,
|
|
380
|
+
* will return a hex string without alpha values.
|
|
381
|
+
*/
|
|
382
|
+
public toHexString(withAlpha:boolean = false):string
|
|
383
|
+
{
|
|
384
|
+
if(withAlpha === false)
|
|
385
|
+
{
|
|
386
|
+
return "#" + this.convert(this._R) +
|
|
387
|
+
this.convert(this._G) +
|
|
388
|
+
this.convert(this._B);
|
|
389
|
+
}
|
|
390
|
+
else
|
|
391
|
+
{
|
|
392
|
+
return "#" + this.convert(this._A) +
|
|
393
|
+
this.convert(this._R) +
|
|
394
|
+
this.convert(this._G) +
|
|
395
|
+
this.convert(this._B);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
public toString(): string {
|
|
400
|
+
return "Color{A=" + this._A.toString() + ",R=" + this._R.toString() +
|
|
401
|
+
",G=" + this._G.toString() + ",B=" + this._B.toString() + "}";
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
public getRed(): number {
|
|
405
|
+
return this._R;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
public getGreen(): number {
|
|
409
|
+
return this._G;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
public getBlue(): number {
|
|
413
|
+
return this._B;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
public getAlpha(): number {
|
|
417
|
+
return this._A;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
*
|
|
422
|
+
* @param alpha 0-255
|
|
423
|
+
*/
|
|
424
|
+
public setAlpha(alpha: number): void {
|
|
425
|
+
this._A = alpha;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
public toInt(): number {
|
|
429
|
+
return this.toARGB();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* get alpha value from uint
|
|
435
|
+
* */
|
|
436
|
+
private getAlphaFromColor(color: number): number {
|
|
437
|
+
let alpha: number = 255;
|
|
438
|
+
if (color > 16777215) {
|
|
439
|
+
|
|
440
|
+
alpha = (color >>> 24);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return alpha;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* get red value from uint
|
|
447
|
+
* */
|
|
448
|
+
private getRedFromColor(color: number): number {
|
|
449
|
+
let red: number = 255;
|
|
450
|
+
red = (color >> 16) & 0xFF;
|
|
451
|
+
return red;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* get green value from uint
|
|
455
|
+
* */
|
|
456
|
+
private getGreenFromColor(color: number): number {
|
|
457
|
+
let green: number = 255;
|
|
458
|
+
green = (color >> 8) & 0xFF;
|
|
459
|
+
return green;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* get blue value from uint
|
|
463
|
+
* */
|
|
464
|
+
private getBlueFromColor(color: number): number {
|
|
465
|
+
let blue: number = 255;
|
|
466
|
+
if (color > 16777215) {
|
|
467
|
+
|
|
468
|
+
blue = color & 0x000000FF;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
else {
|
|
472
|
+
|
|
473
|
+
blue = color & 0x0000FF;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return blue;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
import { type double } from "../../graphics2d/BasicTypes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Units of Measure to be used with {@link MilStdAttributes#DistanceUnits}
|
|
6
|
+
* Default is meters.
|
|
7
|
+
*/
|
|
8
|
+
export class DistanceUnit {
|
|
9
|
+
private static readonly FEET_PER_METER: double = 3.28084;
|
|
10
|
+
private static readonly FLIGHT_LEVEL_PER_METER: double = 0.0328084; // hundreds of feet
|
|
11
|
+
public readonly conversionFactor: double = 0;
|
|
12
|
+
public readonly label: string;
|
|
13
|
+
|
|
14
|
+
public constructor(conversionFactor: double, label: string) {
|
|
15
|
+
this.conversionFactor = conversionFactor;
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static parse(distanceUnitText: string): DistanceUnit | null {
|
|
20
|
+
if (distanceUnitText == null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
let parts: string[] = distanceUnitText.split(",");
|
|
24
|
+
if (parts.length !== 2) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
let conversionFactor: double = parseFloat(parts[0].trim());
|
|
28
|
+
let label: string = parts[1].trim();
|
|
29
|
+
|
|
30
|
+
return new DistanceUnit(conversionFactor, label);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public toAttribute(): string {
|
|
34
|
+
return this.conversionFactor + "," + this.label;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public static METERS: DistanceUnit = new DistanceUnit(1, "M");
|
|
38
|
+
public static FEET: DistanceUnit = new DistanceUnit(DistanceUnit.FEET_PER_METER, "FT");
|
|
39
|
+
public static FLIGHT_LEVEL: DistanceUnit = new DistanceUnit(DistanceUnit.FLIGHT_LEVEL_PER_METER, "FL");
|
|
40
|
+
}
|