Example usage for org.jfree.chart.plot XYPlot addChangeListener

List of usage examples for org.jfree.chart.plot XYPlot addChangeListener

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot addChangeListener.

Prototype

public void addChangeListener(PlotChangeListener listener) 

Source Link

Document

Registers an object for notification of changes to the plot.

Usage

From source file:edu.ucla.stat.SOCR.motionchart.MotionBubbleRenderer.java

/**
 * Sets the plot that the renderer is assigned to.
 *
 * @param plot the plot (<code>null</code> permitted).
 *//*  w  w  w.  java  2 s  .co  m*/
@Override
public void setPlot(XYPlot plot) {
    XYPlot prevPlot = getPlot();
    if (prevPlot != null && plot != prevPlot) {
        prevPlot.removeChangeListener(this);
        ValueAxis prevDomainAxis = prevPlot.getDomainAxis();
        ValueAxis prevRangeAxis = prevPlot.getRangeAxis();

        if (prevDomainAxis != null)
            prevDomainAxis.removeChangeListener(this);

        if (prevRangeAxis != null)
            prevRangeAxis.removeChangeListener(this);
    }

    super.setPlot(plot);

    domainAxis = plot.getDomainAxis();
    rangeAxis = plot.getRangeAxis();

    if (domainAxis != null) {
        domainAxisLength = domainAxis.getRange().getLength();
        domainAxis.addChangeListener(this);
    }

    if (rangeAxis != null) {
        rangeAxisLength = rangeAxis.getRange().getLength();
        rangeAxis.addChangeListener(this);
    }

    plot.addChangeListener(this);
}

From source file:org.jfree.chart.plot.StackedXYPlot.java

/**
 * Adds a subplot with the specified weight 
 * @param subplot  the subplot (<code>null</code> not permitted).
 * @param weight  the weight (must be >= 1).
 *//*from  w  w  w  . j av  a2  s  .  c om*/
@Override
public void add(XYPlot subplot, int weight) {

    Objects.requireNonNull(subplot, "subplot must not be null");
    if (weight <= 0) {
        throw new IllegalArgumentException("weight must be >= 1.");
    }
    subplot.setParent(this);
    subplot.setWeight(weight);
    subplot.addChangeListener(this);
    subplot.setRangeZeroBaselineVisible(false);
    subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0), false);

    List subplots = Collections.EMPTY_LIST;
    try {
        subplots = (List) FieldUtils.readField(this, "subplots", true);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(StackedXYPlot.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
    subplots.add(subplot);

    ValueAxis axis = getDomainAxis();
    if (axis != null) {
        axis.configure();
    }
    fireChangeEvent();
}