|
@@ -3,6 +3,7 @@ import { CircumferenceModel } from "../models/circumference-model";
|
|
import { PointDrawer } from "../../point-component/drawers/point-drawer";
|
|
import { PointDrawer } from "../../point-component/drawers/point-drawer";
|
|
import { DrawerAggregator } from "../../../core/drawers/drawer-aggregator";
|
|
import { DrawerAggregator } from "../../../core/drawers/drawer-aggregator";
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
|
|
+import { selector as Selector } from "../../../core/application/selector";
|
|
|
|
|
|
export class CircumferenceDrawer extends Drawer {
|
|
export class CircumferenceDrawer extends Drawer {
|
|
constructor() {
|
|
constructor() {
|
|
@@ -18,6 +19,30 @@ export class CircumferenceDrawer extends Drawer {
|
|
}
|
|
}
|
|
|
|
|
|
draw(e) {
|
|
draw(e) {
|
|
|
|
+ const points = Selector.getSelectedPoints();
|
|
|
|
+ if (points == undefined || points.length == 0) {
|
|
|
|
+ this.drawByStates(e);
|
|
|
|
+ } else
|
|
|
|
+ this.drawByPoints(points, undefined, e);
|
|
|
|
+ }
|
|
|
|
+ drawByPoints(points, aggregators, e) {
|
|
|
|
+ if (aggregators == undefined)
|
|
|
|
+ aggregators = Selector.getSelectedPointsAggregators();
|
|
|
|
+ else {
|
|
|
|
+ aggregators = [
|
|
|
|
+ Objects.getByGenericObject(this.pointA)[0],
|
|
|
|
+ Objects.getByGenericObject(this.pointB)[0]
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ this.centerAggregator = aggregators[0];
|
|
|
|
+ this.radiusAggregator = aggregators[1];
|
|
|
|
+ this.center = points[0];
|
|
|
|
+ this.radius = points[1];
|
|
|
|
+ this.createAndDraw(this.center, this.radius);
|
|
|
|
+ this.clear();
|
|
|
|
+ this.setStatus("");
|
|
|
|
+ }
|
|
|
|
+ drawByStates(e) {
|
|
if (this.state == undefined) {
|
|
if (this.state == undefined) {
|
|
this.state = this.states[0];
|
|
this.state = this.states[0];
|
|
this.setStatus("Selecione o centro da Circunferência");
|
|
this.setStatus("Selecione o centro da Circunferência");
|
|
@@ -29,24 +54,28 @@ export class CircumferenceDrawer extends Drawer {
|
|
} else if (this.state == this.states[1]) {
|
|
} else if (this.state == this.states[1]) {
|
|
this.radiusAggregator = this.pointDrawer.drawPoint();
|
|
this.radiusAggregator = this.pointDrawer.drawPoint();
|
|
this.radius = this.radiusAggregator.genericObject;
|
|
this.radius = this.radiusAggregator.genericObject;
|
|
- this.circumference = new CircumferenceModel(this.center, this.radius)
|
|
|
|
- this.konvaObject = this.drawcircumference(this.circumference);
|
|
|
|
- const aggregator = new DrawerAggregator(
|
|
|
|
- this,
|
|
|
|
- this.circumference,
|
|
|
|
- this.konvaObject,
|
|
|
|
- ELEMENTS_CLASS.CIRCUMFERENCE
|
|
|
|
- );
|
|
|
|
- super.addAggregator(aggregator);
|
|
|
|
- this.centerAggregator.addAggregator(aggregator);
|
|
|
|
- this.radiusAggregator.addAggregator(aggregator);
|
|
|
|
- Drawer.drawObject(this.konvaObject);
|
|
|
|
- this.konvaObject.zIndex(0);
|
|
|
|
- super.batchDraw();
|
|
|
|
- this.clear();
|
|
|
|
- this.setStatus("");
|
|
|
|
|
|
+ this.createAndDraw(this.center, this.radius);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ createAndDraw(center, radius) {
|
|
|
|
+ this.center = center;
|
|
|
|
+ this.radius = radius;
|
|
|
|
+ this.circumference = new CircumferenceModel(this.center, this.radius)
|
|
|
|
+ this.konvaObject = this.drawcircumference(this.circumference);
|
|
|
|
+ const aggregator = new DrawerAggregator(
|
|
|
|
+ this,
|
|
|
|
+ this.circumference,
|
|
|
|
+ this.konvaObject,
|
|
|
|
+ ELEMENTS_CLASS.CIRCUMFERENCE
|
|
|
|
+ );
|
|
|
|
+ super.addAggregator(aggregator);
|
|
|
|
+ this.centerAggregator.addAggregator(aggregator);
|
|
|
|
+ this.radiusAggregator.addAggregator(aggregator);
|
|
|
|
+ Drawer.drawObject(this.konvaObject);
|
|
|
|
+ this.konvaObject.zIndex(0);
|
|
|
|
+ super.batchDraw();
|
|
|
|
+ return aggregator;
|
|
|
|
+ }
|
|
drawcircumference(circumference) {
|
|
drawcircumference(circumference) {
|
|
const circle = new Konva.Circle({
|
|
const circle = new Konva.Circle({
|
|
x: circumference.center.posX,
|
|
x: circumference.center.posX,
|
|
@@ -66,12 +95,12 @@ export class CircumferenceDrawer extends Drawer {
|
|
return circle;
|
|
return circle;
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- update(aggregator, e) {
|
|
|
|
- const center = aggregator.genericObject.center;
|
|
|
|
- aggregator.konvaObject.radius(aggregator.genericObject.getRadius());
|
|
|
|
- aggregator.konvaObject.x(center.posX);
|
|
|
|
- aggregator.konvaObject.y(center.posY);
|
|
|
|
- super.batchDraw();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ update(aggregator, e) {
|
|
|
|
+ const center = aggregator.genericObject.center;
|
|
|
|
+ aggregator.konvaObject.radius(aggregator.genericObject.getRadius());
|
|
|
|
+ aggregator.konvaObject.x(center.posX);
|
|
|
|
+ aggregator.konvaObject.y(center.posY);
|
|
|
|
+ super.batchDraw();
|
|
|
|
+ }
|
|
}
|
|
}
|