/framework/experimental/graphic/GraphicContext.php

http://zoop.googlecode.com/ · PHP · 165 lines · 23 code · 6 blank · 136 comment · 0 complexity · 69c062d1336d1defddd7531edcb9bded MD5 · raw file

  1. <?php
  2. abstract class GraphicContext
  3. {
  4. // general stuff
  5. protected $width;
  6. protected $height;
  7. /*
  8. // the font stuff
  9. var $textSize;
  10. var $textStyle;
  11. var $textFontName;
  12. // the color stuff
  13. var $colors;
  14. var $curLineColor;
  15. var $lineColorStack;
  16. var $curFillColor;
  17. var $curTextColor;
  18. */
  19. function __construct()
  20. {
  21. /*
  22. // the font stuff
  23. $this->textSize = 10;
  24. $this->textStyle = '';
  25. $this->textFontName = 'Arial';
  26. // the color stuff
  27. $this->colors = array();
  28. $this->addColor('black', 0, 0, 0);
  29. $this->addColor('gray', 128, 128, 128);
  30. $this->addColor('white', 255, 255, 255);
  31. $this->setCurLineColor('black');
  32. $this->setCurFillColor('gray');
  33. $this->setCurTextColor('black');
  34. $this->lineColorStack = array();
  35. */
  36. }
  37. public function init($size, $fontName, $fontSize)
  38. {
  39. trigger_error('pseudo virtual function called');
  40. }
  41. protected function assignSize($size)
  42. {
  43. $parts = explode(':', $size);
  44. $this->width = $parts[0];
  45. $this->height = $parts[1];
  46. }
  47. public function getWidth()
  48. {
  49. return $this->width;
  50. }
  51. /*
  52. // it just so happens these are always implemented the same way so far
  53. function setColor($name, $r, $g, $b)
  54. {
  55. $this->addColor($name, $r, $g, $b);
  56. }
  57. function getHeight()
  58. {
  59. return $this->height;
  60. }
  61. function getPageHeight()
  62. {
  63. return $this->getHeight();
  64. }
  65. function _getCurTextColor()
  66. {
  67. return $this->colors[$this->curTextColor];
  68. }
  69. function _getCurLineColor()
  70. {
  71. return $this->colors[$this->curLineColor];
  72. }
  73. function _getCurFillColor()
  74. {
  75. return $this->colors[$this->curFillColor];
  76. }
  77. function setCurLineColor($color)
  78. {
  79. $this->curLineColor = $color;
  80. }
  81. function setCurFillColor($color)
  82. {
  83. $this->curFillColor = $color;
  84. }
  85. function setCurTextColor($color)
  86. {
  87. $this->curTextColor = $color;
  88. }
  89. function pushLineColor($color)
  90. {
  91. array_push($this->lineColorStack, $this->curLineColor);
  92. $this->setCurLineColor($color);
  93. }
  94. function popLineColor()
  95. {
  96. // is this right? shouldn't we be setting it to what is on the top AFTER we pop the stack
  97. assert(count($this->lineColorStack) > 0);
  98. $this->setCurLineColor(array_pop($this->lineColorStack));
  99. }
  100. function getPageWidth()
  101. {
  102. return $this->width;
  103. }
  104. function getTextSize()
  105. {
  106. return $this->textSize;
  107. }
  108. function setTextSize($size)
  109. {
  110. $this->textSize = $size;
  111. }
  112. function getTextStyle()
  113. {
  114. return $this->textStyle;
  115. }
  116. function setTextStyle($style)
  117. {
  118. $this->textStyle = $style;
  119. }
  120. function getTextFontName()
  121. {
  122. return $this->textFontName;
  123. }
  124. function setTextFontName($font)
  125. {
  126. $this->textFontName = $font;
  127. }
  128. function useKerningHack()
  129. {
  130. return 0;
  131. }
  132. function getLineHeightMultiplier()
  133. {
  134. return 1;
  135. }
  136. */
  137. }