[Schmitzm-commits] r133 - trunk/src/schmitzm/jfree
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat May 30 22:18:07 CEST 2009
Author: alfonx
Date: 2009-05-30 22:18:07 +0200 (Sat, 30 May 2009)
New Revision: 133
Modified:
trunk/src/schmitzm/jfree/JFreeChartUtil.java
Log:
/**
* @returns all {@link DatasetSelectionModel DatasetSelectionModels} that can be reached via the renderers of this chart.
*/
public static List<DatasetSelectionModel<?>> getDatasetSelectionModelFor(JFreeChart chart) {
ArrayList<DatasetSelectionModel<?>> renderers = new ArrayList<DatasetSelectionModel<?>>();
Modified: trunk/src/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/JFreeChartUtil.java 2009-05-30 20:02:25 UTC (rev 132)
+++ trunk/src/schmitzm/jfree/JFreeChartUtil.java 2009-05-30 20:18:07 UTC (rev 133)
@@ -24,6 +24,7 @@
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.labels.XYToolTipGenerator;
+import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
@@ -174,19 +175,27 @@
}
/**
- * Returns all Rednerer
- * @param chart
- * @return
+ * @returns all {@link DatasetSelectionModel DatasetSelectionModels} that can be reached via the renderers of this chart.
*/
public static List<DatasetSelectionModel<?>> getDatasetSelectionModelFor(JFreeChart chart) {
ArrayList<DatasetSelectionModel<?>> renderers = new ArrayList<DatasetSelectionModel<?>>();
- for (int i = 0; i < chart.getXYPlot().getRendererCount(); i++) {
- XYItemRenderer renderer = chart.getXYPlot().getRenderer(i);
- if (renderer instanceof DatasetSelectionModelProvider){
- renderers.add( ((DatasetSelectionModelProvider)renderer).getSelectionModel());
+
+ Plot plot = chart.getPlot();
+
+ if (plot instanceof XYPlot) {
+ XYPlot xyplot = (XYPlot)plot;
+
+ for (int i = 0; i < xyplot.getRendererCount(); i++) {
+ XYItemRenderer renderer = xyplot.getRenderer(i);
+ if (renderer instanceof DatasetSelectionModelProvider){
+ renderers.add( ((DatasetSelectionModelProvider)renderer).getSelectionModel());
+ }
}
}
+
+ // TODO Other types of Charts have the renderers hidden somewhere else.
+
return renderers;
}
More information about the Schmitzm-commits
mailing list