質問

I'm currently learning GEF (as in the Eclipse project), and while doing so have come across a question.

In my future application I will have to connect a Figure with the nested figure of some other Figure. I have found that via the following code (quoted from memory, used in a pure Draw2D application) I can access the nested figure.

(Figure)someFigure.getChildren().get(1)

From trying it out I have found out that when the accessed Figure has added to it a) a Label and b) a Figure (add()ed in this order), the above code will return the nested Figure.

Obviously this isn't optimal, as the same code with get(0) will probably result in an error (I guess a casting error).

My question is: Is there a native/easier way to access nested figures, especially without having to cast?

Many thanks in advance!

役に立ちましたか?

解決

Don't think there is a way. If you own the code that adds the figures, why not create your own model instead of relying on draw2d (BTW, this is what GEF does).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top