Package com.positive.charts.renderer

Source Code of com.positive.charts.renderer.AbstractRenderer

package com.positive.charts.renderer;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.eclipse.core.runtime.ListenerList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;

import com.positive.charts.event.RendererChangeEvent;
import com.positive.charts.event.RendererChangeListener;
import com.positive.charts.labels.ItemLabelAnchor;
import com.positive.charts.labels.ItemLabelPosition;
import com.positive.charts.plot.DrawingSupplier;
import com.positive.charts.plot.Plot;
import com.positive.charts.plot.PlotOrientation;
import com.positive.charts.util.DrawingAssets;
import com.positive.charts.util.Stroke;
import com.positive.charts.util.TextAnchor;
import com.positive.colorchecker.StaticColorChecker;

/**
* Base class providing common services for renderers. Most methods that update
* attributes of the renderer will fire a {@link RendererChangeEvent}, which
* normally means the plot that owns the renderer will receive notification that
* the renderer has been changed (the plot will, in turn, notify the chart).
*/
public abstract class AbstractRenderer implements ChartRenderer {

  /** A useful constant. */
  public static final Double ZERO = new Double(0.0);

  private Rectangle shape;

  private Rectangle baseShape;

  /** A flag that controls the visibility of ALL series. */
  private Boolean seriesVisible = null;

  /** A map of flags between series index and its visibility. */
  private final Map seriesVisibleList;

  /** The default visibility for each series. */
  private boolean baseSeriesVisible = true;

  /** A flag that controls the visibility of ALL series in the legend. */
  private Boolean seriesVisibleInLegend = Boolean.TRUE;

  /**
   * A list of flags that controls whether or not each series is visible in
   * the legend.
   */
  private final List seriesVisibleInLegendList;

  /** The default visibility for each series in the legend. */
  private boolean baseSeriesVisibleInLegend = true;

  /** Visibility of the item labels for ALL series (optional). */
  private Boolean itemLabelsVisible = Boolean.FALSE;

  /** Visibility of the item labels PER series. */
  private final List itemLabelsVisibleList;

  /** The base item labels visible. */
  private boolean baseItemLabelsVisible = false;

  /** The item label font for ALL series (optional). */
  private Font itemLabelFont = null;

  /** The item label font list (one font per series). */
  private final ArrayList itemLabelFontList;

  /** The base item label font. */
  private Font baseItemLabelFont;

  /** The positive item label position for ALL series (optional). */
  private ItemLabelPosition positiveItemLabelPosition = null;

  /** The positive item label position (per series). */
  private final List positiveItemLabelPositionList;

  /** The fallback positive item label position. */
  private ItemLabelPosition basePositiveItemLabelPosition;

  /** The negative item label position for ALL series (optional). */
  private ItemLabelPosition negativeItemLabelPosition = null;

  /** The negative item label position (per series). */
  private final List negativeItemLabelPositionList;

  /** The fallback negative item label position. */
  private ItemLabelPosition baseNegativeItemLabelPosition;

  /** The item label anchor offset. */
  public int itemLabelAnchorOffset = 2;

  /**
   * Storage for series colors, used for draw operation (opposite to fill
   * operations). Should not be disposed.
   */
  private final Map paintMap;

  /** Storage for series strokes. */
  private final Map strokeMap;

  /** Storage for series strokes. */
  private final Map outlineStrokeMap;

  private final Map fillPaintMap;

  /** The outline paint list. */
  private final Map outlinePaintMap;

  private final Map shapeMap;

  private final Map itemLabelPaintMap;

  /**
   * A flag that controls whether or not entities are generated for ALL series
   * (optional).
   */
  private Boolean createEntities = null;

  /**
   * Flags that control whether or not entities are generated for each series.
   * This will be overridden by 'createEntities'.
   */
  private final List createEntitiesList;

  /**
   * The default flag that controls whether or not entities are generated.
   * This flag is used when both the above flags return null.
   */
  private boolean baseCreateEntities = true;

  /** Storage for registered change listeners. */
  private transient final ListenerList listenerList;

  /**
   * Default constructor.
   */
  public AbstractRenderer() {
    this.seriesVisibleList = new TreeMap();
    this.seriesVisibleInLegendList = new ArrayList();
    this.itemLabelsVisibleList = new ArrayList();
    this.itemLabelFontList = new ArrayList();

    this.positiveItemLabelPositionList = new ArrayList();
    this.basePositiveItemLabelPosition = new ItemLabelPosition(
        ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);

    this.negativeItemLabelPositionList = new ArrayList();
    this.baseNegativeItemLabelPosition = new ItemLabelPosition(
        ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);

    this.createEntitiesList = new ArrayList();

    this.paintMap = new TreeMap();
    this.fillPaintMap = new TreeMap();
    this.strokeMap = new TreeMap();
    this.outlineStrokeMap = new TreeMap();
    this.outlinePaintMap = new TreeMap();
    this.shapeMap = new TreeMap();
    this.itemLabelPaintMap = new TreeMap();

    this.listenerList = new ListenerList();
  }

  /**
   * Registers an object to receive notification of changes to the renderer.
   *
   * @param listener
   *            the listener (<code>null</code> not permitted).
   */
  public void addChangeListener(final RendererChangeListener listener) {
    if (listener == null) {
      throw new IllegalArgumentException("Null 'listener' argument.");
    }
    this.listenerList.add(listener);
  }

  /**
   * Calculates the item label anchor point.
   *
   * @param anchor
   *            the anchor.
   * @param x
   *            the x coordinate.
   * @param y
   *            the y coordinate.
   * @param orientation
   *            the plot orientation.
   *
   * @return The anchor point (never <code>null</code>).
   */
  protected Point calculateLabelAnchorPoint(final ItemLabelAnchor anchor,
      final int x, final int y, final PlotOrientation orientation) {
    return anchor.calculateLabelAnchorPoint(this.itemLabelAnchorOffset, x,
        y);
  }

  // SERIES VISIBLE (not yet respected by all renderers)

  public void clearSeriesVisible() {
    this.seriesVisibleList.clear();
  }

  /**
   * Returns the base visibility for all series.
   *
   * @return The base visibility.
   */
  public boolean getBaseCreateEntities() {
    return this.baseCreateEntities;
  }

  /**
   * Returns the base fill paint.
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getBaseFillPaint() {
    return this.getDrawingAssets().getColor(Plot.COLOR_SERIES_FILL_BASE);
  }

  /**
   * Returns the base item label font (this is used when no other font setting
   * is available).
   *
   * @return The font (<code>never</code> null).
   */
  public Font getBaseItemLabelFont() {
    return this.baseItemLabelFont;
  }

  /**
   * Returns the base item label paint.
   *
   * @return The paint (never <code>null<code>).
   */
  public Color getBaseItemLabelPaint() {
    return this.getDrawingAssets().getColor(Plot.COLOR_ITEM_LABEL_BASE);
  }

