ScalableContentPane suggestions

24 views
Skip to first unread message

Tomáš Mikula

unread,
Aug 13, 2014, 8:27:37 AM8/13/14
to jfxtr...@googlegroups.com
Hi,

I needed a ScalableContentPane, but I ended up rolling my own implementation, for the following reasons. You can take them as suggestions.

1. I don't see a reason why content should be a Pane instead of arbitrary Node (as for example ScrollPane's content).
2. ScalableContentPane should subclass Region (just like ScrollPane does), not Pane. Pane exposes modifiable list of children (getChildren()), but modifying it directly doesn't make sense for ScalableContentPane.
3. A convenient constructor that takes the content node would be nice (just like ScrollPane has one).

Some more comments:

4. Isn't autoRescale the only meaningful mode?
5. Similarly, is limiting the scaling factor (minScale/maxScale) any useful? computeMinWidth/computeMinHeight do not honor minScale anyway.
6. What about centering the content when keeping aspect ratio?

Here is my implementation that incorporates all of the above.

Regards,
Tomas

Michael Hoffer

unread,
Aug 13, 2014, 9:16:59 AM8/13/14
to jfxtr...@googlegroups.com
Hi Tomas,

thanks for your suggestions. 

1. I don't see a reason why content should be a Pane instead of arbitrary Node (as for example ScrollPane's content).
2. ScalableContentPane should subclass Region (just like ScrollPane does), not Pane. Pane exposes modifiable list of children (getChildren()), but modifying it directly doesn't make sense for ScalableContentPane.
3. A convenient constructor that takes the content node would be nice (just like ScrollPane has one).
 
True. Region makes indeed more sense for the parent. We should probably also support plain nodes as content.

4. Isn't autoRescale the only meaningful mode?
 
No.  the autoscale feature can be disturbing for MDI based applications. If you move content around and everything scales immediately you can run into serious performance problems.
 
5. Similarly, is limiting the scaling factor (minScale/maxScale) any useful? computeMinWidth/computeMinHeight do not honor minScale anyway.
 
Yes. The min-/max-/auto scale are used very often, e.g. for VWorkflows (https://github.com/miho/VWorkflows). Usually you don't want to make content as big as possible. Think of internal windows with giant buttons etc. Therefore we added optional limits.

6. What about centering the content when keeping aspect ratio?

Good idea.

Out of curiosity, what kind of content do you scale?

Regards,
Michael

Tomas Mikula

unread,
Aug 13, 2014, 10:47:41 AM8/13/14
to jfxtr...@googlegroups.com
Hi Michael,

On Wed, Aug 13, 2014 at 3:16 PM, Michael Hoffer <michi...@gmail.com> wrote:
> Hi Tomas,
>
> thanks for your suggestions.
>
>> 1. I don't see a reason why content should be a Pane instead of arbitrary
>> Node (as for example ScrollPane's content).
>> 2. ScalableContentPane should subclass Region (just like ScrollPane does),
>> not Pane. Pane exposes modifiable list of children (getChildren()), but
>> modifying it directly doesn't make sense for ScalableContentPane.
>> 3. A convenient constructor that takes the content node would be nice
>> (just like ScrollPane has one).
>
>
> True. Region makes indeed more sense for the parent. We should probably also
> support plain nodes as content.
>
>> 4. Isn't autoRescale the only meaningful mode?
>
>
> No. the autoscale feature can be disturbing for MDI based applications. If
> you move content around and everything scales immediately you can run into
> serious performance problems.

OK, makes sense.

>
>>
>> 5. Similarly, is limiting the scaling factor (minScale/maxScale) any
>> useful? computeMinWidth/computeMinHeight do not honor minScale anyway.
>
>
> Yes. The min-/max-/auto scale are used very often, e.g. for VWorkflows
> (https://github.com/miho/VWorkflows). Usually you don't want to make content
> as big as possible. Think of internal windows with giant buttons etc.
> Therefore we added optional limits.
>
>> 6. What about centering the content when keeping aspect ratio?
>
>
> Good idea.
>
> Out of curiosity, what kind of content do you scale?

I scale diagrams, i.e. shapes, as in this screenshot:
https://bytebucket.org/TomasMikula/kappaide/wiki/kappa-ide.png

Regards,
Tomas

>
> Regards,
> Michael
>
> Am Mittwoch, 13. August 2014 14:27:37 UTC+2 schrieb Tomáš Mikula:
>>
>> Hi,
>>
>> I needed a ScalableContentPane, but I ended up rolling my own
>> implementation, for the following reasons. You can take them as suggestions.
>>
>> 1. I don't see a reason why content should be a Pane instead of arbitrary
>> Node (as for example ScrollPane's content).
>> 2. ScalableContentPane should subclass Region (just like ScrollPane does),
>> not Pane. Pane exposes modifiable list of children (getChildren()), but
>> modifying it directly doesn't make sense for ScalableContentPane.
>> 3. A convenient constructor that takes the content node would be nice
>> (just like ScrollPane has one).
>>
>> Some more comments:
>>
>> 4. Isn't autoRescale the only meaningful mode?
>> 5. Similarly, is limiting the scaling factor (minScale/maxScale) any
>> useful? computeMinWidth/computeMinHeight do not honor minScale anyway.
>> 6. What about centering the content when keeping aspect ratio?
>>
>> Here is my implementation that incorporates all of the above.
>>
>> https://bitbucket.org/TomasMikula/kappaide/src/8dd36baf395c45fc132a62cb05c486ad162aab65/src/main/java/kappa/ide/util/ScalableContentPane.java
>>
>> Regards,
>> Tomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "JFXtras Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jfxtras-dev...@googlegroups.com.
> To post to this group, send email to jfxtr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/jfxtras-dev.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages