1 /*
  2  *Copyright (c) 2009, TellurianRing.com
  3  *All rights reserved.
  4  *
  5  *Redistribution and use in source and binary forms, with or without modification,
  6  *are permitted provided that the following conditions are met:
  7  *
  8  *   Redistributions of source code must retain the above copyright notice, this
  9  *   list of conditions and the following disclaimer.
 10  *   Redistributions in binary form must reproduce the above copyright notice,
 11  *   this list of conditions and the following disclaimer in the documentation
 12  *   and/or other materials provided with the distribution.
 13  *   Neither the name of the Organization (TellurianRing.com) nor the names of
 14  *   its contributors may be used to endorse or promote products derived from
 15  *   this software without specific prior written permission.
 16  *
 17  *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 18  *ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 19  *WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 20  *DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 21  *ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22  *(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 23  *LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 24  *ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25  *(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 26  *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27  */
 28 /**
 29  * @class Describes an x and y coordinate.
 30  * @example // Creating a point from a JSON object
 31  * var myPoint = Point({ x: 10, y: 10 });
 32  * @example // creating a point from another Point object, or a Bounds object.
 33  * var myPoint2 = Point(myPoint);
 34  * var bounds = Bounds(myPoint2);
 35  * var myPoint3 = Point(bounds);
 36  * @param {Point, Bounds, Object} _details Another Point object, or Bounds
 37  *        object. Can also be created with a JSON object with these attributes:
 38  * <table cellpadding="0" cellspacing="1" border="0" class="constructor_details">
 39  *    <tr><th>Property</th> <th>Required</th> <th>Default</th></tr>
 40  *    <tr><td>x</td>        <td>yes</td>      <td></td></tr>
 41  *    <tr><td>y</td>        <td>yes</td>      <td></td></tr>
 42  * </table>
 43  */
 44 function Point(_details) { // {{{
 45    /** @constructs */
 46    function _Point(_details) { // {{{
 47       var that = this;
 48       /** @field Public details field. Contains user's original details object. */
 49       this.details = _details;
 50       /** @field X coordinate */
 51       this.x = check(_details.x, 0);
 52       /** @field Y coordinate */
 53       this.y = check(_details.y, 0);
 54       
 55       /**
 56        * This extends the provided child function with this instance.
 57        */
 58       this.extend = function(_child) { // {{{
 59          _child.prototype = that;
 60       } // }}} extend
 61    } // }}} _Point
 62    var thePoint = new _Point(_details);
 63    return thePoint;
 64 } // }}} Point
 65 // These properties are for jEdit - Programmer's Text Editor.
 66 // Load this file in jEdit to see what they do.
 67 // ::folding=explicit:mode=javascript:noTabs=true:collapseFolds=4::
 68