mxGraphAbstractHierarchyCell.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. * Copyright (c) 2006-2015, Gaudenz Alder
  4. */
  5. /**
  6. * Class: mxGraphAbstractHierarchyCell
  7. *
  8. * An abstraction of an internal hierarchy node or edge
  9. *
  10. * Constructor: mxGraphAbstractHierarchyCell
  11. *
  12. * Constructs a new hierarchical layout algorithm.
  13. */
  14. function mxGraphAbstractHierarchyCell()
  15. {
  16. this.x = [];
  17. this.y = [];
  18. this.temp = [];
  19. };
  20. /**
  21. * Variable: maxRank
  22. *
  23. * The maximum rank this cell occupies. Default is -1.
  24. */
  25. mxGraphAbstractHierarchyCell.prototype.maxRank = -1;
  26. /**
  27. * Variable: minRank
  28. *
  29. * The minimum rank this cell occupies. Default is -1.
  30. */
  31. mxGraphAbstractHierarchyCell.prototype.minRank = -1;
  32. /**
  33. * Variable: x
  34. *
  35. * The x position of this cell for each layer it occupies
  36. */
  37. mxGraphAbstractHierarchyCell.prototype.x = null;
  38. /**
  39. * Variable: y
  40. *
  41. * The y position of this cell for each layer it occupies
  42. */
  43. mxGraphAbstractHierarchyCell.prototype.y = null;
  44. /**
  45. * Variable: width
  46. *
  47. * The width of this cell. Default is 0.
  48. */
  49. mxGraphAbstractHierarchyCell.prototype.width = 0;
  50. /**
  51. * Variable: height
  52. *
  53. * The height of this cell. Default is 0.
  54. */
  55. mxGraphAbstractHierarchyCell.prototype.height = 0;
  56. /**
  57. * Variable: nextLayerConnectedCells
  58. *
  59. * A cached version of the cells this cell connects to on the next layer up
  60. */
  61. mxGraphAbstractHierarchyCell.prototype.nextLayerConnectedCells = null;
  62. /**
  63. * Variable: previousLayerConnectedCells
  64. *
  65. * A cached version of the cells this cell connects to on the next layer down
  66. */
  67. mxGraphAbstractHierarchyCell.prototype.previousLayerConnectedCells = null;
  68. /**
  69. * Variable: temp
  70. *
  71. * Temporary variable for general use. Generally, try to avoid
  72. * carrying information between stages. Currently, the longest
  73. * path layering sets temp to the rank position in fixRanks()
  74. * and the crossing reduction uses this. This meant temp couldn't
  75. * be used for hashing the nodes in the model dfs and so hashCode
  76. * was created
  77. */
  78. mxGraphAbstractHierarchyCell.prototype.temp = null;
  79. /**
  80. * Function: getNextLayerConnectedCells
  81. *
  82. * Returns the cells this cell connects to on the next layer up
  83. */
  84. mxGraphAbstractHierarchyCell.prototype.getNextLayerConnectedCells = function(layer)
  85. {
  86. return null;
  87. };
  88. /**
  89. * Function: getPreviousLayerConnectedCells
  90. *
  91. * Returns the cells this cell connects to on the next layer down
  92. */
  93. mxGraphAbstractHierarchyCell.prototype.getPreviousLayerConnectedCells = function(layer)
  94. {
  95. return null;
  96. };
  97. /**
  98. * Function: isEdge
  99. *
  100. * Returns whether or not this cell is an edge
  101. */
  102. mxGraphAbstractHierarchyCell.prototype.isEdge = function()
  103. {
  104. return false;
  105. };
  106. /**
  107. * Function: isVertex
  108. *
  109. * Returns whether or not this cell is a node
  110. */
  111. mxGraphAbstractHierarchyCell.prototype.isVertex = function()
  112. {
  113. return false;
  114. };
  115. /**
  116. * Function: getGeneralPurposeVariable
  117. *
  118. * Gets the value of temp for the specified layer
  119. */
  120. mxGraphAbstractHierarchyCell.prototype.getGeneralPurposeVariable = function(layer)
  121. {
  122. return null;
  123. };
  124. /**
  125. * Function: setGeneralPurposeVariable
  126. *
  127. * Set the value of temp for the specified layer
  128. */
  129. mxGraphAbstractHierarchyCell.prototype.setGeneralPurposeVariable = function(layer, value)
  130. {
  131. return null;
  132. };
  133. /**
  134. * Function: setX
  135. *
  136. * Set the value of x for the specified layer
  137. */
  138. mxGraphAbstractHierarchyCell.prototype.setX = function(layer, value)
  139. {
  140. if (this.isVertex())
  141. {
  142. this.x[0] = value;
  143. }
  144. else if (this.isEdge())
  145. {
  146. this.x[layer - this.minRank - 1] = value;
  147. }
  148. };
  149. /**
  150. * Function: getX
  151. *
  152. * Gets the value of x on the specified layer
  153. */
  154. mxGraphAbstractHierarchyCell.prototype.getX = function(layer)
  155. {
  156. if (this.isVertex())
  157. {
  158. return this.x[0];
  159. }
  160. else if (this.isEdge())
  161. {
  162. return this.x[layer - this.minRank - 1];
  163. }
  164. return 0.0;
  165. };
  166. /**
  167. * Function: setY
  168. *
  169. * Set the value of y for the specified layer
  170. */
  171. mxGraphAbstractHierarchyCell.prototype.setY = function(layer, value)
  172. {
  173. if (this.isVertex())
  174. {
  175. this.y[0] = value;
  176. }
  177. else if (this.isEdge())
  178. {
  179. this.y[layer -this. minRank - 1] = value;
  180. }
  181. };