Example usage for org.jfree.chart.axis ValueAxis setPlot

List of usage examples for org.jfree.chart.axis ValueAxis setPlot

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis setPlot.

Prototype

public void setPlot(Plot plot) 

Source Link

Document

Sets a reference to the plot that the axis is assigned to.

Usage

From source file:org.tsho.dmc2.core.chart.AbstractDmcPlot.java

protected AbstractDmcPlot(ValueAxis domainAxis, ValueAxis rangeAxis) {
    super();//from  ww w. ja v  a2 s . c o m
    coreStatusListeners = new ArrayList();

    this.anchorX = 0.0;
    this.anchorY = 0.0;

    this.domainAxis = domainAxis;
    if (domainAxis != null) {
        domainAxis.setPlot(this);
        this.anchorX = domainAxis.getRange().getCentralValue();
    }

    this.rangeAxis = rangeAxis;
    if (rangeAxis != null) {
        rangeAxis.setPlot(this);
        this.anchorY = rangeAxis.getRange().getCentralValue();
    }

    this.paint = DEFAULT_PAINT;
    this.stroke = DEFAULT_STROKE;
    this.gridStroke = DEFAULT_GRIDLINE_STROKE;
    this.gridPaint = DEFAULT_GRIDLINE_PAINT;

    this.alpha = false;
    this.drawGridlines = true;
    plotAntialias = true;
}

From source file:org.proteosuite.FastScatterPlot.java

/**
 * Creates a new fast scatter plot.//from w w w.j  a va2s. com
 * <P>
 * The data is an array of x, y values:  data[0][i] = x, data[1][i] = y.
 *
 * @param data  the data.
 * @param domainAxis  the domain (x) axis.
 * @param rangeAxis  the range (y) axis.
 */
public FastScatterPlot(float[][] data, ValueAxis domainAxis, ValueAxis rangeAxis) {

    super();

    this.data = data;
    this.xDataRange = calculateXDataRange(data);
    this.yDataRange = calculateYDataRange(data);
    this.domainAxis = domainAxis;
    if (domainAxis != null) {
        domainAxis.setPlot(this);
        domainAxis.addChangeListener(this);
    }

    this.rangeAxis = rangeAxis;
    if (rangeAxis != null) {
        rangeAxis.setPlot(this);
        rangeAxis.addChangeListener(this);
    }

    this.paint = Color.red;

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

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

}

From source file:de.laures.cewolf.jfree.ThermometerPlot.java

/**
 * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to all registered listeners.
 *
 * @param axis  the new axis (<code>null</code> not permitted).
 *
 * @see #getRangeAxis()//from ww  w.  ja v a  2 s .  c o  m
 */
public void setRangeAxis(ValueAxis axis) {
    if (axis == null) {
        throw new IllegalArgumentException("Null 'axis' argument.");
    }
    // plot is registered as a listener with the existing axis...
    this.rangeAxis.removeChangeListener(this);

    axis.setPlot(this);
    axis.addChangeListener(this);
    this.rangeAxis = axis;
    fireChangeEvent();
}

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

/**
 * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to
 * all registered listeners.//from w w  w  .  j  av a  2s.c o  m
 *
 * @param axis  the axis (<code>null</code> permitted).
 *
 */
