[Schmitzm-commits] r499 - branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Oct 25 14:26:55 CET 2009
Author: alfonx
Date: 2009-10-25 14:26:54 +0100 (Sun, 25 Oct 2009)
New Revision: 499
Modified:
branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/PointSelectionCategoryRenderer.java
branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionRenderer.java
branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionXYLineAndShapeRenderer.java
Log:
Added selectionOutlinePaint to the SelectionRenderer interface
Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/PointSelectionCategoryRenderer.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/PointSelectionCategoryRenderer.java 2009-10-25 13:18:01 UTC (rev 498)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/PointSelectionCategoryRenderer.java 2009-10-25 13:26:54 UTC (rev 499)
@@ -77,6 +77,8 @@
/** Holds the selection color for each series. */
protected Paint selectionPaint = null;
+
+private Paint selectionOutlinePaint;
/**
* Creates a new renderer.
@@ -93,6 +95,8 @@
protected void init() {
// set a default highlight color for the primary series
setSelectionPaint(Color.YELLOW);
+ setSelectionOutlinePaint(Color.RED);
+ setUseOutlinePaint(true);
}
/**
@@ -208,6 +212,11 @@
Comparable<?> itemKey = dataset.getColumnKey(column);
if ( selectionModel.isItemSelected(seriesKey, itemKey) ) {
setSeriesPaint( row, selPaint, false );
+
+ // Apply the selection outline color
+ if (getSelectionOutlinePaint() != null)
+ setSeriesOutlinePaint( row, getSelectionOutlinePaint(), false );
+
super.drawItem(g, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass);
}
} else
@@ -215,4 +224,14 @@
} else
LOGGER.debug("No selection model set for renderer. All series rendererd normally.");
}
+
+ @Override
+ public Paint getSelectionOutlinePaint() {
+ return selectionOutlinePaint;
+ }
+
+ @Override
+ public void setSelectionOutlinePaint(Paint paint) {
+ selectionOutlinePaint = paint;
+ }
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionRenderer.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionRenderer.java 2009-10-25 13:18:01 UTC (rev 498)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionRenderer.java 2009-10-25 13:26:54 UTC (rev 499)
@@ -45,10 +45,20 @@
* Returns the color, the selected data is rendered with.
*/
public Paint getSelectionPaint();
+ /**
+ * Returns the color, the selected data is outlined with.
+ */
+ public Paint getSelectionOutlinePaint();
/**
* Sets the color, the selected data is rendered with.
* @param paint color for the selected data
*/
public void setSelectionPaint(Paint paint);
+
+ /**
+ * Sets the color, the selected data is outlined with.
+ * @param paint color for the selected data
+ */
+ public void setSelectionOutlinePaint(Paint paint);
}
Modified: branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionXYLineAndShapeRenderer.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionXYLineAndShapeRenderer.java 2009-10-25 13:18:01 UTC (rev 498)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionXYLineAndShapeRenderer.java 2009-10-25 13:26:54 UTC (rev 499)
@@ -1,247 +1,292 @@
-/*******************************************************************************
- * Copyright (c) 2009 Martin O. J. Schmitz.
- *
- * This file is part of the SCHMITZM library - a collection of utility
- * classes based on Java 1.6, focusing (not only) on Java Swing
- * and the Geotools library.
- *
- * The SCHMITZM project is hosted at:
- * http://wald.intevation.org/projects/schmitzm/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License (license.txt)
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * or try this link: http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Martin O. J. Schmitz - initial API and implementation
- * Stefan A. Krüger - additional utility classes
- ******************************************************************************/
-package schmitzm.jfree.chart.renderer;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Paint;
-import java.awt.geom.Rectangle2D;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.jfree.chart.axis.ValueAxis;
-import org.jfree.chart.plot.CrosshairState;
-import org.jfree.chart.plot.Plot;
-import org.jfree.chart.plot.PlotRenderingInfo;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.xy.XYItemRendererState;
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
-import org.jfree.data.general.Dataset;
-import org.jfree.data.xy.XYDataset;
-
-import schmitzm.jfree.chart.SelectableChartPanel;
-import schmitzm.jfree.chart.selection.SeriesDatasetSelectionModel;
-import schmitzm.lang.LangUtil;
-
-/**
- * Extends the {@link XYLineAndShapeRenderer} with the
- * {@link SelectionRenderer} functionality. Additionally redefines
- * the {@link #drawItem(Graphics2D, XYItemRendererState, Rectangle2D, PlotRenderingInfo, XYPlot, ValueAxis, ValueAxis, XYDataset, int, int, CrosshairState, int)}
- * method to realize the highlight rendering of the selected
- * items.<br>
- * <b>Note:</b><br>
- * An adequate {@link SeriesDatasetSelectionModel} is automatically
- * created when a new {@link Plot} is set. Manually calling {@link #setSelectionModel(SeriesDatasetSelectionModel)}
- * is usually not necessary. Overwrite {@link #createAndSetSelectionModel()} to
- * avoid this behavior.<br>
- * If no selection model is set, the behavior of this renderer is exactly
- * like the super class.
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
- * @deprecated This class is not used anymore because the selection rendering
- * is no longer realized by the origin dataset renderer (e.g. because
- * the selected data items should be rendered in the foregound!).
- * Instead the {@link SelectableChartPanel} inserts explicit
- * renderers to the plot to draw only the selected data items highlighted.
- */
-public class SelectionXYLineAndShapeRenderer extends XYLineAndShapeRenderer implements SelectionRenderer<SeriesDatasetSelectionModel> {
- /** Used for log and debug messages. */
- protected Logger LOGGER = LangUtil.createLogger(this);
-
- /** Holds the selection model, the renderer uses to determine whether a
- * data item is selected or not. */
- protected SeriesDatasetSelectionModel selectionModel = null;
-
- /** Holds the selection color for each series. */
- protected Map<Integer,Paint> selectionPaint = new HashMap<Integer, Paint>();
-
- /**
- * Creates a new renderer.
- */
- public SelectionXYLineAndShapeRenderer() {
- super();
- init();
- }
-
- /**
- * Creates a new renderer.
- * @param lines indicates whether lines are rendered between the data points
- * @param shapes indicates whether shapes are rendered under the data line
- */
- public SelectionXYLineAndShapeRenderer(boolean lines, boolean shapes) {
- super(lines, shapes);
- init();
- }
-
- /**
- * Called by every constructor to initialize the extensions
- * of this renderer.
- */
- protected void init() {
- // set a default highlight color for the primary series
- setSelectionPaint(Color.YELLOW);
- }
-
- /**
- * Sets the selection model the renderer uses to determine whether
- * a data item is selected or not.
- * @param model the selection model
- */
- public void setSelectionModel(SeriesDatasetSelectionModel model) {
- this.selectionModel = model;
- }
-
- /**
- * Returns the selection model the renderer uses to determine whether
- * a data item is selected or not.
- */
- public SeriesDatasetSelectionModel getSelectionModel() {
- return selectionModel;
- }
-
- /**
- * Creates and sets an adequate {@link SeriesDatasetSelectionModel}
- * according to the {@link Dataset} of the current {@link Plot}. Automatically
- * called by {@link #setPlot(XYPlot)}.<br>
- * Sets the selection model to {@code null} if the renderer is not
- * connected to a plot or the plot contains no dataset.
- * @see #createSelectionModel(XYDataset)
- */
- public void createAndSetSelectionModel() {
- XYPlot plot = getPlot();
- XYDataset newDataset = (plot == null) ? null : plot.getDataset();
- if ( getSelectionModel() == null || getSelectionModel().getDataset() != newDataset )
- setSelectionModel( newDataset != null ? createSelectionModel(newDataset) : null );
- }
-
- /**
- * Creates an adequate {@link SeriesDatasetSelectionModel}
- * according to the given {@link Dataset}. Subclasses can overwrite this
- * method to create an alternative {@link SeriesDatasetSelectionModel}.
- */
- public SeriesDatasetSelectionModel createSelectionModel(Dataset dataset) {
- if ( !(dataset instanceof XYDataset) )
- throw new IllegalArgumentException(LangUtil.getSimpleClassName(this)+".createSelectionModel(.) can only be applied for XYDataset: "+LangUtil.getSimpleClassName(dataset));
- return new SeriesDatasetSelectionModel((XYDataset)dataset);
- }
-
- /**
- * Returns the color, the selected data <b>of the primary series</b>
- * is rendered with.
- * @return {@code null} if no selection color is defined
- * for the series
- */
- public Paint getSelectionPaint() {
- return getSelectionPaint(0);
- }
-
- /**
- * Sets the color, the selected data <b>of the primary series</b>
- * is rendered with.
- * @param paint color for the selected data
- */
- public void setSelectionPaint(Paint paint) {
- setSelectionPaint(0, paint);
- }
-
- /**
- * Returns the color, the selected data is rendered with.
- * @param series the data series
- * @return {@code null} if no selection color is defined
- * for the series
- */
- public Paint getSelectionPaint(int series) {
- return selectionPaint.get(series);
- }
-
- /**
- * Sets the color, the selected data is rendered with.
- * @param series the data series
- * @param paint color for the selected data
- */
- public void setSelectionPaint(int series, Paint paint) {
- selectionPaint.put(series, paint);
- }
-
- /**
- * Creates and sets a new {@link SeriesDatasetSelectionModel}, if no selection model
- * is set yet, or the selection model's dataset differs from the dataset of the
- * new plot.
- * @param plot the plot rendered by this renderer
- */
- public void setPlot(XYPlot plot) {
- super.setPlot(plot);
- createAndSetSelectionModel();
- }
-
- /**
- * Sets the rendering color (temporary for the rendering process) to the
- * {@linkplain #getSelectionPaint(int) highlight color}, if the item is
- * defined as selected (by the {@linkplain #getSelectionModel() selection model}).
- */
- public void drawItem(Graphics2D g,
- XYItemRendererState state,
- Rectangle2D dataArea,
- PlotRenderingInfo info,
- XYPlot plot,
- ValueAxis domainAxis,
- ValueAxis rangeAxis,
- XYDataset dataset,
- int series,
- int item,
- CrosshairState crosshairState,
- int pass) {
-
- // Save the normal rendering color
- Paint origPaint = getSeriesPaint(series);
-
- // if selection model and color is set and the item is selected
- // the highlighting selection color is (temporary) set for the
- // rendering process
- if ( getSelectionModel() != null ) {
- Paint selPaint = getSelectionPaint(series);
- if ( selPaint != null ) {
- Comparable seriesKey = dataset.getSeriesKey(series);
- if ( selectionModel.isItemSelected(seriesKey, item) )
- setSeriesPaint( series, selPaint, false );
- else
- setSeriesPaint( series, origPaint, false );
- } else
- LOGGER.warn("No selection paint set for series "+series+". Series is rendererd normally.");
- } else
- LOGGER.debug("No selection model set for renderer. All series rendererd normally.");
-
- // rendering
- super.drawItem(g, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass);
-
- // reset the original rendering color
- setSeriesPaint( series, origPaint, false );
- }
-}
+///*******************************************************************************
+// * Copyright (c) 2009 Martin O. J. Schmitz.
+// *
+// * This file is part of the SCHMITZM library - a collection of utility
+// * classes based on Java 1.6, focusing (not only) on Java Swing
+// * and the Geotools library.
+// *
+// * The SCHMITZM project is hosted at:
+// * http://wald.intevation.org/projects/schmitzm/
+// *
+// * This program is free software; you can redistribute it and/or
+// * modify it under the terms of the GNU Lesser General Public License
+// * as published by the Free Software Foundation; either version 3
+// * of the License, or (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU Lesser General Public License (license.txt)
+// * along with this program; if not, write to the Free Software
+// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+// * or try this link: http://www.gnu.org/licenses/lgpl.html
+// *
+// * Contributors:
+// * Martin O. J. Schmitz - initial API and implementation
+// * Stefan A. Krüger - additional utility classes
+// ******************************************************************************/
+//package schmitzm.jfree.chart.renderer;
+//
+//import java.awt.Color;
+//import java.awt.Graphics2D;
+//import java.awt.Paint;
+//import java.awt.geom.Rectangle2D;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//import org.apache.log4j.Logger;
+//import org.jfree.chart.axis.ValueAxis;
+//import org.jfree.chart.plot.CrosshairState;
+//import org.jfree.chart.plot.Plot;
+//import org.jfree.chart.plot.PlotRenderingInfo;
+//import org.jfree.chart.plot.XYPlot;
+//import org.jfree.chart.renderer.xy.XYItemRendererState;
+//import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
+//import org.jfree.data.general.Dataset;
+//import org.jfree.data.xy.XYDataset;
+//
+//import schmitzm.jfree.chart.SelectableChartPanel;
+//import schmitzm.jfree.chart.selection.SeriesDatasetSelectionModel;
+//import schmitzm.lang.LangUtil;
+//
+///**
+// * Extends the {@link XYLineAndShapeRenderer} with the {@link SelectionRenderer}
+// * functionality. Additionally redefines the
+// * {@link #drawItem(Graphics2D, XYItemRendererState, Rectangle2D, PlotRenderingInfo, XYPlot, ValueAxis, ValueAxis, XYDataset, int, int, CrosshairState, int)}
+// * method to realize the highlight rendering of the selected items.<br>
+// * <b>Note:</b><br>
+// * An adequate {@link SeriesDatasetSelectionModel} is automatically created when
+// * a new {@link Plot} is set. Manually calling
+// * {@link #setSelectionModel(SeriesDatasetSelectionModel)} is usually not
+// * necessary. Overwrite {@link #createAndSetSelectionModel()} to avoid this
+// * behavior.<br>
+// * If no selection model is set, the behavior of this renderer is exactly like
+// * the super class.
+// *
+// * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+// * @deprecated This class is not used anymore because the selection rendering is
+// * no longer realized by the origin dataset renderer (e.g. because
+// * the selected data items should be rendered in the foregound!).
+// * Instead the {@link SelectableChartPanel} inserts explicit
+// * renderers to the plot to draw only the selected data items
+// * highlighted.
+// */
+//public class SelectionXYLineAndShapeRenderer extends XYLineAndShapeRenderer
+// implements SelectionRenderer<SeriesDatasetSelectionModel> {
+// /** Used for log and debug messages. */
+// protected Logger LOGGER = LangUtil.createLogger(this);
+//
+// /**
+// * Holds the selection model, the renderer uses to determine whether a data
+// * item is selected or not.
+// */
+// protected SeriesDatasetSelectionModel selectionModel = null;
+//
+// /** Holds the selection color for each series. */
+// protected Map<Integer, Paint> selectionPaint = new HashMap<Integer, Paint>();
+// /**
+// * Returns the color, the selected data is rendered with.
+// *
+// * @param series
+// * the data series
+// * @return {@code null} if no selection color is defined for the series
+// */
+// public Paint getSelectionOutlinePaint(int series) {
+// return selectionPaint.get(series);
+// }
+//
+// /**
+// * Creates a new renderer.
+// */
+// public SelectionXYLineAndShapeRenderer() {
+// super();
+// init();
+// }
+//
+// /**
+// * Creates a new renderer.
+// *
+// * @param lines
+// * indicates whether lines are rendered between the data points
+// * @param shapes
+// * indicates whether shapes are rendered under the data line
+// */
+// public SelectionXYLineAndShapeRenderer(boolean lines, boolean shapes) {
+// super(lines, shapes);
+// init();
+// }
+//
+// /**
+// * Called by every constructor to initialize the extensions of this
+// * renderer.
+// */
+// protected void init() {
+// // set a default highlight color for the primary series
+// setUseOutlinePaint(true);
+// setSelectionPaint(Color.YELLOW);
+// setSelectionOutlinePaint(Color.RED);
+// }
+//
+// /**
+// * Sets the selection model the renderer uses to determine whether a data
+// * item is selected or not.
+// *
+// * @param model
+// * the selection model
+// */
+// public void setSelectionModel(SeriesDatasetSelectionModel model) {
+// this.selectionModel = model;
+// }
+//
+// /**
+// * Returns the selection model the renderer uses to determine whether a data
+// * item is selected or not.
+// */
+// public SeriesDatasetSelectionModel getSelectionModel() {
+// return selectionModel;
+// }
+//
+// /**
+// * Creates and sets an adequate {@link SeriesDatasetSelectionModel}
+// * according to the {@link Dataset} of the current {@link Plot}.
+// * Automatically called by {@link #setPlot(XYPlot)}.<br>
+// * Sets the selection model to {@code null} if the renderer is not connected
+// * to a plot or the plot contains no dataset.
+// *
+// * @see #createSelectionModel(XYDataset)
+// */
+// public void createAndSetSelectionModel() {
+// XYPlot plot = getPlot();
+// XYDataset newDataset = (plot == null) ? null : plot.getDataset();
+// if (getSelectionModel() == null
+// || getSelectionModel().getDataset() != newDataset)
+// setSelectionModel(newDataset != null ? createSelectionModel(newDataset)
+// : null);
+// }
+//
+// /**
+// * Creates an adequate {@link SeriesDatasetSelectionModel} according to the
+// * given {@link Dataset}. Subclasses can overwrite this method to create an
+// * alternative {@link SeriesDatasetSelectionModel}.
+// */
+// public SeriesDatasetSelectionModel createSelectionModel(Dataset dataset) {
+// if (!(dataset instanceof XYDataset))
+// throw new IllegalArgumentException(
+// LangUtil.getSimpleClassName(this)
+// + ".createSelectionModel(.) can only be applied for XYDataset: "
+// + LangUtil.getSimpleClassName(dataset));
+// return new SeriesDatasetSelectionModel((XYDataset) dataset);
+// }
+//
+// /**
+// * Returns the color, the selected data <b>of the primary series</b> is
+// * rendered with.
+// *
+// * @return {@code null} if no selection color is defined for the series
+// */
+// public Paint getSelectionPaint() {
+// return getSelectionPaint(0);
+// }
+//
+// /**
+// * Sets the color, the selected data <b>of the primary series</b> is
+// * rendered with.
+// *
+// * @param paint
+// * color for the selected data
+// */
+// public void setSelectionPaint(Paint paint) {
+// setSelectionPaint(0, paint);
+// }
+//
+// /**
+// * Returns the color, the selected data is rendered with.
+// *
+// * @param series
+// * the data series
+// * @return {@code null} if no selection color is defined for the series
+// */
+// public Paint getSelectionPaint(int series) {
+// return selectionPaint.get(series);
+// }
+//
+// /**
+// * Sets the color, the selected data is rendered with.
+// *
+// * @param series
+// * the data series
+// * @param paint
+// * color for the selected data
+// */
+// public void setSelectionPaint(int series, Paint paint) {
+// selectionPaint.put(series, paint);
+// }
+//
+// /**
+// * Creates and sets a new {@link SeriesDatasetSelectionModel}, if no
+// * selection model is set yet, or the selection model's dataset differs from
+// * the dataset of the new plot.
+// *
+// * @param plot
+// * the plot rendered by this renderer
+// */
+// public void setPlot(XYPlot plot) {
+// super.setPlot(plot);
+// createAndSetSelectionModel();
+// }
+//
+// /**
+// * Sets the rendering color (temporary for the rendering process) to the
+// * {@linkplain #getSelectionPaint(int) highlight color}, if the item is
+// * defined as selected (by the {@linkplain #getSelectionModel() selection
+// * model}).
+// */
+// public void drawItem(Graphics2D g, XYItemRendererState state,
+// Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
+// ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
+// int series, int item, CrosshairState crosshairState, int pass) {
+//
+// // Save the normal rendering color
+// Paint origPaint = getSeriesPaint(series);
+//
+// // if selection model and color is set and the item is selected
+// // the highlighting selection color is (temporary) set for the
+// // rendering process
+// if (getSelectionModel() != null) {
+// Paint selPaint = getSelectionPaint(series);
+// if (selPaint != null) {
+// Comparable seriesKey = dataset.getSeriesKey(series);
+// if (selectionModel.isItemSelected(seriesKey, item))
+// setSeriesPaint(series, selPaint, false);
+// else
+// setSeriesPaint(series, origPaint, false);
+// } else
+// LOGGER.warn("No selection paint set for series " + series
+// + ". Series is rendererd normally.");
+// } else
+// LOGGER
+// .debug("No selection model set for renderer. All series rendererd normally.");
+//
+// // rendering
+// super.drawItem(g, state, dataArea, info, plot, domainAxis, rangeAxis,
+// dataset, series, item, crosshairState, pass);
+//
+// // reset the original rendering color
+// setSeriesPaint(series, origPaint, false);
+// }
+//
+// @Override
+// public Paint getSelectionOutlinePaint() {
+// return getSeriesOutlinePaint(0);
+// }
+//
+// @Override
+// public void setSelectionOutlinePaint(Paint paint) {
+// setSeriesOutlinePaint(0, paint);
+// }
+//
+//
+//
+//}
More information about the Schmitzm-commits
mailing list