  /**
   * Returns the base setting for item label visibility.
   *
   * @return A flag.
   */
  public Boolean getBaseItemLabelsVisible() {
    return Boolean.valueOf(this.baseItemLabelsVisible);
  }

  /**
   * Returns the base item label position for negative values.
   *
   * @return The position (never <code>null</code>).
   */
  public ItemLabelPosition getBaseNegativeItemLabelPosition() {
    return this.baseNegativeItemLabelPosition;
  }

  /**
   * Returns the base outline paint.
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getBaseOutlinePaint() {
    return this.getDrawingAssets().getColor(Plot.COLOR_SERIES_OUTLINE_BASE);
  }

  /**
   * Returns the base outline stroke.
   *
   * @return The stroke (never <code>null</code>).
   */
  public Stroke getBaseOutlineStroke() {
    return this.getDrawingAssets().getStroke(
        Plot.STROKE_SERIES_OUTLINE_BASE);
  }

  /**
   * Returns the base paint.
   *
   * @return The base paint (never <code>null</code>).
   */
  public Color getBasePaint() {
    return this.getDrawingAssets().getColor(Plot.COLOR_SERIES_BASE);
  }

  /**
   * Returns the base positive item label position.
   *
   * @return The position (never <code>null</code>).
   */
  public ItemLabelPosition getBasePositiveItemLabelPosition() {
    return this.basePositiveItemLabelPosition;
  }

  /**
   * Returns the base visibility for all series.
   *
   * @return The base visibility.
   */
  public boolean getBaseSeriesVisible() {
    return this.baseSeriesVisible;
  }

  // SERIES VISIBLE IN LEGEND (not yet respected by all renderers)

  /**
   * Returns the base visibility in the legend for all series.
   *
   * @return The base visibility.
   */
  public boolean getBaseSeriesVisibleInLegend() {
    return this.baseSeriesVisibleInLegend;
  }

  /**
   * Returns the base shape.
   *
   * @return The shape (never <code>null</code>).
   */
  public Rectangle getBaseShape() {
    return this.baseShape;
  }

  /**
   * Returns the base stroke.
   *
   * @return The base stroke (never <code>null</code>).
   */
  public Stroke getBaseStroke() {
    return this.getDrawingAssets().getStroke(Plot.STROKE_SERIES_BASE);
  }

  /**
   * Returns the flag that controls whether or not chart entities are created
   * for the items in ALL series. This flag overrides the per series and
   * default settings - you must set it to <code>null</code> if you want the
   * other settings to apply.
   *
   * @return The flag (possibly <code>null</code>).
   */
  public Boolean getCreateEntities() {
    return this.createEntities;
  }

  /**
   * Returns the drawing assets from the plot. Subclasses must implement this
   * method/
   *
   * @return The drawing assets.
   */
  public abstract DrawingAssets getDrawingAssets();

  /**
   * Returns the drawing supplier from the plot.
   *
   * @return The drawing supplier.
   */
  public abstract DrawingSupplier getDrawingSupplier();

  /**
   * Returns the paint used to fill data items as they are drawn.
   * <p>
   * The default implementation passes control to the
   * {@link #getSeriesColor(int)} method. You can override this method if you
   * require different behaviour.
   *
   * @param row
   *            the row (or series) index (zero-based).
   * @param column
   *            the column (or category) index (zero-based).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getItemColor(final int row, final int column) {
    return this.getSeriesColor(row);
  }

  /**
   * Returns a boolean that indicates whether or not the specified item should
   * have a chart entity created for it.
   *
   * @param series
   *            the series index.
   * @param item
   *            the item index.
   *
   * @return A boolean.
   */
  public boolean getItemCreateEntity(final int series, final int item) {
    if (this.createEntities != null) {
      return this.createEntities.booleanValue();
    } else {
      final Boolean b = this.getSeriesCreateEntities(series);
      if (b != null) {
        return b.booleanValue();
      } else {
        return this.baseCreateEntities;
      }
    }
  }

  /**
   * Returns the paint used to fill data items as they are drawn. The default
   * implementation passes control to the {@link #getSeriesFillPaint(int)}
   * method - you can override this method if you require different behaviour.
   *
   * @param row
   *            the row (or series) index (zero-based).
   * @param column
   *            the column (or category) index (zero-based).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getItemFillPaint(final int row, final int column) {
    return this.getSeriesFillPaint(row);
  }

  /**
   * Returns the item label anchor offset.
   *
   * @return The offset.
   */
  public int getItemLabelAnchorOffset() {
    return this.itemLabelAnchorOffset;
  }

  /**
   * Returns the font used for all item labels. This may be <code>null</code>,
   * in which case the per series font settings will apply.
   *
   * @return The font (possibly <code>null</code>).
   */
  public Font getItemLabelFont() {
    return this.itemLabelFont;
  }

  /**
   * Returns the font for an item label.
   *
   * @param row
   *            the row index (zero-based).
   * @param column
   *            the column index (zero-based).
   *
   * @return The font (never <code>null</code>).
   */
  public Font getItemLabelFont(final int row, final int column) {
    Font result = this.itemLabelFont;
    if (result == null) {
      result = this.getSeriesItemLabelFont(row);
      if (result == null) {
        result = this.baseItemLabelFont;
      }
    }
    return result;
  }

  /**
   * Returns the paint used for all item labels. This may be <code>null</code>
   * , in which case the per series paint settings will apply.
   *
   * @return The paint (possibly <code>null</code>).
   */
  public Color getItemLabelPaint() {
    return this.getDrawingAssets().getColor(Plot.COLOR_ITEM_LABEL_OVERRIDE);
  }

  /**
   * Returns the paint used to draw an item label.
   *
   * @param row
   *            the row index (zero based).
   * @param column
   *            the column index (zero based).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getItemLabelPaint(final int row, final int column) {
    Color result = this.getDrawingAssets().getColor(
        Plot.COLOR_ITEM_LABEL_OVERRIDE);
    if (result == null) {
      result = this.getSeriesItemLabelPaint(row);
      if (result == null) {
        result = this.getDrawingAssets().getColor(
            Plot.COLOR_ITEM_LABEL_BASE);
      }
    }
    return result;
  }

  /**
   * Returns the paint used to outline data items as they are drawn.
   * <p>
   * The default implementation passes control to the getSeriesOutlinePaint
   * method. You can override this method if you require different behaviour.
   *
   * @param row
   *            the row (or series) index (zero-based).
   * @param column
   *            the column (or category) index (zero-based).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getItemOutlinePaint(final int row, final int column) {
    return this.getSeriesOutlinePaint(row);
  }

  /**
   * Returns the stroke used to outline data items. The default implementation
   * passes control to the {@link #getSeriesOutlineStroke(int)} method. You
   * can override this method if you require different behaviour.
   *
   * @param row
   *            the row (or series) index (zero-based).
   * @param column
   *            the column (or category) index (zero-based).
   *
   * @return The stroke (never <code>null</code>).
   */
  public Stroke getItemOutlineStroke(final int row, final int column) {
    return this.getSeriesOutlineStroke(row);
  }

