XYGraph - suggested way for user interaction [message #1708458] |
Wed, 16 September 2015 14:01  |
Eclipse User |
|
|
|
Hallo,
I created an RCP application with a Nebula XYGraph chart, and now I am adding clickable squares.
The idea is to add a clickable square centered on a data point, and to react to user clicks by executing arbitrary code.

For now I draw few squares. Each one is a RectangleFigure, added on top of the XYGraph figure, and each one has an attached Mouse listener.
RectangleFigure nodeRect = new RectangleFigure();
nodeRect.setForegroundColor(COLOR_RED);
nodeRect.setBackgroundColor(COLOR_YELLOW);
for(int i=0; i<3; i++){
int xVal = 100*(1+i);
int yVal = 100*(1+i);
nodeRect.setBounds(new Rectangle(xVal, yVal, 30, 30));
xyGraph.add(nodeRect);
// listener prints the click
nodeRect.addMouseListener( myMouseClickListener );
}
In this case, the clickable squares (Draw2D Figure) are on a layer external to XYGraph, and this brings two issues:
- The clickable squares are not linked to data points in the XYGraph chart, so I will have to "rescale" their x and y relatively to the graph. I don't know how to scale data from XYGraph space to Draw2d space.
- When resizing the XYGraph container, my squares are cut off, and I have to explicitly move them. So I think I need to intercept the XYGraph resize event. I don't know how to intercept the XYGraph resize events.

I already checked the XYGraph source code and examples. But I found no examples on this, and I found a little bit difficult to interact with XYGraph.
( I tried using annotations, but the mouse events are intercepted and canceled by the XYGraph listening system)
So, I would like to know if someone could point me to some example / best practices on how to add and interactive layer on XYGraph.
Any advice or suggestion it would be extremely useful.
Kind Regards
[Updated on: Thu, 17 September 2015 06:07] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08042 seconds