AutoSized elements – possible to always do an auto size if Width and Height = -1 (for generated files)

5 answers

That seems to regard “auto size” as an attribute of the element.

Currently the “auto size” is a command but not an attribute of the element, not all the elements can perform the “auto size” command.

Do you think the element needs an “auto size” attribute?


If I was doing it, I’d have a check for height and width = -1, adding an autosize attrib seems unnecessary as you recalc the size of the element when the content is changed anyway. So there is no need to persist an autosize setting..

Either way will do the job, just means one less node to check/generate.
It’s just a hack for a file generated outside the gui of course..



Actually I think the “auto size” attribute is not needed, no matter which way it is implemented. I can not imagine the case that user need an element with “auto adjusted” size. I think user need the element as big as they specify it.

On the other hand, we defined the minimun size of each element, to avoid having too small elements in the plot (that will be a nightmare, isn’t it?), so we can not consider the -1 size.


I don’t know how you deserialize the plot file, but I just was thinking that when you read in width and height and they were -1, you could simply recalc them, instead of storing the values (-1) in associated fields.

Depends how flexible you’re decoder is (I don’t like the fact that almost everything is a void node, instead of the fully qualified object name, but that’s another story).


We don’t control the serialize/deserialize directely, the plot object is a Java bean and will be serialize to xml file via the default encoder provided by Java platform.

The details about the data handling is not the main problem. I think ForeUI user will not input “-1” in the width or height field, since they just need to click the “auto size” button, that is faster.

If you like to set the width and height to “-1” externally, and hope ForeUI support that format (replace the -1 to actual size), that’s not very difficult. If it is the case, we’d better discuss via email since it will not be a “public” feature of ForeUI.


This question is now closed