Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:32 Go to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
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??


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay

[Updated on: Tue, 13 April 2010 08:50]

Report message to a 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 09:44 Go to previous messageGo to next message
Charu Sharma is currently offline Charu SharmaFriend
Messages: 17
Registered: May 2011
Location: Pune
Junior Member
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 11:54 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
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: Tue Apr 16 15:53:10 GMT 2024

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

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

Back to the top