home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LANGUAGE / SMALTALK / TEXTBOOK / AP30.ST (.txt) < prev    next >
Text File  |  1997-04-22  |  3KB  |  124 lines

  1.  
  2. 'Smalltalk Textbook Appendix 30'!
  3.  
  4.  
  5.  
  6.  
  7.  
  8. EngiVertex subclass: #EngiClassVertex
  9.     instanceVariableNames: 'className classIcon '
  10.     classVariableNames: ''
  11.     poolDictionaries: ''
  12.     category: 'Engi-Inheritance'!
  13. EngiClassVertex comment:
  14. '
  15.  
  16. Engi 0.07 (24 March 1994)
  17. Copyright (C) 1994 by Atsushi Aoki
  18.  
  19. '!
  20.  
  21.  
  22. !EngiClassVertex methodsFor: 'accessing'!
  23.  
  24. className
  25.     ^className!
  26.  
  27. className: aSymbol 
  28.     className := aSymbol.
  29.     classIcon := (' ' , aSymbol asString , ' ') asComposedText.
  30.     classIcon gridWithLead: 0.
  31.     self vertexExtent: classIcon bounds extent! !
  32.  
  33. !EngiClassVertex methodsFor: 'bounds accessing'!
  34.  
  35. computeBounds
  36.     | bounds |
  37.     bounds := classIcon bounds.
  38.     bounds := bounds align: bounds origin with: self vertexPoint.
  39.     ^bounds! !
  40.  
  41. !EngiClassVertex methodsFor: 'displaying'!
  42.  
  43. displayFilledOn: graphicsContext at: aPoint 
  44.     | aRectangle |
  45.     self fillColor isNil ifFalse: [((self bounds translatedBy: aPoint)
  46.             intersects: graphicsContext clippingBounds)
  47.             ifTrue: 
  48.                 [aRectangle := self vertexPoint extent: self vertexExtent.
  49.                 aRectangle := (aRectangle translatedBy: aPoint) rounded.
  50.                 graphicsContext paint: self fillColor.
  51.                 graphicsContext lineWidth: self lineWidth.
  52.                 graphicsContext displayRectangle: aRectangle]]!
  53.  
  54. displayStrokedOn: graphicsContext at: aPoint 
  55.     | aRectangle |
  56.     self strokeColor isNil ifFalse: [((self bounds translatedBy: aPoint)
  57.             intersects: graphicsContext clippingBounds)
  58.             ifTrue: 
  59.                 [aRectangle := self vertexPoint extent: self vertexExtent.
  60.                 aRectangle := (aRectangle translatedBy: aPoint) rounded.
  61.                 graphicsContext paint: self strokeColor.
  62.                 graphicsContext lineWidth: self lineWidth.
  63.                 classIcon displayOn: graphicsContext at: aRectangle origin]]! !
  64.  
  65. !EngiClassVertex methodsFor: 'printing'!
  66.  
  67. printOn: aStream 
  68.     aStream nextPutAll: 'vertex('.
  69.     aStream nextPutAll: self className asString.
  70.     aStream nextPutAll: ')'! !
  71.  
  72.  
  73.  
  74.  
  75.  
  76. EngiBranch subclass: #EngiClassBranch
  77.     instanceVariableNames: ''
  78.     classVariableNames: ''
  79.     poolDictionaries: ''
  80.     category: 'Engi-Inheritance'!
  81. EngiClassBranch comment:
  82. '
  83.  
  84. Engi 0.07 (24 March 1994)
  85. Copyright (C) 1994 by Atsushi Aoki
  86.  
  87. '!
  88.  
  89.  
  90. !EngiClassBranch methodsFor: 'point accessing'!
  91.  
  92. endPoint
  93.     endVertex isNil ifTrue: [^Point zero].
  94.     ^endVertex bounds leftCenter!
  95.  
  96. startPoint
  97.     startVertex isNil ifTrue: [^Point zero].
  98.     ^startVertex bounds rightCenter! !
  99.  
  100. !EngiClassBranch methodsFor: 'displaying'!
  101.  
  102. displayStrokedOn: graphicsContext at: aPoint 
  103.     | startPoint endPoint centerPoint |
  104.     self strokeColor isNil ifFalse: [((self bounds translatedBy: aPoint)
  105.             intersects: graphicsContext clippingBounds)
  106.             ifTrue: 
  107.                 [startPoint := (self startPoint + aPoint) rounded.
  108.                 endPoint := (self endPoint + aPoint) rounded.
  109.                 graphicsContext paint: self strokeColor.
  110.                 graphicsContext lineWidth: self lineWidth.
  111.                 centerPoint := (startPoint + (endPoint - startPoint / 2)) rounded.
  112.                 graphicsContext displayLineFrom: startPoint to: centerPoint x @ startPoint y.
  113.                 graphicsContext displayLineFrom: centerPoint x @ startPoint y to: centerPoint x @ endPoint y.
  114.                 graphicsContext displayLineFrom: centerPoint x @ endPoint y to: endPoint]]! !
  115.  
  116. !EngiClassBranch methodsFor: 'printing'!
  117.  
  118. printOn: aStream 
  119.     aStream nextPutAll: 'branch('.
  120.     aStream nextPutAll: self startVertex className asString.
  121.     aStream nextPutAll: ','.
  122.     aStream nextPutAll: self endVertex className asString.
  123.     aStream nextPutAll: ')'! !
  124.