  public Color getItemPaint(final int row, final int column) {
    return this.getSeriesPaint(row);
  }

  /**
   * Returns the paint used to fill an item drawn by the renderer. slapukhov:
   * Method gets color directly from paintMap. Thats because SWT doesnot allow
   * alpha values on color, so we use null values to represent such a color.
   * This method is used by GroupedStackedBarRenderer.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The paint (never <code>null</code>).
   */
  protected Color getItemPaintNoCheck(final int series) {
    // otherwise look up the paint list
    Color color = (Color) this.paintMap.get(new Integer(series));

    final Color colorOverride = this.getDrawingAssets().getColor(
        Plot.COLOR_SERIES_OVERRIDE);
    if ((color != null) && (colorOverride != null)) {
      color = colorOverride;
    }

    return color;
  }

  /**
   * Returns a shape used to represent a data item.
   * <p>
   * The default implementation passes control to the getSeriesShape method.
   * You can override this method if you require different behaviour.
   *
   * @param row
   *            the row (or series) index (zero-based).
   * @param column
   *            the column (or category) index (zero-based).
   *
   * @return The shape (never <code>null</code>).
   */
  public Rectangle getItemShape(final int row, final int column) {
    return this.getSeriesShape(row);
  }

  // // FILL PAINT //////////////////////////////////////////////////////////

  /**
   * Returns the stroke style to use with the data items as they are drawn.
   *
   * <p>
   * The default implementation returns the {@link #getSeriesStroke(int)}
   * stroke.
   *
   * @param series
   *            the row (or series) index (zero-based)
   * @param item
   *            the column (or category) index (zero-based)
   * @return The stroke style.
   */
  public Stroke getItemStroke(final int series, final int item) {
    return this.getSeriesStroke(series);
  }

  /**
   * Returns a boolean that indicates whether or not the specified item should
   * be drawn (this is typically used to hide an entire series).
   *
   * @param series
   *            the series index.
   * @param item
   *            the item index.
   *
   * @return A boolean.
   */
  public boolean getItemVisible(final int series, final int item) {
    return this.isSeriesVisible(series);
  }

  /**
   * Returns the item label position for negative values in ALL series.
   *
   * @return The item label position (possibly <code>null</code>).
   */
  public ItemLabelPosition getNegativeItemLabelPosition() {
    return this.negativeItemLabelPosition;
  }

  /**
   * Returns the item label position for negative values. This method can be
   * overridden to provide customisation of the item label position for
   * individual data items.
   *
   * @param row
   *            the row index (zero-based).
   * @param column
   *            the column (zero-based).
   *
   * @return The item label position (never <code>null</code>).
   */
  public ItemLabelPosition getNegativeItemLabelPosition(final int row,
      final int column) {
    return this.getSeriesNegativeItemLabelPosition(row);
  }

  /**
   * Returns the item label position for positive values in ALL series.
   *
   * @return The item label position (possibly <code>null</code>).
   */
  public ItemLabelPosition getPositiveItemLabelPosition() {
    return this.positiveItemLabelPosition;
  }

  /**
   * Returns the item label position for positive values.
   *
   * @param row
   *            the row index (zero-based).
   * @param column
   *            the column index (zero-based).
   *
   * @return The item label position (never <code>null</code>).
   */
  public ItemLabelPosition getPositiveItemLabelPosition(final int row,
      final int column) {
    return this.getSeriesPositiveItemLabelPosition(row);
  }

  /**
   * Returns the paint used to fill an item drawn by the renderer.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getSeriesColor(final int series) {
    // return the override, if there is one...
    Color color = this.getDrawingAssets().getColor(
        Plot.COLOR_SERIES_OVERRIDE);
    if (color != null) {
      return color;
    }

    // otherwise look up the paint list
    color = (Color) this.paintMap.get(new Integer(series));

    if (color == null) {
      // ask drawing supplier for next color
      final DrawingSupplier supplier = this.getDrawingSupplier();
      if (supplier != null) {
        color = supplier.getNextPaint();
        this.paintMap.put(new Integer(series), color);
      } else {
        color = this.getDrawingAssets()
            .getColor(Plot.COLOR_SERIES_BASE);
      }
    }
    return color;
  }

  /**
   * Returns the flag that controls whether entities are created for a series.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The flag (possibly <code>null</code>).
   */
  public Boolean getSeriesCreateEntities(final int series) {
    return (Boolean) this.createEntitiesList.get(series);
  }

  /**
   * Returns the paint used to fill an item drawn by the renderer.
   *
   * @param series
   *            the series (zero-based index).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getSeriesFillPaint(final int series) {
    final Color color = this.getDrawingAssets().getColor(
        Plot.COLOR_SERIES_FILL_OVERRIDE);
    if (color != null) {
      return color;
    }

    // otherwise look up the paint table
    Color seriesFillPaint = (Color) this.fillPaintMap.get(new Integer(series));
    if (seriesFillPaint == null) {
      seriesFillPaint = this.getDrawingAssets().getColor(
          Plot.COLOR_SERIES_FILL_BASE);
      ;
    }
    return seriesFillPaint;

  }

  // OUTLINE PAINT //////////////////////////////////////////////////////////

  /**
   * Returns the font for all the item labels in a series.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The font (possibly <code>null</code>).
   */
  public Font getSeriesItemLabelFont(final int series) {
    return (Font) this.itemLabelFontList.get(series);
  }

  /**
   * Returns the paint used to draw the item labels for a series.
   *
   * @param series
   *            the series index (zero based).
   *
   * @return The paint (possibly <code>null<code>).
   */
  public Color getSeriesItemLabelPaint(final int series) {
    return (Color) this.itemLabelPaintMap.get(new Integer(series));
  }

  /**
   * Returns the item label position for all negative values in a series.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The item label position (never <code>null</code>).
   */
  public ItemLabelPosition getSeriesNegativeItemLabelPosition(final int series) {
    // return the override, if there is one...
    if (this.negativeItemLabelPosition != null) {
      return this.negativeItemLabelPosition;
    }

    // otherwise look up the position list
    ItemLabelPosition position = (ItemLabelPosition) this.negativeItemLabelPositionList
        .get(series);
    if (position == null) {
      position = this.baseNegativeItemLabelPosition;
    }
    return position;
  }

