@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,391 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
* this work for additional information regarding copyright ownership.
|
|
5
|
+
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
* (the "License"); you may not use this file except in compliance with
|
|
7
|
+
* the License. You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @author Denis M. Kishenko
|
|
19
|
+
* @version $Revision$
|
|
20
|
+
*/
|
|
21
|
+
//THIS CLASS MODIFIED TO WORK ON JAVASCRIPT
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
import { type int, type double, type float } from "../graphics2d/BasicTypes";
|
|
26
|
+
|
|
27
|
+
import { AffineTransform } from "../graphics2d/AffineTransform"
|
|
28
|
+
import { PathIterator } from "../graphics2d/PathIterator"
|
|
29
|
+
import { Point } from "../graphics2d/Point"
|
|
30
|
+
import { Point2D } from "../graphics2d/Point2D"
|
|
31
|
+
import { Rectangle } from "../graphics2d/Rectangle"
|
|
32
|
+
import { Rectangle2D } from "../graphics2d/Rectangle2D"
|
|
33
|
+
import { Path } from "../../../android/graphics/Path";
|
|
34
|
+
import { RectF } from "../../../android/graphics/RectF";
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
export class Polygon {
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The points buffer capacity
|
|
45
|
+
*/
|
|
46
|
+
private static BUFFER_CAPACITY:int = 4;
|
|
47
|
+
|
|
48
|
+
public npoints: int = 0;
|
|
49
|
+
|
|
50
|
+
public xpoints: int[];
|
|
51
|
+
|
|
52
|
+
public ypoints: int[];
|
|
53
|
+
|
|
54
|
+
protected bounds: Rectangle;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
public constructor();
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param xpoints
|
|
62
|
+
* @param ypoints
|
|
63
|
+
* @param npoints
|
|
64
|
+
*/
|
|
65
|
+
public constructor(xpoints: int[], ypoints: int[], npoints: int);
|
|
66
|
+
public constructor(...args: unknown[]) {
|
|
67
|
+
switch (args.length) {
|
|
68
|
+
case 0: {
|
|
69
|
+
|
|
70
|
+
this.xpoints = [];
|
|
71
|
+
this.ypoints = [];
|
|
72
|
+
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
case 3: {
|
|
77
|
+
const [xpoints, ypoints, npoints] = args as [int[], int[], int];
|
|
78
|
+
|
|
79
|
+
// awt.111=Parameter npoints is greater than array length
|
|
80
|
+
if (npoints > xpoints.length || npoints > ypoints.length) {
|
|
81
|
+
throw Error("Parameter npoints is greater than array length");
|
|
82
|
+
}
|
|
83
|
+
// awt.112=Negative number of points
|
|
84
|
+
if (npoints < 0) {
|
|
85
|
+
throw Error("Negative number of points");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.npoints = npoints;
|
|
89
|
+
this.xpoints = this.copyOf(xpoints, npoints);
|
|
90
|
+
this.ypoints = this.copyOf(ypoints, npoints);
|
|
91
|
+
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
default: {
|
|
96
|
+
throw Error(`Invalid number of arguments`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private copyOf<T>(original:Array<T>, length): Array<T>
|
|
102
|
+
{
|
|
103
|
+
let arr:Array<T> = [];
|
|
104
|
+
|
|
105
|
+
try
|
|
106
|
+
{
|
|
107
|
+
for(let i:number = 0; i < length; i++)
|
|
108
|
+
{
|
|
109
|
+
//should just be copying integer arrays so this simple copy should be fine.
|
|
110
|
+
arr.push(original.at(i));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch(e)
|
|
114
|
+
{
|
|
115
|
+
throw new Error("Polygon.copyOf - " + e.message);
|
|
116
|
+
}
|
|
117
|
+
return arr;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public reset(): void {
|
|
121
|
+
this.npoints = 0;
|
|
122
|
+
this.bounds = null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public invalidate(): void {
|
|
126
|
+
this.bounds = null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public addPoint(px: int, py: int): void
|
|
130
|
+
{
|
|
131
|
+
this.xpoints.push(px);
|
|
132
|
+
this.ypoints.push(py);
|
|
133
|
+
this.npoints++;
|
|
134
|
+
if (this.bounds != null)
|
|
135
|
+
{
|
|
136
|
+
let temp:Rectangle = new Rectangle( Math.min(this.bounds.getMinX(), px),
|
|
137
|
+
Math.min(this.bounds.getMinY(), py),
|
|
138
|
+
Math.max(this.bounds.getMaxX() - this.bounds.getMinX(), px - this.bounds.getMinX()),
|
|
139
|
+
Math.max(this.bounds.getMaxY() - this.bounds.getMinY(), py - this.bounds.getMinY()));
|
|
140
|
+
|
|
141
|
+
this.bounds.setRect(temp);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
public getBounds(): Rectangle {
|
|
147
|
+
if (this.bounds != null) {
|
|
148
|
+
return this.bounds;
|
|
149
|
+
}
|
|
150
|
+
if (this.npoints == 0) {
|
|
151
|
+
return new Rectangle();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let bx1:int = this.xpoints[0];
|
|
155
|
+
let by1:int = this.ypoints[0];
|
|
156
|
+
let bx2:int = bx1;
|
|
157
|
+
let by2:int = by1;
|
|
158
|
+
|
|
159
|
+
for (let i:int = 1; i < this.npoints; i++) {
|
|
160
|
+
let x:int = this.xpoints[i];
|
|
161
|
+
let y:int = this.ypoints[i];
|
|
162
|
+
if (x < bx1) {
|
|
163
|
+
bx1 = x;
|
|
164
|
+
} else if (x > bx2) {
|
|
165
|
+
bx2 = x;
|
|
166
|
+
}
|
|
167
|
+
if (y < by1) {
|
|
168
|
+
by1 = y;
|
|
169
|
+
} else if (y > by2) {
|
|
170
|
+
by2 = y;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return this.bounds = new Rectangle(bx1, by1, bx2 - bx1, by2 - by1);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public getBoundingBox(): Rectangle {
|
|
178
|
+
return this.getBounds();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
public contains(p: Point | Point2D): boolean;
|
|
183
|
+
public contains(r: Rectangle2D): boolean;
|
|
184
|
+
public contains(x: double, y: double): boolean;
|
|
185
|
+
public contains(x: double, y: double, w: double, h: double): boolean;
|
|
186
|
+
public contains(...args: unknown[]): boolean {
|
|
187
|
+
switch (args.length) {
|
|
188
|
+
case 1: {
|
|
189
|
+
if (args[0] instanceof Rectangle2D) {
|
|
190
|
+
const [r] = args as [Rectangle2D];
|
|
191
|
+
return this.contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
|
192
|
+
} else if (args[0] instanceof Point || args[0] instanceof Point2D) {
|
|
193
|
+
const [p] = args as [Point | Point2D];
|
|
194
|
+
return this.contains(p.getX(), p.getY());
|
|
195
|
+
} else {
|
|
196
|
+
throw "Invalid argument type"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
case 2: {
|
|
201
|
+
const [x, y] = args as [double, double];
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
if (this.npoints <= 2 || !this.getBoundingBox().contains(x as int, y as int)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
let hits: int = 0;
|
|
208
|
+
|
|
209
|
+
let lastx: int = this.xpoints[this.npoints - 1];
|
|
210
|
+
let lasty: int = this.ypoints[this.npoints - 1];
|
|
211
|
+
let curx: int = 0;
|
|
212
|
+
let cury: int = 0;
|
|
213
|
+
|
|
214
|
+
for (let i: int = 0; i < this.npoints; lastx = curx, lasty = cury, i++) {
|
|
215
|
+
curx = this.xpoints[i];
|
|
216
|
+
cury = this.ypoints[i];
|
|
217
|
+
|
|
218
|
+
if (cury === lasty) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let leftx: int = 0;
|
|
223
|
+
if (curx < lastx) {
|
|
224
|
+
if (x >= lastx) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
leftx = curx;
|
|
228
|
+
} else {
|
|
229
|
+
if (x >= curx) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
leftx = lastx;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
let test1: double = 0;
|
|
236
|
+
let test2: double = 0;
|
|
237
|
+
if (cury < lasty) {
|
|
238
|
+
if (y < cury || y >= lasty) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (x < leftx) {
|
|
242
|
+
hits++;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
test1 = x - curx;
|
|
246
|
+
test2 = y - cury;
|
|
247
|
+
} else {
|
|
248
|
+
if (y < lasty || y >= cury) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (x < leftx) {
|
|
252
|
+
hits++;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
test1 = x - lastx;
|
|
256
|
+
test2 = y - lasty;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (test1 < (test2 / (lasty - cury) * (lastx - curx))) {
|
|
260
|
+
hits++;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return ((hits & 1) !== 0);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
case 4: {
|
|
268
|
+
const [x, y, w, h] = args as [double, double, double, double];
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if (this.npoints <= 0 || !this.getBoundingBox().intersects(x, y, w, h)) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
default: {
|
|
279
|
+
throw Error(`Invalid number of arguments`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
public getBounds2D(): null {
|
|
287
|
+
//return getBounds();
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
public intersects(r: Rectangle2D): boolean;
|
|
293
|
+
|
|
294
|
+
public intersects(x: double, y: double, w: double, h: double): boolean;
|
|
295
|
+
public intersects(...args: unknown[]): boolean {
|
|
296
|
+
switch (args.length) {
|
|
297
|
+
case 1: {
|
|
298
|
+
const [r] = args as [Rectangle2D];
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
return this.intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
case 4: {
|
|
308
|
+
const [x, y, w, h] = args as [double, double, double, double];
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
if (this.npoints <= 0 || !this.getBoundingBox().intersects(x, y, w, h)) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (this.bounds != null) {
|
|
316
|
+
let fx: float = x as float;
|
|
317
|
+
let fy: float = y as float;
|
|
318
|
+
let fw: float = w as float;
|
|
319
|
+
let fh: float = h as float;
|
|
320
|
+
//not sure if math is correct here
|
|
321
|
+
let that: Path = new Path();
|
|
322
|
+
//start
|
|
323
|
+
that.moveTo(fx, fy);
|
|
324
|
+
//go right
|
|
325
|
+
that.lineTo(fx + fw, fy);
|
|
326
|
+
//go down
|
|
327
|
+
that.lineTo(fx + fw, fy - fh);
|
|
328
|
+
//go left
|
|
329
|
+
that.lineTo(fx, fy - fh);
|
|
330
|
+
//close
|
|
331
|
+
that.close();
|
|
332
|
+
//bounds holder
|
|
333
|
+
let thatBounds: RectF = new RectF();
|
|
334
|
+
let rectf: RectF = new RectF(this.bounds.x as float, this.bounds.y as float, this.bounds.x as float + this.bounds.width as float, this.bounds.y as float + this.bounds.height as float);
|
|
335
|
+
return RectF.intersects(rectf, thatBounds);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
default: {
|
|
346
|
+
throw Error(`Invalid number of arguments`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
public getPathIterator(at: AffineTransform | null): PathIterator;
|
|
354
|
+
public getPathIterator(at: AffineTransform, flatness: double): PathIterator;
|
|
355
|
+
public getPathIterator(...args: unknown[]): PathIterator {
|
|
356
|
+
switch (args.length) {
|
|
357
|
+
case 1: {
|
|
358
|
+
const [at] = args as [AffineTransform];
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
let pi: PathIterator = new PathIterator(null);
|
|
362
|
+
let j: int = 0;
|
|
363
|
+
if (this.npoints > 0) {
|
|
364
|
+
pi.moveTo(this.xpoints[0], this.ypoints[0]);
|
|
365
|
+
for (j = 1; j < this.npoints; j++) {
|
|
366
|
+
pi.lineTo(this.xpoints[j], this.ypoints[j]);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
pi.reset();
|
|
370
|
+
return pi;
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
case 2: {
|
|
377
|
+
const [at, flatness] = args as [AffineTransform, double];
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
return this.getPathIterator(at);
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
default: {
|
|
387
|
+
throw Error(`Invalid number of arguments`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|