|Problems with calculated text size [message #1072662]
||Tue, 23 July 2013 08:21
| Bernhard Berger
Registered: October 2011
I'm trying to layout some diagram and I have some problems with calculating the size of a text. Perhaps someone can enlighten me.
Concretely, I'm trying to display a rectangle and some text under it (you can see the result in the appended screenshot). Both elements are contained in an invisible rectangle. Now I've some problems with calculating the size of the text. I googled and found several forum threads mentioning calculateSize and so forth. I created the following code:
final Shape rectShape = peService.createShape(containerShape, true);
final RoundedRectangle rect = gaService.createRoundedRectangle(rectShape, 40, 40);
MultiText text = gaService.createMultiText(nameShape, businessObject.getName());
final Font textFont = gaService.manageDefaultFont(peService.getDiagramForShape(containerShape));
final IDimension dimension = GraphitiUi.getUiLayoutService().calculateTextSize(text.getValue(), textFont);
... layouting ...
My problem is that I do not understand the unit of the text dimension. The result is width=24 and height=9 but when I use it for the size of the text I can only see a very small part of it. If I multiply both values by 2 everything looks fine. Can someone explain the?
|Re: Problems with calculated text size [message #1250899 is a reply to message #1072662]
||Wed, 19 February 2014 18:12
| nicolas h
Registered: February 2011
Location: Grenoble, France
I also need to calculate the size of a multitext, but I don't manage to.
I tried this two codes:
dimension = GraphitiUi.getUiLayoutService().calculateTextSize(text.getValue(), textFont);
dimension = gaService.calculateSize(text);
The first case works, but I want now to set the width et only calculate the height. Is that possible ?
I tried this:
But when I calculate, the width value is greater than the one I set.
In the second case, the calculateSize method simply does not return a calculated value.
What is the best solution to calculate size at set width ?
Powered by FUDForum
. Page generated in 0.09476 seconds