  /**
   * Returns the paint used to outline an item drawn by the renderer.
   *
   * @param series
   *            the series (zero-based index).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getSeriesOutlinePaint(final int series) {

    // return the override, if there is one...
    final Color color = this.getDrawingAssets().getColor(
        Plot.COLOR_SERIES_OUTLINE_OVERRIDE);
    if (color != null) {
      return color;
    }

    // otherwise look up the paint table
    Color seriesOutlinePaint = (Color) this.outlinePaintMap.get(new Integer(series));
    if (seriesOutlinePaint == null) {
      final DrawingSupplier supplier = this.getDrawingSupplier();
      if (supplier != null) {
        seriesOutlinePaint = supplier.getNextOutlinePaint();
        this.outlinePaintMap.put(new Integer(series),
            seriesOutlinePaint);
      } else {
        seriesOutlinePaint = this.getDrawingAssets().getColor(
            Plot.COLOR_SERIES_OUTLINE_BASE);
      }
    }
    return seriesOutlinePaint;

  }

  /**
   * Returns the stroke used to outline the items in a series.
   *
   * @param series
   *            the series (zero-based index).
   *
   * @return The stroke (never <code>null</code>).
   */
  public Stroke getSeriesOutlineStroke(final int series) {

    final Stroke stroke = this.getDrawingAssets().getStroke(
        Plot.STROKE_SERIES_OUTLINE_OVERRIDE);
    if (stroke != null) {
      return stroke;
    }

    // otherwise look up the stroke table
    Stroke result = (Stroke) this.outlineStrokeMap.get(new Integer(series));
    if (result == null) {
      // ask drawing supplier for next color
      final DrawingSupplier supplier = this.getDrawingSupplier();
      if (supplier != null) {
        result = supplier.getNextStroke();
        this.outlineStrokeMap.put(new Integer(series), result);
      } else {
        result = this.getDrawingAssets().getStroke(
            Plot.STROKE_SERIES_OUTLINE_BASE);
      }
    }
    return result;

  }

  /**
   * Returns the paint used to fill an item drawn by the renderer.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The paint (never <code>null</code>).
   */
  public Color getSeriesPaint(final int series) {
    return this.getSeriesColor(series);
  }

  /**
   * Returns the item label position for all positive values in a series.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The item label position (never <code>null</code>).
   */
  public ItemLabelPosition getSeriesPositiveItemLabelPosition(final int series) {
    // return the override, if there is one...
    if (this.positiveItemLabelPosition != null) {
      return this.positiveItemLabelPosition;
    }

    // otherwise look up the position table
    ItemLabelPosition position = (ItemLabelPosition) this.positiveItemLabelPositionList
        .get(series);
    if (position == null) {
      position = this.basePositiveItemLabelPosition;
    }
    return position;
  }

  /**
   * Returns a shape used to represent the items in a series.
   *
   * @param series
   *            the series (zero-based index).
   *
   * @return The shape (never <code>null</code>).
   */
  public Rectangle getSeriesShape(final int series) {

    // return the override, if there is one...
    if (this.shape != null) {
      return this.shape;
    }

    // otherwise look up the shape list
    Rectangle result = (Rectangle) this.shapeMap.get(new Integer(series));
    if (result == null) {
      result = new Rectangle(-3, -3, 7, 7);
    }
    return result;

  }

  /**
   * Returns the stroke style to use when drawing given series.
   *
   * @param index
   *            the series index (zero-based)
   *
   * @return the stroke style to use to draw the series.
   */
  public Stroke getSeriesStroke(final int index) {
    Stroke stroke = this.getDrawingAssets().getStroke(
        Plot.STROKE_SERIES_OVERRIDE);
    if (stroke != null) {
      return stroke;
    }

    stroke = (Stroke) this.strokeMap.get(new Integer(index));
    if (stroke == null) {
      stroke = this.getDrawingAssets().getStroke(Plot.STROKE_SERIES_BASE);
      if (stroke == null) {
        this.getDrawingAssets().setStroke(Plot.STROKE_SERIES_BASE,
            stroke = new Stroke(1));
      }
    }
    return stroke;
  }

  // STROKE

  /**
   * Returns the flag that controls the visibility of ALL series. This flag
   * overrides the per series and default settings - you must set it to
   * <code>null</code> if you want the other settings to apply.
   *
   * @return The flag (possibly <code>null</code>).
   */
  public Boolean getSeriesVisible() {
    return this.seriesVisible;
  }

  /**
   * Returns the flag that controls whether a series is visible.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The flag (possibly <code>null</code>).
   */
  public Boolean getSeriesVisible(final int series) {
    return (Boolean) this.seriesVisibleList.get(new Integer(series));
  }

  /**
   * Returns the flag that controls the visibility of ALL series in the
   * legend. This flag overrides the per series and default settings - you
   * must set it to <code>null</code> if you want the other settings to apply.
   *
   * @return The flag (possibly <code>null</code>).
   */
  public Boolean getSeriesVisibleInLegend() {
    return this.seriesVisibleInLegend;
  }

  /**
   * Returns the flag that controls whether a series is visible in the legend.
   * This method returns only the "per series" settings - to incorporate the
   * override and base settings as well, you need to use the
   * {@link #isSeriesVisibleInLegend(int)} method.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The flag (possibly <code>null</code>).
   */
  public Boolean getSeriesVisibleInLegend(final int series) {
    return (Boolean) this.seriesVisibleInLegendList.get(series);
  }

  /**
   * Returns <code>true</code> if an item label is visible, and
   * <code>false</code> otherwise.
   *
   * @param row
   *            the row index (zero-based).
   * @param column
   *            the column index (zero-based).
   *
   * @return A boolean.
   */
  public boolean isItemLabelVisible(final int row, final int column) {
    return this.isSeriesItemLabelsVisible(row);
  }

  /**
   * Returns <code>true</code> if the item labels for a series are visible,
   * and <code>false</code> otherwise.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return A boolean.
   */
  public boolean isSeriesItemLabelsVisible(final int series) {
    // return the override, if there is one...
    if (this.itemLabelsVisible != null) {
      return this.itemLabelsVisible.booleanValue();
    }

    // otherwise look up the boolean table
    Boolean b = (Boolean) this.itemLabelsVisibleList.get(series);
    if (b == null) {
      b = Boolean.valueOf(this.baseItemLabelsVisible);
    }
    if (b == null) {
      b = Boolean.FALSE;
    }
    return b.booleanValue();
  }

  /**
   * Returns a boolean that indicates whether or not the specified series
   * should be drawn.
   *
   * @param series
   *            the series index.
   *
   * @return A boolean.
   */
  public boolean isSeriesVisible(final int series) {
    boolean result = this.baseSeriesVisible;
    if (this.seriesVisible != null) {
      result = this.seriesVisible.booleanValue();
    } else {
      Boolean b = null;
      try {
        b = (Boolean) this.seriesVisibleList.get(new Integer(series));
      } catch (final IndexOutOfBoundsException e) {
        // Ignore.
      }
      if (b != null) {
        result = b.booleanValue();
      }
    }
    return result;
  }

  // OUTLINE STROKE

  /**
   * Returns <code>true</code> if the series should be shown in the legend,
   * and <code>false</code> otherwise.
   *
   * @param series
   *            the series index.
   *
   * @return A boolean.
   */
  public boolean isSeriesVisibleInLegend(final int series) {
    boolean result = this.baseSeriesVisibleInLegend;
    if (this.seriesVisibleInLegend != null) {
      result = this.seriesVisibleInLegend.booleanValue();
    } else {
      final Boolean b = (Boolean) this.seriesVisibleInLegendList
          .get(series);
      if (b != null) {
        result = b.booleanValue();
      }
    }
    return result;
  }

