diff --git a/platform/features/layout/src/elements/ElementProxy.js b/platform/features/layout/src/elements/ElementProxy.js index f580b509cd..277353e315 100644 --- a/platform/features/layout/src/elements/ElementProxy.js +++ b/platform/features/layout/src/elements/ElementProxy.js @@ -11,18 +11,54 @@ define( * This handles the generic operations (e.g. remove) so that * subclasses only need to implement element-specific behaviors. * @constructor - * @param element the telemetry element + * @param element the fixed position element, as stored in its + * configuration * @param index the element's index within its array * @param {Array} elements the full array of elements */ function ElementProxy(element, index, elements) { return { + /** + * The element as stored in the view configuration. + */ element: element, + /** + * Get and/or set the x position of this element. + * Units are in fixed position grid space. + * @param {number} [x] the new x position (if setting) + * @returns {number} the x position + */ x: new AccessorMutator(element, 'x'), + /** + * Get and/or set the y position of this element. + * Units are in fixed position grid space. + * @param {number} [y] the new y position (if setting) + * @returns {number} the y position + */ y: new AccessorMutator(element, 'y'), + /** + * Get and/or set the z index of this element. + * @param {number} [z] the new z index (if setting) + * @returns {number} the z index + */ z: new AccessorMutator(element, 'z'), + /** + * Get and/or set the width of this element. + * Units are in fixed position grid space. + * @param {number} [w] the new width (if setting) + * @returns {number} the width + */ width: new AccessorMutator(element, 'width'), + /** + * Get and/or set the height of this element. + * Units are in fixed position grid space. + * @param {number} [h] the new height (if setting) + * @returns {number} the height + */ height: new AccessorMutator(element, 'height'), + /** + * Remove this element from the fixed position view. + */ remove: function () { if (elements[index] === element) { elements.splice(index, 1); diff --git a/platform/features/layout/src/elements/LineProxy.js b/platform/features/layout/src/elements/LineProxy.js index fbba73abdb..14671689dd 100644 --- a/platform/features/layout/src/elements/LineProxy.js +++ b/platform/features/layout/src/elements/LineProxy.js @@ -6,11 +6,22 @@ define( 'use strict'; /** - * + * Selection/diplay proxy for line elements of a fixed position + * view. + * @constructor + * @param element the fixed position element, as stored in its + * configuration + * @param index the element's index within its array + * @param {Array} elements the full array of elements */ function LineProxy(element, index, elements) { var proxy = new ElementProxy(element, index, elements); + /** + * Get the top-left x coordinate, in grid space, of + * this line's bounding box. + * @returns {number} the x coordinate + */ proxy.x = function (v) { var x = Math.min(element.x, element.x2), delta = v - x; @@ -21,6 +32,11 @@ define( return x; }; + /** + * Get the top-left y coordinate, in grid space, of + * this line's bounding box. + * @returns {number} the y coordinate + */ proxy.y = function (v) { var y = Math.min(element.y, element.y2), delta = v - y; @@ -31,26 +47,60 @@ define( return y; }; + /** + * Get the width, in grid space, of + * this line's bounding box. + * @returns {number} the width + */ proxy.width = function () { return Math.max(Math.abs(element.x - element.x2), 1); }; + /** + * Get the height, in grid space, of + * this line's bounding box. + * @returns {number} the height + */ proxy.height = function () { return Math.max(Math.abs(element.y - element.y2), 1); }; + /** + * Get the x position, in grid units relative to + * the top-left corner, of the first point in this line + * segment. + * @returns {number} the x position of the first point + */ proxy.x1 = function () { return element.x - proxy.x(); }; + /** + * Get the y position, in grid units relative to + * the top-left corner, of the first point in this line + * segment. + * @returns {number} the y position of the first point + */ proxy.y1 = function () { return element.y - proxy.y(); }; + /** + * Get the x position, in grid units relative to + * the top-left corner, of the second point in this line + * segment. + * @returns {number} the x position of the second point + */ proxy.x2 = function () { return element.x2 - proxy.x(); }; + /** + * Get the y position, in grid units relative to + * the top-left corner, of the second point in this line + * segment. + * @returns {number} the y position of the second point + */ proxy.y2 = function () { return element.y2 - proxy.y(); };