public void setRangeAxis(ValueAxis axis) {

    if (axis != null) {
        axis.setPlot(this);
    }

    // plot is likely registered as a listener with the existing axis...
    ValueAxis existing = getRangeAxis();
    if (existing != null) {
        existing.removeChangeListener(this);
    }

    this.rangeAxes.set(0, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    notifyListeners(new PlotChangeEvent(this));

}

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

/**
 * Returns a clone of the plot./*from   w w  w .  j a v  a2  s . c o  m*/
 *
 * @return A clone.
 *
 * @throws CloneNotSupportedException  this can occur if some component of
 *         the plot cannot be cloned.
 */
public Object clone() throws CloneNotSupportedException {

    MyXYPlot clone = (MyXYPlot) super.clone();
    clone.domainAxes = (ObjectList) ObjectUtilities.clone(this.domainAxes);
    for (int i = 0; i < this.domainAxes.size(); i++) {
        ValueAxis axis = (ValueAxis) this.domainAxes.get(i);
        if (axis != null) {
            ValueAxis clonedAxis = (ValueAxis) axis.clone();
            clone.domainAxes.set(i, clonedAxis);
            clonedAxis.setPlot(clone);
            clonedAxis.addChangeListener(clone);
        }
    }
    clone.domainAxisLocations = (ObjectList) this.domainAxisLocations.clone();

    clone.rangeAxes = (ObjectList) ObjectUtilities.clone(this.rangeAxes);
    for (int i = 0; i < this.rangeAxes.size(); i++) {
        ValueAxis axis = (ValueAxis) this.rangeAxes.get(i);
        if (axis != null) {
            ValueAxis clonedAxis = (ValueAxis) axis.clone();
            clone.rangeAxes.set(i, clonedAxis);
            clonedAxis.setPlot(clone);
            clonedAxis.addChangeListener(clone);
        }
    }
    clone.rangeAxisLocations = (ObjectList) ObjectUtilities.clone(this.rangeAxisLocations);

    // the datasets are not cloned, but listeners need to be added...
    clone.datasets = (ObjectList) ObjectUtilities.clone(this.datasets);
    for (int i = 0; i < clone.datasets.size(); ++i) {
        XYDataset d = getDataset(i);
        if (d != null) {
            d.addChangeListener(clone);
        }
    }

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

    clone.renderers = (ObjectList) ObjectUtilities.clone(this.renderers);
    for (int i = 0; i < this.renderers.size(); i++) {
        XYItemRenderer renderer2 = (XYItemRenderer) this.renderers.get(i);
        if (renderer2 instanceof PublicCloneable) {
            PublicCloneable pc = (PublicCloneable) renderer2;
            clone.renderers.set(i, pc.clone());
        }
    }
    clone.foregroundDomainMarkers = (Map) ObjectUtilities.clone(this.foregroundDomainMarkers);
    clone.backgroundDomainMarkers = (Map) ObjectUtilities.clone(this.backgroundDomainMarkers);
    clone.foregroundRangeMarkers = (Map) ObjectUtilities.clone(this.foregroundRangeMarkers);
    clone.backgroundRangeMarkers = (Map) ObjectUtilities.clone(this.backgroundRangeMarkers);
    clone.annotations = (List) ObjectUtilities.deepClone(this.annotations);
    if (this.fixedDomainAxisSpace != null) {
        clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedDomainAxisSpace);
    }
    if (this.fixedRangeAxisSpace != null) {
        clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedRangeAxisSpace);
    }
    return clone;

}

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

/**
 * Sets a range axis and, if requested, sends a {@link PlotChangeEvent} to
 * all registered listeners./* w w w. ja  v  a  2s.co  m*/
 *
 * @param index  the axis index.
 * @param axis  the axis (<code>null</code> permitted).
 * @param notify and notify the listeners
 */
public void setRangeAxis(int index, ValueAxis axis, boolean notify) {
    ValueAxis existing = getRangeAxis(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    if (axis != null) {
        axis.setPlot(this);
    }
    this.rangeAxes.set(index, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}

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

/**
 * Sets a domain axis and, if requested, sends a {@link PlotChangeEvent} to
 * all registered listeners.//  w  w w . j a  v a2  s .com
 *
 * @param index  the axis index.
 * @param axis  the axis.
 * @param notify  notify listeners?
 */
public void setDomainAxis(int index, ValueAxis axis, boolean notify) {
    ValueAxis existing = getDomainAxis(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    if (axis != null) {
        axis.setPlot(this);
    }
    this.domainAxes.set(index, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    if (notify) {
        notifyListeners(new PlotChangeEvent(this));
    }
}

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

/**
 * Creates a new plot.//  w w w  . j  a v a  2  s  .c  o  m
 *
 * @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();

}