[Fixed Position] Add JSDoc
Add clarifying comments to different elements proxies, WTD-880.
This commit is contained in:
@@ -11,18 +11,54 @@ define(
|
|||||||
* This handles the generic operations (e.g. remove) so that
|
* This handles the generic operations (e.g. remove) so that
|
||||||
* subclasses only need to implement element-specific behaviors.
|
* subclasses only need to implement element-specific behaviors.
|
||||||
* @constructor
|
* @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 index the element's index within its array
|
||||||
* @param {Array} elements the full array of elements
|
* @param {Array} elements the full array of elements
|
||||||
*/
|
*/
|
||||||
function ElementProxy(element, index, elements) {
|
function ElementProxy(element, index, elements) {
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* The element as stored in the view configuration.
|
||||||
|
*/
|
||||||
element: element,
|
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'),
|
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'),
|
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'),
|
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'),
|
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'),
|
height: new AccessorMutator(element, 'height'),
|
||||||
|
/**
|
||||||
|
* Remove this element from the fixed position view.
|
||||||
|
*/
|
||||||
remove: function () {
|
remove: function () {
|
||||||
if (elements[index] === element) {
|
if (elements[index] === element) {
|
||||||
elements.splice(index, 1);
|
elements.splice(index, 1);
|
||||||
|
|||||||
@@ -6,11 +6,22 @@ define(
|
|||||||
'use strict';
|
'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) {
|
function LineProxy(element, index, elements) {
|
||||||
var proxy = new ElementProxy(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) {
|
proxy.x = function (v) {
|
||||||
var x = Math.min(element.x, element.x2),
|
var x = Math.min(element.x, element.x2),
|
||||||
delta = v - x;
|
delta = v - x;
|
||||||
@@ -21,6 +32,11 @@ define(
|
|||||||
return x;
|
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) {
|
proxy.y = function (v) {
|
||||||
var y = Math.min(element.y, element.y2),
|
var y = Math.min(element.y, element.y2),
|
||||||
delta = v - y;
|
delta = v - y;
|
||||||
@@ -31,26 +47,60 @@ define(
|
|||||||
return y;
|
return y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the width, in grid space, of
|
||||||
|
* this line's bounding box.
|
||||||
|
* @returns {number} the width
|
||||||
|
*/
|
||||||
proxy.width = function () {
|
proxy.width = function () {
|
||||||
return Math.max(Math.abs(element.x - element.x2), 1);
|
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 () {
|
proxy.height = function () {
|
||||||
return Math.max(Math.abs(element.y - element.y2), 1);
|
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 () {
|
proxy.x1 = function () {
|
||||||
return element.x - proxy.x();
|
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 () {
|
proxy.y1 = function () {
|
||||||
return element.y - proxy.y();
|
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 () {
|
proxy.x2 = function () {
|
||||||
return element.x2 - proxy.x();
|
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 () {
|
proxy.y2 = function () {
|
||||||
return element.y2 - proxy.y();
|
return element.y2 - proxy.y();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user