Get and set Text size in any DNode and DEdge [message #1743160] |
Mon, 12 September 2016 15:01  |
Eclipse User |
|
|
|
Hi,
I intended to set programmatically the size of the font used in all the labels of all DNode and DEdge of a given DRepresentation.
The code below is where I got so far, but it doesn't seem to modify the representations at all. Actually even description.getLabelSize() doesn't return the correct size value when I set it manually in the Properties view, see screenshot.
Any idea what I might be doing wrong ????
many thanks in advance for a quick feedback,
Benoît
***************
"rep" is of type DRepresentation
for (DRepresentationElement repElt: rep.getRepresentationElements()) {
if (repElt instanceof DNode || repElt instanceof DNodeContainer || repElt instanceof DNodeList || repElt instanceof DNodeListElement) {
if (repElt.getStyle().getDescription() instanceof NodeStyleDescription) {
NodeStyleDescription desc = (NodeStyleDescription) repElt.getStyle().getDescription();
desc.setLabelSize(fontSize);
repElt.getStyle().setDescription(desc);
} else if (repElt.getStyle().getDescription() instanceof ContainerStyleDescription) {
ContainerStyleDescription desc = (ContainerStyleDescription) repElt.getStyle().getDescription();
desc.setLabelSize(fontSize);
repElt.getStyle().setDescription(desc);
}
} else if (repElt instanceof DEdge) {
EdgeStyleDescription desc = (EdgeStyleDescription)repElt.getStyle().getDescription();
if (desc.getBeginLabelStyleDescription() != null) {
desc.getBeginLabelStyleDescription().setLabelSize(fontSize);
}
if (desc.getCenterLabelStyleDescription() != null) {
desc.getCenterLabelStyleDescription().setLabelSize(fontSize);
}
if (desc.getEndLabelStyleDescription() != null) {
desc.getEndLabelStyleDescription().setLabelSize(fontSize);
}
repElt.getStyle().setDescription(desc);
}
|
|
|
|
|
|
Re: Get and set Text size in any DNode and DEdge [message #1743303 is a reply to message #1743204] |
Wed, 14 September 2016 04:48  |
Eclipse User |
|
|
|
The font used is not defined in the VSM, it's a GMF-only attribute. You'll need to update the FontStyle element of the underlying GMF Notation View object. It's a little indirect to obtain it, you'll need something like view.getStyle(NotationPackage.eINSTANCE.getFontStyle()), where 'view' is a GMF view.
If you have the edit part, it looks like this:
FontStyle fontStyle = (FontStyle) part.getNotationView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
|
|
|
Powered by
FUDForum. Page generated in 3.90739 seconds