Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » moving child elements
moving child elements [message #238925] Mon, 08 October 2007 10:48 Go to next message
Richard Adams is currently offline Richard AdamsFriend
Messages: 77
Registered: July 2009
Location: Edinburgh
Member
Hello,
I'm fairly new to GEF and have a query about coordinate systems etc.

We have a model object ('MyShape')which can be represented as a shape
which can contain nested Shapes. In addition to this, the MyShape object
needs to have some invisible padding around it.

Our MyShape Figure therefore is a complex figure of 2 layers; the first
holds the
RectangleFigure or Ellipse object from draw2d, the top layer is the
content pane into which to add new MyShape figures as children. Both are
FreeForm layers with FreeFormLayout, and the whole figure uses a stack
layout. This works OK except if I move
the parent container, the children don't move.

If I want to continue to use absolute coordinates, do I need to write my
own code
to update the child elements locations? Where is the best place to do
this? In the move command or in refreshVisuals or refreshChildren()?

Or would it be better to change to relative coordinates?

When I first started doing this I didn't have the invisible padding
requirement
and so the MyShapeFigure WAS a draw2d Rectange or ELlipse figure - in this
case
child elements kept their location relatve location when their parent was
moved, even though draw2D Shapes don't set useRelativeLocation ==true.
Only
now that I have a complex figure do I have problems moving the children.

Thanks for any advice,

Richard


Re: moving child elements [message #238937 is a reply to message #238925] Mon, 08 October 2007 11:56 Go to previous messageGo to next message
Richard Adams is currently offline Richard AdamsFriend
Messages: 77
Registered: July 2009
Location: Edinburgh
Member
Just to expand on my previous post; here is the the figure
creation code:
// extends figure
public ShapeFigure(ShapeType shapeType, int padding) {
setLayoutManager(new StackLayout());
this.padding = padding;
this.shapeType = shapeType;

// 'box' isa draw2d shape e.g., rectangleFigure
this.box = createFigure(shapeType);
box.setLayoutManager(new XYLayout());

// layer for this shape
bottom = new FreeformLayer();
bottom.setLayoutManager(new FreeFormLayout());

// layer for child figures
top = new FreeformLayer();
top.setLayoutManager(new FreeformLayout());

top.add(box);
add(bottom);
add(top);

// temporary figure boundary highlight
setBorder(new LineBorder(ColorConstants.red,1));


}


Re: moving child elements [message #238942 is a reply to message #238925] Mon, 08 October 2007 11:58 Go to previous messageGo to next message
Richard Adams is currently offline Richard AdamsFriend
Messages: 77
Registered: July 2009
Location: Edinburgh
Member
Just to expand on my previous post; here is the the figure
creation code. Basically I need other ShapeFigures added to 'top' to follow
the parent figures around when moving.

~Thanks

// extends figure
public ShapeFigure(ShapeType shapeType, int padding) {
setLayoutManager(new StackLayout());
this.padding = padding;
this.shapeType = shapeType;

// 'box' is a draw2d shape e.g., rectangleFigure
this.box = createFigure(shapeType);

// layer for this shape
bottom = new FreeformLayer();
bottom.setLayoutManager(new FreeFormLayout());

// layer for child figures
top = new FreeformLayer();
top.setLayoutManager(new FreeformLayout());

top.add(box);
add(bottom);
add(top);

// temporary figure boundary highlight
setBorder(new LineBorder(ColorConstants.red,1));


}


Re: moving child elements [message #238962 is a reply to message #238942] Tue, 09 October 2007 06:53 Go to previous message
Richard Adams is currently offline Richard AdamsFriend
Messages: 77
Registered: July 2009
Location: Edinburgh
Member
Just to add, basically I am trying to get the behaviour of the 'Circuit'
in the
logic example, but as well as merely being a container, to also have a
shape
as its content.
Any help greatly appreciated

Richard


Previous Topic:Adding classes from action
Next Topic:graphical editor fly layout palette
Goto Forum:
  


Current Time: Tue Apr 23 16:43:15 GMT 2024

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

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

Back to the top