  /**
   * Returns the paint used to fill an item drawn by the renderer.
   *
   * @param series
   *            the series index (zero-based).
   *
   * @return The paint (never <code>null</code>).
   *
   * @since 1.0.6
   */
  public Color lookupSeriesPaint(final int series) {

    // return the override, if there is one...
    // if (this.paint != null) {
    // return this.paint;
    // }
    // // otherwise look up the paint list
    // Paint seriesPaint = getSeriesPaint(series);
    // if (seriesPaint == null && this.autoPopulateSeriesPaint) {
    // DrawingSupplier supplier = getDrawingSupplier();
    // if (supplier != null) {
    // seriesPaint = supplier.getNextPaint();
    // setSeriesPaint(series, seriesPaint, false);
    // }
    // }
    // if (seriesPaint == null) {
    // seriesPaint = this.basePaint;
    // }
    return  StaticColorChecker.dublicateColor(SWT.COLOR_BLACK);// Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);

  }

  /**
   * Returns a shape used to represent the items in a series.
   *
   * @param series
   *            the series (zero-based index).
   *
   * @return The shape (never <code>null</code>).
   *
   * @since 1.0.6
   */
  public Rectangle lookupSeriesShape(final int series) {

    // return the override, if there is one...
    // if (this.shape != null) {
    // return this.shape;
    // }
    // // otherwise look up the shape list
    // Shape result = getSeriesShape(series);
    // if (result == null && this.autoPopulateSeriesShape) {
    // DrawingSupplier supplier = getDrawingSupplier();
    // if (supplier != null) {
    // result = supplier.getNextShape();
    // setSeriesShape(series, result, false);
    // }
    // }
    // if (result == null) {
    // result = this.baseShape;
    // }
    return new Rectangle(0, 0, 8, 8);

  }

  /**
   * Notifies all registered listeners that the renderer has been modified.
   *
   * @param event
   *            information about the change event.
   */
  public void notifyListeners(final RendererChangeEvent event) {
    final Object[] listeners = this.listenerList.getListeners();
    for (int i = 0; i < listeners.length; i++) {
      final RendererChangeListener listener = (RendererChangeListener) listeners[i];
      listener.rendererChanged(event);
    }
  }

  /**
   * Deregisters an object so that it no longer receives notification of
   * changes to the renderer.
   *
   * @param listener
   *            the object (<code>null</code> not permitted).
   */
  public void removeChangeListener(final RendererChangeListener listener) {
    if (listener == null) {
      throw new IllegalArgumentException("Null 'listener' argument.");
    }
    this.listenerList.remove(listener);
  }

  /**
   * Sets the base flag that controls whether entities are created for a
   * series, and sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param create
   *            the flag.
   */
  public void setBaseCreateEntities(final boolean create) {
    // defer argument checking...
    this.setBaseCreateEntities(create, true);
  }

