Roassal3
Roassal3 copied to clipboard
RSDSM should offer a way to easily customize the color of any cell
For example a block [:x :y | ... color of cell at X/Y ]
Hi, please consider
| dsm v keys palette |
v := Dictionary new
at: #A put: #(B C);
at: #B put: #(A C);
at: #C put: #(A);
yourself.
keys := #(9 A B C D).
dsm := RSDSMStronglyConnected new.
dsm objects: keys.
dsm setShouldFeedY.
dsm dependency: [ :k | v at: k ifAbsent: #() ].
dsm build.
palette := NSScale category10.
dsm shapes
reject: [ :shape | shape color = dsm selectedColor ]
thenDo: [ :shape | | association |
association := shape model.
shape color: (palette scale: association key) translucent. ].
dsm canvas

DSM currently uses 2 colors. selectedColor is used when there is a dependency between x and y objects. unSelectedColor is used when there is no dependency between them.
Users can modify the colors after the building process.
Maybe you will need a new DSM class, like
| dsm bag keys palette |
map := Dictionary new
at: #A put: #(B C B) asBag;
at: #B put: #(A C) asBag;
at: #C put: #(A) asBag;
yourself.
keys := #(9 A B C D).
dsm := RSScoredDSM new.
dsm objects: keys.
dsm setShouldFeedY.
dsm highScoreColor: Color red.
dsm lowScoreColor: Color veryVeryLightGray.
dsm score: [ :k :v | (map at: k) occurrencesOf: v ].
dsm
The idea is that you can change the change the default colors. And with the highest score is going the be red and 0 is going to be lowest score.
done