[Schmitzm-commits] r1839 - in trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree: . chart

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 25 19:26:41 CET 2012


Author: mojays
Date: 2012-01-25 19:26:40 +0100 (Wed, 25 Jan 2012)
New Revision: 1839

Modified:
   trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java
   trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/SelectableChartPanel.java
Log:
Some handling for combined charts.

Modified: trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java	2012-01-24 21:11:53 UTC (rev 1838)
+++ trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java	2012-01-25 18:26:40 UTC (rev 1839)
@@ -58,7 +58,10 @@
 import org.jfree.chart.labels.StandardXYToolTipGenerator;
 import org.jfree.chart.labels.XYToolTipGenerator;
 import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.CombinedDomainCategoryPlot;
 import org.jfree.chart.plot.CombinedDomainXYPlot;
+import org.jfree.chart.plot.CombinedRangeCategoryPlot;
+import org.jfree.chart.plot.CombinedRangeXYPlot;
 import org.jfree.chart.plot.PiePlot;
 import org.jfree.chart.plot.Plot;
 import org.jfree.chart.plot.PlotOrientation;
@@ -855,9 +858,42 @@
 	 */
 	public static SelectionRenderer<?> getSelectionRendererForDataset(
 			Plot plot, Dataset dataset) {
-//	    if (plot instanceof CombinedDomainXYPlot ) {
-//	      
-//	    }
+      if ( plot instanceof CombinedRangeXYPlot ) {
+        for (Object p : ((CombinedRangeXYPlot)plot).getSubplots()) {
+          SelectionRenderer<?> r = getSelectionRendererForDataset((Plot)p,dataset);
+          if ( r != null )
+            return r;
+        }
+        return null;
+      }
+      
+      if ( plot instanceof CombinedRangeCategoryPlot ) {
+        for (Object p : ((CombinedRangeCategoryPlot)plot).getSubplots()) {
+          SelectionRenderer<?> r = getSelectionRendererForDataset((Plot)p,dataset);
+          if ( r != null )
+            return r;
+        }
+        return null;
+      }
+
+      if ( plot instanceof CombinedDomainXYPlot ) {
+        for (Object p : ((CombinedDomainXYPlot)plot).getSubplots()) {
+          SelectionRenderer<?> r = getSelectionRendererForDataset((Plot)p,dataset);
+          if ( r != null )
+            return r;
+        }
+        return null;
+      }
+
+      if ( plot instanceof CombinedDomainCategoryPlot ) {
+        for (Object p : ((CombinedDomainCategoryPlot)plot).getSubplots()) {
+          SelectionRenderer<?> r = getSelectionRendererForDataset((Plot)p,dataset);
+          if ( r != null )
+            return r;
+        }
+        return null;
+      }
+
 	  
 		if (plot instanceof XYPlot) {
 			XYPlot xyPlot = (XYPlot) plot;
@@ -927,6 +963,30 @@
 			Plot plot) {
 		Map<Integer, SelectionRenderer<?>> selRenderer = new HashMap<Integer, SelectionRenderer<?>>();
 
+	      if ( plot instanceof CombinedRangeXYPlot ) {
+	        for (Object p : ((CombinedRangeXYPlot)plot).getSubplots())
+	          selRenderer.putAll( getSelectionRenderer((Plot)p) );
+	        return selRenderer;
+	      }
+	      
+	      if ( plot instanceof CombinedRangeCategoryPlot ) {
+            for (Object p : ((CombinedRangeCategoryPlot)plot).getSubplots())
+              selRenderer.putAll( getSelectionRenderer((Plot)p) );
+            return selRenderer;
+	      }
+
+	      if ( plot instanceof CombinedDomainXYPlot ) {
+            for (Object p : ((CombinedDomainXYPlot)plot).getSubplots())
+              selRenderer.putAll( getSelectionRenderer((Plot)p) );
+            return selRenderer;
+	      }
+
+	      if ( plot instanceof CombinedDomainCategoryPlot ) {
+            for (Object p : ((CombinedDomainCategoryPlot)plot).getSubplots())
+              selRenderer.putAll( getSelectionRenderer((Plot)p) );
+            return selRenderer;
+	      }
+
 		if (plot instanceof XYPlot) {
 			XYPlot xyPlot = (XYPlot) plot;
 			for (int i = 0; i < xyPlot.getRendererCount(); i++) {

Modified: trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/SelectableChartPanel.java
===================================================================
--- trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/SelectableChartPanel.java	2012-01-24 21:11:53 UTC (rev 1838)
+++ trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/SelectableChartPanel.java	2012-01-25 18:26:40 UTC (rev 1839)
@@ -45,6 +45,10 @@
 import org.jfree.chart.event.ChartChangeEvent;
 import org.jfree.chart.event.ChartChangeEventType;
 import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.CombinedDomainCategoryPlot;
+import org.jfree.chart.plot.CombinedDomainXYPlot;
+import org.jfree.chart.plot.CombinedRangeCategoryPlot;
+import org.jfree.chart.plot.CombinedRangeXYPlot;
 import org.jfree.chart.plot.DatasetRenderingOrder;
 import org.jfree.chart.plot.Plot;
 import org.jfree.chart.plot.XYPlot;
@@ -325,14 +329,37 @@
 		  selectionTracker.setEnabled(windowSelectionMode != WindowSelectionMode.ZOOM_IN_CHART);
 	}
 	
+    /**
+     * This methods creates a {@link SelectionRenderer} for each {@link Dataset}
+     * in the plot to realize the highlight of the selected items.
+     */
+    protected void updateSelectionRenderers() {
+      if ( getChart() == null || getChart().getPlot() == null )
+        return;
+      Plot plot = getChart().getPlot();
+      if ( plot instanceof CombinedRangeXYPlot )
+        for (Object p : ((CombinedRangeXYPlot)plot).getSubplots())
+          updateSelectionRenderers((Plot)p);
+      else if ( plot instanceof CombinedRangeCategoryPlot )
+        for (Object p : ((CombinedRangeCategoryPlot)plot).getSubplots())
+          updateSelectionRenderers((Plot)p);
+      else if ( plot instanceof CombinedDomainXYPlot )
+        for (Object p : ((CombinedDomainXYPlot)plot).getSubplots())
+          updateSelectionRenderers((Plot)p);
+      else if ( plot instanceof CombinedDomainCategoryPlot )
+        for (Object p : ((CombinedDomainCategoryPlot)plot).getSubplots())
+          updateSelectionRenderers((Plot)p);
+      else 
+        updateSelectionRenderers(plot);
+    }
+    
 	/**
 	 * This methods creates a {@link SelectionRenderer} for each {@link Dataset}
 	 * in the plot to realize the highlight of the selected items.
 	 */
-	protected void updateSelectionRenderers() {
-	  if ( getChart() == null || getChart().getPlot() == null )
+	protected void updateSelectionRenderers(Plot plot) {
+	  if ( plot == null )
 	    return;
-	  Plot plot = getChart().getPlot();
 	  
 	  if ( plot instanceof XYPlot ) {
         XYPlot xyPlot = (XYPlot)plot;



More information about the Schmitzm-commits mailing list