pharo-graphics / Roassal

The Roassal Visualization Engine
MIT License
14 stars 8 forks source link

RSTreeMap does not computes the area correctly #16

Closed akevalion closed 8 months ago

akevalion commented 8 months ago

Consider

    | b labels |
    b := RSTreeMap new.
    labels := (1 to: 100) collect: #asString.
    b boxShape color: Color veryLightGray.
    b from: labels using: [ #() ].
    b modelWeight: [ :n | n size ].
    b build.
    b shapes @ (RSLabeled new
        in: [ :lbl | lbl location middle ];
        yourself).
    ^ b canvas

image

akevalion commented 8 months ago

The problem is that extent: and extent does not work like the same. Dirty rectangles changes the way to compute the base rectangle for bounding shapes with borders, then extent: should do the same consider

box := RSBox new.
box borderWidth: 10.
box extent: 50@50. "now the extent of the box with the border should be 50@50."
box extent: 0@0. "The extent now is 10@10"

Now this is fixed

| b labels |
b := RSTreeMap new.
b boxShape 
    @ RSDraggable;
    @ (RSLabeled new
    in: [ :lbl | lbl location middle ];
    yourself).

labels := (1 to: 100) collect: #asString.
b boxShape color: Color veryLightGray.
b from: labels using: [ #() ].
b modelWeight: [ :n | n size ].
b build.

^ b canvas
image

Note: the treemap works better with b boxShape noBorder.

image
...
b build.
b shapes do: [ :s | s borderColor: Color black ].
^ b canvas
image