Summary: | [Zest] Graph.getFigureAt does not work with scaled layers | ||
---|---|---|---|
Product: | [Tools] GEF | Reporter: | Zviki Cohen <zvikico> |
Component: | GEF-Legacy Zest | Assignee: | gef-inbox <gef-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | jnorris, m.schrey, mail |
Version: | 3.4 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Zviki Cohen
2008-06-17 11:16:45 EDT
I second this suggestion. The getFigureAt method isn't useful because I just end up with a GraphLabel when I want the GraphNode and there's no way to efficiently get the GraphNode since the figure2ItemMap is private. Please either add the getItemAt method as described above or make the getGraphItem(IFigure figure) method public API. This problem drove me crazy too. Because of the private Method I had no chance to get my Nested Objects. But I really want to use Zest so here is a small workaround for those who are contaminated such as me ;) For example I want to get the "node" at mouse location when a button is released: graph.addMouseListener(new MouseListener() { public void mouseUp(MouseEvent e) { //this just gives us a GraphLabel etc. like postet above. IFigure figure = graph.getFigureAt(e.x, e.y); ... } ... } Now I do the following using reflections (sorry for that but it works) // first the same as above (still in the mouseUp-method) IFigure figure = graph.getFigureAt(e.x, e.y); GraphItem item = null; // now the bad things begin... try { // getting private field Field f = Graph.class.getDeclaredField("figure2ItemMap"); // set field public f.setAccessible(true); // get field HashMap figure2ItemMap = (HashMap)f.get(graph); f.setAccessible(false); // use field to get the GraphItem item = (GraphItem) figure2ItemMap.get(figure); } catch (Exception e1) { // this should not happen e1.printStackTrace(); } Hope I could help someone. Btw. I first tried it with the "getGraphItem" method but this didn't work. Maybe because it is neither declared as private nor than public. Nevertheless the bug should be fixed sometime. Its just a little public in front of the "getGraphItem" method. :P Any news on that bug? I would also find an official getGraphItemAt() or similar method very handy. Re-assigning back to inbox, as Ian is no longer active committer. |