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

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

Introduction

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

Prototype

public int getDomainAxisCount() 

Source Link

Document

Returns the number of domain axes.

Usage

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

/**
 * Pan the plot/*w ww  .j  a  v  a  2  s  .c o m*/
 *
 * @param right to right
 * @param percent by how much
 */
protected void panPlot(boolean right, double percent) {
    if (!(plot instanceof XYPlot)) {
        return;
    }
    XYPlot xyPlot = (XYPlot) plot;
    int cnt = xyPlot.getDomainAxisCount();
    for (int i = 0; i < cnt; i++) {
        ValueAxis axis = (ValueAxis) xyPlot.getDomainAxis(i);
        org.jfree.data.Range range = axis.getRange();
        double width = range.getUpperBound() - range.getLowerBound();
        double width2 = width / 2.0;
        double step = (right ? width * percent : -width * percent);
        axis.centerRange(range.getLowerBound() + step + width2);
    }
}

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

/**
 * Pan the plot//from w  ww.ja v a 2 s . co m
 *
 * @param right to right
 * @param percent by how much
 */
protected void panPlot(boolean right, double percent) {
    if (!(chart.getPlot() instanceof XYPlot)) {
        return;
    }
    XYPlot plot = (XYPlot) chart.getPlot();
    int cnt = plot.getDomainAxisCount();
    for (int i = 0; i < cnt; i++) {
        ValueAxis axis = (ValueAxis) plot.getDomainAxis(i);
        org.jfree.data.Range range = axis.getRange();
        double width = range.getUpperBound() - range.getLowerBound();
        double width2 = width / 2.0;
        double step = (right ? width * percent : -width * percent);
        axis.centerRange(range.getLowerBound() + step + width2);
    }
}

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

/**
 * reset the axis'/*  w  w w .j  a v  a  2  s  . co m*/
 */
