Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Resizing Support
Resizing Support [message #901780] Tue, 14 August 2012 14:50 Go to next message
Frank Burton is currently offline Frank Burton
Messages: 2
Registered: August 2012
Junior Member
Hi,

I've implemented a simple shape for my DSL.

It is a Ellipse that contains both a Ellipse and a Rectangle.

Now as per the tutorial resizing the ellipse does not resize the shapes inside of it.
I have looked at the Layout feature however I can't find out how to access the Ellipse and Rectangles contained within the outer ellipse (within the layout feature) let alone attempt to scale them.

Also, I'm not trying to do anything special with the scaling I just want it to be the same as if it was drawn again at that size in the editor. If there any shortcut method I could use to implement this other than scaling everything.

Thanks in advance,
Frank
Re: Resizing Support [message #901782 is a reply to message #901780] Tue, 14 August 2012 15:04 Go to previous messageGo to next message
Miriam Baran is currently offline Miriam Baran
Messages: 16
Registered: May 2012
Junior Member
Hi Frank,
in my case the inner Ellipse and Rectangle are children of the outer Ellipses GA (not the outer ellipse itself), unlike in the tutorial. That may be different for you, but you can still try it out.
Good Luck
Re: Resizing Support [message #901809 is a reply to message #901780] Tue, 14 August 2012 16:04 Go to previous message
Frank Burton is currently offline Frank Burton
Messages: 2
Registered: August 2012
Junior Member
Thank you.
Got it.

Here's the code for anyone else who has a similar problem.

@Override
public boolean layout(ILayoutContext context) {

ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
GraphicsAlgorithm containerGa = containerShape.getGraphicsAlgorithm();
IGaService gaService = Graphiti.getGaService();
IDimension size = gaService.calculateSize(containerGa);

//Container shape is a ellipse

//Look at the children the rectangle and the ellipse
for (GraphicsAlgorithm shapeGraphicsAlgorithm : containerGa.getGraphicsAlgorithmChildren())
{
if (shapeGraphicsAlgorithm instanceof Ellipse)
{
Ellipse innerCircle = (Ellipse) shapeGraphicsAlgorithm;
innerCircle.setHeight((int)(size.getHeight() * 0.Cool);
innerCircle.setWidth((int)(size.getWidth() * 0.Cool);
innerCircle.setX((int)(size.getWidth() * 0.1));
innerCircle.setY((int)(size.getHeight() * 0.1));
}

if (shapeGraphicsAlgorithm instanceof Rectangle)
{
Rectangle innerRectangle = (Rectangle) shapeGraphicsAlgorithm;
innerRectangle.setHeight((int)((size.getHeight() * 0.6)) + 1);
innerRectangle.setWidth((int)(size.getWidth()));
innerRectangle.setX(0);
innerRectangle.setY((int)(size.getHeight() * 0.5));
}
}

//Now resize text, which for some reason works differently than normal shapes...
Shape textbox = containerShape.getChildren().get(0);
textbox.getGraphicsAlgorithm().setX(0);
textbox.getGraphicsAlgorithm().setY((int)(size.getHeight() * 0.4));
textbox.getGraphicsAlgorithm().setWidth((int)size.getWidth());

return false;
}
Previous Topic:User defined attributes for the graphical elements on the canvas
Next Topic:Custom Tooltips for Decorators
Goto Forum:
  


Current Time: Sat Sep 20 12:02:59 GMT 2014

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

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