JFreeChart - Lasso to select multiple points ?
JFreeChart - Lasso to select multiple points ?
Hi,
I was wondering whether JFreeChart has some provision to select multiple points via a lasso effect. The normal way of doing it would be if a user selects a point with the mouse and drags the mouse across several points; however in JFreeChart, this is how the chart zoom works.
So, I was thinking if we could code an addition whereby a normal drag results in zoom (as usual) while a ALT+ mouse drag (or SHIFT+drag) causes the point selection via lasso. I can code how the lasso would work but do not know how to code the detection of ALT+ drag on my XYLineChart. Is there a way of doing this in JFreeChart ?
Kindly let me know soon. Thanks.
I was wondering whether JFreeChart has some provision to select multiple points via a lasso effect. The normal way of doing it would be if a user selects a point with the mouse and drags the mouse across several points; however in JFreeChart, this is how the chart zoom works.
So, I was thinking if we could code an addition whereby a normal drag results in zoom (as usual) while a ALT+ mouse drag (or SHIFT+drag) causes the point selection via lasso. I can code how the lasso would work but do not know how to code the detection of ALT+ drag on my XYLineChart. Is there a way of doing this in JFreeChart ?
Kindly let me know soon. Thanks.
Re: JFreeChart - Lasso to select multiple points ?
If anyone has any feedback about this question, please let me know soon.
Thanks.
Thanks.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: JFreeChart - Lasso to select multiple points ?
It is not implemented in JFreeChart 1.0.17, but this feature has been implemented in the JFreeChart-FSE ("future state edition") project on GitHub:
https://github.com/jfree/jfreechart-fse
There has not been a release from this repo, but you can build it from the source. Feedback is welcome, I have not had time recently to work on this but I would like to get a release done from this repo some time in the coming months (my aim is to have JFreeChart 2.0 in 2014). The lasso selection came from some code that I wrote some years ago now, but Michael Zinsmaier from KNIME.org has done a big chunk of work to structure this and the dataset selection state.
https://github.com/jfree/jfreechart-fse
There has not been a release from this repo, but you can build it from the source. Feedback is welcome, I have not had time recently to work on this but I would like to get a release done from this repo some time in the coming months (my aim is to have JFreeChart 2.0 in 2014). The lasso selection came from some code that I wrote some years ago now, but Michael Zinsmaier from KNIME.org has done a big chunk of work to structure this and the dataset selection state.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: JFreeChart - Lasso to select multiple points ?
Hi David,
Thanks for getting back to me about this. Can you give me a little more insight into how the Lasso feature has been implemented as I will be trying out the JFreeChart-FSE API later today.
Is it via the Shift+ mouse Drag combination or in some other way ? Kindly let me know.
Thanks,
Ajit.
Thanks for getting back to me about this. Can you give me a little more insight into how the Lasso feature has been implemented as I will be trying out the JFreeChart-FSE API later today.
Is it via the Shift+ mouse Drag combination or in some other way ? Kindly let me know.
Thanks,
Ajit.
Re: JFreeChart - Lasso to select multiple points ?
Hi David,
I have downloaded the source ZIP for JFreeChart-FSE. But, how exactly do I build it from the source ? I'm not sure what you meant by it.
If anyone knows how to do this, please let me know as I'm not sure how to go about doing this.
Thanks,
Ajit.
I have downloaded the source ZIP for JFreeChart-FSE. But, how exactly do I build it from the source ? I'm not sure what you meant by it.
If anyone knows how to do this, please let me know as I'm not sure how to go about doing this.
Thanks,
Ajit.
Last edited by AjitPS on Thu Jan 16, 2014 3:59 pm, edited 1 time in total.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: JFreeChart - Lasso to select multiple points ?
These are the steps:
1) git clone https://github.com/jfree/jfreechart-fse.git
2) cd jfreechart-fse
3) mvn clean install
Then in the 'target' directory you will find jfreechart-fse-1.0-SNAPSHOT.jar, and also a 'classes' directory. You can run one of the demos like this:
java -classpath target/classes org.jfree.chart.demo.selection.SelectionDemo1
1) git clone https://github.com/jfree/jfreechart-fse.git
2) cd jfreechart-fse
3) mvn clean install
Then in the 'target' directory you will find jfreechart-fse-1.0-SNAPSHOT.jar, and also a 'classes' directory. You can run one of the demos like this:
java -classpath target/classes org.jfree.chart.demo.selection.SelectionDemo1
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: JFreeChart - Lasso to select multiple points ?
Thanks a lot David.
I will try this out and let you know how it goes.
I will try this out and let you know how it goes.
Re: JFreeChart - Lasso to select multiple points ?
Hi David,
I managed to get the JFreeChart source files and built them into the jar through Maven. However, I wanted to know how exactly does the selection of multiple points work in this new version of JFreeChart ? Is it Shift+ mouse drag [across the points] ?
However, I noticed that some of the older methods are either missing or different from the new jar. These include .getXYPlot() which no longer exists [I have to use .getPlot() & cast it to XYPlot) and Renderer.setBaseItemLabelGenerator() which is missing too. Also, when we first create an XYLineChart, the new ChartFactory.createXYLineChart() method now has just 4 parameters: title, x-axis label, y-axis label and the dataset. How can we add the older parameters that are no longer there: PlotOrientation, Legend, Tooltips and URL's to the chart. I would like to use these older features in the chart along with the new Shift+ drag "multi-select points" feature but don't know how to implement this now that these methods are missing.
Please let me know how to use XYPlot in this new version of JFreeChart & how to set the Legend, PlotOrientation and Tooltips for a chart.
Thanks.
I managed to get the JFreeChart source files and built them into the jar through Maven. However, I wanted to know how exactly does the selection of multiple points work in this new version of JFreeChart ? Is it Shift+ mouse drag [across the points] ?
However, I noticed that some of the older methods are either missing or different from the new jar. These include .getXYPlot() which no longer exists [I have to use .getPlot() & cast it to XYPlot) and Renderer.setBaseItemLabelGenerator() which is missing too. Also, when we first create an XYLineChart, the new ChartFactory.createXYLineChart() method now has just 4 parameters: title, x-axis label, y-axis label and the dataset. How can we add the older parameters that are no longer there: PlotOrientation, Legend, Tooltips and URL's to the chart. I would like to use these older features in the chart along with the new Shift+ drag "multi-select points" feature but don't know how to implement this now that these methods are missing.
Please let me know how to use XYPlot in this new version of JFreeChart & how to set the Legend, PlotOrientation and Tooltips for a chart.
Thanks.
Re: JFreeChart - Lasso to select multiple points ?
Hi,
Did anyone get the chance to perhaps see my last post about lasso in JFreeChart ?
I know the new version of JFreeChart: JFreeChart-FSE implements the lasso feature but how does it happen ? What mouse + key combination does it ? Is it CTRL + mouse drag ? If anyone knows, please let me know soon.
Thanks.
Did anyone get the chance to perhaps see my last post about lasso in JFreeChart ?
I know the new version of JFreeChart: JFreeChart-FSE implements the lasso feature but how does it happen ? What mouse + key combination does it ? Is it CTRL + mouse drag ? If anyone knows, please let me know soon.
Thanks.
Re: JFreeChart - Lasso to select multiple points ?
I tried to implement a lasso-like feature in JFreeChart 1.0.16 but am not able to achieve the required functionality. I can use the ChartMouseListener on my ChartPanel to get x, y values of a point when it is clicked using the following code:
However, this is in the ChartMouseListener using the ChartMouseEvent. In order to do the lasso by detecting a key (SHIFT or CTRL or ALT) press along with a mouse drag, I need to have a regular MouseListener on the ChartPanel and use its mousePressed() & mouseReleased() methods which use the MouseEvent and not ChartMouseEvent.
How can I implement a similar method in a MouseListener on my ChartPanel that would detect the plotted points' x, y co-ordinated when I press and release the mouse on the ChartPanel ?
Any feedback and help would be highly appreciated. Thanks.
Code: Select all
chartPanel.addChartMouseListener(new ChartMouseListener() {
@Override
public void chartMouseClicked(ChartMouseEvent cme) {
// returnXYvalues(cme);
}
@Override
public void chartMouseMoved(ChartMouseEvent cme) {
returnXYvalues(cme);
}
private void returnXYvalues(ChartMouseEvent cme) {
double pointX= cme.getTrigger().getPoint().x;
double pointY= cme.getTrigger().getPoint().y;
Rectangle2D plotArea = chartPanel.getScreenDataArea();
XYPlot plot = (XYPlot) chart.getPlot(); // the XY Plot.
double chartX = plot.getDomainAxis().java2DToValue(pointX, plotArea, plot.getDomainAxisEdge());
double chartY = plot.getRangeAxis().java2DToValue(pointY, plotArea, plot.getRangeAxisEdge());
System.out.println("JFreeChart: current point: X= "+ chartX +", Y= "+ chartY);
}
});
How can I implement a similar method in a MouseListener on my ChartPanel that would detect the plotted points' x, y co-ordinated when I press and release the mouse on the ChartPanel ?
Any feedback and help would be highly appreciated. Thanks.
Re: JFreeChart - Lasso to select multiple points ?
Hi David,
I have spent the last 2 days trying to work how and where the lasso feature is implemented in the JFreeChart-FSE project. The zoom works as it did in the odler versions (via mouse drag) and clicking on a point is the same as before too. Is there some key combination (CTRL + drag, Shift+ drag, etc.) that results in the lasso effect ? Please let me know.
Thanks.
I have spent the last 2 days trying to work how and where the lasso feature is implemented in the JFreeChart-FSE project. The zoom works as it did in the odler versions (via mouse drag) and clicking on a point is the same as before too. Is there some key combination (CTRL + drag, Shift+ drag, etc.) that results in the lasso effect ? Please let me know.
Thanks.
david.gilbert wrote:It is not implemented in JFreeChart 1.0.17, but this feature has been implemented in the JFreeChart-FSE ("future state edition") project on GitHub:
https://github.com/jfree/jfreechart-fse
There has not been a release from this repo, but you can build it from the source. Feedback is welcome, I have not had time recently to work on this but I would like to get a release done from this repo some time in the coming months (my aim is to have JFreeChart 2.0 in 2014). The lasso selection came from some code that I wrote some years ago now, but Michael Zinsmaier from KNIME.org has done a big chunk of work to structure this and the dataset selection state.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: JFreeChart - Lasso to select multiple points ?
Did you run the demo that I suggested?
Via the API, you get to decide which mouse handlers you want to install on the ChartPanel and what modifier keys are required to invoke the handler. For instance, if you want the lasso selection only while the SHIFT key is being pressed, you would add the following line:
...because in that demo the lasso selection is the default mouse handler (no modifier keys required) so I am surprised you did not see it.Then in the 'target' directory you will find jfreechart-fse-1.0-SNAPSHOT.jar, and also a 'classes' directory. You can run one of the demos like this:
java -classpath target/classes org.jfree.chart.demo.selection.SelectionDemo1
Via the API, you get to decide which mouse handlers you want to install on the ChartPanel and what modifier keys are required to invoke the handler. For instance, if you want the lasso selection only while the SHIFT key is being pressed, you would add the following line:
Code: Select all
selectionHandler.setModifier(InputEvent.SHIFT_MASK);
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: JFreeChart - Lasso to select multiple points ?
Hi David,
Thanks for replying. I had done what you mentioned above using a RectangularRegionSelectionHandler:
However, I'm not sure how to add it to my ChartPanel and how to get details about the points selected by it.
Do I have to override selectionHandler.mouseReleased() ? The documentation for mouseReleased() reads:
Could you tell me how to set this selectionHandler to the chartPanel to enable the lasso and which method of it to use to get information about the points ?
Thanks for replying. I had done what you mentioned above using a RectangularRegionSelectionHandler:
Code: Select all
RectangularRegionSelectionHandler selectionHandler = new RectangularRegionSelectionHandler();
selectionHandler.setModifier(InputEvent.SHIFT_MASK);
Do I have to override selectionHandler.mouseReleased() ? The documentation for mouseReleased() reads:
I tried adding the selectionHandler as a mouseHandler but I'm not sure that's the right thing to do:finishes the selection and calls the SelectionManager of the event source. The SelectionManager is then responsible for the processing of the geometric selection.
Code: Select all
chartPanel.addMouseHandler(selectionHandler);
Re: JFreeChart - Lasso to select multiple points ?
Hi David,
I have managed to get it working now. Thanks for all your guidance.
I have managed to get it working now. Thanks for all your guidance.
Re: JFreeChart - Lasso to select multiple points ?
Hi David,
I have managed to implement lasso selection of points. I have it set up using the Shift + mouse drag combination. However, I wish to have it just via mouse drag and have the ChartPanel's default Zoom occur via Shift+ mouse drag.
Can this be done ? I'm not sure whether we can override how the zoom() method of the ChartPanel is initiated. Kindly let me know what you think.
Thanks.
I have managed to implement lasso selection of points. I have it set up using the Shift + mouse drag combination. However, I wish to have it just via mouse drag and have the ChartPanel's default Zoom occur via Shift+ mouse drag.
Can this be done ? I'm not sure whether we can override how the zoom() method of the ChartPanel is initiated. Kindly let me know what you think.
Thanks.