Plot.js 1.59 KB
Newer Older
yaqizhang's avatar
yaqizhang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

class Plot {
    /**
    * @classdesc 所有图元的基类,用来实现绘制图元。
    * @constructs
    * @author daiyujie
    * @param {ol.Coordinate} points 图元的点集
    */
    constructor(points) {
        this.setPoints(points);
        this.geo_type ='RootTest'; 
    }
    /**
	 * 是否为图元
	 */
    isPlot() {
        return true;
    }
    /**
	 * 设置点集
     * @param {ol.Coordinate} points 图元的点集
	 */
    setPoints(value) {
        this.points = value ? value : [];
        if (this.points.length >= 1)
            this.generate();
    }
    /**
	 * 获取当前图元的点集
     * @return {ol.Coordinate}  图元的点集
	 */
    getPoints() {
        return this.points.slice(0);
    }
    /**
	 * 获取当前图元的点集数量
     * @return {Number}  图元的点集的数量
	 */
    getPointCount() {
        return this.points.length;
    }
    /**
	 * 更新某个索引的点
     * @param {ol.Coordinate} point 点
     * @param {index} index 位置
	 */
    updatePoint(point, index) {
        if (index >= 0 && index < this.points.length) {
            this.points[index] = point;
            this.generate();
        }
    }
    /**
     * 更新最后一个点
     * @param {ol.Coordinate} point 
     */
    updateLastPoint(point) {
        this.updatePoint(point, this.points.length - 1);
    }
    /**
    * @override
    * 图元绘制逻辑.各个图元用来覆盖
    */
    generate() {
        //--TODO
    }
    /**
    * @override
    * 图元结束绘制回调
    */
    finishDrawing() {
        //--TODO
    }
}
export default Plot;