[Schmitzm-commits] r503 - branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Oct 27 12:00:09 CET 2009
Author: mojays
Date: 2009-10-27 12:00:09 +0100 (Tue, 27 Oct 2009)
New Revision: 503
Modified:
branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionXYLineAndShapeRenderer.java
Log:
tests with MY OWN eclipse formatter :-)
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-27 10:24:18 UTC (rev 502)
+++ branches/1.0-gt2-2.6/src/schmitzm/jfree/chart/renderer/SelectionXYLineAndShapeRenderer.java 2009-10-27 11:00:09 UTC (rev 503)
@@ -53,41 +53,45 @@
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>
+ * 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.
+ * 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
+ * @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.
+ * renderers to the plot to draw only the selected data items
+ * highlighted.
*/
-public class SelectionXYLineAndShapeRenderer extends XYLineAndShapeRenderer implements SelectionRenderer<SeriesDatasetSelectionModel> {
+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. */
+ /**
+ * 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 (used for all series). */
- protected Map<Integer,Paint> selectionPaint = new HashMap<Integer, Paint>();
-
+ protected Map<Integer, Paint> selectionPaint = new HashMap<Integer, Paint>();
+
/** Holds the outline paint for selected items (used for all series). */
protected Paint selectionOutlinePaint = null;
-// /** Holds the selection {@link Stroke} (used for all series). */
-// protected Stroke selectionStroke = null;
+ // /** Holds the selection {@link Stroke} (used for all series). */
+ // protected Stroke selectionStroke = null;
/**
* Creates a new renderer.
@@ -99,79 +103,82 @@
/**
* 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
+ * @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.
+ * 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.
+ * 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.
+ * 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)
+ * 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();
+ XYPlot plot = getPlot();
XYDataset newDataset = (plot == null) ? null : plot.getDataset();
- if ( getSelectionModel() == null || getSelectionModel().getDataset() != newDataset )
- setSelectionModel( newDataset != null ? createSelectionModel(newDataset) : null );
+ 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}.
+ * 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);
+ 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
+ * 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.
+ * 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) {
@@ -179,49 +186,48 @@
}
/**
- * Returns the outline color for selected points. This paint is
- * used for all series.
+ * Returns the outline color for selected points. This paint is used for all
+ * series.
*/
@Override
public Paint getSelectionOutlinePaint() {
- return selectionOutlinePaint;
+ return selectionOutlinePaint;
}
-
+
/**
- * Sets the outline paint for selected points. This paint is
- * used for all series.
+ * Sets the outline paint for selected points. This paint is used for all
+ * series.
* @param paint a color
*/
@Override
public void setSelectionOutlinePaint(Paint paint) {
- selectionOutlinePaint = paint;
+ selectionOutlinePaint = paint;
}
-// /**
-// * Returns the {@link Stroke}, the selected data is rendered with.
-// * @return {@code null} if no special stroke is set (the base stroke
-// * should be used)
-// */
-// @Override
-// public Stroke getSelectionStroke() {
-// return selectionStroke;
-// }
-//
-// /**
-// * Sets the {@link Stroke}, the selected data is rendered with.
-// * @param stroke {@link Stroke} for the selected data (set to {@code null}
-// * if the base stroke should be used)
-// */
-// @Override
-// public void setSelectionStroke(Stroke stroke) {
-// this.selectionStroke = stroke;
-// }
+ // /**
+ // * Returns the {@link Stroke}, the selected data is rendered with.
+ // * @return {@code null} if no special stroke is set (the base stroke
+ // * should be used)
+ // */
+ // @Override
+ // public Stroke getSelectionStroke() {
+ // return selectionStroke;
+ // }
+ //
+ // /**
+ // * Sets the {@link Stroke}, the selected data is rendered with.
+ // * @param stroke {@link Stroke} for the selected data (set to {@code null}
+ // * if the base stroke should be used)
+ // */
+ // @Override
+ // public void setSelectionStroke(Stroke stroke) {
+ // this.selectionStroke = stroke;
+ // }
/**
* 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
+ * @return {@code null} if no selection color is defined for the series
*/
public Paint getSelectionPaint(int series) {
return selectionPaint.get(series);
@@ -235,11 +241,11 @@
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.
+ * 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) {
@@ -250,20 +256,13 @@
/**
* 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}).
+ * 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) {
+ 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);
@@ -272,28 +271,29 @@
// 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 ) {
+ if (getSelectionModel() != null) {
+ Paint selPaint = getSelectionPaint(series);
+ if (selPaint != null) {
Comparable seriesKey = dataset.getSeriesKey(series);
- if ( selectionModel.isItemSelected(seriesKey, item) ) {
- setSeriesPaint( series, selPaint, false );
+ if (selectionModel.isItemSelected(seriesKey, item)) {
+ setSeriesPaint(series, selPaint, false);
if (getSelectionOutlinePaint() != null)
- setSeriesOutlinePaint(series, selectionOutlinePaint, false );
-
+ setSeriesOutlinePaint(series, selectionOutlinePaint, false);
} else {
- setSeriesPaint( series, origPaint, false );
- setSeriesOutlinePaint(series, origOutlinePaint, false );
+ setSeriesPaint(series, origPaint, false);
+ setSeriesOutlinePaint(series, origOutlinePaint, false);
}
} else
- LOGGER.warn("No selection paint set for series "+series+". Series is rendererd normally.");
+ 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);
-
+ super.drawItem(g, state, dataArea, info, plot, domainAxis, rangeAxis,
+ dataset, series, item, crosshairState, pass);
+
// reset the original rendering color
- setSeriesPaint( series, origPaint, false );
+ setSeriesPaint(series, origPaint, false);
}
}
More information about the Schmitzm-commits
mailing list