syncing master
This commit is contained in:
@@ -9,7 +9,10 @@ class ArrayVisualization {
|
||||
this.isDualTilt = isDualTilt;
|
||||
this.subarrayDisplay = subarrayDisplay;
|
||||
this.buildings = buildings;
|
||||
|
||||
// Default options
|
||||
this.scale = 10;
|
||||
this.panels = [];
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -22,12 +25,12 @@ class ArrayVisualization {
|
||||
this.stage.mouseMoveOutside = true;
|
||||
this.adjustScale(this.buildings);
|
||||
|
||||
this.drawArray(this.container, this.panelData, this.scale);
|
||||
this.drawArray(this.container, this.panelData);
|
||||
this.container.x = 0;
|
||||
this.container.y = 0;
|
||||
this.stage.addChild(this.container);
|
||||
|
||||
this.drawBuildings(this.buildings,this.scale);
|
||||
this.drawBuildings(this.buildings, this.scale);
|
||||
|
||||
this.stage.update();
|
||||
|
||||
@@ -76,13 +79,13 @@ class ArrayVisualization {
|
||||
|
||||
}
|
||||
|
||||
drawBuildings(buildings, scale) {
|
||||
if (!buildings) {
|
||||
drawBuildings(buildings) {
|
||||
if (!buildings || buildings.length === 0) {
|
||||
console.log("No Buildings!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!scale) {
|
||||
if (!this.scale) {
|
||||
console.log("No Scale - don't know how big the buildings should be!");
|
||||
return;
|
||||
}
|
||||
@@ -99,14 +102,14 @@ class ArrayVisualization {
|
||||
|
||||
line.graphics.beginStroke(color);
|
||||
|
||||
line.graphics.moveTo(firstPoint.x * scale, firstPoint.y * scale);
|
||||
line.graphics.moveTo(firstPoint.x * this.scale, firstPoint.y * this.scale);
|
||||
|
||||
for (let j = 1; j < building.length; j++ ) {
|
||||
nextPoint = building[j];
|
||||
line.graphics.lineTo(nextPoint.x * scale ,nextPoint.y * scale);
|
||||
line.graphics.moveTo(nextPoint.x * scale,nextPoint.y * scale);
|
||||
line.graphics.lineTo(nextPoint.x * this.scale, nextPoint.y * this.scale);
|
||||
line.graphics.moveTo(nextPoint.x * this.scale, nextPoint.y * this.scale);
|
||||
}
|
||||
line.graphics.lineTo(firstPoint.x * scale, firstPoint.y * scale );
|
||||
line.graphics.lineTo(firstPoint.x * this.scale, firstPoint.y * this.scale );
|
||||
line.graphics.endStroke();
|
||||
|
||||
}
|
||||
@@ -121,7 +124,7 @@ class ArrayVisualization {
|
||||
this.container.removeChild(this.panels[i]);
|
||||
}
|
||||
|
||||
this.drawArray(this.container, this.panelData, this.scale);
|
||||
this.drawArray(this.container, this.panelData);
|
||||
|
||||
let selectedPanel = this.selectedPanel;
|
||||
this.selectedPanel = undefined;
|
||||
@@ -134,18 +137,14 @@ class ArrayVisualization {
|
||||
}
|
||||
|
||||
drawArray(container, panels) {
|
||||
this.panels = [];
|
||||
let treatCoordinatesAsCenterpoints = this.buildings && this.buildings.length > 0;
|
||||
for (let i = 0; i < panels.length; i++) {
|
||||
let panel = panels[i];
|
||||
|
||||
let box = new Panel(panel, this.isDualTilt, this.scale, treatCoordinatesAsCenterpoints);
|
||||
let box = new Panel(panels[i], this.isDualTilt, this.scale, treatCoordinatesAsCenterpoints);
|
||||
container.addChild(box);
|
||||
this.panels.push(box);
|
||||
|
||||
let self = this;
|
||||
box.on("click", function () {
|
||||
self.selectPanel(i);
|
||||
box.on("click", () => {
|
||||
this.selectPanel(i);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user