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

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

Introduction

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

Prototype

public void centerRange(double value) 

Source Link

Document

Centers the axis range about the specified value and sends an AxisChangeEvent to all registered listeners.

Usage

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

/**
 * Move plot up/down./*from www.j a v  a  2s  . c o  m*/
 *
 * @param up up
 */
private void upDownPlot(boolean up) {
    if (!(plot instanceof XYPlot)) {
        return;
    }
    XYPlot xyPlot = (XYPlot) plot;

    int cnt = xyPlot.getRangeAxisCount();
    for (int i = 0; i < cnt; i++) {
        ValueAxis axis = (ValueAxis) xyPlot.getRangeAxis(i);
        org.jfree.data.Range range = axis.getRange();
        double width = range.getUpperBound() - range.getLowerBound();
        double width2 = width / 2.0;
        double step = (up ? width * 0.1 : -width * 0.1);
        axis.centerRange(range.getLowerBound() + step + width2);
    }
}

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

/**
 * Move plot up/down.//from ww w .j av a  2s  .  c  o m
 *
 * @param up up
 */
private void upDownPlot(boolean up) {
    if (!(chart.getPlot() instanceof XYPlot)) {
        return;
    }
    XYPlot plot = (XYPlot) chart.getPlot();

    int cnt = plot.getRangeAxisCount();
    for (int i = 0; i < cnt; i++) {
        ValueAxis axis = (ValueAxis) plot.getRangeAxis(i);
        org.jfree.data.Range range = axis.getRange();
        double width = range.getUpperBound() - range.getLowerBound();
        double width2 = width / 2.0;
        double step = (up ? width * 0.1 : -width * 0.1);
        axis.centerRange(range.getLowerBound() + step + width2);
    }
}

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

/**
 * Pan the plot//from www  . j  a va 2 s .  co 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 w  w  . ja v a  2s .c  o  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.TimeSeriesChartWrapper.java

/**
 * Center the domain axis about/* w w  w.  j a  va  2  s.co m*/
 *
 * @param wayPoint  The way point
 */
public void centerOn(WayPoint wayPoint) {
    ValueAxis axis = (ValueAxis) plot.getDomainAxis();
    axis.centerRange(wayPoint.getDomainValue());
}

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

/**
 * Center the range axis//w ww  .j  a  v  a  2s  . c  o  m
 *
 * @param rangeFilter  The range filter
 */
public void centerOn(RangeFilter rangeFilter) {
    ValueAxis axis = (ValueAxis) plot.getRangeAxis();
    axis.centerRange(rangeFilter.getRangeValue());

}

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

/**
 * Set the time we're at//from   www  . j  a v a  2 s  .  c  o m
 *
 * @param value time
 * @param andDriveAnimation Set the time in the animation widget
 */
protected void setTime(double value, boolean andDriveAnimation) {
    if (inSetTime) {
        return;
    }
    inSetTime = true;
    if (timeWayPoint == null) {
        setTimeWayPoint(new WayPoint(value, this));
        timeWayPoint.setIsForAnimation(true);
        timeWayPoint.setName("Time");
        wayPoints.add(timeWayPoint);
        plot.addAnnotation(timeWayPoint);
    }
    timeWayPoint.setDomainValue(value);
    ValueAxis axis = (ValueAxis) plot.getDomainAxis();
    axis.centerRange(value);
    firePropertyChange(PROP_TIMERANGE, null, segments);

    if (andDriveAnimation && getDriveTime() && (animationWidget != null)) {
        lastTimeWeDrove = System.currentTimeMillis();
        animationWidget.setTimeFromUser(new Real(RealType.Time, value / 1000));
    }
    inSetTime = false;
}