Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Label-text doesn`t have the right color
Label-text doesn`t have the right color [message #214139] Wed, 24 December 2008 04:36 Go to next message
Eclipse User
Originally posted by: cayla_sha.gmx.net

Hello!

I have some labels and I want the text of this labels in a certain color
(not black).
I made a label in the *.gmfgraph-file with a child Foreground Color. It
looks like this:
Figure Descriptor SomeFigure
|_ Rectangle SomeRectangle
|_ Grid Layout 2
|_ Label MyLabel
|_ Grid Layout Data true
|_ Foreground: blue
|_ Basic Font Tahoma (Height: 8)

But in the editor the label-text is black.

In the EditPart of the Rectangle the labels foreground-color is set to
blue but apparently the editor doesn`t care about that.

I already tried to switch the order of the settings inside the EditPart,
so that the color is set first, than the font and finally the text. And
I tried other combinations as well. But this didn`t change anything.

Where is the error? How can I make the label-text blue?

Merry Christmas!
Julia
Re: Label-text doesn`t have the right color [message #214213 is a reply to message #214139] Sun, 28 December 2008 10:38 Go to previous messageGo to next message
Eclipse User
Originally posted by: cayla_sha.gmx.net

PS:
I have some new information regarding the font-color.

First in the EditPart of the figure, which holds the label, the
foregroundcolor of the label is set to blue.

But after this, the foregroundcolor is set back to black inside of the
EditPart of the label itself.
There is this Method: <LabelName>EditPart.setFontColor(Color c). This
Method is called from GraphicalEditPart.refreshFontColor() - and this
method has the totally wrong values.
The method refreshFontColor() fetches the FontStyle in this line:
FontStyle style = (FontStyle)
getPrimaryView().getStyle(NotationPackage.Literals.FONT_STYL E);
And when I look into the variable "style" during debugging it has
fontHeight=9 and fontColor=0, although I set different values in the
gmfgraph-file.

That means, that somewhere in this NotationPackage a wrong value is set.
But I don`t understand this concept with this NotationPackage.
NotationPackage itself is just an interface. I can`t find an
implementation. But there must be a file in my generated Code which
holds all the styles and this file has the wrong values.
Can anyone help me?
Re: Label-text doesn`t have the right color [message #214269 is a reply to message #214213] Tue, 30 December 2008 08:54 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Cayla,

You are right – label colour will be changed to the “default” one during
update with the underlying notation model element. The problem is: by default
most of the diagram colours are synchronized with corresponding preferences
and can be modified using “Appearance” properties tab. Nevertheless you can
manually break this synchronization:
1. by modifying refreshVisuals() method in a LabelEditPart and commenting
out refreshFontColor() method call from there (or by overriding refreshFontColor()
in LabelEditPart with an empty method).
2. by removing FontStyle from the label container - you have to modify ***ViewFactory
generated for the label container node and replace createStyles() method
with custom implementation to avoid FontDtyle association with the notation
model element of label parent
3. modify getFontStyleOwnerView() method in LabelEditPart to return
this.getModel() instead of getPrimaryView().

-----------------
Alex Shatalin
Re: Label-text doesn`t have the right color [message #214343 is a reply to message #214269] Tue, 30 December 2008 12:45 Go to previous messageGo to next message
Eclipse User
Originally posted by: cayla_sha.gmx.net

Hello Alex!

Thanks a lot!
I chose option 1 and it works great :D

kind regards
Julia
Re: Label-text doesn`t have the right color [message #216310 is a reply to message #214269] Fri, 23 January 2009 10:08 Go to previous messageGo to next message
Robert Wloch is currently offline Robert Wloch
Messages: 109
Registered: July 2009
Senior Member
Alex Shatalin wrote:
> 3. modify getFontStyleOwnerView() method in LabelEditPart to return
> this.getModel() instead of getPrimaryView().

For some reason I just tried your 3rd option. While diggin into it, a
found the Xpand template TextAware.xpt doing this check:
«IF isFixedFont(viewmap)-»
return (org.eclipse.gmf.runtime.notation.View) getModel();
«ELSE-»
return getPrimaryView();
«ENDIF-»
Looks to me as if I wouldn't have to modify generated code to enable my
modeled label colors. Indeed, in my gmfgen under
Gen Diagram -> Gen Child Node X -> Gen Node Label Y -> Parent Assigned
Viewmap -> Style Attributes
there is an option "Fixed Font". Setting to to true will generate your
suggested code change at the right place. However, no effect. The label's
font color remains black. Is there another way in gmfgen to enable label
colors modeled in gmfgraph model?

Thanks for helping!

Rob
Re: Label-text doesn`t have the right color [message #216984 is a reply to message #216310] Fri, 30 January 2009 11:10 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Robert,

> Looks to me as if I wouldn't have to modify generated code to enable
> my modeled label colors. Indeed, in my gmfgen under
> Gen Diagram -> Gen Child Node X -> Gen Node Label Y -> Parent Assigned
> Viewmap -> Style Attributes there is an option "Fixed Font".
Right - this is another way to generate appropriate code. Sorry for not pointint
to it from the very beggining..

> suggested code change at the right place. However, no effect. The
> label's font color remains black. Is there another way in gmfgen to enable
> label colors modeled in gmfgraph model?
I do not remember any other. Can you debug the code to see why incorrect
color was used?

-----------------
Alex Shatalin
Re: Label-text doesn`t have the right color [message #221818 is a reply to message #216984] Wed, 18 March 2009 12:55 Go to previous message
Andreas Schoeneck is currently offline Andreas Schoeneck
Messages: 22
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------070707050601080205040103
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hi Alex,

> I do not remember any other. Can you debug the code to see why incorrect
> color was used?

I am not Robert, but I experience the same problem. The problem seems
that getFontStyleOwnerView() is never called (directly or indirectly) by
refreshFontColor(). It is likely to be called by refreshFontUnderline(),
refreshStrikeThrough() and refreshFont().
refreshFontColor() is a call to GraphicalEditPart, i.e. it doesn't get
overwritten/there's no explicit implementation in the generated class.
From there standard color behavior is assumed as you explained.

Adding the following method to the **Label*EditPart classes does the trick:


@Override
protected void refreshFontColor() {
FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
NotationPackage.eINSTANCE.getFontStyle());
if ( style != null ) {
setFontColor(DiagramColorRegistry.getInstance().
getColor(new Integer(style.getFontColor())));
}
}

Though this method should be added by the generator in appropriate
cases, I think.

Regards
Andy

--------------070707050601080205040103
Content-Type: text/x-vcard; charset=utf-8;
name="as_maps.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="as_maps.vcf"

YmVnaW46dmNhcmQNCmZuOkFuZHJlYXMgU2Nob2VuZWNrDQpuOlNjaG9lbmVj aztBbmRyZWFz
DQplbWFpbDtpbnRlcm5ldDphcy5tYXBzQGdtYWlsLmNvbQ0KeC1tb3ppbGxh LWh0bWw6RkFM
U0UNCnZlcnNpb246Mi4xDQplbmQ6dmNhcmQNCg0K
--------------070707050601080205040103--
Previous Topic:How insere an image
Next Topic:How to open a diagram in patir of a drawn element?
Goto Forum:
  


Current Time: Sat May 25 21:26:37 EDT 2013

Powered by FUDForum. Page generated in 0.07710 seconds