123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- import defined from "../Core/defined.js";
- import DeveloperError from "../Core/DeveloperError.js";
- import Event from "../Core/Event.js";
- import EventHelper from "../Core/EventHelper.js";
- import Property from "./Property.js";
- function PropertyArray(value) {
- this._value = undefined;
- this._definitionChanged = new Event();
- this._eventHelper = new EventHelper();
- this.setValue(value);
- }
- Object.defineProperties(PropertyArray.prototype, {
-
- isConstant: {
- get: function () {
- var value = this._value;
- if (!defined(value)) {
- return true;
- }
- var length = value.length;
- for (var i = 0; i < length; i++) {
- if (!Property.isConstant(value[i])) {
- return false;
- }
- }
- return true;
- },
- },
-
- definitionChanged: {
- get: function () {
- return this._definitionChanged;
- },
- },
- });
- PropertyArray.prototype.getValue = function (time, result) {
-
- if (!defined(time)) {
- throw new DeveloperError("time is required.");
- }
-
- var value = this._value;
- if (!defined(value)) {
- return undefined;
- }
- var length = value.length;
- if (!defined(result)) {
- result = new Array(length);
- }
- var i = 0;
- var x = 0;
- while (i < length) {
- var property = this._value[i];
- var itemValue = property.getValue(time, result[i]);
- if (defined(itemValue)) {
- result[x] = itemValue;
- x++;
- }
- i++;
- }
- result.length = x;
- return result;
- };
- PropertyArray.prototype.setValue = function (value) {
- var eventHelper = this._eventHelper;
- eventHelper.removeAll();
- if (defined(value)) {
- this._value = value.slice();
- var length = value.length;
- for (var i = 0; i < length; i++) {
- var property = value[i];
- if (defined(property)) {
- eventHelper.add(
- property.definitionChanged,
- PropertyArray.prototype._raiseDefinitionChanged,
- this
- );
- }
- }
- } else {
- this._value = undefined;
- }
- this._definitionChanged.raiseEvent(this);
- };
- PropertyArray.prototype.equals = function (other) {
- return (
- this === other ||
- (other instanceof PropertyArray &&
- Property.arrayEquals(this._value, other._value))
- );
- };
- PropertyArray.prototype._raiseDefinitionChanged = function () {
- this._definitionChanged.raiseEvent(this);
- };
- export default PropertyArray;
|