mxPoint.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. * Copyright (c) 2006-2015, Gaudenz Alder
  4. */
  5. /**
  6. * Class: mxPoint
  7. *
  8. * Implements a 2-dimensional vector with double precision coordinates.
  9. *
  10. * Constructor: mxPoint
  11. *
  12. * Constructs a new point for the optional x and y coordinates. If no
  13. * coordinates are given, then the default values for <x> and <y> are used.
  14. */
  15. function mxPoint(x, y)
  16. {
  17. this.x = (x != null) ? x : 0;
  18. this.y = (y != null) ? y : 0;
  19. };
  20. /**
  21. * Variable: x
  22. *
  23. * Holds the x-coordinate of the point. Default is 0.
  24. */
  25. mxPoint.prototype.x = null;
  26. /**
  27. * Variable: y
  28. *
  29. * Holds the y-coordinate of the point. Default is 0.
  30. */
  31. mxPoint.prototype.y = null;
  32. /**
  33. * Function: equals
  34. *
  35. * Returns true if the given object equals this point.
  36. */
  37. mxPoint.prototype.equals = function(obj)
  38. {
  39. return obj != null && obj.x == this.x && obj.y == this.y;
  40. };
  41. /**
  42. * Function: clone
  43. *
  44. * Returns a clone of this <mxPoint>.
  45. */
  46. mxPoint.prototype.clone = function()
  47. {
  48. // Handles subclasses as well
  49. return mxUtils.clone(this);
  50. };
  51. __mxOutput.mxPoint = typeof mxPoint !== 'undefined' ? mxPoint : undefined;