[Schmitzm-commits] r1801 - in trunk: schmitzm-core/src/main/java/de/schmitzm/swing/table schmitzm-core/src/main/java/de/schmitzm/temp schmitzm-jfree/src/main/java/de/schmitzm/jfree schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Dec 2 12:58:29 CET 2011
Author: mojays
Date: 2011-12-02 12:58:28 +0100 (Fri, 02 Dec 2011)
New Revision: 1801
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/AbstractTableModel.java
trunk/schmitzm-core/src/main/java/de/schmitzm/temp/BaseTypeUtil.java
trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java
trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/StyledToolTipGenerator.java
trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java
Log:
AbstractTableModel: new method to update table/column structure
ChartAxisStyle: Bugfix for applying axis label angle (must be applied as radian)
JFreeChartUtil: new method to determine plot for dataset, handle situations in that main plot is a combined plot
StyledToolTipGenerator: instead using main plot, determine plot by new JFreeChartUtil method to deal with combined plots
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/AbstractTableModel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/AbstractTableModel.java 2011-12-01 18:03:32 UTC (rev 1800)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/AbstractTableModel.java 2011-12-02 11:58:28 UTC (rev 1801)
@@ -44,6 +44,15 @@
protected String[] colNames = createColumnNames();
/**
+ * Ruft {@link #createColumnNames()} auf und anschliessend
+ * {@link #fireTableStructureChanged()}.
+ */
+ protected void updateColumnStructure() {
+ colNames = createColumnNames();
+ fireTableStructureChanged();
+ }
+
+ /**
* Liefert die Anzahl an Spalten.
* @param col Spaltenindex (beginnend bei 0)
*/
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/temp/BaseTypeUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/temp/BaseTypeUtil.java 2011-12-01 18:03:32 UTC (rev 1800)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/temp/BaseTypeUtil.java 2011-12-02 11:58:28 UTC (rev 1801)
@@ -455,7 +455,7 @@
* @param destType
* Typ, in den das Objekt umgewandelt wird
*/
- public static Object convertNumber(Number source, Class<Number> destType) {
+ public static Object convertNumber(Number source, Class<? extends Number> destType) {
if (Double.class.equals(destType))
return source.doubleValue();
if (Float.class.equals(destType))
Modified: trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java 2011-12-01 18:03:32 UTC (rev 1800)
+++ trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/JFreeChartUtil.java 2011-12-02 11:58:28 UTC (rev 1801)
@@ -35,6 +35,7 @@
import java.awt.Stroke;
import java.text.DecimalFormat;
import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -57,6 +58,7 @@
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.labels.XYToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.CombinedDomainXYPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
@@ -575,12 +577,12 @@
*/
public static ValueAxis getRangeAxisForDataset(Plot plot, Dataset dataset) {
int idx = getDatasetIndex(plot, dataset);
-
- if ( plot instanceof XYPlot )
- return ((XYPlot)plot).getRangeAxisForDataset(idx);
- if ( plot instanceof CategoryPlot )
- return ((CategoryPlot)plot).getRangeAxisForDataset(idx);
-
+ if ( idx >= 0 ) {
+ if ( plot instanceof XYPlot )
+ return ((XYPlot)plot).getRangeAxisForDataset(idx);
+ if ( plot instanceof CategoryPlot )
+ return ((CategoryPlot)plot).getRangeAxisForDataset(idx);
+ }
LOGGER.warn("Could not determine range axis for plot: "+LangUtil.getSimpleClassName(plot));
return null;
}
@@ -783,7 +785,31 @@
return renderer;
}
- /**
+ /**
+ * Returns the plot from chart where a special dataset is rendered in.
+ * Normally all datasets are rendered in the same plot, so simply
+ * calling {@link JFreeChart#getPlot()} will suffice.<br>
+ * But this method also handles the case that this plot is a
+ * combined plot! In this case the SUB-PLOT is returned which
+ * renderes the dataset.
+ *
+ * @param chart
+ * a chart
+ * @param dataset
+ * the dataset the plot is returned for
+ */
+ public static Plot getPlotForDataset(JFreeChart chart, Dataset dataset) {
+ Plot plot = chart.getPlot();
+ if ( plot instanceof CombinedDomainXYPlot ) {
+ List<XYPlot> plots = ((CombinedDomainXYPlot)plot).getSubplots();
+ for(XYPlot p : plots)
+ if ( p.getRendererForDataset((XYDataset)dataset) != null )
+ return p;
+ }
+ return plot;
+ }
+
+ /**
* Returns a series from a dataset. If no series exists a new one is created.
* @param dataset the dataset
* @param seriesKey the key to return the series for
@@ -829,6 +855,10 @@
*/
public static SelectionRenderer<?> getSelectionRendererForDataset(
Plot plot, Dataset dataset) {
+// if (plot instanceof CombinedDomainXYPlot ) {
+//
+// }
+
if (plot instanceof XYPlot) {
XYPlot xyPlot = (XYPlot) plot;
for (int i = 0; i < xyPlot.getDatasetCount(); i++) {
Modified: trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/StyledToolTipGenerator.java
===================================================================
--- trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/StyledToolTipGenerator.java 2011-12-01 18:03:32 UTC (rev 1800)
+++ trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/StyledToolTipGenerator.java 2011-12-02 11:58:28 UTC (rev 1801)
@@ -138,7 +138,9 @@
*/
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
- XYPlot plot = chart.getXYPlot();
+// MS-20111202: handle combined plots!
+// XYPlot plot = chart.getXYPlot();
+ XYPlot plot = (XYPlot)JFreeChartUtil.getPlotForDataset(chart, dataset);
XYItemRenderer rend = (XYItemRenderer)plot.getRendererForDataset(dataset);
ValueAxis rangeAxis = JFreeChartUtil.getRangeAxisForDataset(plot, dataset);
Modified: trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java
===================================================================
--- trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java 2011-12-01 18:03:32 UTC (rev 1800)
+++ trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java 2011-12-02 11:58:28 UTC (rev 1801)
@@ -161,8 +161,8 @@
/**
* Sets the angle (in degrees) the label text is rotated by.
*
- * @param color
- * Color for the label text
+ * @param angle
+ * Angle for the label text
*/
public void setLabelAngle(Double angle) {
this.angleDegr = angle;
@@ -295,7 +295,7 @@
if (getPaint() != null)
axis.setLabelPaint(getPaint());
if (getLabelAngle() != null)
- axis.setLabelAngle(getLabelAngle());
+ axis.setLabelAngle(getLabelAngleRadian());
if (getLabelFont() != null)
axis.setLabelFont(getLabelFont());
if (getValuesFont() != null)
More information about the Schmitzm-commits
mailing list