  /**
   * Sets the base flag that controls whether entities are created and, if
   * requested, sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param create
   *            the visibility.
   * @param notify
   *            notify listeners?
   */
  public void setBaseCreateEntities(final boolean create, final boolean notify) {
    this.baseCreateEntities = create;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base fill paint and sends a {@link RendererChangeEvent} to all
   * registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   */
  public void setBaseFillPaint(final Color paint) {
    // defer argument checking...
    this.setBaseFillPaint(paint, true);
  }

  /**
   * Sets the base fill paint and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   * @param notify
   *            notify listeners?
   */
  public void setBaseFillPaint(final Color paint, final boolean notify) {
    if (paint == null) {
      throw new IllegalArgumentException("Null 'paint' argument.");
    }
    this.getDrawingAssets().setColor(Plot.COLOR_SERIES_FILL_BASE, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  // SHAPE

  /**
   * Sets the base item label font and sends a {@link RendererChangeEvent} to
   * all registered listeners.
   *
   * @param font
   *            the font (<code>null</code> not permitted).
   */
  public void setBaseItemLabelFont(final Font font) {
    if (font == null) {
      throw new IllegalArgumentException("Null 'font' argument.");
    }
    this.setBaseItemLabelFont(font, true);
  }

  /**
   * Sets the base item label font and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param font
   *            the font (<code>null</code> not permitted).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setBaseItemLabelFont(final Font font, final boolean notify) {
    this.baseItemLabelFont = font;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base item label paint and sends a {@link RendererChangeEvent} to
   * all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   */
  public void setBaseItemLabelPaint(final Color paint) {
    // defer argument checking...
    this.setBaseItemLabelPaint(paint, true);
  }

  /**
   * Sets the base item label paint and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners..
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setBaseItemLabelPaint(final Color paint, final boolean notify) {
    if (paint == null) {
      throw new IllegalArgumentException("Null 'paint' argument.");
    }
    this.getDrawingAssets().setColor(Plot.COLOR_ITEM_LABEL_BASE, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base flag that controls whether or not item labels are visible.
   *
   * @param visible
   *            the flag.
   */
  public void setBaseItemLabelsVisible(final boolean visible) {
    this.setBaseItemLabelsVisible(Boolean.valueOf(visible));
  }

  /**
   * Sets the base setting for item label visibility.
   *
   * @param visible
   *            the flag (<code>null</code> is permitted, and viewed as
   *            equivalent to <code>Boolean.FALSE</code>).
   */
  public void setBaseItemLabelsVisible(final Boolean visible) {
    this.setBaseItemLabelsVisible(visible, true);
  }

  /**
   * Sets the base visibility for item labels and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param visible
   *            the flag (<code>null</code> is permitted, and viewed as
   *            equivalent to <code>Boolean.FALSE</code>).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setBaseItemLabelsVisible(final Boolean visible,
      final boolean notify) {
    this.baseItemLabelsVisible = visible.booleanValue();
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base item label position for negative values and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param position
   *            the position (<code>null</code> not permitted).
   */
  public void setBaseNegativeItemLabelPosition(
      final ItemLabelPosition position) {
    this.setBaseNegativeItemLabelPosition(position, true);
  }

  /**
   * Sets the base negative item label position and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param position
   *            the position (<code>null</code> not permitted).
   * @param notify
   *            notify registered listeners?
   */
  public void setBaseNegativeItemLabelPosition(
      final ItemLabelPosition position, final boolean notify) {
    if (position == null) {
      throw new IllegalArgumentException("Null 'position' argument.");
    }
    this.baseNegativeItemLabelPosition = position;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  // ITEM LABEL VISIBILITY...

  /**
   * Sets the base outline paint and sends a {@link RendererChangeEvent} to
   * all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   */
  public void setBaseOutlinePaint(final Color paint) {
    // defer argument checking...
    this.setBaseOutlinePaint(paint, true);
  }

  /**
   * Sets the base outline paint and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   * @param notify
   *            notify listeners?
   */
  public void setBaseOutlinePaint(final Color paint, final boolean notify) {
    if (paint == null) {
      throw new IllegalArgumentException("Null 'paint' argument.");
    }
    this.getDrawingAssets().setColor(Plot.COLOR_SERIES_OUTLINE_BASE, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base outline stroke and sends a {@link RendererChangeEvent} to
   * all registered listeners.
   *
   * @param stroke
   *            the stroke (<code>null</code> not permitted).
   */
  public void setBaseOutlineStroke(final Stroke stroke) {
    this.setBaseOutlineStroke(stroke, true);
  }

  /**
   * Sets the base outline stroke and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param stroke
   *            the stroke (<code>null</code> not permitted).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setBaseOutlineStroke(final Stroke stroke, final boolean notify) {
    if (stroke == null) {
      throw new IllegalArgumentException("Null 'stroke' argument.");
    }
    this.getDrawingAssets().setStroke(Plot.STROKE_SERIES_OUTLINE_BASE,
        stroke);

    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base paint and sends a {@link RendererChangeEvent} to all
   * registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   */
  public void setBasePaint(final Color paint) {
    // defer argument checking...
    this.setBasePaint(paint, true);
  }

  /**
   * Sets the base paint and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> not permitted).
   * @param notify
   *            notify listeners?
   */
  public void setBasePaint(final Color paint, final boolean notify) {
    this.getDrawingAssets().setColor(Plot.COLOR_SERIES_BASE, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base positive item label position.
   *
   * @param position
   *            the position (<code>null</code> not permitted).
   */
  public void setBasePositiveItemLabelPosition(
      final ItemLabelPosition position) {
    // defer argument checking...
    this.setBasePositiveItemLabelPosition(position, true);
  }

  /**
   * Sets the base positive item label position and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param position
   *            the position (<code>null</code> not permitted).
   * @param notify
   *            notify registered listeners?
   */
  public void setBasePositiveItemLabelPosition(
      final ItemLabelPosition position, final boolean notify) {
    if (position == null) {
      throw new IllegalArgumentException("Null 'position' argument.");
    }
    this.basePositiveItemLabelPosition = position;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base visibility and sends a {@link RendererChangeEvent} to all
   * registered listeners.
   *
   * @param visible
   *            the flag.
   */
  public void setBaseSeriesVisible(final boolean visible) {
    // defer argument checking...
    this.setBaseSeriesVisible(visible, true);
  }

  /**
   * Sets the base visibility and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param visible
   *            the visibility.
   * @param notify
   *            notify listeners?
   */
  public void setBaseSeriesVisible(final boolean visible, final boolean notify) {
    this.baseSeriesVisible = visible;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base visibility in the legend and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param visible
   *            the flag.
   */
  public void setBaseSeriesVisibleInLegend(final boolean visible) {
    // defer argument checking...
    this.setBaseSeriesVisibleInLegend(visible, true);
  }

  /**
   * Sets the base visibility in the legend and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param visible
   *            the visibility.
   * @param notify
   *            notify listeners?
   */
  public void setBaseSeriesVisibleInLegend(final boolean visible,
      final boolean notify) {
    this.baseSeriesVisibleInLegend = visible;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  // // ITEM LABEL FONT //////////////////////////////////////////////////////

  /**
   * Sets the base shape and sends a {@link RendererChangeEvent} to all
   * registered listeners.
   *
   * @param shape
   *            the shape (<code>null</code> not permitted).
   */
  public void setBaseShape(final Rectangle shape) {
    // defer argument checking...
    this.setBaseShape(shape, true);
  }

  /**
   * Sets the base shape and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param shape
   *            the shape (<code>null</code> not permitted).
   * @param notify
   *            notify listeners?
   */
  public void setBaseShape(final Rectangle shape, final boolean notify) {
    if (shape == null) {
      throw new IllegalArgumentException("Null 'shape' argument.");
    }
    this.baseShape = shape;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the base stroke.
   *
   * @param stroke
   *            the stroke (<code>null</code> not permitted).
   */
  public void setBaseStroke(final Stroke stroke) {
    // defer argument checking...
    this.setBaseStroke(stroke, true);
  }

  /**
   * Sets the base stroke and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param stroke
   *            the stroke (<code>null</code> not permitted).
   * @param notify
   *            notify listeners?
   */
  public void setBaseStroke(final Stroke stroke, final boolean notify) {
    if (stroke == null) {
      throw new IllegalArgumentException("Null 'stroke' argument.");
    }
    this.getDrawingAssets().setStroke(Plot.STROKE_SERIES_BASE, stroke);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the flag that controls whether or not chart entities are created for
   * the items in ALL series, and sends a {@link RendererChangeEvent} to all
   * registered listeners. This flag overrides the per series and default
   * settings - you must set it to <code>null</code> if you want the other
   * settings to apply.
   *
   * @param create
   *            the flag (<code>null</code> permitted).
   */
  public void setCreateEntities(final Boolean create) {
    this.setCreateEntities(create, true);
  }

  /**
   * Sets the flag that controls whether or not chart entities are created for
   * the items in ALL series, and sends a {@link RendererChangeEvent} to all
   * registered listeners. This flag overrides the per series and default
   * settings - you must set it to <code>null</code> if you want the other
   * settings to apply.
   *
   * @param create
   *            the flag (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setCreateEntities(final Boolean create, final boolean notify) {
    this.createEntities = create;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the fill paint for ALL series (optional).
   *
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setFillPaint(final Color paint) {
    this.setFillPaint(paint, true);
  }

  /**
   * Sets the fill paint for ALL series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setFillPaint(final Color paint, final boolean notify) {
    this.getDrawingAssets()
        .setColor(Plot.COLOR_SERIES_FILL_OVERRIDE, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label anchor offset.
   *
   * @param offset
   *            the offset.
   */
  public void setItemLabelAnchorOffset(final int offset) {
    this.itemLabelAnchorOffset = offset;
    this.notifyListeners(new RendererChangeEvent(this));
  }

  /**
   * Sets the item label font for ALL series and sends a
   * {@link RendererChangeEvent} to all registered listeners. You can set this
   * to <code>null</code> if you prefer to set the font on a per series basis.
   *
   * @param font
   *            the font (<code>null</code> permitted).
   */
  public void setItemLabelFont(final Font font) {
    this.setItemLabelFont(font, true);
  }

  // COLORS

  /**
   * Sets the item label font for ALL series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param font
   *            the font (<code>null</code> permitted).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setItemLabelFont(final Font font, final boolean notify) {
    this.itemLabelFont = font;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label paint for ALL series and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setItemLabelPaint(final Color paint) {
    this.setItemLabelPaint(paint, true);
  }

  /**
   * Sets the item label paint for ALL series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint.
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setItemLabelPaint(final Color paint, final boolean notify) {
    this.getDrawingAssets().setColor(Plot.COLOR_ITEM_LABEL_OVERRIDE, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the visibility of the item labels for ALL series.
   *
   * @param visible
   *            the flag.
   */
  public void setItemLabelsVisible(final boolean visible) {
    this.setItemLabelsVisible(Boolean.valueOf(visible));
  }

  /**
   * Sets the visibility of the item labels for ALL series (optional).
   *
   * @param visible
   *            the flag (<code>null</code> permitted).
   */
  public void setItemLabelsVisible(final Boolean visible) {
    this.setItemLabelsVisible(visible, true);
  }

  /**
   * Sets the visibility of item labels for ALL series and, if requested,
   * sends a {@link RendererChangeEvent} to all registered listeners.
   *
   * @param visible
   *            a flag that controls whether or not the item labels are
   *            visible (<code>null</code> permitted).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setItemLabelsVisible(final Boolean visible, final boolean notify) {
    this.itemLabelsVisible = visible;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label position for negative values in ALL series, and sends
   * a {@link RendererChangeEvent} to all registered listeners. You need to
   * set this to <code>null</code> to expose the settings for individual
   * series.
   *
   * @param position
   *            the position (<code>null</code> permitted).
   */
  public void setNegativeItemLabelPosition(final ItemLabelPosition position) {
    this.setNegativeItemLabelPosition(position, true);
  }

  /**
   * Sets the item label position for negative values in ALL series and (if
   * requested) sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param position
   *            the position (<code>null</code> permitted).
   * @param notify
   *            notify registered listeners?
   */
  public void setNegativeItemLabelPosition(final ItemLabelPosition position,
      final boolean notify) {
    this.negativeItemLabelPosition = position;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the outline paint for ALL series (optional).
   *
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setOutlinePaint(final Color paint) {
    this.setOutlinePaint(paint, true);
  }

  /**
   * Sets the outline paint for ALL series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setOutlinePaint(final Color paint, final boolean notify) {
    this.getDrawingAssets().setColor(Plot.COLOR_SERIES_OUTLINE_OVERRIDE,
        paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the outline stroke for ALL series and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   */
  public void setOutlineStroke(final Stroke stroke) {
    this.setOutlineStroke(stroke, true);
  }

  /**
   * Sets the outline stroke for ALL series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setOutlineStroke(final Stroke stroke, final boolean notify) {
    this.getDrawingAssets().setStroke(Plot.STROKE_SERIES_OUTLINE_OVERRIDE,
        stroke);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the paint to be used for ALL series, and sends a
   * {@link RendererChangeEvent} to all registered listeners. If this is
   * <code>null</code>, the renderer will use the paint for the series.
   *
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setPaint(final Color paint) {
    this.setPaint(paint, true);
  }

  /**
   * Sets the paint to be used for all series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param paint
   *            the paint (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setPaint(final Color paint, final boolean notify) {
    this.getDrawingAssets().setColor(Plot.COLOR_SERIES_OVERRIDE, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label position for positive values in ALL series, and sends
   * a {@link RendererChangeEvent} to all registered listeners. You need to
   * set this to <code>null</code> to expose the settings for individual
   * series.
   *
   * @param position
   *            the position (<code>null</code> permitted).
   */
  public void setPositiveItemLabelPosition(final ItemLabelPosition position) {
    this.setPositiveItemLabelPosition(position, true);
  }

  /**
   * Sets the positive item label position for ALL series and (if requested)
   * sends a {@link RendererChangeEvent} to all registered listeners.
   *
   * @param position
   *            the position (<code>null</code> permitted).
   * @param notify
   *            notify registered listeners?
   */
  public void setPositiveItemLabelPosition(final ItemLabelPosition position,
      final boolean notify) {
    this.positiveItemLabelPosition = position;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  // POSITIVE ITEM LABEL POSITION...

  /**
   * Sets the color for the given series.
   *
   * @param index
   *            the series index (zero-based)
   * @param color
   *            the color to use when drawing given series
   */
  public void setSeriesColor(final int index, final Color color) {
    this.paintMap.put(new Integer(index), color);
  }

  /**
   * Sets the flag that controls whether entities are created for a series,
   * and sends a {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param create
   *            the flag (<code>null</code> permitted).
   */
  public void setSeriesCreateEntities(final int series, final Boolean create) {
    this.setSeriesCreateEntities(series, create, true);
  }

  /**
   * Sets the flag that controls whether entities are created for a series
   * and, if requested, sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param series
   *            the series index.
   * @param create
   *            the flag (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesCreateEntities(final int series, final Boolean create,
      final boolean notify) {
    this.createEntitiesList.set(series, create);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the paint used for a series fill and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setSeriesFillPaint(final int series, final Color paint) {
    this.setSeriesFillPaint(series, paint, true);
  }

  /**
   * Sets the paint used to fill a series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param paint
   *            the paint (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesFillPaint(final int series, final Color paint,
      final boolean notify) {
    this.fillPaintMap.put(new Integer(series), paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label font for a series and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param font
   *            the font (<code>null</code> permitted).
   */
  public void setSeriesItemLabelFont(final int series, final Font font) {
    this.setSeriesItemLabelFont(series, font, true);
  }

  /**
   * Sets the item label font for a series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero based).
   * @param font
   *            the font (<code>null</code> permitted).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setSeriesItemLabelFont(final int series, final Font font,
      final boolean notify) {
    this.itemLabelFontList.set(series, font);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label paint for a series and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series (zero based index).
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setSeriesItemLabelPaint(final int series, final Color paint) {
    this.setSeriesItemLabelPaint(series, paint, true);
  }

  /**
   * Sets the item label paint for a series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero based).
   * @param paint
   *            the paint (<code>null</code> permitted).
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setSeriesItemLabelPaint(final int series, final Color paint,
      final boolean notify) {
    this.itemLabelPaintMap.put(new Integer(series), paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets a flag that controls the visibility of the item labels for a series.
   *
   * @param series
   *            the series index (zero-based).
   * @param visible
   *            the flag.
   */
  public void setSeriesItemLabelsVisible(final int series,
      final boolean visible) {
    this.setSeriesItemLabelsVisible(series, Boolean.valueOf(visible));
  }

  // NEGATIVE ITEM LABEL POSITION...

  /**
   * Sets the visibility of the item labels for a series.
   *
   * @param series
   *            the series index (zero-based).
   * @param visible
   *            the flag (<code>null</code> permitted).
   */
  public void setSeriesItemLabelsVisible(final int series,
      final Boolean visible) {
    this.setSeriesItemLabelsVisible(series, visible, true);
  }

  /**
   * Sets the visibility of item labels for a series and, if requested, sends
   * a {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param visible
   *            the visible flag.
   * @param notify
   *            a flag that controls whether or not listeners are notified.
   */
  public void setSeriesItemLabelsVisible(final int series,
      final Boolean visible, final boolean notify) {
    this.itemLabelsVisibleList.set(series, visible);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label position for negative values in a series and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param position
   *            the position (<code>null</code> permitted).
   */
  public void setSeriesNegativeItemLabelPosition(final int series,
      final ItemLabelPosition position) {
    this.setSeriesNegativeItemLabelPosition(series, position, true);
  }

  /**
   * Sets the item label position for negative values in a series and (if
   * requested) sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param position
   *            the position (<code>null</code> permitted).
   * @param notify
   *            notify registered listeners?
   */
  public void setSeriesNegativeItemLabelPosition(final int series,
      final ItemLabelPosition position, final boolean notify) {
    this.negativeItemLabelPositionList.set(series, position);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the paint used for a series outline and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setSeriesOutlinePaint(final int series, final Color paint) {
    this.setSeriesOutlinePaint(series, paint, true);
  }

  /**
   * Sets the paint used to draw the outline for a series and, if requested,
   * sends a {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param paint
   *            the paint (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesOutlinePaint(final int series, final Color paint,
      final boolean notify) {
    this.outlinePaintMap.put(new Integer(series), paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the outline stroke used for a series and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   */
  public void setSeriesOutlineStroke(final int series, final Stroke stroke) {
    this.setSeriesOutlineStroke(series, stroke, true);
  }

  /**
   * Sets the outline stroke for a series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index.
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesOutlineStroke(final int series, final Stroke stroke,
      final boolean notify) {
    this.outlineStrokeMap.put(new Integer(series), stroke);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the paint used for a series and sends a {@link RendererChangeEvent}
   * to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param paint
   *            the paint (<code>null</code> permitted).
   */
  public void setSeriesPaint(final int series, final Color paint) {
    this.setSeriesPaint(series, paint, true);
  }

  /**
   * Sets the paint used for a series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index.
   * @param paint
   *            the paint (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesPaint(final int series, final Color paint,
      final boolean notify) {
    this.setSeriesColor(series, paint);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the item label position for all positive values in a series and
   * sends a {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param position
   *            the position (<code>null</code> permitted).
   */
  public void setSeriesPositiveItemLabelPosition(final int series,
      final ItemLabelPosition position) {
    this.setSeriesPositiveItemLabelPosition(series, position, true);
  }

  /**
   * Sets the item label position for all positive values in a series and (if
   * requested) sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param position
   *            the position (<code>null</code> permitted).
   * @param notify
   *            notify registered listeners?
   */
  public void setSeriesPositiveItemLabelPosition(final int series,
      final ItemLabelPosition position, final boolean notify) {
    this.positiveItemLabelPositionList.set(series, position);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the shape used for a series and sends a {@link RendererChangeEvent}
   * to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param shape
   *            the shape (<code>null</code> permitted).
   */
  public void setSeriesShape(final int series, final Rectangle shape) {
    this.setSeriesShape(series, shape, true);
  }

  /**
   * Sets the shape for a series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero based).
   * @param shape
   *            the shape (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesShape(final int series, final Rectangle shape,
      final boolean notify) {
    this.shapeMap.put(new Integer(series), shape);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the stroke used for a series and sends a {@link RendererChangeEvent}
   * to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   */
  public void setSeriesStroke(final int series, final Stroke stroke) {
    this.setSeriesStroke(series, stroke, true);
  }

  /**
   * Sets the stroke for a series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesStroke(final int series, final Stroke stroke,
      final boolean notify) {
    this.strokeMap.put(new Integer(series), stroke);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the flag that controls the visibility of ALL series and sends a
   * {@link RendererChangeEvent} to all registered listeners. This flag
   * overrides the per series and default settings - you must set it to
   * <code>null</code> if you want the other settings to apply.
   *
   * @param visible
   *            the flag (<code>null</code> permitted).
   */
  public void setSeriesVisible(final Boolean visible) {
    this.setSeriesVisible(visible, true);
  }

  /**
   * Sets the flag that controls the visibility of ALL series and sends a
   * {@link RendererChangeEvent} to all registered listeners. This flag
   * overrides the per series and default settings - you must set it to
   * <code>null</code> if you want the other settings to apply.
   *
   * @param visible
   *            the flag (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesVisible(final Boolean visible, final boolean notify) {
    this.seriesVisible = visible;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the flag that controls whether a series is visible and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param visible
   *            the flag (<code>null</code> permitted).
   */
  public void setSeriesVisible(final int series, final Boolean visible) {
    this.setSeriesVisible(series, visible, true);
  }

  /**
   * Sets the flag that controls whether a series is visible and, if
   * requested, sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param series
   *            the series index.
   * @param visible
   *            the flag (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesVisible(final int series, final Boolean visible,
      final boolean notify) {
    this.seriesVisibleList.put(new Integer(series), visible);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the flag that controls the visibility of ALL series in the legend
   * and sends a {@link RendererChangeEvent} to all registered listeners. This
   * flag overrides the per series and default settings - you must set it to
   * <code>null</code> if you want the other settings to apply.
   *
   * @param visible
   *            the flag (<code>null</code> permitted).
   */
  public void setSeriesVisibleInLegend(final Boolean visible) {
    this.setSeriesVisibleInLegend(visible, true);
  }

  /**
   * Sets the flag that controls the visibility of ALL series in the legend
   * and sends a {@link RendererChangeEvent} to all registered listeners. This
   * flag overrides the per series and default settings - you must set it to
   * <code>null</code> if you want the other settings to apply.
   *
   * @param visible
   *            the flag (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesVisibleInLegend(final Boolean visible,
      final boolean notify) {
    this.seriesVisibleInLegend = visible;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the flag that controls whether a series is visible in the legend and
   * sends a {@link RendererChangeEvent} to all registered listeners.
   *
   * @param series
   *            the series index (zero-based).
   * @param visible
   *            the flag (<code>null</code> permitted).
   */
  public void setSeriesVisibleInLegend(final int series, final Boolean visible) {
    this.setSeriesVisibleInLegend(series, visible, true);
  }

  /**
   * Sets the flag that controls whether a series is visible in the legend
   * and, if requested, sends a {@link RendererChangeEvent} to all registered
   * listeners.
   *
   * @param series
   *            the series index.
   * @param visible
   *            the flag (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setSeriesVisibleInLegend(final int series,
      final Boolean visible, final boolean notify) {
    this.seriesVisibleInLegendList.set(series, visible);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the shape for ALL series (optional) and sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param shape
   *            the shape (<code>null</code> permitted).
   */
  public void setShape(final Rectangle shape) {
    this.setShape(shape, true);
  }

  /**
   * Sets the shape for ALL series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param shape
   *            the shape (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setShape(final Rectangle shape, final boolean notify) {
    this.shape = shape;
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

  /**
   * Sets the stroke for ALL series and sends a {@link RendererChangeEvent} to
   * all registered listeners.
   *
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   */
  public void setStroke(final Stroke stroke) {
    this.setStroke(stroke, true);
  }

  /**
   * Sets the stroke for ALL series and, if requested, sends a
   * {@link RendererChangeEvent} to all registered listeners.
   *
   * @param stroke
   *            the stroke (<code>null</code> permitted).
   * @param notify
   *            notify listeners?
   */
  public void setStroke(final Stroke stroke, final boolean notify) {
    this.getDrawingAssets().setStroke(Plot.STROKE_SERIES_OVERRIDE, stroke);
    if (notify) {
      this.notifyListeners(new RendererChangeEvent(this));
    }
  }

}
TOP

Related Classes of com.positive.charts.renderer.AbstractRenderer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.