Skip to main content



      Home
Home » Eclipse Projects » GEF » How to add new Layers and show specific figures in Them?
How to add new Layers and show specific figures in Them? [message #526839] Tue, 13 April 2010 04:32 Go to next message
Eclipse UserFriend
Hi,

Can any body point to a piece of code or example where a new layer addition ( like connection and gridlayer) has been done...

After doing that how can i tell the editpart that my figure should be added in the above layer??

[Updated on: Tue, 13 April 2010 04:50] by Moderator

Re: How to add new Layers and show specific figures in Them? [message #1015926 is a reply to message #526839] Mon, 04 March 2013 04:44 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I am also looking for same. Please let me know if you find solution.
sharmacharu08atgmaildotcom.

Thanks in advance.
Re: How to add new Layers and show specific figures in Them? [message #1015951 is a reply to message #1015926] Mon, 04 March 2013 06:54 Go to previous message
Eclipse UserFriend
Hi,

you can do that by exdending RootEditPart:
public class CustomScalableFreeformRootEditPart extends ScalableFreeformRootEditPart {

    public static final String CUSTOM_LAYER = "Custom layer";

    ...

    @Override
    protected void createLayers(LayeredPane layeredPane) {
	super.createLayers(layeredPane);
        FreeformLayer customLayer = new FreeformLayer();
        customLayer .setLayoutManager(new FreeformLayout());
	layeredPane.addLayerAfter(customLayer , CUSTOM_LAYER, LayerConstants.SCALABLE_LAYERS);
    }
}

Then in the EditPart that is parent of the EditPart being added to the custom layer:
public class ParentEditPart extends AbstractGraphicalEditPart {
    
    ...

    @Override
    protected void addChildVisual(EditPart childEditPart, int index) {
	IFigure child = ((GraphicalEditPart) childEditPart).getFigure();
        if (childEditPart instanceof CustomEditPart) {
            getLayer(CustomScalableFreeformRootEditPart.CUSTOM_LAYER).add(child, index);
        } else {
	    super.add(child, index);
        }
    }

    @Override
    protected void removeChildVisual(EditPart childEditPart) {
        IFigure child = ((GraphicalEditPart) childEditPart).getFigure();
	if (childEditPart instanceof CustomEditPart) {
            getLayer(CustomScalableFreeformRootEditPart.CUSTOM_LAYER).remove(index);
        } else {
	    super.remove(child);
        }
    }
}

Note that the code above will probably throw exceptions because of wrong index.
This is because model indexes are not sync with visual indexes.
(The model of CustomEditPart is eg at index 1, but the visual representation is at index 0)

So you have to reimplement indexing or don't use indexing at all. (*.add(child, -1))
Previous Topic:highlight my node
Next Topic:ScalableFreeformRootEditPart negative coordinates
Goto Forum:
  


Current Time: Wed Jul 02 10:17:45 EDT 2025

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

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

Back to the top