Example usage for org.jfree.chart.renderer.xy XYItemRenderer addChangeListener

List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer addChangeListener

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYItemRenderer addChangeListener.

Prototype

public void addChangeListener(RendererChangeListener listener);

Source Link

Document

Add a renderer change listener.

Usage

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Provides serialization support./* ww  w  . j a  va 2  s  . co  m*/
 *
 * @param stream  the input stream.
 *
 * @throws IOException  if there is an I/O error.
 * @throws ClassNotFoundException  if there is a classpath problem.
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {

    stream.defaultReadObject();
    this.domainGridlineStroke = SerialUtilities.readStroke(stream);
    this.domainGridlinePaint = SerialUtilities.readPaint(stream);
    this.rangeGridlineStroke = SerialUtilities.readStroke(stream);
    this.rangeGridlinePaint = SerialUtilities.readPaint(stream);
    this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream);
    this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream);
    this.domainCrosshairStroke = SerialUtilities.readStroke(stream);
    this.domainCrosshairPaint = SerialUtilities.readPaint(stream);
    this.rangeCrosshairStroke = SerialUtilities.readStroke(stream);
    this.rangeCrosshairPaint = SerialUtilities.readPaint(stream);
    this.domainTickBandPaint = SerialUtilities.readPaint(stream);
    this.rangeTickBandPaint = SerialUtilities.readPaint(stream);
    this.quadrantOrigin = SerialUtilities.readPoint2D(stream);
    this.quadrantPaint = new Paint[4];
    for (int i = 0; i < 4; i++) {
        this.quadrantPaint[i] = SerialUtilities.readPaint(stream);
    }

    // register the plot as a listener with its axes, datasets, and 
    // renderers...
    int domainAxisCount = this.domainAxes.size();
    for (int i = 0; i < domainAxisCount; i++) {
        Axis axis = (Axis) this.domainAxes.get(i);
        if (axis != null) {
            axis.setPlot(this);
            axis.addChangeListener(this);
        }
    }
    int rangeAxisCount = this.rangeAxes.size();
    for (int i = 0; i < rangeAxisCount; i++) {
        Axis axis = (Axis) this.rangeAxes.get(i);
        if (axis != null) {
            axis.setPlot(this);
            axis.addChangeListener(this);
        }
    }
    int datasetCount = this.datasets.size();
    for (int i = 0; i < datasetCount; i++) {
        Dataset dataset = (Dataset) this.datasets.get(i);
        if (dataset != null) {
            dataset.addChangeListener(this);
        }
    }
    int rendererCount = this.renderers.size();
    for (int i = 0; i < rendererCount; i++) {
        XYItemRenderer renderer = (XYItemRenderer) this.renderers.get(i);
        if (renderer != null) {
            renderer.addChangeListener(this);
        }
    }

}

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Sets a renderer and sends a {@link PlotChangeEvent} is sent to all
 * registered listeners./*from   w w  w .j  a v  a2  s.  c  om*/
 *
 * @param index  the index.
 * @param renderer  the renderer.
 */
public void setRenderer(int index, XYItemRenderer renderer) {
    XYItemRenderer existing = getRenderer(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    this.renderers.set(index, renderer);
    if (renderer != null) {
        renderer.setPlot(this);
        renderer.addChangeListener(this);
    }
    configureDomainAxes();
    configureRangeAxes();
    notifyListeners(new PlotChangeEvent(this));
}

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Creates a new plot.//from ww  w . j ava 2 s  .  c  om
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param domainAxis  the domain axis (<code>null</code> permitted).
 * @param rangeAxis  the range axis (<code>null</code> permitted).
 * @param renderer  the renderer (<code>null</code> permitted).
 */
public MyXYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) {

    super();

    this.orientation = PlotOrientation.VERTICAL;
    this.weight = 1; // only relevant when this is a subplot
    this.axisOffset = RectangleInsets.ZERO_INSETS;

    // allocate storage for datasets, axes and renderers (all optional)
    this.domainAxes = new ObjectList();
    this.domainAxisLocations = new ObjectList();
    this.foregroundDomainMarkers = new HashMap();
    this.backgroundDomainMarkers = new HashMap();

    this.rangeAxes = new ObjectList();
    this.rangeAxisLocations = new ObjectList();
    this.foregroundRangeMarkers = new HashMap();
    this.backgroundRangeMarkers = new HashMap();

    this.datasets = new ObjectList();
    this.renderers = new ObjectList();

    this.datasetToDomainAxisMap = new TreeMap();
    this.datasetToRangeAxisMap = new TreeMap();

    this.datasets.set(0, dataset);
    if (dataset != null) {
        dataset.addChangeListener(this);
    }

    this.renderers.set(0, renderer);
    if (renderer != null) {
        renderer.setPlot(this);
        renderer.addChangeListener(this);
    }

    this.domainAxes.set(0, domainAxis);
    this.mapDatasetToDomainAxis(0, 0);
    if (domainAxis != null) {
        domainAxis.setPlot(this);
        domainAxis.addChangeListener(this);
    }
    this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT);

    this.rangeAxes.set(0, rangeAxis);
    this.mapDatasetToRangeAxis(0, 0);
    if (rangeAxis != null) {
        rangeAxis.setPlot(this);
        rangeAxis.addChangeListener(this);
    }
    this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT);

    configureDomainAxes();
    configureRangeAxes();

    this.domainGridlinesVisible = true;
    this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE;
    this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT;

    this.rangeGridlinesVisible = true;
    this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE;
    this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT;

    this.rangeZeroBaselineVisible = false;
    this.rangeZeroBaselinePaint = Color.black;
    this.rangeZeroBaselineStroke = new BasicStroke(0.5f);

    this.domainCrosshairVisible = false;
    this.domainCrosshairValue = 0.0;
    this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;

    this.rangeCrosshairVisible = false;
    this.rangeCrosshairValue = 0.0;
    this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE;
    this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT;

    this.annotations = new java.util.ArrayList();

}