0

Is there a way to develop a GUI which has graph data structure at the backend so that if we want to have information about a particular node or edge, we just tap its corresponding GUI representation and the app gives us the required info?

3
Contributors
4
Replies
22
Views
1 Year
Discussion Span
Last Post by JamesCherrill
0

Yes.
The simplest way is to display each node as some kind of button. Edges are a bit more fiddly - you proably want to allow the user to tap "close" to the line because the line itself will be a difficultly small target. If the graph is tidy, with no overlap of edges then you can use buttons for the edges as well (transparent button with a line drawn across it). Otherwize you will have to draw the edges as lines and have some code to determine if a tap is on or close to an edge line - which would need a little thought, but the code's not too hard.

0

well i am trying to create a map of my residential block. Is it possible to use graph data structure as backend and buttons as GUI?

0

Yes, absolutely. Although Buttons are the simplest to implement, you may not get the look and feel that you really want, so a better general solution is:
As you draw the graph in your GUI you store the Shape (maybe just a simple Rectangle) of the thing you just drew for each node or edge etc. With each such shape store the object it represents (ie create a Map with the Shape as key and the node/edge object as the value).
Now when the user interacts with the GUI you can loop through the stored Shapes to see which one the user has tapped (use Shape's contains(tapped Point) method) and use that to get the object it represents. Then you can display all the info for that object.
Frankly, that part of the code is really easy. The hardest part is coming up with code that draws the graph ina way that is clear and looks good.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.