Anchor creation breaks Graphiti [message #992764] |
Sat, 22 December 2012 14:54 |
Philipp Adolf Messages: 3 Registered: December 2012 |
Junior Member |
|
|
I'm having trouble using FixPointAnchor and BoxRelativeAnchor. Whenever I call the PECreateService methods to create either of those in my AddFeature, I get a "refresh edit part problem" which is caused by a NullPointerException at org.eclipse.draw2d.Figure.add when I add an object and I can't select the object afterwards, not even using ctrl-A. Graphiti also shows me scroll bars although there is no need to scroll. The exception is not triggered while my code is running, but afterwards, during drawing, I suspect, given the name of the package the exception occurs in.
I prepared a small example, which was created using the Graphiti Plug-in wizard, and contains the code for the tutorial Add- and CreateFeatures plus four lines to create and initialize a BoxRelativeAnchor (taken from the Anchors section of the tutorial). The exception occurs every time I drag EClass from the palette onto the diagram. Using the PredefinedEClass also works.
It seems to be too simple to do something wrong, but maybe I'm missing something obvious. I'm happy for every help I can get, as I need some kind of anchor that is not a ChopBoxAnchor.
|
|
|
Re: Anchor creation breaks Graphiti [message #993099 is a reply to message #992764] |
Sun, 23 December 2012 11:33 |
Andreas Graf Messages: 211 Registered: July 2009 |
Senior Member |
|
|
Hi Philipp,
having only briefly looked at your code, I think it is because you don't create a graphics algorithm for your anchor. IIRC, according to the tutorial, ChopBoxAnchors are the only one without a GA.
I have code similiar to yours, but with the additional fragment (onea is my relative anchor):
final Rectangle rectangle = gaService.createPlainRectangle(onea);
rectangle.setForeground(manageColor(IColorConstant.LIGHT_BLUE));
rectangle.setBackground(manageColor(IColorConstant.WHITE));
rectangle.setLineWidth(2);
rectangle.setLineVisible(true);
Graphiti.getGaService().setLocationAndSize(rectangle, -12, -6, 12, 12);
What would be nice in Graphiti would be an earlier and more specific exception, but I haven't found where this should/could be done.
Regards,
Andreas
|
|
|
|
|
Re: Anchor creation breaks Graphiti [message #997026 is a reply to message #996616] |
Thu, 03 January 2013 12:53 |
Philipp Adolf Messages: 3 Registered: December 2012 |
Junior Member |
|
|
Hi Michael,
That is strange, I did the same but I used createPlainRectangle and set a few style options, which still gave me the error when I tested it a week ago. Now I tested your code, which worked, and because I wanted to know what the problem was, I ran my code again which now works too. Maybe Eclipse didn't recompile the class or something, I have no idea. Still, thank you, it's seems to be working without problems now.
Philipp
|
|
|
Powered by
FUDForum. Page generated in 0.02811 seconds