PointGraphics.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*global define*/
  2. define([
  3. '../Core/defaultValue',
  4. '../Core/defined',
  5. '../Core/defineProperties',
  6. '../Core/DeveloperError',
  7. '../Core/Event',
  8. './createPropertyDescriptor'
  9. ], function(
  10. defaultValue,
  11. defined,
  12. defineProperties,
  13. DeveloperError,
  14. Event,
  15. createPropertyDescriptor) {
  16. "use strict";
  17. /**
  18. * An optionally time-dynamic billboard.
  19. * @alias PointGraphics
  20. * @constructor
  21. */
  22. var PointGraphics = function() {
  23. this._color = undefined;
  24. this._colorSubscription = undefined;
  25. this._pixelSize = undefined;
  26. this._pixelSizeSubscription = undefined;
  27. this._outlineColor = undefined;
  28. this._outlineColorSubscription = undefined;
  29. this._outlineWidth = undefined;
  30. this._outlineWidthSubscription = undefined;
  31. this._show = undefined;
  32. this._showSubscription = undefined;
  33. this._scaleByDistance = undefined;
  34. this._scaleByDistanceSubscription = undefined;
  35. this._definitionChanged = new Event();
  36. };
  37. defineProperties(PointGraphics.prototype, {
  38. /**
  39. * Gets the event that is raised whenever a new property is assigned.
  40. * @memberof PointGraphics.prototype
  41. *
  42. * @type {Event}
  43. * @readonly
  44. */
  45. definitionChanged : {
  46. get : function() {
  47. return this._definitionChanged;
  48. }
  49. },
  50. /**
  51. * Gets or sets the {@link Color} {@link Property} specifying the the point's color.
  52. * @memberof PointGraphics.prototype
  53. * @type {Property}
  54. */
  55. color : createPropertyDescriptor('color'),
  56. /**
  57. * Gets or sets the numeric {@link Property} specifying the point's size in pixels.
  58. * @memberof PointGraphics.prototype
  59. * @type {Property}
  60. */
  61. pixelSize : createPropertyDescriptor('pixelSize'),
  62. /**
  63. * Gets or sets the {@link Color} {@link Property} specifying the the point's outline color.
  64. * @memberof PointGraphics.prototype
  65. * @type {Property}
  66. */
  67. outlineColor : createPropertyDescriptor('outlineColor'),
  68. /**
  69. * Gets or sets the numeric {@link Property} specifying the the point's outline width.
  70. * @memberof PointGraphics.prototype
  71. * @type {Property}
  72. */
  73. outlineWidth : createPropertyDescriptor('outlineWidth'),
  74. /**
  75. * Gets or sets the boolean {@link Property} specifying the point's visibility.
  76. * @memberof PointGraphics.prototype
  77. * @type {Property}
  78. */
  79. show : createPropertyDescriptor('show'),
  80. /**
  81. * Gets or sets the {@link NearFarScalar} {@link Property} used to scale billboards based on distance.
  82. * If undefined, a constant size is used.
  83. * @memberof PointGraphics.prototype
  84. * @type {Property}
  85. */
  86. scaleByDistance : createPropertyDescriptor('scaleByDistance')
  87. });
  88. /**
  89. * Duplicates a PointGraphics instance.
  90. *
  91. * @param {PointGraphics} [result] The object onto which to store the result.
  92. * @returns {PointGraphics} The modified result parameter or a new instance if one was not provided.
  93. */
  94. PointGraphics.prototype.clone = function(result) {
  95. if (!defined(result)) {
  96. result = new PointGraphics();
  97. }
  98. result.color = this.color;
  99. result.pixelSize = this.pixelSize;
  100. result.outlineColor = this.outlineColor;
  101. result.outlineWidth = this.outlineWidth;
  102. result.show = this.show;
  103. result.scaleByDistance = this.scaleByDistance;
  104. return result;
  105. };
  106. /**
  107. * Assigns each unassigned property on this object to the value
  108. * of the same property on the provided source object.
  109. *
  110. * @param {PointGraphics} source The object to be merged into this object.
  111. */
  112. PointGraphics.prototype.merge = function(source) {
  113. //>>includeStart('debug', pragmas.debug);
  114. if (!defined(source)) {
  115. throw new DeveloperError('source is required.');
  116. }
  117. //>>includeEnd('debug');
  118. this.color = defaultValue(this.color, source.color);
  119. this.pixelSize = defaultValue(this.pixelSize, source.pixelSize);
  120. this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
  121. this.outlineWidth = defaultValue(this.outlineWidth, source.outlineWidth);
  122. this.show = defaultValue(this.show, source.show);
  123. this.scaleByDistance = defaultValue(this.scaleByDistance, source.scaleByDistance);
  124. };
  125. return PointGraphics;
  126. });