@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
52 lines • 2.24 kB
JavaScript
import { __extends } from "tslib";
import { EShapeCapabilities, EShapeCapability, EShapeConnectorLine } from "@wcardinal/wcardinal-ui";
import { ECommandShapeProperty } from "./e-command-shape-property";
var ECommandShapePropertyPosition = /** @class */ (function (_super) {
__extends(ECommandShapePropertyPosition, _super);
function ECommandShapePropertyPosition(selection) {
return _super.call(this, selection, undefined) || this;
}
ECommandShapePropertyPosition.prototype.toCapability = function (shape) {
if (shape instanceof EShapeConnectorLine) {
var edge = shape.edge;
if (edge.tail.acceptor.shape == null && edge.head.acceptor.shape == null) {
return EShapeCapability.POSITION;
}
return EShapeCapability.NONE;
}
else {
if (EShapeCapabilities.contains(shape, EShapeCapability.POSITION)) {
return EShapeCapability.POSITION;
}
return EShapeCapability.NONE;
}
};
ECommandShapePropertyPosition.prototype.getProperty = function (shape, capability) {
if (shape instanceof EShapeConnectorLine) {
var edge = shape.edge;
var tailLocal = edge.tail.local;
var headLocal = edge.head.local;
return [tailLocal.x, tailLocal.y, headLocal.x, headLocal.y];
}
else {
var position = shape.transform.position;
return [position.x, position.y, 0, 0];
}
};
ECommandShapePropertyPosition.prototype.setProperty = function (shape, capability, property) {
if (shape instanceof EShapeConnectorLine) {
var edge = shape.edge;
edge.tail.local.set(property[0], property[1]);
edge.head.local.set(property[2], property[3]);
}
else {
shape.transform.position.set(property[0], property[1]);
}
};
ECommandShapePropertyPosition.prototype.initProperty = function (shape, capability, property) {
// DO NOTHING
};
return ECommandShapePropertyPosition;
}(ECommandShapeProperty));
export { ECommandShapePropertyPosition };
//# sourceMappingURL=e-command-shape-property-position.js.map