private void resetPlot() {
    if (chart == null) {
        return;
    }
    if (!(chart.getPlot() instanceof XYPlot)) {
        return;
    }
    XYPlot plot = (XYPlot) chart.getPlot();
    int rcnt = plot.getRangeAxisCount();
    for (int i = 0; i < rcnt; i++) {
        ValueAxis axis = (ValueAxis) plot.getRangeAxis(i);
        System.err.println("range axis:" + axis);
        axis.setAutoRange(autoRange);
    }
    int dcnt = plot.getDomainAxisCount();
    for (int i = 0; i < dcnt; i++) {
        ValueAxis axis = (ValueAxis) plot.getDomainAxis(i);
        System.err.println("domain axis:" + axis);
        axis.setAutoRange(autoRange);
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Decreases the length of the domain axis, centered about the given coordinate on the screen.
 * The length of the domain axis is reduced by the value of {@link #getZoomInFactor()}.
 * /*  www  .j av a2 s.c  o m*/
 * @param x
 *            the x coordinate (in screen coordinates).
 * @param y
 *            the y-coordinate (in screen coordinates).
 */

public void shrinkSelectionOnDomain(double x, double y, MouseEvent selectionEvent) {
    Plot p = this.chart.getPlot();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        Selection selectionObject = new Selection();
        for (int i = 0; i < plot.getDomainAxisCount(); i++) {
            ValueAxis domain = plot.getDomainAxis(i);
            double zoomFactor = getZoomInFactor();
            shrinkSelectionXAxis(x, y, selectionObject, domain, i, zoomFactor);
        }
        informSelectionListener(selectionObject, selectionEvent);
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Increases the length of the domain axis, centered about the given coordinate on the screen.
 * The length of the domain axis is increased by the value of {@link #getZoomOutFactor()}.
 * /*from w ww  . j a v a  2s .  c  o  m*/
 * @param x
 *            the x coordinate (in screen coordinates).
 * @param y
 *            the y-coordinate (in screen coordinates).
 */

public void enlargeSelectionOnDomain(double x, double y, MouseEvent selectionEvent) {
    Plot p = this.chart.getPlot();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        Selection selectionObject = new Selection();
        for (int i = 0; i < plot.getDomainAxisCount(); i++) {
            ValueAxis domain = plot.getDomainAxis(i);
            double zoomFactor = getZoomOutFactor();
            shrinkSelectionXAxis(x, y, selectionObject, domain, i, zoomFactor);
        }
        informSelectionListener(selectionObject, selectionEvent);
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Restores the auto-range calculation on the domain axis.
 *//*from ww w.j  a  v a2 s.  c o m*/

public void selectCompleteDomainBounds() {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable z = (Zoomable) plot;
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        // we need to guard against this.zoomPoint being null
        Point2D zp = this.zoomPoint != null ? this.zoomPoint : new Point();
        z.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp);
        plot.setNotify(savedNotify);

        if (plot instanceof XYPlot) {
            XYPlot xyPlot = (XYPlot) plot;
            Selection selectionObject = new Selection();
            for (int i = 0; i < xyPlot.getDomainAxisCount(); i++) {
                ValueAxis domain = xyPlot.getDomainAxis(i);
                Range axisRange = new Range(domain.getLowerBound(), domain.getUpperBound());
                for (String axisName : axisNameResolver.resolveXAxis(i)) {
                    selectionObject.addDelimiter(axisName, axisRange);
                }
            }
            informSelectionListener(selectionObject, null);
        }
    }
}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

public void selectRectangle(Rectangle2D selection, MouseEvent selectionEvent) {
    Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY());
    if (selection.getHeight() > 0 && selection.getWidth() > 0) {

        double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        Plot p = this.chart.getPlot();
        if (p instanceof XYPlot) {
            XYPlot plot = (XYPlot) p;
            Selection selectionObject = new Selection();
            for (int i = 0; i < plot.getDomainAxisCount(); i++) {
                ValueAxis domain = plot.getDomainAxis(i);
                double lowerDomain = domain.getLowerBound();
                double upperDomain = domain.getUpperBound();
                Range axisRange = new Range(lowerDomain + (upperDomain - lowerDomain) * hLower,
                        lowerDomain + (upperDomain - lowerDomain) * hUpper);
                for (String axisName : axisNameResolver.resolveXAxis(i)) {
                    selectionObject.addDelimiter(axisName, axisRange);
                }/*ww  w  .ja va  2 s  . com*/
            }
            for (int i = 0; i < plot.getRangeAxisCount(); i++) {
                ValueAxis range = plot.getRangeAxis(i);
                double lowerRange = range.getLowerBound();
                double upperRange = range.getUpperBound();
                Range axisRange = new Range(lowerRange + (upperRange - lowerRange) * vLower,
                        lowerRange + (upperRange - lowerRange) * vUpper);
                for (String axisName : axisNameResolver.resolveYAxis(i)) {
                    selectionObject.addDelimiter(axisName, axisRange);
                }
            }
            informSelectionListener(selectionObject, selectionEvent);
        }
    }

}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

private void panAxes(double wPercent, double hPercent, MouseEvent selectionEvent) {
    Plot p = this.chart.getPlot();
    if (p instanceof XYPlot) {
        XYPlot plot = (XYPlot) p;
        Selection selectionObject = new Selection();
        for (int i = 0; i < plot.getRangeAxisCount(); i++) {
            ValueAxis axis = plot.getRangeAxis(i);
            double lowerBound = axis.getLowerBound();
            double upperBound = axis.getUpperBound();
            double shift = (upperBound - lowerBound) * hPercent;
            lowerBound += shift;/*from  w  w  w.jav  a  2s . com*/
            upperBound += shift;
            Range axisRange = new Range(lowerBound, upperBound);
            for (String axisName : axisNameResolver.resolveYAxis(i)) {
                selectionObject.addDelimiter(axisName, axisRange);
            }
        }
        for (int i = 0; i < plot.getDomainAxisCount(); i++) {
            ValueAxis axis = plot.getDomainAxis(i);
            double lowerBound = axis.getLowerBound();
            double upperBound = axis.getUpperBound();
            double shift = (upperBound - lowerBound) * wPercent;
            lowerBound += shift;
            upperBound += shift;
            Range axisRange = new Range(lowerBound, upperBound);
            for (String axisName : axisNameResolver.resolveXAxis(i)) {
                selectionObject.addDelimiter(axisName, axisRange);
            }
        }
        informSelectionListener(selectionObject, selectionEvent);
    }
}