'From Squeak3.0 of 4 February 2001 [latest update: #3545] on 23 February 2002 at 10:35:01 pm'! Object subclass: #LogPlotter instanceVariableNames: 'name data form canvas ' classVariableNames: '' poolDictionaries: '' category: 'Ward-Plotting'! !LogPlotter commentStamp: 'ward 2/23/2002 17:23' prior: 0! Plot SerializationThroughput datasets read from text files as gif images. (c) 2002, Ward Cunningham ! !LogPlotter methodsFor: 'input/output' stamp: 'ward 2/23/2002 17:11'! display form display! ! !LogPlotter methodsFor: 'input/output' stamp: 'ward 2/23/2002 17:10'! read | in out | in _ CrLfFileStream readOnlyFileNamed: name. out _ WriteStream on: Array new. [in atEnd] whileFalse: [out nextPut: (#(tab tab tab tab cr) collect: [:each | in upTo: (Character perform: each)])]. data _ out contents ! ! !LogPlotter methodsFor: 'input/output' stamp: 'ward 2/23/2002 17:19'! save GIFReadWriter putForm: form onFileNamed: self imageName! ! !LogPlotter methodsFor: 'plotting' stamp: 'ward 2/23/2002 17:36'! axis | a b label | label _ self displayText: self runName. label align: label boundingBox bottomCenter with: self area topCenter. label displayOn: form. self xTics do: [:each | a _ self scale: (each @ self yTics first). b _ self scale: (each @ self yTics last). canvas line: a to: b width: 1 color: self gray. label _ self label: each. label align: label boundingBox topCenter with: a. label displayOn: form]. self yTics do: [:each | a _ self scale: (self xTics first @ each). b _ self scale: (self xTics last @ each). canvas line: a to: b width: 1 color: self gray. label _ self label: each. label align: label boundingBox rightCenter with: -4@0 + a. label displayOn: form]. form border: self area width: 1. ! ! !LogPlotter methodsFor: 'plotting' stamp: 'ward 2/23/2002 20:34'! line: columnNumber color: aColor | xData yData to from dot transparentColor label | dot _ Form dotOfSize: 5. xData _ self sequence: 1. yData _ self sequence: columnNumber. transparentColor _ aColor alpha: 0.2. from _ nil. xData with: yData do: [:x :y | to _ self scale: x log @ y log. from notNil ifTrue: [canvas line: from to: to width: 3 color: transparentColor]. form fillShape: dot fillColor: aColor at: to. from _ to.]. label _ self displayText: (self title: columnNumber). to _ 2 @ columnNumber * label height + self area origin. canvas line: -10@0+to to: 10@0+to width: 3 color: transparentColor. form fillShape: dot fillColor: aColor at: to. label align: label boundingBox leftCenter with: 20@0 + to. label displayOn: form.! ! !LogPlotter methodsFor: 'plotting' stamp: 'ward 2/23/2002 20:37'! plot form _ Form extent: 640@480 depth: 16. canvas _ form getCanvas. canvas fillColor: Color white. self axis. self line: 3 color: Color red. self line: 4 color: Color green. self line: 5 color: Color brown. ! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 20:24'! area "plotting area" ^form boundingBox insetBy: (55@20 corner: 20@20) ! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 16:42'! displayText: aString | displayText | displayText _ aString asDisplayText. displayText foregroundColor: Color gray backgroundColor: Color white. ^displayText! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 14:52'! gray | gray | gray _ 0.8. ^Color r: gray g: gray b: gray! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 17:19'! imageName ^(name allButLast: 3), 'gif'! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 16:43'! label: anInteger | value | value _ (anInteger >= 0) ifTrue: [10 raisedToInteger: anInteger] ifFalse: [(10 raisedToInteger: anInteger) asFloat]. ^self displayText: value asString! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 17:59'! runName | tokens | tokens _ (name findTokens: '\') last: 2. ^(tokens first, ' -- ', tokens last) allButLast: 4! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 14:44'! scale: aPoint | scale | "linear to area" scale _ (self area width - 1 / (self xTics last - self xTics first )) @ (self area height - 1 / (self yTics last - self yTics first)). ^(aPoint x - self xTics first * scale x + self area origin x) floor @ (self area corner y - (aPoint y - self yTics first * scale y) - 1) floor! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 16:16'! sequence: columnNumber ^data allButFirst collect: [:each | Number readFrom: (each at: columnNumber)]! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 17:05'! setName: aString name _ aString. ! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 16:03'! title: columnNumber ^data first at: columnNumber! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 14:48'! xTics ^0 to: 5! ! !LogPlotter methodsFor: 'support' stamp: 'ward 2/23/2002 20:03'! yTics ^-3 to: 7! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! LogPlotter class instanceVariableNames: ''! !LogPlotter class methodsFor: 'processing' stamp: 'ward 2/23/2002 17:07'! on: aString ^self new setName: aString! ! !LogPlotter class methodsFor: 'processing' stamp: 'ward 2/23/2002 20:33'! processDirectory: aString | aDirectory | "self processDirectory: 'C:\My Documents\Squeak\TestData'" "self processDirectory: '\\C2\ward\web\doc\SerializationThroughput\contrib\data'" aDirectory _ FileDirectory on: aString. (aDirectory fileNamesMatching: '*.txt') do: [:each | each ~= 'email.txt' ifTrue: [self processFile: (aDirectory fullNameFor: each)]]. aDirectory directoryNames do: [:each | self processDirectory: (aDirectory fullNameFor: each)]. ! ! !LogPlotter class methodsFor: 'processing' stamp: 'ward 2/23/2002 18:16'! processFile: aString "self processFile: 'TestData\bk.txt'" (self on: aString) read; plot; display; save! !