Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » GMF creates -1 coordinates
GMF creates -1 coordinates [message #228911] Tue, 05 May 2009 15:29 Go to next message
Stefan Karl is currently offline Stefan KarlFriend
Messages: 3
Registered: July 2009
Junior Member
Hello, IŽm currently working on a eclipse-plugin based on emf/gmf, which
allows the user to create gui-prototypes on the canvas. Every gui element
that is available in the plugin has coordinates, such as x-position,
y-position, width and height. The coordinates are used to automatically
create the gui prototype in java-swing, the elements are placed via
mOkButton.setBounds(x, y, width, height); This system works just fine in
about 95 percent of all cases, but there is a little problem left.
Sometimes there is a -1 in the generated code, in which one element of the
coordinate should be. For example mOkButton.setBounds(114, 98, -1, 50); If
i resize the width of the ok button, the real coordinate will be generated.

Thank you very much for your help

Greetings Stefan
Re: GMF creates -1 coordinates [message #229504 is a reply to message #228911] Tue, 12 May 2009 11:11 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Stefan,

AFAICan see from FreeFormLayoutEx (layout manager used for the diagram figure)
- preferred size width/height of the child figure will be used in case of
"-1" specified as width/length:

if (widthHint == -1 || heightHint == -1) {
Dimension _preferredSize = f.getPreferredSize(widthHint, heightHint);
bounds = bounds.getCopy();
if (widthHint == -1)
bounds.width = _preferredSize.width;
if (heightHint == -1)
bounds.height = _preferredSize.height;
}

so, if you need to use non-default width/height values you have to always
set size on creating diagram elements.

-----------------
Alex Shatalin
Previous Topic:Fireing CannonicalEditPolicy on diagram open?
Next Topic:Creating collections with at least one item
Goto Forum:
  


Current Time: Fri Mar 29 00:08:57 GMT 2024

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

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

Back to the top