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

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

Introduction

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

Prototype

public void setParent(Plot parent) 

Source Link

Document

Sets the parent plot.

Usage

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 www  .  ja v  a 2  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();
}