Example usage for org.jfree.data RangeInfo getRangeLowerBound

List of usage examples for org.jfree.data RangeInfo getRangeLowerBound

Introduction

In this page you can find the example usage for org.jfree.data RangeInfo getRangeLowerBound.

Prototype

public double getRangeLowerBound(boolean includeInterval);

Source Link

Document

Returns the minimum y-value in the dataset.

Usage

From source file:net.sourceforge.processdash.ev.ui.chart.RangeXYItemRenderer.java

/** Draws the visual representation of a single data item.
 *//* ww w .  j a  v a  2 s. c  o  m*/
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairInfo, int pass) {

    // setup for collecting optional entity info...
    EntityCollection entities = null;
    if (info != null) {
        entities = info.getOwner().getEntityCollection();
    }
    Shape entityArea = null;

    Paint paint = getItemPaint(series, item);
    Stroke seriesStroke = getItemStroke(series, item);
    g2.setPaint(paint);
    g2.setStroke(seriesStroke);

    // get the data point...
    Number x1n = dataset.getX(series, item);
    Number y1n = dataset.getY(series, item);
    if (y1n == null || x1n == null) {
        return;
    }

    double x1 = x1n.doubleValue();
    double y1 = y1n.doubleValue();
    final RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    final RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
    PlotOrientation orientation = plot.getOrientation();

    if (item > 0) {
        // get the previous data point...
        Number x0n = dataset.getX(series, item - 1);
        Number y0n = dataset.getY(series, item - 1);
        if (y0n != null && x0n != null) {
            double x0 = x0n.doubleValue();
            double y0 = y0n.doubleValue();

            double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
            double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

            // only draw if we have good values
            if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1)
                    || Double.isNaN(transY1)) {
                return;
            }

            if (orientation == PlotOrientation.HORIZONTAL) {
                line.setLine(transY0, transX0, transY1, transX1);
            } else if (orientation == PlotOrientation.VERTICAL) {
                line.setLine(transX0, transY0, transX1, transY1);
            }

            if (y1n instanceof RangeInfo) {
                RangeInfo y1r = (RangeInfo) y1n;
                double transY1low = rangeAxis.valueToJava2D(y1r.getRangeLowerBound(false), dataArea,
                        yAxisLocation);
                double transY1high = rangeAxis.valueToJava2D(y1r.getRangeUpperBound(false), dataArea,
                        yAxisLocation);
                drawItemRangeGradient(g2, line, paint, seriesStroke, transX1, transY1low, transX1, transY1high);

            } else if (x1n instanceof RangeInfo) {
                RangeInfo x1r = (RangeInfo) x1n;
                double transX1low = domainAxis.valueToJava2D(x1r.getRangeLowerBound(false), dataArea,
                        xAxisLocation);
                double transX1high = domainAxis.valueToJava2D(x1r.getRangeUpperBound(false), dataArea,
                        xAxisLocation);
                drawItemRangeGradient(g2, line, paint, seriesStroke, transX1low, transY1, transX1high, transY1);

            } else if (line.intersects(dataArea)) {
                g2.draw(line);
            }
        }
    } else if (dataset.getItemCount(series) == 1) {
        Shape shape = getItemShape(series, item);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        }
        if (shape.intersects(dataArea)) {
            if (getItemShapeFilled(series, item)) {
                g2.fill(shape);
            } else {
                g2.draw(shape);
            }
        }
        entityArea = shape;
    }

    if (entities != null && (dataArea.contains(transX1, transY1) || entityArea != null)) {
        addEntity(entities, entityArea, dataset, series, item, transX1, transY1);
    }

}

From source file:org.jfree.data.general.DatasetUtils.java

/**
 * Returns the minimum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * {@code null} if all the data values in the dataset are
 * {@code null}./*from  w  ww.  jav a2s  .co m*/
 *
 * @param dataset  the dataset ({@code null} not permitted).
 *
 * @return The minimum value (possibly {@code null}).
 */
public static Number findMinimumRangeValue(CategoryDataset dataset) {
    Args.nullNotPermitted(dataset, "dataset");
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getRowCount();
        int itemCount = dataset.getColumnCount();
        for (int series = 0; series < seriesCount; series++) {
            for (int item = 0; item < itemCount; item++) {
                Number value;
                if (dataset instanceof IntervalCategoryDataset) {
                    IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;
                    value = icd.getStartValue(series, item);
                } else {
                    value = dataset.getValue(series, item);
                }
                if (value != null) {
                    minimum = Math.min(minimum, value.doubleValue());
                }
            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        } else {
            return new Double(minimum);
        }

    }

}

From source file:org.jfree.data.general.DatasetUtils.java

/**
 * Returns the minimum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * {@code null} if all the data values in the dataset are
 * {@code null}./*w  w w  . j  a  va 2 s .  c  o  m*/
 *
 * @param dataset  the dataset ({@code null} not permitted).
 *
 * @return The minimum value (possibly {@code null}).
 */
public static Number findMinimumRangeValue(XYDataset dataset) {
    Args.nullNotPermitted(dataset, "dataset");

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartYValue(series, item);
                } else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getLowValue(series, item);
                } else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        } else {
            return new Double(minimum);
        }

    }

}

From source file:org.jfree.data.general.DatasetUtilities.java

/**
 * Returns the minimum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * <code>null</code> if all the data values in the dataset are
 * <code>null</code>./*from  w w w  . ja v  a  2s. c  o  m*/
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumRangeValue(CategoryDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getRowCount();
        int itemCount = dataset.getColumnCount();
        for (int series = 0; series < seriesCount; series++) {
            for (int item = 0; item < itemCount; item++) {
                Number value;
                if (dataset instanceof IntervalCategoryDataset) {
                    IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;
                    value = icd.getStartValue(series, item);
                } else {
                    value = dataset.getValue(series, item);
                }
                if (value != null) {
                    minimum = Math.min(minimum, value.doubleValue());
                }
            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        } else {
            return new Double(minimum);
        }

    }

}

From source file:org.jfree.data.general.DatasetUtilities.java

/**
 * Returns the minimum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * <code>null</code> if all the data values in the dataset are
 * <code>null</code>.//from   w  w w  .ja  v a  2s .c  om
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumRangeValue(XYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartYValue(series, item);
                } else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getLowValue(series, item);
                } else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        } else {
            return new Double(minimum);
        }

    }

}