Ben Coman wrote:
My question was less about compositing and more about
ROCircleLayout, so I've
split my response into two posts.
I think the main problem I had was that the ROCircleLayout was determining its
radius based only on the number of elements and not the size of the elements. So
I've come up with a different approach - not quite finished but thought I'd
share it now for some feedback. Using the same example from my original post.
Existing ROCircleLayout>>doExecute resulting in [1] is due to this...
radius := elements size * self scaleFactor.
(btw could you change rad to radius anyway - for a while it confused be thinking
this was a variable about radians)
I found changing to the following gave a better result [2]
targetCircumference := 0.
elements do: [ :el | targetCircumference := targetCircumference + el bounds
extent r ].
radius := targetCircumference / 2 / Float pi.
However using 3 or 2 instead of 10 in the third line of that example still has
overlaps [3] [4], so I was wondering what your thoughts were. Perhaps a fudge
factor at those lower element counts. Also, probably this only works for
elements that have the same bounds. With a mix of small and large elements some
will probably still overlap - so I am thinking next of a more dynamic circle -
that evens out the space between nodes and grows or shrinks the circumference as
needed - leading into a force based one, that shifts connected elements around
the circle to be closer to more connected elements.
cheers -ben
[1] ROCircleLayout-original-10nodes.png
[2] ROCircleLayout-sumCircumference-10nodes.png
[3] ROCircleLayout-sumCircumference-3nodes.png
[4] ROCircleLayout-sumCircumference-2nodes.png
Alexandre Bergel wrote:
Hi Ben,
Currently no. We definitely need a better way to specific layouts and their composition.
However this will take time before we have this.
How would you like to specific the layout?
Cheers,
Alexandre
On Aug 30, 2012, at 6:10 PM, Ben Coman <btc(a)openInWorld.com> wrote:
I have been looking at the ROExample
"Nesting" examples and expanded #nesting2 with another level as shown in the
code below, such that there is the outer view, middle "#1" nodes and inner
"#2" nodes. However the initial state of this has much of the middle node1 and
inner node2 nodes overlapping.
How can these be made for the circle layout to leave spacing between the middle node1
nodes?
cheers -ben
--------------------
| view nodes1 |
view := ROView new.
view add: (ROElement sprite addAll: (nodes1 := ROElement spritesOn: (1 to: 10))).
nodes1 do: [:n | n addShape: ROLabel].
nodes1 do:
[ :node1 |
( (node1 model) *100+1 to: (node1 model)*100+5 ) do:
[ :x |
node1 add: ( (ROElement spriteOn: x) addShape: ROLabel).
].
ROGridLayout on: node1 elements.
].
ROCircleLayout on: nodes1.
view openInWindow.
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
I have been working on a new ROCircleLayout so that it is self sizing to
maintain equal space between elements. This is a bit difficult for
elements with a big different in their size in each axis, since even
when neighbouring elements are well spaced, the seconds on over can
still clash (see existing-circle-layout.png).
To address this, my thinking is to selecting the element corner closest
to the center to be pinned to the circle layout (see
new-circle-layout.png). I wanted to share this concept with you early
for your feedback. See attached changeset and these methods:
ROCircleLayout>>
ROExample>>newCircleLayout
ROExample>>existingCircleLayout.
cheers, ben
[previous image attachments deleted]
p.s. I saw your response to my other post. Looks interesting but its
sleep time now so I will digest further tomorrow.
'From Pharo1.4 of 18 April 2012 [Latest update: #14457] on 7 September 2012 at 2:15:13
am'!
!ROCircleLayout methodsFor: 'hook' stamp: 'BenComan 9/7/2012 01:45'!
cornerOf: element nearestCenterForAngle: angle
"For a rectangle placed 'angle' radians from a center point, return the
corner closest to the centre"
(angle sin) < 0
ifTrue:
[
(angle cos) > 0
ifTrue:
[ "top right quadrant, bottom left corner"
^ 0 @ element extent y negated.
]
ifFalse:
[ "top left quadrant, bottom right corner"
^ element extent x negated @ element extent y negated.
]
]
ifFalse:
[
(angle cos) > 0
ifTrue:
[ "bottom right quadrant, top left corner"
^ 0 @ 0.
]
ifFalse:
[ "bottom left quadrant, top right corner"
^ element extent x negated @ 0.
]
]
! !
!ROExample methodsFor: 'layouts' stamp: 'BenComan 9/7/2012 01:59'!
existingCircleLayout
"self new existingCircleLayout"
"For comparison to >>newCircleLayout"
| radius view parentNode circle center el translator |
view := ROView new.
(Array with: 300@50 with:50@300 ) do:
[ :testExtent |
parentNode := (ROElement spriteOn: 'EXAMPLE NEW CIRCLE LAYOUT WITH EXTREME
SIZES', testExtent asString) + ROLabel.
view add: parentNode.
#( -0.1 0.1 1.9 2.1 3.9 4.1 5.9 6.1 ) do:
[ :n |
el := (ROElement spriteOn: n) extent: testExtent.
parentNode add: el.
].
(ROCircleLayout new scaleBy: 20) on: parentNode elements.
].
ROGridLayout on: view elements .
view openInWindow.! !
!ROExample methodsFor: 'layouts' stamp: 'BenComan 9/7/2012 01:54'!
newCircleLayout
"self new newCircleLayout"
"Concept still under development. Just demonstrating for discussion and testing
ROCircleLayout>>cornerOf nearestCenterForAngle:"
| radius view parentNode circle center el translator |
radius := 70.
translator := ROLayoutTranslator default.
view := ROView new.
(Array with: 300@50 with:50@300 ) do:
[ :testExtent |
parentNode := (ROElement spriteOn: 'EXAMPLE NEW CIRCLE LAYOUT WITH EXTREME
SIZES', testExtent asString) + ROLabel.
view add: parentNode.
circle := (ROCircle new elementOn: 'circle') .
circle size: (radius * 2).
center := circle bounds center.
parentNode add: circle.
#( -0.1 0.1 1.9 2.1 3.9 4.1 5.9 6.1 ) do:
[ :n | | angle |
angle := n * Float pi / 4.
el := (ROElement spriteOn: n) extent: testExtent.
translator translate: el to: (Point radius: radius theta: angle) + center +
(ROCircleLayout new cornerOf: el nearestCenterForAngle: angle).
parentNode add: el.
].
].
ROGridLayout on: view elements .
view openInWindow.! !