import Konva from "konva"; import { ActionManager } from "../models/application/actions/action-manager"; export class Layer { constructor(id, konvaLayer) { this.id = id; this.name = "New Construction " + this.id; this.konvaLayer = konvaLayer; this.aggregators = []; this.selectedAggregators = []; this.konvaGroup = new Konva.Group({ draggable: false, resizeEnabled: false }); this.konvaLayer.add(this.konvaGroup); this.actionManager = new ActionManager(); } getKonvaGroup() { return this.konvaGroup; } getKonvaLayer() { return this.konvaLayer; } addAggregator(aggregator) { this.aggregators.push(aggregator); } getAggregators() { return this.aggregators; } getSelectedAggregators() { return this.selectedAggregators; } setSelectedAggregator(aggregator) { if (!this.selectedAggregators.includes(aggregator)) { this.selectedAggregators.push(aggregator); } } removeSelectedAggregator(aggregator) { if (this.selectedAggregators.includes(aggregator)) { let index = this.selectedAggregators.indexOf(aggregator); this.selectedAggregators.splice(index, 1); } } removeAggregator(aggregator) { let index = this.aggregators.indexOf(aggregator); this.aggregators.splice(index, 1); if (this.selectedAggregators.includes(aggregator)) { let index = this.selectedAggregators.indexOf(aggregator); this.selectedAggregators.splice(index, 1); } this.actionManager.remove(aggregator.genericObject); aggregator.konvaObject.destroy(); } }