laya-coreui-es
Version:
laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改
84 lines (83 loc) • 2.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VectorGraphManager = void 0;
const CacheManger_1 = require("./CacheManger");
class VectorGraphManager {
constructor() {
this.useDic = {};
this.shapeDic = {};
this.shapeLineDic = {};
this._id = 0;
this._checkKey = false;
this._freeIdArray = [];
CacheManger_1.CacheManger.regCacheByFunction(this.startDispose.bind(this), this.getCacheList.bind(this));
}
static getInstance() {
return VectorGraphManager.instance = VectorGraphManager.instance || new VectorGraphManager();
}
getId() {
return this._id++;
}
addShape(id, shape) {
this.shapeDic[id] = shape;
if (!this.useDic[id]) {
this.useDic[id] = true;
}
}
addLine(id, Line) {
this.shapeLineDic[id] = Line;
if (!this.shapeLineDic[id]) {
this.shapeLineDic[id] = true;
}
}
getShape(id) {
if (this._checkKey) {
if (this.useDic[id] != null) {
this.useDic[id] = true;
}
}
}
deleteShape(id) {
if (this.shapeDic[id]) {
this.shapeDic[id] = null;
delete this.shapeDic[id];
}
if (this.shapeLineDic[id]) {
this.shapeLineDic[id] = null;
delete this.shapeLineDic[id];
}
if (this.useDic[id] != null) {
delete this.useDic[id];
}
}
getCacheList() {
var str;
var list = [];
for (str in this.shapeDic) {
list.push(this.shapeDic[str]);
}
for (str in this.shapeLineDic) {
list.push(this.shapeLineDic[str]);
}
return list;
}
startDispose(key) {
var str;
for (str in this.useDic) {
this.useDic[str] = false;
}
this._checkKey = true;
}
endDispose() {
if (this._checkKey) {
var str;
for (str in this.useDic) {
if (!this.useDic[str]) {
this.deleteShape(str);
}
}
this._checkKey = false;
}
}
}
exports.VectorGraphManager = VectorGraphManager;