RelationStatsEps.class.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Contains Relation_Stats_Eps class
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. require_once 'libraries/plugins/schema/RelationStats.class.php';
  12. /**
  13. * Relation preferences/statistics
  14. *
  15. * This class fetches the table master and foreign fields positions
  16. * and helps in generating the Table references and then connects
  17. * master table's master field to foreign table's foreign key
  18. * in EPS document.
  19. *
  20. * @package PhpMyAdmin
  21. * @name Relation_Stats_Eps
  22. * @see PMA_EPS
  23. */
  24. class Relation_Stats_Eps extends RelationStats
  25. {
  26. /**
  27. * The "Relation_Stats_Eps" constructor
  28. *
  29. * @param object $diagram The EPS diagram
  30. * @param string $master_table The master table name
  31. * @param string $master_field The relation field in the master table
  32. * @param string $foreign_table The foreign table name
  33. * @param string $foreign_field The relation field in the foreign table
  34. */
  35. public function __construct(
  36. $diagram, $master_table, $master_field, $foreign_table, $foreign_field
  37. ) {
  38. $this->wTick = 10;
  39. parent::__construct(
  40. $diagram, $master_table, $master_field, $foreign_table, $foreign_field
  41. );
  42. $this->ySrc += 10;
  43. $this->yDest += 10;
  44. }
  45. /**
  46. * draws relation links and arrows
  47. * shows foreign key relations
  48. *
  49. * @param boolean $showColor Whether to use one color per relation or not
  50. *
  51. * @see PMA_EPS
  52. *
  53. * @return void
  54. */
  55. public function relationDraw($showColor)
  56. {
  57. /* Commented because $color unused.
  58. if ($showColor) {
  59. $listOfColors = array(
  60. 'red',
  61. 'grey',
  62. 'black',
  63. 'yellow',
  64. 'green',
  65. 'cyan',
  66. 'orange'
  67. );
  68. shuffle($listOfColors);
  69. $color = $listOfColors[0];
  70. } else {
  71. $color = 'black';
  72. }*/
  73. // draw a line like -- to foreign field
  74. $this->diagram->line(
  75. $this->xSrc,
  76. $this->ySrc,
  77. $this->xSrc + $this->srcDir * $this->wTick,
  78. $this->ySrc,
  79. 1
  80. );
  81. // draw a line like -- to master field
  82. $this->diagram->line(
  83. $this->xDest + $this->destDir * $this->wTick,
  84. $this->yDest,
  85. $this->xDest,
  86. $this->yDest,
  87. 1
  88. );
  89. // draw a line that connects to master field line and foreign field line
  90. $this->diagram->line(
  91. $this->xSrc + $this->srcDir * $this->wTick,
  92. $this->ySrc,
  93. $this->xDest + $this->destDir * $this->wTick,
  94. $this->yDest,
  95. 1
  96. );
  97. $root2 = 2 * sqrt(2);
  98. $this->diagram->line(
  99. $this->xSrc + $this->srcDir * $this->wTick * 0.75,
  100. $this->ySrc,
  101. $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
  102. $this->ySrc + $this->wTick / $root2,
  103. 1
  104. );
  105. $this->diagram->line(
  106. $this->xSrc + $this->srcDir * $this->wTick * 0.75,
  107. $this->ySrc,
  108. $this->xSrc + $this->srcDir * (0.75 - 1 / $root2) * $this->wTick,
  109. $this->ySrc - $this->wTick / $root2,
  110. 1
  111. );
  112. $this->diagram->line(
  113. $this->xDest + $this->destDir * $this->wTick / 2,
  114. $this->yDest,
  115. $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
  116. $this->yDest + $this->wTick / $root2,
  117. 1
  118. );
  119. $this->diagram->line(
  120. $this->xDest + $this->destDir * $this->wTick / 2,
  121. $this->yDest,
  122. $this->xDest + $this->destDir * (0.5 + 1 / $root2) * $this->wTick,
  123. $this->yDest - $this->wTick / $root2,
  124. 1
  125. );
  126. }
  127. }