RectangleGraphics.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 Rectangle.
  19. *
  20. * @alias RectangleGraphics
  21. * @constructor
  22. */
  23. var RectangleGraphics = function() {
  24. this._show = undefined;
  25. this._showSubscription = undefined;
  26. this._material = undefined;
  27. this._materialSubscription = undefined;
  28. this._coordinates = undefined;
  29. this._coordinatesSubscription = undefined;
  30. this._height = undefined;
  31. this._heightSubscription = undefined;
  32. this._extrudedHeight = undefined;
  33. this._extrudedHeightSubscription = undefined;
  34. this._granularity = undefined;
  35. this._granularitySubscription = undefined;
  36. this._stRotation = undefined;
  37. this._stRotationSubscription = undefined;
  38. this._rotation = undefined;
  39. this._rotationSubscription = undefined;
  40. this._closeTop = undefined;
  41. this._closeTopSubscription = undefined;
  42. this._closeBottom = undefined;
  43. this._closeBottomSubscription = undefined;
  44. this._outline = undefined;
  45. this._outlineSubscription = undefined;
  46. this._outlineColor = undefined;
  47. this._outlineColorSubscription = undefined;
  48. this._outlineWidth = undefined;
  49. this._outlineWidthSubscription = undefined;
  50. this._definitionChanged = new Event();
  51. };
  52. defineProperties(RectangleGraphics.prototype, {
  53. /**
  54. * Gets the event that is raised whenever a new property is assigned.
  55. * @memberof RectangleGraphics.prototype
  56. *
  57. * @type {Event}
  58. * @readonly
  59. */
  60. definitionChanged : {
  61. get : function() {
  62. return this._definitionChanged;
  63. }
  64. },
  65. /**
  66. * Gets or sets the boolean {@link Property} specifying the rectangle's visibility.
  67. * @memberof RectangleGraphics.prototype
  68. * @type {Property}
  69. */
  70. show : createPropertyDescriptor('show'),
  71. /**
  72. * Gets or sets the {@link Rectangle} {@link Property} specifying the extent.
  73. * @memberof RectangleGraphics.prototype
  74. * @type {Property}
  75. */
  76. coordinates : createPropertyDescriptor('coordinates'),
  77. /**
  78. * Gets or sets the {@link MaterialProperty} specifying the appearance of the rectangle.
  79. * @memberof RectangleGraphics.prototype
  80. * @type {MaterialProperty}
  81. */
  82. material : createPropertyDescriptor('material'),
  83. /**
  84. * Gets or sets the Number {@link Property} specifying the height of the rectangle.
  85. * If undefined, the rectangle will be on the surface.
  86. * @memberof RectangleGraphics.prototype
  87. * @type {Property}
  88. */
  89. height : createPropertyDescriptor('height'),
  90. /**
  91. * Gets or sets the Number {@link Property} specifying the extruded height of the rectangle.
  92. * Setting this property creates a rectangle shaped volume starting at height and ending
  93. * at the extruded height.
  94. * @memberof RectangleGraphics.prototype
  95. * @type {Property}
  96. */
  97. extrudedHeight : createPropertyDescriptor('extrudedHeight'),
  98. /**
  99. * Gets or sets the Number {@link Property} specifying the sampling distance, in radians,
  100. * between each latitude and longitude point.
  101. * @memberof RectangleGraphics.prototype
  102. * @type {Property}
  103. */
  104. granularity : createPropertyDescriptor('granularity'),
  105. /**
  106. * Gets or sets the Number {@link Property} specifying the rotation of the texture coordinates,
  107. * in radians. A positive rotation is counter-clockwise.
  108. * @memberof RectangleGraphics.prototype
  109. * @type {Property}
  110. */
  111. stRotation : createPropertyDescriptor('stRotation'),
  112. /**
  113. * Gets or sets the Number {@link Property} specifying the rotation of the texture coordinates,
  114. * in radians. A positive rotation is counter-clockwise.
  115. * @memberof RectangleGraphics.prototype
  116. * @type {Property}
  117. */
  118. rotation : createPropertyDescriptor('rotation'),
  119. /**
  120. * Gets or sets the Boolean {@link Property} specifying whether the rectangle should be filled.
  121. * @memberof RectangleGraphics.prototype
  122. * @type {Property}
  123. */
  124. fill : createPropertyDescriptor('fill'),
  125. /**
  126. * Gets or sets the Boolean {@link Property} specifying whether the rectangle should be outlined.
  127. * @memberof RectangleGraphics.prototype
  128. * @type {Property}
  129. */
  130. outline : createPropertyDescriptor('outline'),
  131. /**
  132. * Gets or sets the Color {@link Property} specifying whether the color of the outline.
  133. * @memberof RectangleGraphics.prototype
  134. * @type {Property}
  135. */
  136. outlineColor : createPropertyDescriptor('outlineColor'),
  137. /**
  138. * Gets or sets the Number {@link Property} specifying the width of the outline.
  139. * @memberof EllipseGraphics.prototype
  140. * @type {Property}
  141. */
  142. outlineWidth : createPropertyDescriptor('outlineWidth'),
  143. /**
  144. * Gets or sets the Boolean {@link Property} specifying whether an extruded rectangle should have a closed top.
  145. * @memberof RectangleGraphics.prototype
  146. * @type {Property}
  147. */
  148. closeTop : createPropertyDescriptor('closeTop'),
  149. /**
  150. * Gets or sets the Boolean {@link Property} specifying whether an extruded rectangle should have a closed bottom.
  151. * @memberof RectangleGraphics.prototype
  152. * @type {Property}
  153. */
  154. closeBottom : createPropertyDescriptor('closeBottom')
  155. });
  156. /**
  157. * Duplicates a RectangleGraphics instance.
  158. *
  159. * @param {RectangleGraphics} [result] The object onto which to store the result.
  160. * @returns {RectangleGraphics} The modified result parameter or a new instance if one was not provided.
  161. */
  162. RectangleGraphics.prototype.clone = function(result) {
  163. if (!defined(result)) {
  164. result = new RectangleGraphics();
  165. }
  166. result.show = this.show;
  167. result.coordinates = this.coordinates;
  168. result.material = this.material;
  169. result.height = this.height;
  170. result.extrudedHeight = this.extrudedHeight;
  171. result.granularity = this.granularity;
  172. result.stRotation = this.stRotation;
  173. result.rotation = this.rotation;
  174. result.fill = this.fill;
  175. result.outline = this.outline;
  176. result.outlineColor = this.outlineColor;
  177. result.outlineWidth = this.outlineWidth;
  178. result.closeTop = this.closeTop;
  179. result.closeBottom = this.closeBottom;
  180. return result;
  181. };
  182. /**
  183. * Assigns each unassigned property on this object to the value
  184. * of the same property on the provided source object.
  185. *
  186. * @param {RectangleGraphics} source The object to be merged into this object.
  187. */
  188. RectangleGraphics.prototype.merge = function(source) {
  189. //>>includeStart('debug', pragmas.debug);
  190. if (!defined(source)) {
  191. throw new DeveloperError('source is required.');
  192. }
  193. //>>includeEnd('debug');
  194. this.show = defaultValue(this.show, source.show);
  195. this.coordinates = defaultValue(this.coordinates, source.coordinates);
  196. this.material = defaultValue(this.material, source.material);
  197. this.height = defaultValue(this.height, source.height);
  198. this.extrudedHeight = defaultValue(this.extrudedHeight, source.extrudedHeight);
  199. this.granularity = defaultValue(this.granularity, source.granularity);
  200. this.stRotation = defaultValue(this.stRotation, source.stRotation);
  201. this.rotation = defaultValue(this.rotation, source.rotation);
  202. this.fill = defaultValue(this.fill, source.fill);
  203. this.outline = defaultValue(this.outline, source.outline);
  204. this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
  205. this.outlineWidth = defaultValue(this.outlineWidth, source.outlineWidth);
  206. this.closeTop = defaultValue(this.closeTop, source.closeTop);
  207. this.closeBottom = defaultValue(this.closeBottom, source.closeBottom);
  208. };
  209. return RectangleGraphics;
  210. });