buildview - histogram

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

buildview - histogram

Günther Schmidt
Ian,

in your buildview tutorial - the histogram view, you draw bars for each
association on a canvas.

Would it be possible to use a different approach, by creating each bar
as a single view for a single model (the association)?.

In other words, the bar being a single view (or a real graphical object)
that wouldn't have to reverse engeneer if it's been clicked at and which
model it is associated with?

Günther


Reply | Threaded
Open this post in threaded view
|

Re: buildview - histogram

Ian Bartholomew-19
Günther,

> Would it be possible to use a different approach, by creating each bar as
> a single view for a single model (the association)?.

Yes, but if I wanted to do that then I probably wouldn't do it the same way.
It would be easier just adding the columns (instances of a new ContainerView
subclass) as subviews in the Shell view. Something like the following crude
example (save as a pac file, load into an image and evaluate TextPresenter
show).

~-~-~-~-~- snip here

| package |

package := Package name: 'test'.

package paxVersion: 0;

basicComment: ''.



package classNames

add: #TestColumnView;

add: #TestPresenter;

yourself.

package binaryGlobalNames: (Set new

yourself).

package globalAliases: (Set new

yourself).

package allResourceNames: (Set new

add: #TestPresenter -> 'Default view';

yourself).

package setPrerequisites: (IdentitySet new

add: 'Object Arts\Dolphin\Base\Dolphin';

add: 'Object Arts\Dolphin\MVP\Base\Dolphin MVP Base';

yourself).

package!

"Class Definitions"!

Shell subclass: #TestPresenter

instanceVariableNames: ''

classVariableNames: ''

poolDictionaries: ''

classInstanceVariableNames: ''!

ContainerView subclass: #TestColumnView

instanceVariableNames: 'index'

classVariableNames: ''

poolDictionaries: ''

classInstanceVariableNames: ''!

"Global Aliases"!



"Loose Methods"!

"End of package definition"!

"Source Globals"!

"Classes"!

TestPresenter guid: (GUID fromString:
'{B81CD764-ED18-48DA-BAAC-F25AD899A596}')!

TestPresenter comment: ''!

!TestPresenter categoriesForClass!MVP-Presenters! !

!TestPresenter methodsFor!

onColumnSelected: anInteger

MessageBox notify: anInteger printString!

onViewOpened

| r |

super onViewOpened.

r := Random new.

1

to: 10

do:

[:index |

| cv h |

self view addSubView: (cv := TestColumnView index: index).

cv hasBorder: true.

h := (r next * 200) truncated.

cv

position: (index * 20) @ (self view clientHeight - h);

extent: 20 @ h.

cv

when: #selected:

send: #onColumnSelected:

to: self]! !

!TestPresenter categoriesFor: #onColumnSelected:!public! !

!TestPresenter categoriesFor: #onViewOpened!public! !

TestColumnView guid: (GUID fromString:
'{DB555C4A-E226-4308-8E1E-A5514B846869}')!

TestColumnView comment: ''!

!TestColumnView categoriesForClass!MVP-Views! !

!TestColumnView methodsFor!

index

^index!

index: anObject

index := anObject!

onLeftButtonPressed: aMouseEvent

self trigger: #selected: with: index.

^super onLeftButtonPressed: aMouseEvent! !

!TestColumnView categoriesFor: #index!accessing!private! !

!TestColumnView categoriesFor: #index:!accessing!private! !

!TestColumnView categoriesFor: #onLeftButtonPressed:!public! !

!TestColumnView class methodsFor!

index: anInteger

^self new index: anInteger! !

!TestColumnView class categoriesFor: #index:!public! !

"Binary Globals"!

"Resources"!

(ResourceIdentifier class: TestPresenter name: 'Default view') assign:
(Object fromBinaryStoreBytes:

(ByteArray fromBase64String:
'IVNUQiAxIEYCDAABAAAAVmlld1Jlc291cmNlAAAAAA4BJABTVEJSZXNvdXJjZVNUQkJ5dGVBcnJh

eUFjY2Vzc29yUHJveHkAAAAAcgAAABICAAAhU1RCIDEgTggMAAoAAABTVEJWaWV3UHJveHkAAAAA

mgAAAAAAAABSAAAAEAAAAERvbHBoaW4gTVZQIEJhc2VSAAAACQAAAFNoZWxsVmlld2IAAAAbAAAA

AAAAAAAAAABiAAAAAgAAAAEAngEBAAIAoAEAAAAAAAAAAAAAAAAAAAcCAAAAAAAAAAAAAAAAAACg

AQAAAAAAAOoAAAAAAAAAAAEAAGIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAA

AAAAAAAAAAAAAAEAAAAAAAAAAAAAAAYBDwBNZXNzYWdlU2VxdWVuY2UAAAAAygAAAAAAAADQAAAA

YgAAAAIAAAAGAwsATWVzc2FnZVNlbmQAAAAAugAAAAAAAABSAAAAEAAAAGNyZWF0ZUF0OmV4dGVu

dDpiAAAAAgAAAAYCBQBQb2ludAAAAAALAAAACwAAALICAAAAAAAATQMAALsCAACgAQAAYgIAAAAA

AAC6AAAAAAAAAFIAAAAIAAAAbWVudUJhcjpiAAAAAQAAAAAAAACgAQAABgEPAFdJTkRPV1BMQUNF

TUVOVAAAAAByAAAALAAAACwAAAAAAAAAAAAAAP////////////////////8FAAAABQAAAKsBAABi

AQAAygAAAAAAAADQAAAAEAIAALICAAAAAAAAwQAAAMEAAAAAAAAAFQAAAEYFBAADAAAASWNvbgAA

AAAAAAAAEAAAAA4CEQBTVEJTaW5nbGV0b25Qcm94eQAAAACaAAAAAAAAAFIAAAAHAAAARG9scGhp

blIAAAAYAAAASW1hZ2VSZWxhdGl2ZUZpbGVMb2NhdG9yugAAAAAAAABSAAAABwAAAGN1cnJlbnRS

AAAADQAAAFNoZWxsVmlldy5pY28OAh8AU1RCRXh0ZXJuYWxSZXNvdXJjZUxpYnJhcnlQcm94eQAA

AABSAAAAEAAAAGRvbHBoaW5kcjAwNS5kbGwAAAAA'))!


~-~-~-~-~- snip here

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: buildview - histogram

Schwab,Wilhelm K
In reply to this post by Günther Schmidt
Günther,

> in your buildview tutorial - the histogram view, you draw bars for each
> association on a canvas.
>
> Would it be possible to use a different approach, by creating each bar
> as a single view for a single model (the association)?.
>
> In other words, the bar being a single view (or a real graphical object)
> that wouldn't have to reverse engeneer if it's been clicked at and which
> model it is associated with?

Note that there are disadvantages too.  What does the view mean to you
should you decide to render on a printer?  What happens if you have a
very large data set?  Having tried all of this in various ways, I am
generally happiest when I use a "neutral object" (it can be the model or
a separate renderer/visitor) to draw to an arbitrary canvas and use that
same object for scaling to interpret events.  Just my 2 asCents.

Have a good one,

Bill


--
Wilhelm K. Schwab, Ph.D.
[hidden email]