@armyc2.c5isr.renderer/mil-sym-ts-web 2.2.0 → 2.2.1
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/{dist/armyc2.c5isr.renderer-mil-sym-ts-web-2.2.0.tgz → armyc2.c5isr.renderer-mil-sym-ts-web-2.2.1.tgz} +0 -0
- package/package.json +15 -39
- package/buildNode.bat +0 -2
- package/buildWeb.bat +0 -2
- package/dist/LICENSE +0 -201
- package/dist/README.md +0 -57
- package/dist/package.json +0 -16
- package/index.ts +0 -169
- package/package.bak +0 -50
- package/package.node.json +0 -43
- package/package.pack.json +0 -19
- package/package.packWeb.json +0 -16
- package/package.web.json +0 -40
- package/src/main/ts/android/graphics/Bitmap.ts +0 -7
- package/src/main/ts/android/graphics/Paint.ts +0 -26
- package/src/main/ts/android/graphics/Path.ts +0 -78
- package/src/main/ts/android/graphics/PointF.ts +0 -14
- package/src/main/ts/android/graphics/Rect.ts +0 -18
- package/src/main/ts/android/graphics/RectF.ts +0 -50
- package/src/main/ts/android/graphics/Region.ts +0 -36
- package/src/main/ts/android/graphics/Typeface.ts +0 -11
- package/src/main/ts/armyc2/c5isr/JavaLineArray/BasicShapes.ts +0 -99
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CChannelPoints2.ts +0 -34
- package/src/main/ts/armyc2/c5isr/JavaLineArray/CELineArray.ts +0 -193
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Channels.ts +0 -2971
- package/src/main/ts/armyc2/c5isr/JavaLineArray/DISMSupport.ts +0 -4008
- package/src/main/ts/armyc2/c5isr/JavaLineArray/POINT2.ts +0 -93
- package/src/main/ts/armyc2/c5isr/JavaLineArray/Shape2.ts +0 -89
- package/src/main/ts/armyc2/c5isr/JavaLineArray/TacticalLines.ts +0 -515
- package/src/main/ts/armyc2/c5isr/JavaLineArray/arraysupport.ts +0 -5403
- package/src/main/ts/armyc2/c5isr/JavaLineArray/countsupport.ts +0 -1084
- package/src/main/ts/armyc2/c5isr/JavaLineArray/flot.ts +0 -2173
- package/src/main/ts/armyc2/c5isr/JavaLineArray/lineutility.ts +0 -4934
- package/src/main/ts/armyc2/c5isr/JavaLineArray/ref.ts +0 -7
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/Modifier2.ts +0 -5601
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/P1.ts +0 -14
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/TGLight.ts +0 -648
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsChannelUtility.ts +0 -647
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsMETOC.ts +0 -2994
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/clsUtility.ts +0 -2663
- package/src/main/ts/armyc2/c5isr/JavaTacticalRenderer/mdlGeodesic.ts +0 -669
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipPolygon2.ts +0 -971
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsClipQuad.ts +0 -871
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer.ts +0 -3507
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsRenderer2.ts +0 -500
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtility.ts +0 -1089
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityCPOF.ts +0 -2656
- package/src/main/ts/armyc2/c5isr/RenderMultipoints/clsUtilityGE.ts +0 -1419
- package/src/main/ts/armyc2/c5isr/data/genc.json +0 -1407
- package/src/main/ts/armyc2/c5isr/data/msd.json +0 -17311
- package/src/main/ts/armyc2/c5isr/data/mse.json +0 -18500
- package/src/main/ts/armyc2/c5isr/data/svgd.json +0 -31214
- package/src/main/ts/armyc2/c5isr/data/svge.json +0 -30558
- package/src/main/ts/armyc2/c5isr/graphics2d/AffineTransform.ts +0 -10
- package/src/main/ts/armyc2/c5isr/graphics2d/Area.ts +0 -437
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicStroke.ts +0 -429
- package/src/main/ts/armyc2/c5isr/graphics2d/BasicTypes.ts +0 -7
- package/src/main/ts/armyc2/c5isr/graphics2d/BufferedImage.ts +0 -35
- package/src/main/ts/armyc2/c5isr/graphics2d/Font.ts +0 -111
- package/src/main/ts/armyc2/c5isr/graphics2d/FontMetrics.ts +0 -29
- package/src/main/ts/armyc2/c5isr/graphics2d/FontRenderContext.ts +0 -18
- package/src/main/ts/armyc2/c5isr/graphics2d/GeneralPath.ts +0 -211
- package/src/main/ts/armyc2/c5isr/graphics2d/Graphics2D.ts +0 -80
- package/src/main/ts/armyc2/c5isr/graphics2d/IPathIterator.ts +0 -33
- package/src/main/ts/armyc2/c5isr/graphics2d/ImageIO.ts +0 -16
- package/src/main/ts/armyc2/c5isr/graphics2d/Line2D.ts +0 -726
- package/src/main/ts/armyc2/c5isr/graphics2d/PathIterator.ts +0 -141
- package/src/main/ts/armyc2/c5isr/graphics2d/Point.ts +0 -112
- package/src/main/ts/armyc2/c5isr/graphics2d/Point2D.ts +0 -261
- package/src/main/ts/armyc2/c5isr/graphics2d/Polygon.ts +0 -391
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle.ts +0 -567
- package/src/main/ts/armyc2/c5isr/graphics2d/Rectangle2D.ts +0 -445
- package/src/main/ts/armyc2/c5isr/graphics2d/Shape.ts +0 -31
- package/src/main/ts/armyc2/c5isr/graphics2d/Stroke.ts +0 -18
- package/src/main/ts/armyc2/c5isr/graphics2d/TextLayout.ts +0 -45
- package/src/main/ts/armyc2/c5isr/graphics2d/TexturePaint.ts +0 -25
- package/src/main/ts/armyc2/c5isr/renderer/IIconRenderer.ts +0 -15
- package/src/main/ts/armyc2/c5isr/renderer/IconRenderer.ts +0 -22
- package/src/main/ts/armyc2/c5isr/renderer/MilStdIconRenderer.ts +0 -269
- package/src/main/ts/armyc2/c5isr/renderer/ModifierRenderer.ts +0 -9882
- package/src/main/ts/armyc2/c5isr/renderer/PatternFillRenderer.ts +0 -146
- package/src/main/ts/armyc2/c5isr/renderer/SinglePointSVGRenderer.ts +0 -1265
- package/src/main/ts/armyc2/c5isr/renderer/shapes/arc.ts +0 -64
- package/src/main/ts/armyc2/c5isr/renderer/shapes/bcurve.ts +0 -95
- package/src/main/ts/armyc2/c5isr/renderer/shapes/ellipse.ts +0 -93
- package/src/main/ts/armyc2/c5isr/renderer/shapes/line.ts +0 -114
- package/src/main/ts/armyc2/c5isr/renderer/shapes/path.ts +0 -555
- package/src/main/ts/armyc2/c5isr/renderer/shapes/pathiterator.ts +0 -62
- package/src/main/ts/armyc2/c5isr/renderer/shapes/point.ts +0 -120
- package/src/main/ts/armyc2/c5isr/renderer/shapes/rectangle.ts +0 -431
- package/src/main/ts/armyc2/c5isr/renderer/shapes/roundedrectangle.ts +0 -99
- package/src/main/ts/armyc2/c5isr/renderer/shapes/types.ts +0 -25
- package/src/main/ts/armyc2/c5isr/renderer/shapes/utilities.ts +0 -203
- package/src/main/ts/armyc2/c5isr/renderer/utilities/AffiliationColors.ts +0 -104
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Color.ts +0 -481
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DistanceUnit.ts +0 -40
- package/src/main/ts/armyc2/c5isr/renderer/utilities/DrawRules.ts +0 -1323
- package/src/main/ts/armyc2/c5isr/renderer/utilities/EntityCode.ts +0 -51
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ErrorLogger.ts +0 -736
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GENCLookup.ts +0 -106
- package/src/main/ts/armyc2/c5isr/renderer/utilities/GeoPixelConversion3D.ts +0 -84
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IMultiPointRenderer.ts +0 -87
- package/src/main/ts/armyc2/c5isr/renderer/utilities/IPointConversion.ts +0 -34
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ImageInfo.ts +0 -324
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUCache.ts +0 -127
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LRUEntry.ts +0 -18
- package/src/main/ts/armyc2/c5isr/renderer/utilities/LogLevel.ts +0 -111
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MODrawRules.ts +0 -219
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSInfo.ts +0 -1008
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MSLookup.ts +0 -882
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdAttributes.ts +0 -380
- package/src/main/ts/armyc2/c5isr/renderer/utilities/MilStdSymbol.ts +0 -797
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Modifiers.ts +0 -1699
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversion.ts +0 -178
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConversionDummy.ts +0 -45
- package/src/main/ts/armyc2/c5isr/renderer/utilities/PointConverter3D.ts +0 -126
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RectUtilities.ts +0 -118
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererException.ts +0 -11
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererSettings.ts +0 -1201
- package/src/main/ts/armyc2/c5isr/renderer/utilities/RendererUtilities.ts +0 -591
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGInfo.ts +0 -29
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGLookup.ts +0 -753
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGSymbolInfo.ts +0 -137
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SVGTextInfo.ts +0 -438
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEvent.ts +0 -19
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsChangedEventListener.ts +0 -10
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SettingsEventListener.ts +0 -5
- package/src/main/ts/armyc2/c5isr/renderer/utilities/Shape2SVG.ts +0 -404
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeInfo.ts +0 -525
- package/src/main/ts/armyc2/c5isr/renderer/utilities/ShapeUtilities.ts +0 -55
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolDimensionInfo.ts +0 -36
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolID.ts +0 -1055
- package/src/main/ts/armyc2/c5isr/renderer/utilities/SymbolUtilities.ts +0 -2085
- package/src/main/ts/armyc2/c5isr/renderer/utilities/TextInfo.ts +0 -157
- package/src/main/ts/armyc2/c5isr/web/render/GeoPixelConversion.ts +0 -86
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandler.ts +0 -3798
- package/src/main/ts/armyc2/c5isr/web/render/MultiPointHandlerSVG.ts +0 -412
- package/src/main/ts/armyc2/c5isr/web/render/PointConverter.ts +0 -124
- package/src/main/ts/armyc2/c5isr/web/render/SymbolModifiers.ts +0 -26
- package/src/main/ts/armyc2/c5isr/web/render/WebRenderer.ts +0 -677
- package/src/main/ts/armyc2/c5isr/web/render/utilities/JavaRendererUtilities.ts +0 -484
- package/src/main/ts/armyc2/c5isr/web/render/utilities/LineInfo.ts +0 -62
- package/src/main/ts/armyc2/c5isr/web/render/utilities/SymbolInfo.ts +0 -46
- package/src/main/ts/armyc2/c5isr/web/render/utilities/TextInfo.ts +0 -51
- package/src/main/ts/org/gavaghan/geodesy/Angle.ts +0 -31
- package/src/main/ts/org/gavaghan/geodesy/Ellipsoid.ts +0 -71
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCalculator.ts +0 -200
- package/src/main/ts/org/gavaghan/geodesy/GeodeticCurve.ts +0 -55
- package/src/main/ts/org/gavaghan/geodesy/GeodeticMeasurement.ts +0 -68
- package/src/main/ts/org/gavaghan/geodesy/GlobalCoordinates.ts +0 -103
- package/src/main/ts/org/gavaghan/geodesy/GlobalPosition.ts +0 -90
- package/test/ExportSPImages.js +0 -692
- package/test/MPWW.html +0 -556
- package/test/MPWorker.js +0 -318
- package/test/SPWorker.js +0 -233
- package/test/SVGWW.html +0 -363
- package/test/singlePointTester3.html +0 -751
- package/tsconfig.json +0 -54
- package/typedoc.json +0 -30
- package/updateVersion.js +0 -21
- package/webpack.config.js +0 -34
- package/webpackn.config.js +0 -28
- package/webpackr.config.js +0 -47
- package/webpackw.config.js +0 -23
- /package/{dist/C5Ren.d.ts → C5Ren.d.ts} +0 -0
- /package/{dist/C5Ren.js → C5Ren.js} +0 -0
- /package/{dist/C5Ren.js.map → C5Ren.js.map} +0 -0
- /package/{dist/manifest.json → manifest.json} +0 -0
|
@@ -1,1265 +0,0 @@
|
|
|
1
|
-
import { createCanvas, Canvas, CanvasRenderingContext2D } from "canvas";
|
|
2
|
-
import { type int, type float, type double } from "../graphics2d/BasicTypes";
|
|
3
|
-
|
|
4
|
-
import { Point } from "../graphics2d/Point"
|
|
5
|
-
import { Point2D } from "../graphics2d/Point2D"
|
|
6
|
-
import { Rectangle2D } from "../graphics2d/Rectangle2D"
|
|
7
|
-
|
|
8
|
-
import { ModifierRenderer } from "../renderer/ModifierRenderer"
|
|
9
|
-
|
|
10
|
-
import { Color } from "../renderer/utilities/Color"
|
|
11
|
-
import { DrawRules } from "../renderer/utilities/DrawRules"
|
|
12
|
-
import { ErrorLogger } from "../renderer/utilities/ErrorLogger"
|
|
13
|
-
import { ImageInfo } from "../renderer/utilities/ImageInfo"
|
|
14
|
-
import { MilStdAttributes } from "../renderer/utilities/MilStdAttributes"
|
|
15
|
-
import { MSInfo } from "../renderer/utilities/MSInfo"
|
|
16
|
-
import { MSLookup } from "../renderer/utilities/MSLookup"
|
|
17
|
-
import { RectUtilities } from "../renderer/utilities/RectUtilities"
|
|
18
|
-
import { RendererSettings } from "../renderer/utilities/RendererSettings"
|
|
19
|
-
import { RendererUtilities } from "../renderer/utilities/RendererUtilities"
|
|
20
|
-
|
|
21
|
-
import { SVGInfo } from "../renderer/utilities/SVGInfo"
|
|
22
|
-
import { SVGLookup } from "../renderer/utilities/SVGLookup"
|
|
23
|
-
import { SVGSymbolInfo } from "../renderer/utilities/SVGSymbolInfo"
|
|
24
|
-
import { SymbolDimensionInfo } from "../renderer/utilities/SymbolDimensionInfo"
|
|
25
|
-
import { SymbolID } from "../renderer/utilities/SymbolID"
|
|
26
|
-
import { SymbolUtilities } from "../renderer/utilities/SymbolUtilities"
|
|
27
|
-
|
|
28
|
-
import { ShapeUtilities } from "./utilities/ShapeUtilities";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
export class SinglePointSVGRenderer {
|
|
35
|
-
|
|
36
|
-
private readonly TAG: string = "SinglePointSVGRenderer";
|
|
37
|
-
private static _instance: SinglePointSVGRenderer;
|
|
38
|
-
public static readonly RENDERER_ID: string = "2525D";
|
|
39
|
-
private _buffer: any;//OffscreenCanvas | Canvas;
|
|
40
|
-
private _fontRenderContext: any;//OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D;
|
|
41
|
-
|
|
42
|
-
private static isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
43
|
-
private static isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
44
|
-
private static OSCDefined = typeof OffscreenCanvasRenderingContext2D !== 'undefined';//web workers fail isBrowser test
|
|
45
|
-
|
|
46
|
-
public constructor() {
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private init(): void {
|
|
51
|
-
try {
|
|
52
|
-
SVGLookup.getInstance();
|
|
53
|
-
ModifierRenderer.getInstance();
|
|
54
|
-
|
|
55
|
-
if (this._buffer == null || this._buffer === undefined)
|
|
56
|
-
{
|
|
57
|
-
if(SinglePointSVGRenderer.OSCDefined)//(SinglePointSVGRenderer.OSCDefined)
|
|
58
|
-
this._buffer = new OffscreenCanvas(8,8);
|
|
59
|
-
else
|
|
60
|
-
this._buffer = createCanvas(8,8);
|
|
61
|
-
|
|
62
|
-
this._fontRenderContext = this._buffer.getContext("2d");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
} catch (exc) {
|
|
66
|
-
if (exc instanceof Error) {
|
|
67
|
-
ErrorLogger.LogException("SinglePointSVGRenderer", "init", exc);
|
|
68
|
-
} else {
|
|
69
|
-
throw exc;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public static getInstance(): SinglePointSVGRenderer {
|
|
75
|
-
if (!SinglePointSVGRenderer._instance) {
|
|
76
|
-
SinglePointSVGRenderer._instance = new SinglePointSVGRenderer();
|
|
77
|
-
SinglePointSVGRenderer._instance.init();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return SinglePointSVGRenderer._instance;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
public render(symbolID: string, modifiers: Map<string, string>, attributes: Map<string, string>): SVGSymbolInfo {
|
|
85
|
-
let si: SVGSymbolInfo;//new SinglePointInfo(null, x, y);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (modifiers == null) {
|
|
89
|
-
modifiers = new Map<string, string>();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (SymbolID.getSymbolSet(symbolID) === SymbolID.SymbolSet_ControlMeasure ||
|
|
93
|
-
SymbolID.getSymbolSet(symbolID) === SymbolID.SymbolSet_Atmospheric ||
|
|
94
|
-
SymbolID.getSymbolSet(symbolID) === SymbolID.SymbolSet_Oceanographic ||
|
|
95
|
-
SymbolID.getSymbolSet(symbolID) === SymbolID.SymbolSet_MeteorologicalSpace) {
|
|
96
|
-
//30022500001310010000
|
|
97
|
-
si = this.RenderSP(symbolID, modifiers, attributes);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
//30020100001107000000
|
|
101
|
-
si = this.RenderUnit(symbolID, modifiers, attributes);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return si;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public RenderUnit(symbolID: string, modifiers: Map<string, string>, attributes: Map<string, string>): SVGSymbolInfo {
|
|
108
|
-
let ii: ImageInfo;//new SinglePointInfo(null, x, y);
|
|
109
|
-
let si: SVGSymbolInfo = null;
|
|
110
|
-
let newSDI: SymbolDimensionInfo = null;
|
|
111
|
-
try {
|
|
112
|
-
let lineColor: string = null;//SymbolUtilitiesD.getLineColorOfAffiliation(symbolID);
|
|
113
|
-
let fillColor: string = null;
|
|
114
|
-
|
|
115
|
-
if(SymbolID.getSymbolSet(symbolID)==SymbolID.SymbolSet_MineWarfare && RendererSettings.getInstance().getSeaMineRenderMethod()==RendererSettings.SeaMineRenderMethod_MEDAL)
|
|
116
|
-
{
|
|
117
|
-
lineColor = RendererUtilities.colorToHexString(SymbolUtilities.getLineColorOfAffiliation(symbolID), false);
|
|
118
|
-
fillColor = RendererUtilities.colorToHexString(SymbolUtilities.getFillColorOfAffiliation(symbolID), true);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
let iconColor: string = null;
|
|
122
|
-
|
|
123
|
-
let alpha: float = -1;
|
|
124
|
-
|
|
125
|
-
//SVG values
|
|
126
|
-
let frameID: string = null;
|
|
127
|
-
let iconID: string = null;
|
|
128
|
-
let mod1ID: string = null;
|
|
129
|
-
let mod2ID: string = null;
|
|
130
|
-
let siFrame: SVGInfo = null;
|
|
131
|
-
let siIcon: SVGInfo = null;
|
|
132
|
-
let siMod1: SVGInfo = null;
|
|
133
|
-
let siMod2: SVGInfo = null;
|
|
134
|
-
let top: int = 0;
|
|
135
|
-
let left: int = 0;
|
|
136
|
-
let width: int = 0;
|
|
137
|
-
let height: int = 0;
|
|
138
|
-
let svgStart: string = null;
|
|
139
|
-
let strSVG: string = null;
|
|
140
|
-
let strSVGFrame: string = null;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
let symbolBounds: Rectangle2D = null;
|
|
144
|
-
let fullBounds: Rectangle2D = null;
|
|
145
|
-
let fullBMP: ImageBitmap = null;
|
|
146
|
-
|
|
147
|
-
let hasDisplayModifiers: boolean = false;
|
|
148
|
-
let hasTextModifiers: boolean = false;
|
|
149
|
-
|
|
150
|
-
let pixelSize: int = 50;
|
|
151
|
-
let keepUnitRatio: boolean = true;
|
|
152
|
-
let scale: double = 1.0;
|
|
153
|
-
let icon: boolean = false;
|
|
154
|
-
let asIcon: boolean = false;
|
|
155
|
-
let noFrame: boolean = false;
|
|
156
|
-
|
|
157
|
-
let ver: int = SymbolID.getVersion(symbolID);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
// <editor-fold defaultstate="collapsed" desc="Parse Attributes">
|
|
161
|
-
try
|
|
162
|
-
{
|
|
163
|
-
if(attributes != null)
|
|
164
|
-
{
|
|
165
|
-
if (attributes.has(MilStdAttributes.PixelSize)) {
|
|
166
|
-
pixelSize = parseInt(attributes.get(MilStdAttributes.PixelSize));
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
pixelSize = RendererSettings.getInstance().getDefaultPixelSize();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (attributes.has(MilStdAttributes.KeepUnitRatio)) {
|
|
173
|
-
keepUnitRatio = attributes.get(MilStdAttributes.KeepUnitRatio).toLowerCase() === 'true';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (attributes.has(MilStdAttributes.DrawAsIcon)) {
|
|
177
|
-
icon = attributes.get(MilStdAttributes.DrawAsIcon).toLowerCase() === 'true';
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (icon)//icon won't show modifiers or display icons
|
|
181
|
-
{
|
|
182
|
-
//TODO: symbolID modifications as necessary
|
|
183
|
-
keepUnitRatio = false;
|
|
184
|
-
hasDisplayModifiers = false;
|
|
185
|
-
hasTextModifiers = false;
|
|
186
|
-
//symbolID = symbolID.substring(0, 10) + "-----";
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
hasDisplayModifiers = ModifierRenderer.hasDisplayModifiers(symbolID, modifiers);
|
|
190
|
-
hasTextModifiers = ModifierRenderer.hasTextModifiers(symbolID, modifiers);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (attributes.has(MilStdAttributes.LineColor)) {
|
|
194
|
-
lineColor = attributes.get(MilStdAttributes.LineColor);
|
|
195
|
-
}
|
|
196
|
-
if (attributes.has(MilStdAttributes.FillColor)) {
|
|
197
|
-
fillColor = attributes.get(MilStdAttributes.FillColor);
|
|
198
|
-
}
|
|
199
|
-
if (attributes.has(MilStdAttributes.IconColor))
|
|
200
|
-
{
|
|
201
|
-
iconColor = attributes.get(MilStdAttributes.IconColor);
|
|
202
|
-
}//*/
|
|
203
|
-
if (attributes.has(MilStdAttributes.Alpha)) {
|
|
204
|
-
alpha = parseFloat(attributes.get(MilStdAttributes.Alpha));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
} catch (excModifiers) {
|
|
209
|
-
if (excModifiers instanceof Error) {
|
|
210
|
-
ErrorLogger.LogException("SinglePointSVGRenderer", "RenderUnit", excModifiers);
|
|
211
|
-
} else {
|
|
212
|
-
throw excModifiers;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
// </editor-fold>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
//let key: string = SinglePointSVGRenderer.makeCacheKey(symbolID, lineColor, fillColor, pixelSize, keepUnitRatio, false);;
|
|
219
|
-
//see if it's in the cache
|
|
220
|
-
/*if(_unitCache != null)
|
|
221
|
-
{
|
|
222
|
-
ii = _unitCache[key];
|
|
223
|
-
}//*/
|
|
224
|
-
|
|
225
|
-
if (ii == null) //ii is always null because the above check is commented out
|
|
226
|
-
{
|
|
227
|
-
|
|
228
|
-
let version: int = SymbolID.getVersion(symbolID);
|
|
229
|
-
//Get SVG pieces of symbol
|
|
230
|
-
frameID = SVGLookup.getFrameID(symbolID);
|
|
231
|
-
iconID = SVGLookup.getMainIconID(symbolID);
|
|
232
|
-
mod1ID = SVGLookup.getMod1ID(symbolID);
|
|
233
|
-
mod2ID = SVGLookup.getMod2ID(symbolID);
|
|
234
|
-
siFrame = SVGLookup.getInstance().getSVGLInfo(frameID, version);
|
|
235
|
-
siIcon = SVGLookup.getInstance().getSVGLInfo(iconID, version);
|
|
236
|
-
|
|
237
|
-
if (siFrame == null) {
|
|
238
|
-
frameID = SVGLookup.getFrameID(SymbolUtilities.reconcileSymbolID(symbolID));
|
|
239
|
-
siFrame = SVGLookup.getInstance().getSVGLInfo(frameID, version);
|
|
240
|
-
if (siFrame == null)//still no match, get unknown frame
|
|
241
|
-
{
|
|
242
|
-
frameID = SVGLookup.getFrameID(SymbolID.setSymbolSet(symbolID, SymbolID.SymbolSet_Unknown));
|
|
243
|
-
siFrame = SVGLookup.getInstance().getSVGLInfo(frameID, version);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (siIcon == null) {
|
|
248
|
-
if (iconID.substring(2, 8) === "000000" === false && MSLookup.getInstance().getMSLInfo(symbolID) == null) {
|
|
249
|
-
|
|
250
|
-
siIcon = SVGLookup.getInstance().getSVGLInfo("98100000", version);
|
|
251
|
-
}
|
|
252
|
-
//inverted question mark
|
|
253
|
-
else {
|
|
254
|
-
if (SymbolID.getSymbolSet(symbolID) === SymbolID.SymbolSet_Unknown) {
|
|
255
|
-
|
|
256
|
-
siIcon = SVGLookup.getInstance().getSVGLInfo("00000000", version);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
//question mark
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if(RendererSettings.getInstance().getScaleMainIcon())
|
|
264
|
-
siIcon = RendererUtilities.scaleIcon(symbolID,siIcon);
|
|
265
|
-
|
|
266
|
-
siMod1 = SVGLookup.getInstance().getSVGLInfo(mod1ID, version);
|
|
267
|
-
siMod2 = SVGLookup.getInstance().getSVGLInfo(mod2ID, version);
|
|
268
|
-
top = Math.round(siFrame.getBbox().getY());
|
|
269
|
-
left = Math.round(siFrame.getBbox().getX());
|
|
270
|
-
width = Math.round(siFrame.getBbox().getWidth());
|
|
271
|
-
height = Math.round(siFrame.getBbox().getHeight());
|
|
272
|
-
|
|
273
|
-
//update line and fill color of frame SVG
|
|
274
|
-
if (lineColor != null || fillColor != null) {
|
|
275
|
-
|
|
276
|
-
strSVGFrame = RendererUtilities.setSVGFrameColors(symbolID, siFrame.getSVG(), RendererUtilities.getColorFromHexString(lineColor), RendererUtilities.getColorFromHexString(fillColor));
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
else {
|
|
280
|
-
|
|
281
|
-
strSVGFrame = siFrame.getSVG();
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (frameID === "octagon")//for the 1 unit symbol that doesn't have a frame: 30 + 15000
|
|
286
|
-
{
|
|
287
|
-
noFrame = true;
|
|
288
|
-
strSVGFrame = strSVGFrame.replace("<g id=\"octagon\">", "<g id=\"octagon\" display=\"none\">");
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
//get SVG dimensions and target dimensions
|
|
293
|
-
symbolBounds = new Rectangle2D(left, top, width, height);
|
|
294
|
-
let rect: Rectangle2D = RectUtilities.copyRect(symbolBounds);
|
|
295
|
-
let ratio: float = -1;
|
|
296
|
-
|
|
297
|
-
if (pixelSize > 0 && keepUnitRatio === true) {
|
|
298
|
-
let heightRatio: float = SymbolUtilities.getUnitRatioHeight(symbolID);
|
|
299
|
-
let widthRatio: float = SymbolUtilities.getUnitRatioWidth(symbolID);
|
|
300
|
-
|
|
301
|
-
if (noFrame === true)//using octagon with display="none" as frame for a 1x1 shape
|
|
302
|
-
{
|
|
303
|
-
heightRatio = 1.0;
|
|
304
|
-
widthRatio = 1.0;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if (heightRatio > widthRatio) {
|
|
308
|
-
pixelSize = ((pixelSize / 1.5) * heightRatio) as int;
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
pixelSize = ((pixelSize / 1.5) * widthRatio) as int;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
if (pixelSize > 0) {
|
|
315
|
-
let p: float = pixelSize;
|
|
316
|
-
let h: float = rect.getHeight() as float;
|
|
317
|
-
let w: float = rect.getWidth() as float;
|
|
318
|
-
|
|
319
|
-
ratio = Math.min((p / h), (p / w));
|
|
320
|
-
|
|
321
|
-
symbolBounds = RectUtilities.makeRectangle2DFromRect(0, 0, w * ratio, h * ratio);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
let sbGroupUnit:string = "";
|
|
325
|
-
if (siFrame != null) {
|
|
326
|
-
|
|
327
|
-
sbGroupUnit += ("<g transform=\"translate(" + (siFrame.getBbox().getX() * -ratio) + ',' + (siFrame.getBbox().getY() * -ratio) + ") scale(" + ratio + "," + ratio + ")\"" + ">");
|
|
328
|
-
if (siFrame != null) {
|
|
329
|
-
|
|
330
|
-
sbGroupUnit += (strSVGFrame);
|
|
331
|
-
}
|
|
332
|
-
//(siFrame.getSVG());
|
|
333
|
-
|
|
334
|
-
let color:string="";
|
|
335
|
-
if(iconColor != null)
|
|
336
|
-
{
|
|
337
|
-
//make sure string is properly formatted.
|
|
338
|
-
iconColor = RendererUtilities.colorToHexString(RendererUtilities.getColorFromHexString(iconColor),false);
|
|
339
|
-
if(iconColor != null && iconColor != "#000000" && iconColor != "")
|
|
340
|
-
color = " stroke=\"" + iconColor + "\" fill=\"" + iconColor + "\" ";
|
|
341
|
-
else
|
|
342
|
-
iconColor = null;
|
|
343
|
-
}
|
|
344
|
-
let unit:string = "<g" + color + ">";
|
|
345
|
-
if (siIcon != null)
|
|
346
|
-
unit += (siIcon.getSVG());
|
|
347
|
-
if (siMod1 != null)
|
|
348
|
-
unit += (siMod1.getSVG());
|
|
349
|
-
if (siMod2 != null)
|
|
350
|
-
unit += (siMod2.getSVG());
|
|
351
|
-
if(iconColor)
|
|
352
|
-
unit = unit.replaceAll("#000000",iconColor);
|
|
353
|
-
unit += "</g>";
|
|
354
|
-
|
|
355
|
-
sbGroupUnit += unit + "</g>";
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
//center of octagon is the center of all unit symbols
|
|
362
|
-
let centerOctagon: Point = new Point(306, 396);
|
|
363
|
-
ShapeUtilities.offset(centerOctagon,-left,-top);
|
|
364
|
-
//centerOctagon.translate(-left, -top);//offset for the symbol bounds x,y
|
|
365
|
-
//scale center point by same ratio as the symbol
|
|
366
|
-
centerOctagon = new Point((centerOctagon.x * ratio) as int, (centerOctagon.y * ratio) as int);
|
|
367
|
-
|
|
368
|
-
//set centerpoint of the image
|
|
369
|
-
let centerPoint: Point = centerOctagon;
|
|
370
|
-
let centerCache: Point = new Point(centerOctagon.x, centerOctagon.y);
|
|
371
|
-
|
|
372
|
-
//y offset to get centerpoint so we set back to zero when done.
|
|
373
|
-
//symbolBounds.top = 0;
|
|
374
|
-
RectUtilities.shift(symbolBounds, 0, -symbolBounds.getY() as int);
|
|
375
|
-
|
|
376
|
-
//Add core symbol to SVGSymbolInfo
|
|
377
|
-
let anchor: Point2D = new Point2D(symbolBounds.getCenterX(), symbolBounds.getCenterY());
|
|
378
|
-
si = new SVGSymbolInfo(sbGroupUnit.toString().valueOf(), anchor, symbolBounds, symbolBounds);
|
|
379
|
-
|
|
380
|
-
hasDisplayModifiers = ModifierRenderer.hasDisplayModifiers(symbolID, modifiers);
|
|
381
|
-
hasTextModifiers = ModifierRenderer.hasTextModifiers(symbolID, modifiers);
|
|
382
|
-
//process display modifiers
|
|
383
|
-
if (hasDisplayModifiers) {
|
|
384
|
-
newSDI = ModifierRenderer.processUnitDisplayModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
385
|
-
if (newSDI != null) {
|
|
386
|
-
si = newSDI as SVGSymbolInfo;
|
|
387
|
-
newSDI = null;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
//process text modifiers
|
|
393
|
-
if (hasTextModifiers)
|
|
394
|
-
{
|
|
395
|
-
if(modifiers == null)
|
|
396
|
-
modifiers = new Map<string,string>();
|
|
397
|
-
let ss: int = SymbolID.getSymbolSet(symbolID);
|
|
398
|
-
switch (ss) {
|
|
399
|
-
case SymbolID.SymbolSet_LandUnit:
|
|
400
|
-
case SymbolID.SymbolSet_LandCivilianUnit_Organization: {
|
|
401
|
-
if (ver >= SymbolID.Version_2525E) {
|
|
402
|
-
|
|
403
|
-
newSDI = ModifierRenderer.processLandUnitTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
else {
|
|
407
|
-
|
|
408
|
-
newSDI = ModifierRenderer.processLandUnitTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
case SymbolID.SymbolSet_LandEquipment:
|
|
415
|
-
case SymbolID.SymbolSet_SignalsIntelligence_Land: {
|
|
416
|
-
if (ver >= SymbolID.Version_2525E) {
|
|
417
|
-
|
|
418
|
-
newSDI = ModifierRenderer.processLandEquipmentTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
else {
|
|
422
|
-
|
|
423
|
-
newSDI = ModifierRenderer.processLandEquipmentTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
case SymbolID.SymbolSet_LandInstallation: {
|
|
430
|
-
if (ver >= SymbolID.Version_2525E) {
|
|
431
|
-
|
|
432
|
-
newSDI = ModifierRenderer.processLandInstallationTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
else {
|
|
436
|
-
|
|
437
|
-
newSDI = ModifierRenderer.processLandInstallationTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
break;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
case SymbolID.SymbolSet_DismountedIndividuals: {
|
|
444
|
-
newSDI = ModifierRenderer.processDismountedIndividualsTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
445
|
-
break;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
case SymbolID.SymbolSet_Space:
|
|
449
|
-
case SymbolID.SymbolSet_SpaceMissile:
|
|
450
|
-
case SymbolID.SymbolSet_Air:
|
|
451
|
-
case SymbolID.SymbolSet_AirMissile:
|
|
452
|
-
case SymbolID.SymbolSet_SignalsIntelligence_Air: {
|
|
453
|
-
if (ver >= SymbolID.Version_2525E) {
|
|
454
|
-
|
|
455
|
-
newSDI = ModifierRenderer.processAirSpaceUnitTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
else {
|
|
459
|
-
|
|
460
|
-
newSDI = ModifierRenderer.processAirSpaceUnitTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
break;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
case SymbolID.SymbolSet_SignalsIntelligence_Space: {
|
|
467
|
-
if (ver < SymbolID.Version_2525E) {
|
|
468
|
-
|
|
469
|
-
newSDI = ModifierRenderer.processAirSpaceUnitTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
else//SIGINT in 2525E+ uses modifer places based on frame shape
|
|
473
|
-
{
|
|
474
|
-
let frameShape: string = SymbolID.getFrameShape(symbolID);
|
|
475
|
-
if (frameShape === SymbolID.FrameShape_Space || frameShape === SymbolID.FrameShape_Air) {
|
|
476
|
-
|
|
477
|
-
newSDI = ModifierRenderer.processAirSpaceUnitTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
else {
|
|
481
|
-
if (frameShape === SymbolID.FrameShape_LandEquipment_SeaSurface) {
|
|
482
|
-
//sea surface, but can't tell which so default land equip
|
|
483
|
-
newSDI = ModifierRenderer.processLandEquipmentTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
else {
|
|
487
|
-
if (frameShape === SymbolID.FrameShape_SeaSubsurface) {
|
|
488
|
-
|
|
489
|
-
newSDI = ModifierRenderer.processSeaSubSurfaceTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
else {
|
|
493
|
-
//default land equipment
|
|
494
|
-
newSDI = ModifierRenderer.processLandEquipmentTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
case SymbolID.SymbolSet_SeaSurface:
|
|
506
|
-
case SymbolID.SymbolSet_SignalsIntelligence_SeaSurface: {
|
|
507
|
-
if (ver >= SymbolID.Version_2525E) {
|
|
508
|
-
|
|
509
|
-
newSDI = ModifierRenderer.processSeaSurfaceTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
else {
|
|
513
|
-
|
|
514
|
-
newSDI = ModifierRenderer.processSeaSurfaceTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
break;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
case SymbolID.SymbolSet_SeaSubsurface:
|
|
521
|
-
case SymbolID.SymbolSet_SignalsIntelligence_SeaSubsurface: {
|
|
522
|
-
if (ver >= SymbolID.Version_2525E) {
|
|
523
|
-
|
|
524
|
-
newSDI = ModifierRenderer.processSeaSubSurfaceTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
else {
|
|
528
|
-
|
|
529
|
-
newSDI = ModifierRenderer.processSeaSubSurfaceTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
break;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
case SymbolID.SymbolSet_Activities: {
|
|
536
|
-
if (ver >= SymbolID.Version_2525E) {
|
|
537
|
-
|
|
538
|
-
newSDI = ModifierRenderer.processActivitiesTextModifiersE(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
else {
|
|
542
|
-
|
|
543
|
-
newSDI = ModifierRenderer.processActivitiesTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
break;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
case SymbolID.SymbolSet_CyberSpace: {
|
|
550
|
-
newSDI = ModifierRenderer.processCyberSpaceTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
case SymbolID.SymbolSet_MineWarfare: {
|
|
555
|
-
break;
|
|
556
|
-
}
|
|
557
|
-
//no modifiers
|
|
558
|
-
case SymbolID.SymbolSet_Unknown:
|
|
559
|
-
default: { //in theory, will never get here
|
|
560
|
-
newSDI = ModifierRenderer.processUnknownTextModifiers(si, symbolID, modifiers, attributes, this._fontRenderContext);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
if (newSDI != null) {
|
|
568
|
-
si = newSDI as SVGSymbolInfo;
|
|
569
|
-
}
|
|
570
|
-
newSDI = null;//*/
|
|
571
|
-
|
|
572
|
-
let widthOffset: int = 0;
|
|
573
|
-
if (hasTextModifiers) {
|
|
574
|
-
|
|
575
|
-
widthOffset = 2;
|
|
576
|
-
}
|
|
577
|
-
//add for the text outline
|
|
578
|
-
|
|
579
|
-
let svgWidth: int = (si.getImageBounds().getWidth() + widthOffset) as int;
|
|
580
|
-
let svgHeight: int = si.getImageBounds().getHeight() as int;
|
|
581
|
-
//add SVG tag with dimensions
|
|
582
|
-
//draw unit from SVG
|
|
583
|
-
let svgAlpha: string = "";
|
|
584
|
-
if (alpha >= 0 && alpha <= 255) {
|
|
585
|
-
|
|
586
|
-
svgAlpha = " opacity=\"" + alpha / 255 + "\"";
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
svgStart = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"" + svgWidth + "\" height=\"" + svgHeight + "\" viewBox=\"" + 0 + " " + 0 + " " + svgWidth + " " + svgHeight + "\"" + svgAlpha + ">\n";
|
|
590
|
-
let svgTranslateGroup: string;
|
|
591
|
-
|
|
592
|
-
let transX: double = si.getImageBounds().getX() * -1;
|
|
593
|
-
let transY: double = si.getImageBounds().getY() * -1;
|
|
594
|
-
let anchor: Point2D = si.getSymbolCenterPoint();
|
|
595
|
-
let imageBounds: Rectangle2D = si.getImageBounds();
|
|
596
|
-
if (transX > 0 || transY > 0) {
|
|
597
|
-
ShapeUtilities.offset(anchor, transX, transY);
|
|
598
|
-
ShapeUtilities.offset(symbolBounds, transX, transY);
|
|
599
|
-
ShapeUtilities.offset(imageBounds, transX, transY);
|
|
600
|
-
svgTranslateGroup = "<g transform=\"translate(" + transX + "," + transY + ")" + "\">\n";
|
|
601
|
-
}
|
|
602
|
-
imageBounds.setRect(imageBounds.getX(), imageBounds.getY(), svgWidth, svgHeight);
|
|
603
|
-
si = new SVGSymbolInfo(si.getSVG(), anchor, symbolBounds, imageBounds);
|
|
604
|
-
let sbSVG:string = "";
|
|
605
|
-
sbSVG += (svgStart);
|
|
606
|
-
sbSVG += (this.makeDescTag(si));
|
|
607
|
-
sbSVG += (this.makeMetadataTag(symbolID, si));
|
|
608
|
-
if (svgTranslateGroup != null) {
|
|
609
|
-
|
|
610
|
-
sbSVG += (svgTranslateGroup);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
sbSVG += (si.getSVG());
|
|
614
|
-
if (svgTranslateGroup != null) {
|
|
615
|
-
|
|
616
|
-
sbSVG += ("\n</g>");
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
sbSVG += ("\n</svg>");
|
|
620
|
-
si = new SVGSymbolInfo(sbSVG.toString().valueOf(), anchor, symbolBounds, imageBounds);
|
|
621
|
-
} catch (exc) {
|
|
622
|
-
if (exc instanceof Error) {
|
|
623
|
-
ErrorLogger.LogException("SinglePointSVGRenderer", "renderUnit", exc);
|
|
624
|
-
} else {
|
|
625
|
-
throw exc;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
return si;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
public RenderSP(symbolID: string, modifiers: Map<string, string>, attributes: Map<string, string>): SVGSymbolInfo | null {
|
|
633
|
-
let si: SVGSymbolInfo = null;
|
|
634
|
-
|
|
635
|
-
let pixelSize: int = 50;
|
|
636
|
-
let scale: double = 1.0;
|
|
637
|
-
let lineColor: string = null;//SymbolUtilitiesD.getLineColorOfAffiliation(symbolID);
|
|
638
|
-
let fillColor: string = null;
|
|
639
|
-
let alpha: float = -1;
|
|
640
|
-
|
|
641
|
-
let keepUnitRatio: boolean = true;
|
|
642
|
-
let asIcon: boolean = false;
|
|
643
|
-
let hasDisplayModifiers: boolean = false;
|
|
644
|
-
let hasTextModifiers: boolean = false;
|
|
645
|
-
let outlineSymbol: boolean = false;
|
|
646
|
-
|
|
647
|
-
//SVG rendering variables
|
|
648
|
-
let msi: MSInfo = null;
|
|
649
|
-
let iconID: string = null;
|
|
650
|
-
let siIcon: SVGInfo = null;
|
|
651
|
-
let mod1ID: string = null;
|
|
652
|
-
let siMod1: SVGInfo = null;
|
|
653
|
-
let top: int = 0;
|
|
654
|
-
let left: int = 0;
|
|
655
|
-
let width: int = 0;
|
|
656
|
-
let height: int = 0;
|
|
657
|
-
let svgStart: string = null;
|
|
658
|
-
let strSVG: string = null;
|
|
659
|
-
|
|
660
|
-
let ratio: double = 0;
|
|
661
|
-
|
|
662
|
-
let symbolBounds: Rectangle2D = null;
|
|
663
|
-
let fullBounds: Rectangle2D = null;
|
|
664
|
-
let fullBMP: ImageBitmap = null;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
let ii: ImageInfo;
|
|
668
|
-
let drawRule: int = 0;
|
|
669
|
-
|
|
670
|
-
try {
|
|
671
|
-
msi = MSLookup.getInstance().getMSLInfo(symbolID);
|
|
672
|
-
|
|
673
|
-
let ss: int = SymbolID.getSymbolSet(symbolID);
|
|
674
|
-
let ec: int = SymbolID.getEntityCode(symbolID);
|
|
675
|
-
let mod1: int = 0;
|
|
676
|
-
|
|
677
|
-
let hasAPFill: boolean = false;
|
|
678
|
-
if (msi != null) { drawRule = msi.getDrawRule(); }
|
|
679
|
-
if(RendererSettings.getInstance().getActionPointDefaultFill())
|
|
680
|
-
{
|
|
681
|
-
if (SymbolUtilities.isActionPoint(symbolID) || //action points
|
|
682
|
-
drawRule === DrawRules.POINT10 || //Sonobuoy
|
|
683
|
-
ec === 180100 || ec === 180200 || ec === 180400) //ACP, CCP, PUP
|
|
684
|
-
{
|
|
685
|
-
if (SymbolID.getSymbolSet(symbolID) === SymbolID.SymbolSet_ControlMeasure) {
|
|
686
|
-
lineColor = "#000000";
|
|
687
|
-
hasAPFill = true;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
if (lineColor == null) {
|
|
691
|
-
|
|
692
|
-
lineColor = RendererUtilities.colorToHexString(SymbolUtilities.getDefaultLineColor(symbolID), false);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
//fillColor = "#FF0000";
|
|
698
|
-
//stroke-opacity
|
|
699
|
-
//fill-opacity="0.4"
|
|
700
|
-
//opacity
|
|
701
|
-
if (attributes != null) {
|
|
702
|
-
if (attributes.has(MilStdAttributes.PixelSize)) {
|
|
703
|
-
|
|
704
|
-
pixelSize = parseInt(attributes.get(MilStdAttributes.PixelSize));
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
if (attributes.has(MilStdAttributes.LineColor)) {
|
|
708
|
-
|
|
709
|
-
lineColor = attributes.get(MilStdAttributes.LineColor);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
if (attributes.has(MilStdAttributes.FillColor)) {
|
|
713
|
-
|
|
714
|
-
fillColor = attributes.get(MilStdAttributes.FillColor);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
if (attributes.has(MilStdAttributes.Alpha)) {
|
|
718
|
-
|
|
719
|
-
alpha = parseInt(attributes.get(MilStdAttributes.Alpha));
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
if (attributes.has(MilStdAttributes.DrawAsIcon)) {
|
|
723
|
-
|
|
724
|
-
asIcon = attributes.get(MilStdAttributes.DrawAsIcon).toLowerCase() === 'true';
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
if (attributes.has(MilStdAttributes.KeepUnitRatio)) {
|
|
728
|
-
|
|
729
|
-
keepUnitRatio = attributes.get(MilStdAttributes.KeepUnitRatio).toLowerCase() === 'true';
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
if (!(asIcon === true || hasAPFill === true))//don't outline icons because they're not going on the map
|
|
734
|
-
{
|
|
735
|
-
if (attributes.has(MilStdAttributes.OutlineSymbol)) {
|
|
736
|
-
|
|
737
|
-
outlineSymbol = attributes.get(MilStdAttributes.OutlineSymbol).toLowerCase() === 'true';
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
else {
|
|
741
|
-
|
|
742
|
-
outlineSymbol = RendererSettings.getInstance().getOutlineSPControlMeasures();
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
if (SymbolUtilities.isMultiPoint(symbolID)) {
|
|
748
|
-
|
|
749
|
-
outlineSymbol = false;
|
|
750
|
-
}
|
|
751
|
-
//icon previews for multipoints do not need outlines since they shouldn't be on the map
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
if (keepUnitRatio) {
|
|
756
|
-
if(msi.getDrawRule() == DrawRules.POINT1)//Action Points
|
|
757
|
-
pixelSize = Math.ceil((pixelSize/1.5) * 2.0);
|
|
758
|
-
else
|
|
759
|
-
pixelSize = Math.ceil((pixelSize/1.5) * 1.2);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
if (ss === SymbolID.SymbolSet_ControlMeasure && ec === 270701)//static depiction
|
|
766
|
-
{
|
|
767
|
-
//add mine fill to image
|
|
768
|
-
mod1 = SymbolID.getModifier1(symbolID);
|
|
769
|
-
if (!(mod1 >= 13 && mod1 <= 50)) {
|
|
770
|
-
|
|
771
|
-
symbolID = SymbolID.setModifier1(symbolID, 13);
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
//String key = makeCacheKey(symbolID, lineColor, fillColor, pixelSize, keepUnitRatio, outlineSymbol);;
|
|
777
|
-
//see if it's in the cache
|
|
778
|
-
/*if(_tgCache != null)
|
|
779
|
-
{
|
|
780
|
-
ii = _tgCache[key];
|
|
781
|
-
}//*/
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
//if not, generate symbol.
|
|
785
|
-
if (si == null)//*/
|
|
786
|
-
{
|
|
787
|
-
let version: int = SymbolID.getVersion(symbolID);
|
|
788
|
-
//check symbol size////////////////////////////////////////////
|
|
789
|
-
let rect: Rectangle2D;
|
|
790
|
-
iconID = SVGLookup.getMainIconID(symbolID);
|
|
791
|
-
siIcon = SVGLookup.getInstance().getSVGLInfo(iconID, version);
|
|
792
|
-
mod1ID = SVGLookup.getMod1ID(symbolID);
|
|
793
|
-
siMod1 = SVGLookup.getInstance().getSVGLInfo(mod1ID, version);
|
|
794
|
-
let borderPadding: float = 0;
|
|
795
|
-
if (outlineSymbol && siIcon != null)
|
|
796
|
-
{
|
|
797
|
-
borderPadding = RendererUtilities.findWidestStrokeWidth(siIcon.getSVG());
|
|
798
|
-
}
|
|
799
|
-
top = Math.round(siIcon.getBbox().getY()) as int;
|
|
800
|
-
left = Math.round(siIcon.getBbox().getX()) as int;
|
|
801
|
-
width = Math.round(siIcon.getBbox().getWidth()) as int;
|
|
802
|
-
height = Math.round(siIcon.getBbox().getHeight()) as int;
|
|
803
|
-
|
|
804
|
-
let strSVGIcon: string;
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
if (hasAPFill) //Action Point(s), Sonobuoys, ACP, CCP, PUP
|
|
808
|
-
{
|
|
809
|
-
let apFill: string;
|
|
810
|
-
if (fillColor != null) {
|
|
811
|
-
|
|
812
|
-
apFill = fillColor;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
else {
|
|
816
|
-
|
|
817
|
-
apFill = RendererUtilities.colorToHexString(SymbolUtilities.getFillColorOfAffiliation(symbolID), false);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
siIcon = new SVGInfo(siIcon.getID(), siIcon.getBbox(), siIcon.getSVG().replaceAll("fill=\"none\"", "fill=\"" + apFill + "\""));
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
//update line and fill color of frame SVG
|
|
824
|
-
if (msi.getSymbolSet() === SymbolID.SymbolSet_ControlMeasure && (lineColor != null || fillColor != null)) {
|
|
825
|
-
if (outlineSymbol) {
|
|
826
|
-
// create outline with larger stroke-width first (if selected)
|
|
827
|
-
strSVGIcon = RendererUtilities.setSVGSPCMColors(symbolID, siIcon.getSVG(), RendererUtilities.getIdealOutlineColor(RendererUtilities.getColorFromHexString(lineColor)), RendererUtilities.getColorFromHexString(fillColor), true);
|
|
828
|
-
}
|
|
829
|
-
else {
|
|
830
|
-
|
|
831
|
-
strSVGIcon = "";
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
// append normal symbol SVG to be layered on top of outline
|
|
836
|
-
strSVGIcon += RendererUtilities.setSVGSPCMColors(symbolID, siIcon.getSVG(), RendererUtilities.getColorFromHexString(lineColor), RendererUtilities.getColorFromHexString(fillColor), false);
|
|
837
|
-
}
|
|
838
|
-
else {
|
|
839
|
-
//weather symbol (don't change color of weather graphics)
|
|
840
|
-
strSVGIcon = siIcon.getSVG();
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
//If symbol is Static Depiction, add internal mine graphic based on sector modifier 1
|
|
845
|
-
if (SymbolID.getEntityCode(symbolID) === 270701 && siMod1 != null) {
|
|
846
|
-
if (outlineSymbol) {
|
|
847
|
-
// create outline with larger stroke-width first (if selected)
|
|
848
|
-
strSVGIcon += RendererUtilities.setSVGSPCMColors(mod1ID, siMod1.getSVG(), RendererUtilities.getIdealOutlineColor(RendererUtilities.getColorFromHexString("#00A651")), RendererUtilities.getColorFromHexString("#00A651"), true);
|
|
849
|
-
}
|
|
850
|
-
//strSVGIcon += siMod1.getSVG();
|
|
851
|
-
strSVGIcon += RendererUtilities.setSVGSPCMColors(mod1ID, siMod1.getSVG(), RendererUtilities.getColorFromHexString(lineColor), RendererUtilities.getColorFromHexString(fillColor), false);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
if (pixelSize > 0) {
|
|
855
|
-
symbolBounds = RectUtilities.toRectangle2D(left, top, width, height);//actual measurement of symbol svg
|
|
856
|
-
rect = RectUtilities.copyRect(symbolBounds);
|
|
857
|
-
|
|
858
|
-
//adjust size
|
|
859
|
-
let p: float = pixelSize;
|
|
860
|
-
let h: double = rect.getHeight();
|
|
861
|
-
let w: double = rect.getWidth();
|
|
862
|
-
|
|
863
|
-
ratio = Math.min((p / h), (p / w));
|
|
864
|
-
|
|
865
|
-
//measurement of target size/location of symbol after being translated/scaled into the new SVG
|
|
866
|
-
symbolBounds = RectUtilities.toRectangle2D(0, 0, w * ratio, h * ratio);//.makeRect(0f, 0f, w * ratio, h * ratio);
|
|
867
|
-
|
|
868
|
-
//make sure border padding isn't excessive.
|
|
869
|
-
w = symbolBounds.getWidth();
|
|
870
|
-
h = symbolBounds.getHeight();
|
|
871
|
-
|
|
872
|
-
if (borderPadding > (h * 0.1)) {
|
|
873
|
-
borderPadding = (h * 0.1) as float;
|
|
874
|
-
}
|
|
875
|
-
else {
|
|
876
|
-
if (borderPadding > (w * 0.1)) {
|
|
877
|
-
borderPadding = (w * 0.1) as float;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
//*/
|
|
881
|
-
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
let borderPaddingBounds: Rectangle2D;
|
|
885
|
-
let offset: int = 0;
|
|
886
|
-
if (msi.getSymbolSet() === SymbolID.SymbolSet_ControlMeasure && outlineSymbol && borderPadding !== 0) {
|
|
887
|
-
borderPaddingBounds = RectUtilities.toRectangle2D(0, 0, (rect.getWidth() + (borderPadding)) * ratio, (rect.getHeight() + (borderPadding)) * ratio);//.makeRect(0f, 0f, w * ratio, h * ratio);
|
|
888
|
-
symbolBounds = borderPaddingBounds;
|
|
889
|
-
|
|
890
|
-
//grow size SVG to accommodate the outline we added
|
|
891
|
-
offset = borderPadding as int / 2;//4;
|
|
892
|
-
RectUtilities.grow(rect, offset);
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
let strLineJoin: string = "";
|
|
897
|
-
|
|
898
|
-
if (msi.getSymbolSet() === SymbolID.SymbolSet_ControlMeasure && msi.getDrawRule() === DrawRules.POINT1) {
|
|
899
|
-
//smooth out action points
|
|
900
|
-
strLineJoin = " stroke-linejoin=\"round\" ";
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
let sbGroupUnit:string = "";
|
|
905
|
-
if (siIcon != null) {
|
|
906
|
-
sbGroupUnit += ("<g transform=\"translate(" + (rect.getX() * -ratio) + ',' + (rect.getY() * -ratio) + ") scale(" + ratio + "," + ratio + ")\"" + strLineJoin + ">");
|
|
907
|
-
sbGroupUnit += (strSVGIcon);//(siIcon.getSVG());
|
|
908
|
-
sbGroupUnit += ("</g>");
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
//Point centerPoint = SymbolUtilities.getCMSymbolAnchorPoint(symbolID, RectUtilities.makeRectangle2DFromRect(offset, offset, symbolBounds.getWidth()-offset, symbolBounds.getHeight()-offset));
|
|
912
|
-
let centerPoint: Point = SymbolUtilities.getCMSymbolAnchorPoint(symbolID, RectUtilities.makeRectangle2DFromRect(0, 0, symbolBounds.getWidth(), symbolBounds.getHeight()));
|
|
913
|
-
|
|
914
|
-
/*if (borderPaddingBounds != null) {
|
|
915
|
-
RectUtilities.grow(symbolBounds, 4);
|
|
916
|
-
}//*/
|
|
917
|
-
|
|
918
|
-
si = new SVGSymbolInfo(sbGroupUnit.toString().valueOf(), centerPoint.toPoint2D(), symbolBounds, symbolBounds);
|
|
919
|
-
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
let siNew: SVGSymbolInfo = null;
|
|
923
|
-
|
|
924
|
-
////////////////////////////////////////////////////////////////////
|
|
925
|
-
hasDisplayModifiers = ModifierRenderer.hasDisplayModifiers(symbolID, modifiers);
|
|
926
|
-
hasTextModifiers = ModifierRenderer.hasTextModifiers(symbolID, modifiers);
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
if (SymbolUtilities.isMultiPoint(symbolID)) {
|
|
930
|
-
hasTextModifiers = false;
|
|
931
|
-
hasDisplayModifiers = false;
|
|
932
|
-
}
|
|
933
|
-
//process display modifiers
|
|
934
|
-
if (asIcon === false && (hasTextModifiers || hasDisplayModifiers)) {
|
|
935
|
-
let sdiTemp: SymbolDimensionInfo;
|
|
936
|
-
let cLineColor: Color = RendererUtilities.getColorFromHexString(lineColor);
|
|
937
|
-
|
|
938
|
-
if (SymbolUtilities.isSPWithSpecialModifierLayout(symbolID))//(SymbolUtilitiesD.isTGSPWithSpecialModifierLayout(symbolID))
|
|
939
|
-
{
|
|
940
|
-
sdiTemp = ModifierRenderer.ProcessTGSPWithSpecialModifierLayout(si, symbolID, modifiers, attributes, cLineColor, this._fontRenderContext);
|
|
941
|
-
}
|
|
942
|
-
else {
|
|
943
|
-
sdiTemp = ModifierRenderer.ProcessTGSPModifiers(si, symbolID, modifiers, attributes, cLineColor, this._fontRenderContext);
|
|
944
|
-
}
|
|
945
|
-
siNew = (sdiTemp instanceof SVGSymbolInfo ? sdiTemp as SVGSymbolInfo : null);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
if (siNew != null) {
|
|
949
|
-
si = siNew;
|
|
950
|
-
}
|
|
951
|
-
siNew = null;
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
//add SVG tag with dimensions
|
|
955
|
-
//draw unit from SVG
|
|
956
|
-
let svgAlpha: string = "";
|
|
957
|
-
if (alpha >= 0 && alpha <= 255) {
|
|
958
|
-
|
|
959
|
-
svgAlpha = " opacity=\"" + alpha / 255 + "\"";
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
svgStart = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"" + si.getImageBounds().getWidth() + "\" height=\"" + si.getImageBounds().getHeight() + "\" viewBox=\"" + 0 + " " + 0 + " " + si.getImageBounds().getWidth() + " " + si.getImageBounds().getHeight() + "\"" + svgAlpha + ">\n";
|
|
963
|
-
let svgTranslateGroup: string;
|
|
964
|
-
|
|
965
|
-
let transX: double = si.getImageBounds().getX() * -1;
|
|
966
|
-
let transY: double = si.getImageBounds().getY() * -1;
|
|
967
|
-
let anchor: Point2D = si.getSymbolCenterPoint();
|
|
968
|
-
let imageBounds: Rectangle2D = si.getImageBounds();
|
|
969
|
-
if (transX > 0 || transY > 0) {
|
|
970
|
-
ShapeUtilities.offset(anchor, transX, transY);
|
|
971
|
-
ShapeUtilities.offset(symbolBounds, transX, transY);
|
|
972
|
-
ShapeUtilities.offset(imageBounds, transX, transY);
|
|
973
|
-
svgTranslateGroup = "<g transform=\"translate(" + transX + "," + transY + ")" + "\">\n";
|
|
974
|
-
}
|
|
975
|
-
si = new SVGSymbolInfo(si.getSVG(), anchor, symbolBounds, imageBounds);
|
|
976
|
-
let sbSVG:string = "";
|
|
977
|
-
sbSVG += (svgStart);
|
|
978
|
-
sbSVG += (this.makeDescTag(si));
|
|
979
|
-
sbSVG += (this.makeMetadataTag(symbolID, si));
|
|
980
|
-
if (svgTranslateGroup != null) {
|
|
981
|
-
|
|
982
|
-
sbSVG += (svgTranslateGroup);
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
sbSVG += (si.getSVG());
|
|
986
|
-
if (svgTranslateGroup != null) {
|
|
987
|
-
|
|
988
|
-
sbSVG += ("\n</g>");
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
sbSVG += ("\n</svg>");
|
|
992
|
-
si = new SVGSymbolInfo(sbSVG.toString().valueOf(), anchor, symbolBounds, imageBounds);
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
} catch (exc) {
|
|
996
|
-
if (exc instanceof Error) {
|
|
997
|
-
ErrorLogger.LogException("SinglePointSVGRenderer", "RenderSP", exc);
|
|
998
|
-
ErrorLogger.LogMessage(" SymbolID: " + symbolID);
|
|
999
|
-
return null;
|
|
1000
|
-
} else {
|
|
1001
|
-
throw exc;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
return si;
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
/**
|
|
1008
|
-
*
|
|
1009
|
-
* @param symbolID
|
|
1010
|
-
* @param attributes
|
|
1011
|
-
* @returns
|
|
1012
|
-
*/
|
|
1013
|
-
public RenderModifier(symbolID:string, attributes:Map<string,string>):SVGSymbolInfo
|
|
1014
|
-
{
|
|
1015
|
-
let temp:SVGSymbolInfo = null;
|
|
1016
|
-
let basicSymbolID:string = null;
|
|
1017
|
-
|
|
1018
|
-
let lineColor:string = null;
|
|
1019
|
-
let fillColor:string = null;//SymbolUtilities.getFillColorOfAffiliation(symbolID);
|
|
1020
|
-
|
|
1021
|
-
let alpha:number = -1;
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
//SVG rendering variables
|
|
1025
|
-
let msi:MSInfo = null;
|
|
1026
|
-
let iconID:string = null;
|
|
1027
|
-
let siIcon:SVGInfo = null;
|
|
1028
|
-
let top:number = 0;
|
|
1029
|
-
let left:number = 0;
|
|
1030
|
-
let width:number = 0;
|
|
1031
|
-
let height:number = 0;
|
|
1032
|
-
let svgStart:string = null;
|
|
1033
|
-
let strSVG:string = null;
|
|
1034
|
-
|
|
1035
|
-
let ratio:number = 0;
|
|
1036
|
-
|
|
1037
|
-
let symbolBounds:Rectangle2D = null;
|
|
1038
|
-
let fullBounds:Rectangle2D = null;
|
|
1039
|
-
|
|
1040
|
-
let drawAsIcon:boolean = false;
|
|
1041
|
-
let pixelSize:number = -1;
|
|
1042
|
-
let keepUnitRatio:boolean = true;
|
|
1043
|
-
let hasDisplayModifiers:boolean = false;
|
|
1044
|
-
let hasTextModifiers:boolean = false;
|
|
1045
|
-
let drawCustomOutline:boolean = false;
|
|
1046
|
-
|
|
1047
|
-
try
|
|
1048
|
-
{
|
|
1049
|
-
|
|
1050
|
-
msi = MSLookup.getInstance().getMSLInfo(symbolID);
|
|
1051
|
-
//Get Attributes
|
|
1052
|
-
if (attributes != null)
|
|
1053
|
-
{
|
|
1054
|
-
/*if (attributes.containsKey(MilStdAttributes.KeepUnitRatio))
|
|
1055
|
-
{
|
|
1056
|
-
keepUnitRatio = Boolean.parseBoolean(attributes.get(MilStdAttributes.KeepUnitRatio));
|
|
1057
|
-
}*/
|
|
1058
|
-
|
|
1059
|
-
lineColor = RendererUtilities.colorToHexString(SymbolUtilities.getLineColorOfAffiliation(symbolID), false);
|
|
1060
|
-
if (attributes.has(MilStdAttributes.LineColor))
|
|
1061
|
-
{
|
|
1062
|
-
lineColor = attributes.get(MilStdAttributes.LineColor);
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
if (attributes.has(MilStdAttributes.FillColor))
|
|
1066
|
-
{
|
|
1067
|
-
fillColor = attributes.get(MilStdAttributes.FillColor);
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
if (attributes.has(MilStdAttributes.Alpha))
|
|
1071
|
-
{
|
|
1072
|
-
alpha = parseInt(attributes.get(MilStdAttributes.Alpha));
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
if (attributes.has(MilStdAttributes.DrawAsIcon))
|
|
1076
|
-
{
|
|
1077
|
-
drawAsIcon = (attributes.get(MilStdAttributes.DrawAsIcon).toLowerCase()==='true');
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
if (attributes.has(MilStdAttributes.PixelSize))
|
|
1081
|
-
{
|
|
1082
|
-
pixelSize = parseInt(attributes.get(MilStdAttributes.PixelSize));
|
|
1083
|
-
if(msi.getSymbolSet() == SymbolID.SymbolSet_ControlMeasure)
|
|
1084
|
-
{
|
|
1085
|
-
if(SymbolID.getEntityCode(symbolID)==270701)//static depiction
|
|
1086
|
-
pixelSize = Math.floor(pixelSize * 0.9);//try to scale to be somewhat in line with units
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
if(drawAsIcon===false)//don't outline icons because they're not going on the map
|
|
1093
|
-
{
|
|
1094
|
-
if(attributes.has(MilStdAttributes.OutlineSymbol))
|
|
1095
|
-
drawCustomOutline = (attributes.get(MilStdAttributes.OutlineSymbol).toLowerCase()==='true');
|
|
1096
|
-
else
|
|
1097
|
-
drawCustomOutline = RendererSettings.getInstance().getOutlineSPControlMeasures();
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
catch (e)
|
|
1101
|
-
{
|
|
1102
|
-
ErrorLogger.LogException("SinglePointSVGRenderer", "RenderModifier2-Getting Attributes", e);
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
try
|
|
1106
|
-
{
|
|
1107
|
-
let ii:SVGSymbolInfo = null;
|
|
1108
|
-
|
|
1109
|
-
let version:number = SymbolID.getVersion(symbolID);
|
|
1110
|
-
//check symbol size////////////////////////////////////////////
|
|
1111
|
-
let rect:Rectangle2D = null;
|
|
1112
|
-
|
|
1113
|
-
iconID = SVGLookup.getMod1ID(symbolID);
|
|
1114
|
-
siIcon = SVGLookup.getInstance().getSVGLInfo(iconID, version);
|
|
1115
|
-
top = Math.round(siIcon.getBbox().getY());
|
|
1116
|
-
left = Math.round(siIcon.getBbox().getX());
|
|
1117
|
-
width = Math.round(siIcon.getBbox().getWidth());
|
|
1118
|
-
height = Math.round(siIcon.getBbox().getHeight());
|
|
1119
|
-
|
|
1120
|
-
let strSVGIcon:string = "";
|
|
1121
|
-
let strSVGOutline:string = null;
|
|
1122
|
-
|
|
1123
|
-
if(msi.getSymbolSet() == SymbolID.SymbolSet_ControlMeasure && (lineColor != null || fillColor != null))
|
|
1124
|
-
{
|
|
1125
|
-
if(drawCustomOutline)
|
|
1126
|
-
strSVGIcon += RendererUtilities.setSVGSPCMColors(iconID,siIcon.getSVG(), RendererUtilities.getIdealOutlineColor(RendererUtilities.getColorFromHexString(lineColor)), RendererUtilities.getColorFromHexString(fillColor),true);
|
|
1127
|
-
strSVGIcon += RendererUtilities.setSVGSPCMColors(iconID, siIcon.getSVG(), RendererUtilities.getColorFromHexString(lineColor), RendererUtilities.getColorFromHexString(fillColor));
|
|
1128
|
-
}
|
|
1129
|
-
else
|
|
1130
|
-
strSVGIcon = siIcon.getSVG();
|
|
1131
|
-
|
|
1132
|
-
if (pixelSize > 0)
|
|
1133
|
-
{
|
|
1134
|
-
symbolBounds = RectUtilities.toRectangle2D(left,top,width,height);
|
|
1135
|
-
rect = RectUtilities.copyRect(symbolBounds);
|
|
1136
|
-
|
|
1137
|
-
//adjust size
|
|
1138
|
-
let p:number = pixelSize;
|
|
1139
|
-
let h:number = rect.getHeight();
|
|
1140
|
-
let w:number = rect.getWidth();
|
|
1141
|
-
|
|
1142
|
-
ratio = Math.min((p / h), (p / w));
|
|
1143
|
-
|
|
1144
|
-
symbolBounds = RectUtilities.makeRectangle2DFromRect(0, 0, w * ratio, h * ratio);
|
|
1145
|
-
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
//grow size SVG to accommodate the outline we added
|
|
1150
|
-
let offset:number = 0;
|
|
1151
|
-
if(drawCustomOutline) {
|
|
1152
|
-
RectUtilities.grow(rect, 3);
|
|
1153
|
-
offset = 3;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
//Draw glyphs to bitmap
|
|
1157
|
-
let bmp:Rectangle2D;//let bmp:OffscreenCanvas;
|
|
1158
|
-
if(keepUnitRatio) //icons are sized with respect to each other so growing bmp to fit outline isn't a big deal
|
|
1159
|
-
{
|
|
1160
|
-
bmp = new Rectangle2D(0,0,Math.floor(symbolBounds.getWidth() + (offset * 2)), Math.floor(symbolBounds.getHeight() + (offset * 2)));
|
|
1161
|
-
}
|
|
1162
|
-
else //try to stay within the confines of the pixelSize as "keepUnitRatio==false" means the user wants to stay within the set pixelSize
|
|
1163
|
-
{
|
|
1164
|
-
bmp = new Rectangle2D(0,0,Math.floor(symbolBounds.getWidth()), Math.floor(symbolBounds.getHeight()));
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
symbolBounds = RectUtilities.makeRectangle2DFromRect(offset, offset, bmp.width-offset, bmp.height-offset);
|
|
1169
|
-
|
|
1170
|
-
svgStart = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"" + bmp.getX() + " " + bmp.getY() + " " + bmp.getWidth() + " " + bmp.getHeight() + "\" width=\"" + bmp.getWidth() + "\" height=\"" + bmp.getHeight() + "\">";
|
|
1171
|
-
|
|
1172
|
-
let sbGroupUnit:string = ("<g transform=\"translate(" + ((siIcon.getBbox().getX() * -ratio) + offset) + ',' + ((siIcon.getBbox().getY() * -ratio)+offset) + ") scale(" + ratio + "," + ratio + ")\"" + ">");
|
|
1173
|
-
|
|
1174
|
-
strSVG = svgStart + sbGroupUnit + strSVGIcon + "</g></svg>";
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
let centerPoint:Point = SymbolUtilities.getCMSymbolAnchorPoint(symbolID,RectUtilities.toRectangle2D(offset, offset, symbolBounds.getWidth(), symbolBounds.getHeight()));
|
|
1178
|
-
|
|
1179
|
-
ii = new SVGSymbolInfo(strSVG, centerPoint.toPoint2D(), symbolBounds,symbolBounds);
|
|
1180
|
-
|
|
1181
|
-
//cleanup
|
|
1182
|
-
//bmp.recycle();
|
|
1183
|
-
symbolBounds = null;
|
|
1184
|
-
fullBounds = null;
|
|
1185
|
-
|
|
1186
|
-
return ii;
|
|
1187
|
-
}
|
|
1188
|
-
catch (e)
|
|
1189
|
-
{
|
|
1190
|
-
ErrorLogger.LogException("SinglePointSVGRenderer", "RenderSP", e);
|
|
1191
|
-
}
|
|
1192
|
-
return null;
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
/**
|
|
1196
|
-
*
|
|
1197
|
-
* @param si
|
|
1198
|
-
* @returns
|
|
1199
|
-
*/
|
|
1200
|
-
private makeDescTag(si: SVGSymbolInfo): string {
|
|
1201
|
-
let sbDesc:string = "";
|
|
1202
|
-
|
|
1203
|
-
if (si != null) {
|
|
1204
|
-
let bounds: Rectangle2D = si.getSymbolBounds();
|
|
1205
|
-
let iBounds: Rectangle2D = si.getImageBounds();
|
|
1206
|
-
sbDesc += ("<desc>") + (si.getSymbolCenterX()) + (" ") + (si.getSymbolCenterY()) + (" ");
|
|
1207
|
-
sbDesc += (bounds.getX()) + (" ") + (bounds.getY()) + (" ") + (bounds.getWidth()) + (" ") + (bounds.getHeight()) + (" ");
|
|
1208
|
-
sbDesc += (iBounds.getX()) + (" ") + (iBounds.getY()) + (" ") + (iBounds.getWidth()) + (" ") + (iBounds.getHeight());
|
|
1209
|
-
sbDesc += ("</desc>\n");
|
|
1210
|
-
}
|
|
1211
|
-
return sbDesc.toString().valueOf();
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
/**
|
|
1215
|
-
*
|
|
1216
|
-
* @param symbolID
|
|
1217
|
-
* @param si
|
|
1218
|
-
* @returns
|
|
1219
|
-
*/
|
|
1220
|
-
private makeMetadataTag(symbolID: string, si: SVGSymbolInfo): string {
|
|
1221
|
-
let sbDesc:string = "";
|
|
1222
|
-
|
|
1223
|
-
if (si != null) {
|
|
1224
|
-
let bounds: Rectangle2D = si.getSymbolBounds();
|
|
1225
|
-
let iBounds: Rectangle2D = si.getImageBounds();
|
|
1226
|
-
sbDesc += ("<metadata>\n");
|
|
1227
|
-
sbDesc += ("<symbolID>") + (symbolID) + ("</symbolID>\n");
|
|
1228
|
-
sbDesc += ("<anchor>") + (si.getSymbolCenterX()) + (" ") + (si.getSymbolCenterY()) + ("</anchor>\n");
|
|
1229
|
-
sbDesc += ("<symbolBounds>") + (bounds.getX()) + (" ") + (bounds.getY()) + (" ") + (bounds.getWidth()) + (" ") + (bounds.getHeight()) + ("</symbolBounds>\n");
|
|
1230
|
-
sbDesc += ("<imageBounds>") + (iBounds.getX()) + (" ") + (iBounds.getY()) + (" ") + (iBounds.getWidth()) + (" ") + (iBounds.getHeight()) + ("</imageBounds>\n");;
|
|
1231
|
-
sbDesc += ("</metadata>\n");
|
|
1232
|
-
}
|
|
1233
|
-
return sbDesc.toString().valueOf();
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
private getSVGString(symbolID: string, isOutline: boolean): string {
|
|
1237
|
-
let version: int = SymbolID.getVersion(symbolID);
|
|
1238
|
-
let svgi: SVGInfo = SVGLookup.getInstance().getSVGLInfo(SymbolUtilities.getBasicSymbolID(symbolID), version);
|
|
1239
|
-
|
|
1240
|
-
let strSVG: string = svgi.getSVG();
|
|
1241
|
-
if (isOutline) {
|
|
1242
|
-
|
|
1243
|
-
strSVG = strSVG.replace("<g id=\"" + SymbolUtilities.getBasicSymbolID(symbolID) + "\">", "<g id=\"" + SymbolUtilities.getBasicSymbolID(symbolID) + "_outline\">");
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
let svgStart: string;
|
|
1248
|
-
if (svgi.getBbox().getMaxY() > 400) {
|
|
1249
|
-
|
|
1250
|
-
svgStart = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 612 792\">";
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
else {
|
|
1254
|
-
|
|
1255
|
-
svgStart = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 400 400\">";
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
strSVG = svgStart + strSVG + "</svg>";
|
|
1260
|
-
|
|
1261
|
-
return strSVG;
|
|
1262
|
-
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
}
|