Graphical Interaction


Maybe somebody can help me. How is it possible to Create a Graphic as the following one and how is it possible that I can move the Head in between the Circle an adapt the Level based on the information where the Head is? My Problem is the moving Head, how can I realize it and what is the way to get the Info where the Head is.


First problem how do you draw it.

Just have a parent component that contains 5 children components
1.) the circle container
2.) the head
3,4,5) the nodes

To handle the movement have the parent component be a MouseListener of the head and the nodes, when mouse drag is called you can reposition the head / node accordingly (I suggest positioning the centre point as opposed to the top left one), checking that you limit the co-ordinates to a circle equal to the size of the circle container component.

To adjust some level based on the distance between the head and some node you can calculate the distance between the two in the parent component by using the Point method getDistanceFrom(), you might need to get the absolute value, but then you can map the value to a value of 0 to 1 by using jmap, for example:

jmap (myAbsDistance, 0.f, (float) circleContainer.getWidth(), 0.f, 1.f);

Does that help?