|
(no subject) [message #687828 is a reply to message #687582] |
Thu, 23 June 2011 10:19 |
Ivar Refsdal Messages: 24 Registered: May 2011 |
Junior Member |
|
|
Hi Vitaly,
I am quite new to GMF, so take my answer with some caution,
but anyway:
You can change the default font color in XXXViewProvider.java in the
createXXXX_XXX methods.
If you want the template, it is located in
/org.eclipse.gmf.codegen/templates/xpt/providers/ViewProvider.xpt
Particularly you could look at:
> «DEFINE initFontFromPrefs(String viewVar, String prefStoreVar) FOR gmfgen::GenCommonBase-»
> org.eclipse.gmf.runtime.notation.FontStyle «viewVar»FontStyle = (org.eclipse.gmf.runtime.notation.FontStyle) «viewVar».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.Literals.FONT_STYLE);
> if («viewVar»FontStyle != null) {«REM»Given this template is invoked only when FontStyle is present, no need to check fontStyle for null, but at least this gives a scope for fontData var«ENDREM»
> org.eclipse.swt.graphics.FontData fontData = org.eclipse.jface.preference.PreferenceConverter.getFontData(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_DEFAULT_FONT);
> «viewVar»FontStyle.setFontName(fontData.getName());
> «viewVar»FontStyle.setFontHeight(fontData.getHeight());
> «viewVar»FontStyle.setBold((fontData.getStyle() & org.eclipse.swt.SWT.BOLD) != 0);
> «viewVar»FontStyle.setItalic((fontData.getStyle() & org.eclipse.swt.SWT.ITALIC) != 0);
> org.eclipse.swt.graphics.RGB fontRGB = org.eclipse.jface.preference.PreferenceConverter.getColor(«prefStoreVar», org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_FONT_COLOR);
> «viewVar»FontStyle.setFontColor(org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.RGBToInteger(fontRGB).intValue());
> }
> «ENDDEFINE»
I agree it would be good to have a possibility to specify it in gmfgraph
or gmfgen. I could not find it either..
Best regards,
Ivar
Vitaly Savickas wrote, on 06/22/2011 09:21 PM:
> Such a simple thing as setting font color for node labels and I don't
> know how to do it. There are few unanswered posts in the forum, but I
> can't believe such a basic thing is not supported?! Anyone knows how to
> do it in gmfgraph or gmfgen, or at least using template modifications?
> My font color must be the same for all diagram labels.
>
> Regards,
> Vitaly
|
|
|
|
Re: (no subject) [message #687896 is a reply to message #687874] |
Thu, 23 June 2011 13:13 |
Ivar Refsdal Messages: 24 Registered: May 2011 |
Junior Member |
|
|
Thanks also to you Vitaly,
your solution is far better.
I agree about the lack of such a requirement is not very good.
The GenCommonBase for which the setFontColor method is generated
actually has a styles attribute, so perhaps it's possible to fit it
inside there. I also do not have the knowledge to fix this..
Stadnik and Shatalin were the initial contributors of TextAware.xpt, but
both seems to have left the forums some years ago.
Best
Ivar
Vitaly Savickas wrote, on 06/23/2011 02:36 PM:
> Thanks Ivar,
>
> The bit you have shown is only used if some global color preferences are
> present thus not useful for default diagram. But I have modified the
> TextAware template i.e. changed provided color to figure's foreground
> color in setFontColor method definition. Not a clean solution at all,
> but at least it is persisted on regeneration and the color can be
> modified now from gmfgraph by setting corresponding foreground color. A
> better solution would be to extend the gen metamodel and use it in
> templates, but I don't have the required knowledge. Anyway, I still
> can't believe there is no facility for such a basic requirement in GMF.
>
> Regards,
> Vitaly
|
|
|
Powered by
FUDForum. Page generated in 0.03799 seconds