Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Set default (initialization) color for a figure
Set default (initialization) color for a figure [message #189230] Fri, 23 May 2008 17:40 Go to next message
Eclipse UserFriend
Originally posted by: mehrdad.saadatmand.gmail.com

Hi,

I want to give my figures a default backgroud color, while letting the user
change it if they want. In what class should I set the backgroundcolor, so
that it is only set on figure creation and does not overwrite user set
colors?

Thanks,
Mehrdad
Re: Set default (initialization) color for a figure [message #189310 is a reply to message #189230] Mon, 26 May 2008 10:21 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mehrdad,

Just override corresponding ???ViewFactory.initializeFromPreferences() method.
First you can call super. implementation and then set some color there. By
this you'll modify default color for each newly created elements of this
type.

-----------------
Alex Shatalin
Re: Set default (initialization) color for a figure [message #189594 is a reply to message #189230] Tue, 27 May 2008 22:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ste-re.gmx.de

I think it should also be possible when you set a background color
in the graphical definition for your node
Re: Set default (initialization) color for a figure [message #189602 is a reply to message #189594] Tue, 27 May 2008 23:29 Go to previous message
Eclipse UserFriend
Originally posted by: mehrdad.saadatmand.gmail.com

Thanks, Actually Alex's solution was exactly what I needed. Having it in the
graphical definition, disables user from changing it to their own desired
color.


@Override protected void initializeFromPreferences(View view)
{
super.initializeFromPreferences(view);
IPreferenceStore store = (IPreferenceStore)
getPreferencesHint().getPreferenceStore();
int fillcol= store.getDefaultInt("CompBackColor");
FillStyle fillstl = (FillStyle)
view.getStyle(NotationPackage.Literals.FILL_STYLE);
fillstl.setFillColor(fillcol);

}


If I add this code to the decorateView method, it also works fine as far as
initlization is needed. I'm curious to know what the difference between
having it here in initializeFromPreferences and putting it in decorateView
method is, conceptually.



"Stefan" <ste-re@gmx.de> wrote in message
news:g1i1ae$98c$1@build.eclipse.org...
>I think it should also be possible when you set a background color in the
>graphical definition for your node
Previous Topic:RollbackException with emf.transaction: pre-commit validation?
Next Topic:Centering the text within a label?
Goto Forum:
  


Current Time: Fri Mar 29 00:38:46 GMT 2024

Powered by FUDForum. Page generated in 0.04750 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top