@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,120 @@
|
|
|
1
|
+
import { Point2D } from "../../graphics2d/Point2D";
|
|
2
|
+
|
|
3
|
+
export class Point{
|
|
4
|
+
public x = 0;
|
|
5
|
+
public y = 0;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param x
|
|
10
|
+
* @param y
|
|
11
|
+
*/
|
|
12
|
+
constructor(x:number,y:number)
|
|
13
|
+
{
|
|
14
|
+
this.x = x;
|
|
15
|
+
this.y = y;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Returns a string representing one of the shape types
|
|
19
|
+
* from "armyc2.c2sd.renderer.so.ShapeTypes"
|
|
20
|
+
* @returns {String}
|
|
21
|
+
*/
|
|
22
|
+
public getShapeType():string
|
|
23
|
+
{
|
|
24
|
+
return "POINT";//armyc2.c2sd.renderer.so.ShapeTypes.POINT;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @returns {Number}
|
|
29
|
+
*/
|
|
30
|
+
public getX():number
|
|
31
|
+
{
|
|
32
|
+
return this.x;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @returns {Number}
|
|
37
|
+
*/
|
|
38
|
+
public getY():number
|
|
39
|
+
{
|
|
40
|
+
return this.y;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Reset the x & y of this point object.
|
|
44
|
+
* @param {Number} x
|
|
45
|
+
* @param {Number} y
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
48
|
+
public setLocation(x:number,y:number): void
|
|
49
|
+
{
|
|
50
|
+
this.x = x;
|
|
51
|
+
this.y = y;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* move x & y by specified amounts.
|
|
55
|
+
* @param {Number} x shift x point by this value
|
|
56
|
+
* @param {Number} y shift y point by this value
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
public shift(x:number,y:number): void
|
|
60
|
+
{
|
|
61
|
+
this.x += x;
|
|
62
|
+
this.y += y;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* @returns {String} like "{x:#,y:#}"
|
|
66
|
+
*/
|
|
67
|
+
public toStringFormatted(): string
|
|
68
|
+
{
|
|
69
|
+
return "{x:" + this.x + ", y:" + this.y + "}";
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Makes a copy of this point object.
|
|
73
|
+
* @returns {armyc2.c2sd.renderer.so.Point} Copy of original point.
|
|
74
|
+
*/
|
|
75
|
+
public clone():Point
|
|
76
|
+
{
|
|
77
|
+
return new Point(this.x,this.y);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* @param {CanvasRenderingContext2D} context object from html5 canvas
|
|
81
|
+
* @returns {void}
|
|
82
|
+
*/
|
|
83
|
+
public setPath(context:CanvasRenderingContext2D): void
|
|
84
|
+
{
|
|
85
|
+
let x = this.x;
|
|
86
|
+
let y = this.y;
|
|
87
|
+
|
|
88
|
+
//context.beginPath();
|
|
89
|
+
context.moveTo(x, y);
|
|
90
|
+
context.lineTo(x + 1,y);
|
|
91
|
+
context.lineTo(x + 1,y + 1);
|
|
92
|
+
context.lineTo(x,y + 1);
|
|
93
|
+
context.closePath();
|
|
94
|
+
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* @param {context} context object from html5 canvas
|
|
98
|
+
* @returns {void}
|
|
99
|
+
*/
|
|
100
|
+
public stroke(context:CanvasRenderingContext2D): void{
|
|
101
|
+
context.beginPath();
|
|
102
|
+
this.setPath(context);
|
|
103
|
+
context.stroke();
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @param {context} context object from html5 canvas
|
|
107
|
+
* @returns {void}
|
|
108
|
+
*/
|
|
109
|
+
public fill(context:CanvasRenderingContext2D): void{
|
|
110
|
+
context.beginPath();
|
|
111
|
+
this.setPath(context);
|
|
112
|
+
context.fill();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
public toPoint2D()
|
|
116
|
+
{
|
|
117
|
+
return new Point2D(this.x,this.y);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { Rectangle2D } from "../../graphics2d/Rectangle2D";
|
|
2
|
+
import { Point } from "./point";
|
|
3
|
+
import { ShapeTypes } from "./types";
|
|
4
|
+
|
|
5
|
+
export class Rectangle
|
|
6
|
+
{
|
|
7
|
+
|
|
8
|
+
private x:number;
|
|
9
|
+
private y:number;
|
|
10
|
+
private width:number;
|
|
11
|
+
private height:number;
|
|
12
|
+
private bottom:number;
|
|
13
|
+
private right:number;
|
|
14
|
+
|
|
15
|
+
public static readonly OUT_LEFT = 1;
|
|
16
|
+
public static readonly OUT_TOP = 2;
|
|
17
|
+
public static readonly OUT_RIGHT = 4;
|
|
18
|
+
public static readonly OUT_BOTTOM = 8;
|
|
19
|
+
|
|
20
|
+
constructor(x:number,y:number,width:number,height:number)
|
|
21
|
+
{
|
|
22
|
+
this.x = x,
|
|
23
|
+
this.y = y,
|
|
24
|
+
this.width = width,
|
|
25
|
+
this.height = height,
|
|
26
|
+
this.bottom = y + height,
|
|
27
|
+
this.right = x + width;
|
|
28
|
+
}
|
|
29
|
+
// <editor-fold defaultstate="collapsed" desc="Public Property Functions">
|
|
30
|
+
|
|
31
|
+
public getShapeType():string
|
|
32
|
+
{
|
|
33
|
+
return ShapeTypes.RECTANGLE;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public getBounds():Rectangle
|
|
37
|
+
{
|
|
38
|
+
return new Rectangle(this.x-1,
|
|
39
|
+
this.y-1,
|
|
40
|
+
this.width+2,
|
|
41
|
+
this.height+2);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
public toRectangle2D():Rectangle2D
|
|
45
|
+
{
|
|
46
|
+
return new Rectangle2D(this.x,
|
|
47
|
+
this.y,
|
|
48
|
+
this.width,
|
|
49
|
+
this.height);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public getX():number
|
|
53
|
+
{
|
|
54
|
+
return this.x;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
public getY():number{
|
|
58
|
+
return this.y;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
public getWidth():number{
|
|
62
|
+
return this.width;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
public getHeight():number{
|
|
66
|
+
return this.height;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
public getBottom():number{
|
|
70
|
+
return this.bottom;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
public getRight():number{
|
|
74
|
+
return this.right;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
public getCenterX():number{
|
|
78
|
+
return this.x + (this.width/2);
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @returns {Number}
|
|
83
|
+
*/
|
|
84
|
+
public getCenterY(){
|
|
85
|
+
return this.y + (this.height/2);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* setLocation x,y (top,left) while maintaining the width and height.
|
|
90
|
+
* @param x
|
|
91
|
+
* @param y
|
|
92
|
+
*/
|
|
93
|
+
public setLocation(x:number,y:number):void{
|
|
94
|
+
this.x = x;
|
|
95
|
+
this.y = y;
|
|
96
|
+
this.bottom = y + this.height;
|
|
97
|
+
this.right = x + this.width;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
public isEmpty():boolean
|
|
101
|
+
{
|
|
102
|
+
return (this.width <= 0.0) || (this.height <= 0.0);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// </editor-fold>
|
|
106
|
+
|
|
107
|
+
// <editor-fold defaultstate="collapsed" desc="Public Utility Functions">
|
|
108
|
+
|
|
109
|
+
public shift(x:number,y:number):void
|
|
110
|
+
{
|
|
111
|
+
this.x += x;
|
|
112
|
+
this.y += y;
|
|
113
|
+
this.right += x;
|
|
114
|
+
this.bottom +=y;
|
|
115
|
+
//height & width shouldn't change in a full shift of the rectangle.
|
|
116
|
+
//this.height = this.bottom - this.y;
|
|
117
|
+
//this.width = this.right - this.x;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* moves top,left points leaving bottom,right intact.
|
|
121
|
+
* adjusts the height & width values as necessary
|
|
122
|
+
* @param x
|
|
123
|
+
* @param y
|
|
124
|
+
*/
|
|
125
|
+
public shiftTL(x:number,y:number):void{
|
|
126
|
+
this.x += x;
|
|
127
|
+
this.y += y;
|
|
128
|
+
this.height = this.bottom - this.y;
|
|
129
|
+
this.width = this.right - this.x;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* moves bottom,right points leaving top,left intact.
|
|
133
|
+
* adjusts the height & width values as necessary
|
|
134
|
+
* @param {type} x the amount to move the right point by
|
|
135
|
+
* @param {type} y the amount to move the bottom point by
|
|
136
|
+
* @returns {_L7.Anonym$0.Rectangle.shiftTL}
|
|
137
|
+
*/
|
|
138
|
+
public shiftBR(x:number,y:number):void{
|
|
139
|
+
this.right += x;
|
|
140
|
+
this.bottom += y;
|
|
141
|
+
this.height = this.bottom - this.y;
|
|
142
|
+
this.width = this.right - this.x;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Grow the rectangle by this many pixels in every direction
|
|
147
|
+
* @param pixel
|
|
148
|
+
*/
|
|
149
|
+
public grow (pixel:number){
|
|
150
|
+
this.shiftTL(-pixel,-pixel);
|
|
151
|
+
this.shiftBR(pixel,pixel);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Will merge the bounds of two rectangle.
|
|
156
|
+
* @param rect
|
|
157
|
+
*/
|
|
158
|
+
public union(rect:Rectangle){
|
|
159
|
+
if(rect)
|
|
160
|
+
{
|
|
161
|
+
if(rect.y < this.y)
|
|
162
|
+
this.y = rect.y;
|
|
163
|
+
if(rect.x < this.x)
|
|
164
|
+
this.x = rect.x;
|
|
165
|
+
if(rect.bottom > this.bottom)
|
|
166
|
+
this.bottom = rect.bottom;
|
|
167
|
+
if(rect.right > this.right)
|
|
168
|
+
this.right = rect.right;
|
|
169
|
+
this.width = this.right - this.x;
|
|
170
|
+
this.height = this.bottom - this.y;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public unionPoint(point:Point){
|
|
176
|
+
if(point)
|
|
177
|
+
{
|
|
178
|
+
if(point.y < this.y)
|
|
179
|
+
this.y = point.y;
|
|
180
|
+
if(point.x < this.x)
|
|
181
|
+
this.x = point.x;
|
|
182
|
+
if(point.y > this.bottom)
|
|
183
|
+
this.bottom = point.y;
|
|
184
|
+
if(point.x > this.right)
|
|
185
|
+
this.right = point.x;
|
|
186
|
+
this.width = this.right - this.x;
|
|
187
|
+
this.height = this.bottom - this.y;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* if 2 values passed in, they are assumed to be the x,y of a point.
|
|
194
|
+
* if 4 values passed in, they are assumed to be the x,y,w,h values
|
|
195
|
+
* of a Rectangle.
|
|
196
|
+
* @param x
|
|
197
|
+
* @param y
|
|
198
|
+
* @param w
|
|
199
|
+
* @param h
|
|
200
|
+
* @returns
|
|
201
|
+
*/
|
|
202
|
+
public contains(x:number,y:number,w?:number,h?:number)
|
|
203
|
+
{
|
|
204
|
+
if(x && y && w && h)
|
|
205
|
+
{
|
|
206
|
+
if (this.isEmpty() || w <= 0 || h <= 0) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
var x0 = this.getX(),
|
|
210
|
+
y0 = this.getY();
|
|
211
|
+
return (x >= x0 &&
|
|
212
|
+
y >= y0 &&
|
|
213
|
+
(x + w) <= x0 + this.getWidth() &&
|
|
214
|
+
(y + h) <= y0 + this.getHeight());
|
|
215
|
+
}
|
|
216
|
+
else if(x && y)
|
|
217
|
+
{
|
|
218
|
+
var x0 = this.getX(),
|
|
219
|
+
y0 = this.getY();
|
|
220
|
+
return (x >= x0 &&
|
|
221
|
+
y >= y0 &&
|
|
222
|
+
x < x0 + this.getWidth() &&
|
|
223
|
+
y < y0 + this.getHeight());
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
return false;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
*
|
|
231
|
+
* @param point
|
|
232
|
+
* @returns
|
|
233
|
+
*/
|
|
234
|
+
public containsPoint(point:Point):boolean
|
|
235
|
+
{
|
|
236
|
+
if(point)
|
|
237
|
+
{
|
|
238
|
+
var x = point.getX();
|
|
239
|
+
var y = point.getY();
|
|
240
|
+
var x0 = this.getX(),
|
|
241
|
+
y0 = this.getY();
|
|
242
|
+
return (x >= x0 &&
|
|
243
|
+
y >= y0 &&
|
|
244
|
+
x < x0 + this.getWidth() &&
|
|
245
|
+
y < y0 + this.getHeight());
|
|
246
|
+
}
|
|
247
|
+
else
|
|
248
|
+
return false;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
public containsRectangle(rect:Rectangle):boolean
|
|
252
|
+
{
|
|
253
|
+
if(rect)
|
|
254
|
+
{
|
|
255
|
+
var x = rect.getX();
|
|
256
|
+
var y = rect.getY();
|
|
257
|
+
var w = rect.getWidth();
|
|
258
|
+
var h = rect.getHeight();
|
|
259
|
+
if (this.isEmpty() || w <= 0 || h <= 0)
|
|
260
|
+
{
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
var x0 = this.getX(),
|
|
264
|
+
y0 = this.getY();
|
|
265
|
+
return (x >= x0 &&
|
|
266
|
+
y >= y0 &&
|
|
267
|
+
(x + w) <= x0 + this.getWidth() &&
|
|
268
|
+
(y + h) <= y0 + this.getHeight());
|
|
269
|
+
}
|
|
270
|
+
else
|
|
271
|
+
return false;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Ported from Java
|
|
276
|
+
*/
|
|
277
|
+
private outcode(x:number, y:number)
|
|
278
|
+
{
|
|
279
|
+
var out = 0;
|
|
280
|
+
if (this.width <= 0) {
|
|
281
|
+
out |= Rectangle.OUT_LEFT | Rectangle.OUT_RIGHT;
|
|
282
|
+
} else if (x < this.x) {
|
|
283
|
+
out |= Rectangle.OUT_LEFT;
|
|
284
|
+
} else if (x > this.x + this.width) {
|
|
285
|
+
out |= Rectangle.OUT_RIGHT;
|
|
286
|
+
}
|
|
287
|
+
if (this.height <= 0) {
|
|
288
|
+
out |= Rectangle.OUT_TOP | Rectangle.OUT_BOTTOM;
|
|
289
|
+
} else if (y < this.y) {
|
|
290
|
+
out |= Rectangle.OUT_TOP;
|
|
291
|
+
} else if (y > this.y + this.height) {
|
|
292
|
+
out |= Rectangle.OUT_BOTTOM;
|
|
293
|
+
}
|
|
294
|
+
return out;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Tests if the specified line segment intersects the interior of this
|
|
299
|
+
* <code>Rectangle</code>. Ported from java.
|
|
300
|
+
*
|
|
301
|
+
* @param x1 the X coordinate of the start point of the specified
|
|
302
|
+
* line segment
|
|
303
|
+
* @param y1 the Y coordinate of the start point of the specified
|
|
304
|
+
* line segment
|
|
305
|
+
* @param x2 the X coordinate of the end point of the specified
|
|
306
|
+
* line segment
|
|
307
|
+
* @param y2 the Y coordinate of the end point of the specified
|
|
308
|
+
* line segment
|
|
309
|
+
* @return <code>true</code> if the specified line segment intersects
|
|
310
|
+
* the interior of this <code>Rectangle</code>; <code>false</code>
|
|
311
|
+
* otherwise.
|
|
312
|
+
*/
|
|
313
|
+
public intersectsLine(x1: number, y1: number, x2: number, y2: number):boolean
|
|
314
|
+
{
|
|
315
|
+
let out1: number = 0;
|
|
316
|
+
let out2: number = 0;
|
|
317
|
+
if ((out2 = this.outcode(x2, y2)) === 0) {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
while ((out1 = this.outcode(x1, y1)) !== 0) {
|
|
321
|
+
if ((out1 & out2) !== 0) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
if ((out1 & (Rectangle.OUT_LEFT | Rectangle.OUT_RIGHT)) !== 0) {
|
|
325
|
+
var x = this.getX();
|
|
326
|
+
if ((out1 & Rectangle.OUT_RIGHT) !== 0) {
|
|
327
|
+
x += this.getWidth();
|
|
328
|
+
}
|
|
329
|
+
y1 = y1 + (x - x1) * (y2 - y1) / (x2 - x1);
|
|
330
|
+
x1 = x;
|
|
331
|
+
} else {
|
|
332
|
+
var y = this.getY();
|
|
333
|
+
if ((out1 & Rectangle.OUT_BOTTOM) !== 0) {
|
|
334
|
+
y += this.getHeight();
|
|
335
|
+
}
|
|
336
|
+
x1 = x1 + (y - y1) * (x2 - x1) / (y2 - y1);
|
|
337
|
+
y1 = y;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return true;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// </editor-fold>
|
|
344
|
+
|
|
345
|
+
public setPath(context:OffscreenCanvasRenderingContext2D | any)
|
|
346
|
+
{
|
|
347
|
+
var x = this.getX(),
|
|
348
|
+
y = this.getY(),
|
|
349
|
+
w = this.getWidth(),
|
|
350
|
+
h = this.getHeight();
|
|
351
|
+
|
|
352
|
+
//context.beginPath();
|
|
353
|
+
context.moveTo(x, y);
|
|
354
|
+
context.lineTo(x + w,y);
|
|
355
|
+
context.lineTo(x + w,y + h);
|
|
356
|
+
context.lineTo(x,y + h);
|
|
357
|
+
context.closePath();
|
|
358
|
+
|
|
359
|
+
};
|
|
360
|
+
public stroke(context:OffscreenCanvasRenderingContext2D){
|
|
361
|
+
context.strokeRect(this.getX(),this.getY(),this.getWidth(),this.getHeight());
|
|
362
|
+
};
|
|
363
|
+
public fill(context:OffscreenCanvasRenderingContext2D){
|
|
364
|
+
context.fillRect(this.getX(),this.getY(),this.getWidth(),this.getHeight());
|
|
365
|
+
};
|
|
366
|
+
public clone():Rectangle{
|
|
367
|
+
return new Rectangle(this.x,this.y,this.width,this.height);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* ported from java
|
|
372
|
+
*/
|
|
373
|
+
public intersects(r:Rectangle):boolean
|
|
374
|
+
{
|
|
375
|
+
if(r)
|
|
376
|
+
{
|
|
377
|
+
var tw = this.width;
|
|
378
|
+
var th = this.height;
|
|
379
|
+
var rw = r.width;
|
|
380
|
+
var rh = r.height;
|
|
381
|
+
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
var tx = this.x;
|
|
385
|
+
var ty = this.y;
|
|
386
|
+
var rx = r.x;
|
|
387
|
+
var ry = r.y;
|
|
388
|
+
rw += rx;
|
|
389
|
+
rh += ry;
|
|
390
|
+
tw += tx;
|
|
391
|
+
th += ty;
|
|
392
|
+
// overflow || intersect
|
|
393
|
+
return ((rw < rx || rw > tx) &&
|
|
394
|
+
(rh < ry || rh > ty) &&
|
|
395
|
+
(tw < tx || tw > rx) &&
|
|
396
|
+
(th < ty || th > ry));
|
|
397
|
+
}
|
|
398
|
+
else
|
|
399
|
+
return false;
|
|
400
|
+
|
|
401
|
+
};//*/
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
*
|
|
405
|
+
* @param stroke named color or value of rgb(#,#,#)
|
|
406
|
+
* @param strokeWidth width of line in # of pixels
|
|
407
|
+
* @param fill named color or value of rgb(#,#,#)
|
|
408
|
+
* @returns
|
|
409
|
+
*/
|
|
410
|
+
public toSVGElement(stroke:string | null, strokeWidth:number, fill:string | null):string
|
|
411
|
+
{
|
|
412
|
+
var line = '<rect x="' + this.x + '" y="' + this.y;
|
|
413
|
+
line += '" width="' + this.width + '" height="' + this.height + '"';
|
|
414
|
+
|
|
415
|
+
if(strokeWidth)
|
|
416
|
+
line += ' stroke-width="' + strokeWidth + '"';
|
|
417
|
+
else if(stroke)
|
|
418
|
+
line += ' stroke-width="2"';
|
|
419
|
+
|
|
420
|
+
if(stroke)
|
|
421
|
+
line += ' stroke="' + stroke + '"';
|
|
422
|
+
|
|
423
|
+
if(fill)
|
|
424
|
+
line += ' fill="' + fill + '"';
|
|
425
|
+
else
|
|
426
|
+
line += ' fill="none"';
|
|
427
|
+
|
|
428
|
+
line += '/>';
|
|
429
|
+
return line;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Rectangle } from "./rectangle";
|
|
2
|
+
|
|
3
|
+
export class RoundedRectangle
|
|
4
|
+
{
|
|
5
|
+
private radius:number;
|
|
6
|
+
private rectangle:Rectangle
|
|
7
|
+
|
|
8
|
+
constructor(x,y,w,h,radius)
|
|
9
|
+
{
|
|
10
|
+
|
|
11
|
+
this.radius = radius;
|
|
12
|
+
|
|
13
|
+
this.rectangle = new Rectangle(x,y,w,h);
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
getShapeType():string{
|
|
21
|
+
return "ROUNDED_RECTANGLE";//ShapeTypes.ROUNDED_RECTANGLE;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
getBounds():Rectangle
|
|
28
|
+
{
|
|
29
|
+
return new Rectangle(this.rectangle.getX()-1,
|
|
30
|
+
this.rectangle.getY()-1,
|
|
31
|
+
this.rectangle.getWidth()+2,
|
|
32
|
+
this.rectangle.getHeight()+2);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
shift(x:number,y:number)
|
|
36
|
+
{
|
|
37
|
+
this.rectangle.shift(x,y);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
setPath(context:CanvasRenderingContext2D){
|
|
41
|
+
var x = this.rectangle.getX(),
|
|
42
|
+
y = this.rectangle.getY(),
|
|
43
|
+
w = this.rectangle.getWidth(),
|
|
44
|
+
h = this.rectangle.getHeight();
|
|
45
|
+
if(w < (2 * this.radius))
|
|
46
|
+
this.radius = w/2;
|
|
47
|
+
if(h < (2 * this.radius))
|
|
48
|
+
this.radius = h/2;
|
|
49
|
+
var r = this.radius;
|
|
50
|
+
|
|
51
|
+
//context.beginPath();
|
|
52
|
+
context.moveTo(x + r, y);
|
|
53
|
+
context.lineTo(x + w -r,y);
|
|
54
|
+
context.arcTo(x + w, y, x + w, y+r, r);
|
|
55
|
+
context.lineTo(x + w,y + h - r);
|
|
56
|
+
context.arcTo(x + w, y+h, x+w-r, y + h, r);
|
|
57
|
+
context.lineTo(x + r,y + h);
|
|
58
|
+
context.arcTo(x, y+h, x, y+h-r, r);
|
|
59
|
+
context.lineTo(x,y + r);
|
|
60
|
+
context.arcTo(x, y, x + r, y, r);
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
stroke(context:CanvasRenderingContext2D){
|
|
65
|
+
context.beginPath();
|
|
66
|
+
this.setPath(context);
|
|
67
|
+
context.stroke();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
fill(context:CanvasRenderingContext2D){
|
|
71
|
+
context.beginPath();
|
|
72
|
+
this.setPath(context);
|
|
73
|
+
context.fill();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
toSVGElement(stroke:string | null, strokeWidth:number, fill:string | null):string
|
|
77
|
+
{
|
|
78
|
+
var line = '<rect x="' + this.rectangle.getX() + '" y="' + this.rectangle.getY();
|
|
79
|
+
line += '" rx="' + this.radius + '" ry="' + this.radius;
|
|
80
|
+
line += '" width="' + this.rectangle.getWidth() + '" height="' + this.rectangle.getHeight() + '"';
|
|
81
|
+
|
|
82
|
+
if(strokeWidth)
|
|
83
|
+
line += ' stroke-width="' + strokeWidth + '"';
|
|
84
|
+
else if(stroke)
|
|
85
|
+
line += ' stroke-width="2"';
|
|
86
|
+
|
|
87
|
+
if(stroke)
|
|
88
|
+
line += ' stroke="' + stroke + '"';
|
|
89
|
+
|
|
90
|
+
if(fill)
|
|
91
|
+
line += ' fill="' + fill + '"';
|
|
92
|
+
else
|
|
93
|
+
line += ' fill="none"';
|
|
94
|
+
|
|
95
|
+
line += '/>';
|
|
96
|
+
return line;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class ShapeTypes{
|
|
2
|
+
public static readonly RECTANGLE = "RECTANGLE";
|
|
3
|
+
public static readonly POINT = "POINT";
|
|
4
|
+
public static readonly ELLIPSE = "ELLIPSE";
|
|
5
|
+
public static readonly ROUNDED_RECTANGLE = "ROUNDED_RECTANGLE";
|
|
6
|
+
public static readonly LINE = "LINE";
|
|
7
|
+
public static readonly BCURVE = "BCURVE";
|
|
8
|
+
public static readonly ARC = "ARC";
|
|
9
|
+
public static readonly PATH = "PATH";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class ActionTypes{
|
|
13
|
+
public static readonly ACTION_MOVE_TO = 0;
|
|
14
|
+
public static readonly ACTION_LINE_TO = 1;
|
|
15
|
+
public static readonly ACTION_CURVE_TO = 2;//cubic bezier cirve
|
|
16
|
+
public static readonly ACTION_QUAD_TO = 3;//quadratic bezier curve
|
|
17
|
+
public static readonly ACTION_ARC_TO = 4;
|
|
18
|
+
public static readonly ACTION_ARC = 5;
|
|
19
|
+
public static readonly ACTION_DASHED_LINE_TO = 6;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|