{"version":3,"sources":["https://lively-kernel.org/lively4/BP2019RH1/src/internal/individuals-as-points/venn/venn-diagram.js"],"names":["FORCE_CENTER_SIZE","FORCE_CENTER_COLOR","ForceCenterManager","IndividualsDistributor","IndividualsSimulation","InteractionManager","InspectAction","FreehandDrawer","inside","INDIVIDUALS_DOT_SIZE","THEME_GROUP_COLOR_TRANSPARENCY","VennDiagram","constructor","owner","canvas","freehandSVGLayer","freehandCanvas","freehandLayer","freehandCanvasContext","getContext","canvasContext","forceCenterManager","individualsDistributor","interactionManager","strokeStyle","drawer","parentElement","addListener","start","setDataProcessor","dataProcessor","_propagateDataProcessor","setColorStore","colorStore","_propagateColorStore","setCanvasExtent","newCanvasWidth","newCanvasHeight","setStrokeStyle","updateStrokeStyle","draw","initializeWithData","individuals","deleteSelections","_stopSimulation","initialIndividuals","_preprocessIndividuals","_setupVisualization","addThemeGroup","uuid","name","themes","color","individualsSimulation","stop","_loadNewLayout","_updateInteractionSubjects","_registerForceCenterAnnotations","updateDistribution","updateThemeGroup","removeThemeGroup","recolorIndividuals","colorAction","runOn","filterIndividuals","filterAction","updateIndividuals","_individualsNotEmpty","selectIndividuals","selectAction","inspectIndividual","inspectAction","stopSimulation","_clearCanvas","_drawHulls","_drawIndividuals","_drawForceCenters","drawSelections","setDistribution","getForceCenters","updateForces","inspect","individual","dispatchEvent","CustomEvent","detail","action","bubbles","freehandSelectionCreated","freehandSelectionDeleted","selection","freehandSelectionOnContextMenu","evt","selectionSVG","linePointsArray","linePoints","map","point","x","y","selectedIndividuals","filter","freehandSelectionSVGElement","clientX","clientY","individualsSelection","selectionColor","length","updateLayout","_startLoadingAnimation","loaderDiv","Object","assign","style","_getLoaderDivCSS","appendChild","canvasRootElement","positionX","offsetLeft","offsetWidth","positionY","offsetTop","offsetHeight","border","borderTop","borderRadius","width","height","animation","position","left","top","_endLoadingAnimation","contains","removeChild","forEach","drawing","currentSize","setInitialForceCenter","_setupIndividualsSimulation","_setupInteraction","registerDragging","registerClick","registerDoubleClick","annotations","getForceCenterAnnotations","annotation","setDraggingSubjects","setToggleSubjects","clearRect","convertColorObjectToRGBAValue","currentColor","_drawPoint","forceCenter","getThemeGroups","themeGroup","groupHull","getGroupHull","hullCornerPoints","getPaddedHullCornerPoints","_drawPolygon","getColor","size","beginPath","arc","Math","PI","stroke","fillStyle","fill","cornerPoints","moveTo","shift","lineTo","closePath"],"mappings":";;;;;;;;;;;;AAASA,uB,yBAAAA,iB;AAAmBC,wB,yBAAAA,kB;AAAoBC,wB,yBAAAA,kB;;AACzCC,4B;;AACAC,2B;;AACAC,wB;;AACEC,mB,oBAAAA,a;;AACFC,oB;;AACAC,Y;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,YAAMC,uBAAuB,CAA7B;;;;;;;;;;;;;;AACO,YAAMC,iCAAiC,IAAvC;;;;;;;;;;;;;;;;;;AAEQ,YAAMC,WAAN,CAAkB;AAC/BC,oBAAYC,KAAZ,EAAmBC,MAAnB,EAA2BC,gBAA3B,EAA6CC,cAA7C,EAA6D;AAC3D,eAAKH,KAAL,GAAaA,KAAb;AACA,eAAKC,MAAL,GAAcA,MAAd;AACA,eAAKG,aAAL,GAAqBF,gBAArB;AACA,eAAKC,cAAL,GAAsBA,cAAtB;AACA,eAAKE,qBAAL,GAA6BF,eAAeG,UAAf,CAA0B,IAA1B,CAA7B;AACA,eAAKC,aAAL,GAAqBN,OAAOK,UAAP,CAAkB,IAAlB,CAArB;AACA,eAAKE,kBAAL,GAA0B,IAAInB,kBAAJ,CAAuBY,MAAvB,EAA+B,IAA/B,CAA1B;AACA,eAAKQ,sBAAL,GAA8B,IAAInB,sBAAJ,EAA9B;AACA,eAAKoB,kBAAL,GAA0B,IAAIlB,kBAAJ,CAAuBW,cAAvB,EAAuC,IAAvC,CAA1B;AACA,eAAKQ,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uBAAaE,KAAb;AACAF,uBAAanC,OAAb,CAAsBtC,KAAD,IAAW;AAC9B,iBAAK7E,aAAL,CAAmByJ,MAAnB,CAA0B5E,MAAM,CAAN,CAA1B,EAAoCA,MAAM,CAAN,CAApC;AACD,WAFD;AAGA,eAAK7E,aAAL,CAAmB0J,SAAnB;AACA,eAAK1J,aAAL,CAAmBqJ,IAAnB;AACD;AArU8B;;yBAAZ9J,W","file":"venn-diagram.js","sourcesContent":["import { FORCE_CENTER_SIZE, FORCE_CENTER_COLOR, ForceCenterManager } from \"./force-center-manager.js\"\nimport IndividualsDistributor from \"./individuals-distributor.js\"\nimport IndividualsSimulation from \"./individuals-simulation.js\"\nimport InteractionManager from \"./interaction-manager.js\"\nimport { InspectAction } from '../common/actions.js'\nimport FreehandDrawer from '../common/drawFreehand.js'\nimport inside from \"../common/npm-point-in-polygon.js\"\n\nconst INDIVIDUALS_DOT_SIZE = 3\nexport const THEME_GROUP_COLOR_TRANSPARENCY = \"88\"\n\nexport default class VennDiagram {\n  constructor(owner, canvas, freehandSVGLayer, freehandCanvas) {\n    this.owner = owner\n    this.canvas = canvas\n    this.freehandLayer = freehandSVGLayer\n    this.freehandCanvas = freehandCanvas\n    this.freehandCanvasContext = freehandCanvas.getContext('2d')\n    this.canvasContext = canvas.getContext(\"2d\")\n    this.forceCenterManager = new ForceCenterManager(canvas, this)\n    this.individualsDistributor = new IndividualsDistributor()\n    this.interactionManager = new InteractionManager(freehandCanvas, this)\n    this.strokeStyle = false\n  \n    this.drawer = new FreehandDrawer(this.canvas.parentElement, this.freehandCanvas, this.freehandLayer)\n    this.drawer.addListener(this)\n    this.drawer.start()\n  }\n  \n  // ------------------------------------------\n  // Public Methods\n  // ------------------------------------------\n  \n  setDataProcessor(dataProcessor) {\n    this.dataProcessor = dataProcessor  \n    this._propagateDataProcessor()\n  }\n  \n  setColorStore(colorStore) {\n    this.colorStore = colorStore\n    this._propagateColorStore()\n  }\n  \n  setCanvasExtent(newCanvasWidth, newCanvasHeight) {\n    this.forceCenterManager.setCanvasExtent(newCanvasWidth, newCanvasHeight)\n  }\n  \n  setStrokeStyle(strokeStyle) {\n    this.strokeStyle = strokeStyle\n  }\n  \n  updateStrokeStyle(strokeStyle) {\n    this.strokeStyle = strokeStyle\n    this.draw()\n  }\n  \n  async initializeWithData(individuals) {\n    this.drawer.deleteSelections()\n    this._stopSimulation()\n    this.individuals = individuals\n    this.initialIndividuals = individuals\n    this._preprocessIndividuals()\n    await this._setupVisualization()\n  }\n  \n  async addThemeGroup(uuid, name, themes, color) {\n    this.individualsSimulation.stop()\n    this.forceCenterManager.addThemeGroup(uuid, name, themes, color)\n    await this._loadNewLayout()\n    this._updateInteractionSubjects()\n    this._registerForceCenterAnnotations()\n    this.updateDistribution()\n  }\n  \n  updateThemeGroup(uuid, name, themes, color) {\n    this.forceCenterManager.updateThemeGroup(uuid, name, themes, color);\n    this.updateDistribution()\n  }\n  \n  async removeThemeGroup(uuid) {\n    this.individualsSimulation.stop()\n    this.forceCenterManager.removeThemeGroup(uuid)\n    await this._loadNewLayout()\n    this._updateInteractionSubjects()\n    this.updateDistribution()\n  }\n  \n  recolorIndividuals(colorAction) {\n    this._stopSimulation()\n    colorAction.runOn(this.individuals)\n    colorAction.runOn(this.initialIndividuals)\n    this.updateDistribution()\n  }\n  \n  filterIndividuals(filterAction) {\n    this._stopSimulation()\n    this.individuals = filterAction.runOn(this.initialIndividuals)\n    this.individualsSimulation.updateIndividuals(this.individuals)\n    if(this._individualsNotEmpty()) {\n      this.updateDistribution()\n    }\n  }\n  \n  selectIndividuals(selectAction) {\n    this._stopSimulation()\n    selectAction.runOn(this.individuals)\n    this.updateDistribution()\n  }\n  \n  inspectIndividual(inspectAction) {\n    this.stopSimulation()\n    inspectAction.runOn(this.individuals)\n    inspectAction.runOn(this.initialIndividuals)\n    this.updateDistribution()\n  }\n  \n  draw() {\n    this._clearCanvas(this.canvasContext)\n    this._drawHulls()\n    this._drawIndividuals()\n    this._drawForceCenters()\n    this.drawer.drawSelections()\n  }\n  \n  updateDistribution() {\n    this.individualsDistributor.setDistribution(\n      this.individuals, this.forceCenterManager.getForceCenters())\n    this.individualsSimulation.updateForces()\n  }\n  \n  stopSimulation() {\n    if(this.individualsSimulation) this.individualsSimulation.stop()\n  }\n  \n  inspect(individual) {\n    let inspectAction = new InspectAction(individual, true, this.dataProcessor, this.colorStore)\n    this.owner.dispatchEvent(new CustomEvent(\"individual-inspected\", {\n      detail: {\n        action: inspectAction\n      },\n      bubbles: true\n    }))\n  }\n  \n  freehandSelectionCreated() {\n    this.draw()\n  }\n  \n  freehandSelectionDeleted(selection) {\n    this._clearCanvas(this.freehandCanvasContext)\n    this.drawer.drawSelections()\n\n    this.owner.dispatchEvent(new CustomEvent(\"freehand-selection-deleted\", {\n      detail: {\n        selection: selection\n      },\n      bubbles: true\n    }))\n  }\n  \n  freehandSelectionOnContextMenu(evt, selection, selectionSVG) {\n    let linePointsArray = selection.linePoints.map(point => [point.x, point.y])\n    let selectedIndividuals = this.individuals.filter(point => inside(\n      [point.x, point.y], \n      linePointsArray))\n    this.owner.dispatchEvent(new CustomEvent(\"freehand-selection-contextmenu\", {\n      detail: {\n        freehandSelectionSVGElement: selectionSVG,\n        clientX: evt.clientX,\n        clientY: evt.clientY,\n        individualsSelection: {selectedIndividuals: selectedIndividuals, selectionColor: selection.color}\n      },\n      bubbles: true\n    }))\n}\n    \n  // ------------------------------------------\n  // Private Methods\n  // ------------------------------------------\n  \n  _individualsNotEmpty() {\n    return this.individuals.length\n  }\n  \n  _stopSimulation() {\n   if(this.individualsSimulation) {\n     this.individualsSimulation.stop()\n   }\n  }\n  \n  _propagateDataProcessor() {\n    this.forceCenterManager.setDataProcessor(this.dataProcessor)\n  }\n  \n  _propagateColorStore() {\n    this.forceCenterManager.setColorStore(this.colorStore)\n  }\n  \n  async _loadNewLayout() {\n    //this._startLoadingAnimation()\n    await this.forceCenterManager.updateLayout()\n    //this._endLoadingAnimation()\n  }\n  \n  _startLoadingAnimation() {\n    this.loaderDiv = <div class=\"loader\"></div>;\n    Object.assign(this.loaderDiv.style, this._getLoaderDivCSS())\n    this.canvas.parentElement.appendChild(this.loaderDiv)\n  }\n  \n  _getLoaderDivCSS() {\n    let canvasRootElement = this.canvas.parentElement\n    let positionX = canvasRootElement.offsetLeft + canvasRootElement.offsetWidth / 2;\n    let positionY = canvasRootElement.offsetTop + canvasRootElement.offsetHeight / 2;\n    return {\n      border: \"16px solid #f3f3f3\",\n      borderTop: \"16px solid #3498db\",\n      borderRadius: \"50%\",\n      width: \"80px\",\n      height: \"80px\",\n      animation: \"spin 2s linear infinite\",\n      position: \"absolute\",\n      left: positionX + \"px\",\n      top: positionY + \"px\"\n    }\n  }\n  \n  _endLoadingAnimation() {\n    if (this.canvas.parentElement.contains(this.loaderDiv)) {\n      this.canvas.parentElement.removeChild(this.loaderDiv)\n    }\n  }\n  \n  _preprocessIndividuals(){\n    this.individuals.forEach(individual => {\n      individual.drawing.currentSize = INDIVIDUALS_DOT_SIZE\n    })\n  }\n  \n  async _setupVisualization(){\n    this.forceCenterManager.setInitialForceCenter()\n    await this.forceCenterManager.updateLayout()\n    this.individualsDistributor.setDistribution(\n      this.individuals, \n      this.forceCenterManager.getForceCenters()\n    )\n    this._setupIndividualsSimulation(this.individuals)\n    this._setupInteraction()\n    this._registerForceCenterAnnotations()\n  }\n \n  _setupIndividualsSimulation(individuals) {\n    this.individualsSimulation = new IndividualsSimulation(this, individuals)\n    this.individualsSimulation.start()\n  }\n  \n  _setupInteraction() {\n    this.interactionManager.registerDragging(this.forceCenterManager.getForceCenters())\n    this.interactionManager.registerClick(this.individuals)\n    this.interactionManager.registerDoubleClick(this.forceCenterManager.getForceCenters())\n  }\n  \n  _registerForceCenterAnnotations() {\n    let annotations = this.forceCenterManager.getForceCenterAnnotations()\n    annotations.forEach(annotation => {\n      this.canvas.parentElement.appendChild(annotation)\n    })\n  }\n  \n  _updateInteractionSubjects() {\n    this.interactionManager.setDraggingSubjects(this.forceCenterManager.getForceCenters())\n    this.interactionManager.setToggleSubjects(this.forceCenterManager.getForceCenters())\n  }\n  \n  _clearCanvas(canvasContext) {\n    canvasContext.clearRect(0, 0, this.canvas.width, this.canvas.height);\n  }\n  \n  _drawIndividuals() {\n    this.individuals.forEach(individual => {\n      let color = this.colorStore.convertColorObjectToRGBAValue(\n        individual.drawing.currentColor)\n      this._drawPoint(\n        individual.x, \n        individual.y, \n        individual.drawing.currentSize, \n        color\n      )\n    })\n  }\n  \n  _drawForceCenters() {\n    this.forceCenterManager.getForceCenters().forEach(forceCenter => {\n      this._drawPoint(\n        forceCenter.x,\n        forceCenter.y,\n        FORCE_CENTER_SIZE,\n        FORCE_CENTER_COLOR\n      )\n    })\n  }\n  \n  _drawHulls() {\n    this.forceCenterManager.getThemeGroups().forEach(themeGroup => {\n      let groupHull = themeGroup.getGroupHull()\n      let hullCornerPoints = groupHull.getPaddedHullCornerPoints()\n      if (hullCornerPoints.length > 0) {\n        this._drawPolygon(hullCornerPoints, themeGroup.getColor())\n      }  \n    })\n  }\n  \n  _drawPoint(x, y, size, color) {\n    if (this.strokeStyle) {\n      this.canvasContext.strokeStyle = color;\n      this.canvasContext.beginPath();\n      this.canvasContext.arc(x, y, size, 0, Math.PI * 2, true);\n      this.canvasContext.stroke();\n    } else {\n      this.canvasContext.fillStyle = color;\n      this.canvasContext.beginPath();\n      this.canvasContext.arc(x, y, size, 0, Math.PI * 2, true);\n      this.canvasContext.fill();\n    }\n  }\n  \n  _drawPolygon(cornerPoints, color) {\n    this.canvasContext.fillStyle = color;\n    this.canvasContext.beginPath();\n    this.canvasContext.moveTo(cornerPoints[0][0], cornerPoints[0][1]);\n    cornerPoints.shift()\n    cornerPoints.forEach((point) => {\n      this.canvasContext.lineTo(point[0], point[1]);\n    })\n    this.canvasContext.closePath();\n    this.canvasContext.fill();\n  }\n}"]}