Home » Modeling » Graphiti » resizing elements nested in rectangle
resizing elements nested in rectangle [message #780941] |
Fri, 20 January 2012 04:38 |
Josef Pohl Messages: 82 Registered: January 2012 |
Member |
|
|
Hi there, sorry to be an annoyance. I have really enjoyed this framework and think you have done a wonderful job here.
My current issue involves an invisible rectangle and some elements nested inside of it.
Inside of my invisible rectangle I have a standard rectangle stacked (horizontally) on a small polygon ( a diamond shape which only shows up under certain model conditions).
Here is my code for creating this:
{
int offset = 0;
Rectangle invisible = gaService.createInvisibleRectangle(containerShape);
if(addedClass.isToBeDeveloped()){
offset = 20;
}
gaService.setLocationAndSize(invisible,context.getX(), context.getY(), width, height+offset);
link(containerShape, addedClass);
}
{
Shape shape = peCreateService.createShape(containerShape, false);
// create and set graphics algorithm
Rectangle rectangle =
gaService.createRectangle(shape);
rectangle.setForeground(manageColor(CLASS_FOREGROUND));
rectangle.setBackground(manageColor(CLASS_BACKGROUND));
rectangle.setLineWidth(2);
gaService.setLocationAndSize(rectangle,
0,0,width,height);
// create link and wire it
link(shape, addedClass);
}
{
if(addedClass.isToBeDeveloped()){
Shape shape = peCreateService.createShape(containerShape, false);
int[] diamondXY = new int[] {10,0,20,10,10,20,0,10};
Polygon p = gaService.createPolygon(shape, diamondXY);
p.setBackground(manageColor(UNDEV_BACKGROUND));
p.setForeground(manageColor(UNDEV_FOREGROUND));
p.setLineWidth(2);
//gaService.setLocationAndSize(p, width/2, height, 10, 10);
gaService.setLocation(p, (width/2-10), (height));
link(shape, addedClass);
}
}
If I comment out the first "link" under the invisible rectangle I get the correct layout of my elements. A box on top of a small diamond.
If I leave it in, the box is fine, but the diamond is skewed. The right half of the diamond stretches out to the bounding invisible rectangle.
However, if I comment out the first link under the invisible rectangle the resize (implemented in Layout) does not work properly. The invisible rectangle is resized but the regular rectangle moves into the upper right hand corner.
If I leave it in the resize works for the regular rectangle as desired but the position of the diamond is static.
Here is the Layout code:
....
for (Shape shape : containerShape.getChildren()){
GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();
IGaService gaService = Graphiti.getGaService();
IDimension size =
gaService.calculateSize(graphicsAlgorithm);
if (containerWidth != size.getWidth()) {
if (graphicsAlgorithm instanceof Polyline) {
Polyline polyline = (Polyline) graphicsAlgorithm;
Point secondPoint = polyline.getPoints().get(1);
Point newSecondPoint =
gaService.createPoint(containerWidth, secondPoint.getY());
polyline.getPoints().set(1, newSecondPoint);
anythingChanged = true;
}else if (graphicsAlgorithm instanceof MultiText) {
MultiText mt = (MultiText) graphicsAlgorithm;
mt.setHeight(containerHeight - DESCRIPTION_OFFSET);
mt.setWidth(containerWidth);
anythingChanged = true;
} else if (graphicsAlgorithm instanceof Rectangle){
Rectangle rt = (Rectangle) graphicsAlgorithm;
rt.setHeight(containerHeight - UNDEVELOPED_OFFSET );
rt.setWidth(containerWidth);
} else if (graphicsAlgorithm instanceof Polygon){
Polygon pg = (Polygon) graphicsAlgorithm;
pg.setX(containerWidth/2);
pg.setY(containerHeight - UNDEVELOPED_OFFSET);
}else {
gaService.setWidth(graphicsAlgorithm,
containerWidth);
anythingChanged = true;
}
}
}
return anythingChanged;
So here are my questions:
1. What would be causing the right hand side of my polygon to become skewed like that dependent on the link(containerShape,addedClass) addition?
2. What would keep my resize/layout adjustment from working properly?
I did notice that unless the link(containerShape, addedClass) line was in there the resize methods for this feature were not called, which I thought was a bit odd, but I could not come up with an answer on that one.
Thanks
Joe
|
|
| | | | |
Goto Forum:
Current Time: Thu Apr 25 02:10:37 GMT 2024
Powered by FUDForum. Page generated in 0.03667 seconds
|