当前位置: 首页>>代码示例>>Java>>正文


Java XYDataset.getYValue方法代码示例

本文整理汇总了Java中org.jfree.data.xy.XYDataset.getYValue方法的典型用法代码示例。如果您正苦于以下问题:Java XYDataset.getYValue方法的具体用法?Java XYDataset.getYValue怎么用?Java XYDataset.getYValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.data.xy.XYDataset的用法示例。


在下文中一共展示了XYDataset.getYValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateToolTip

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:SymbolicXYItemLabelGenerator.java

示例2: getPreviousHeight

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Calculates the stacked value of the all series up to, but not including <code>series</code>
 * for the specified category, <code>category</code>.  It returns 0.0 if <code>series</code>
 * is the first series, i.e. 0.
 *
 * @param data  the data.
 * @param series  the series.
 * @param index  the index.
 *
 * @return double returns a cumulative value for all series' values up to
 * but excluding <code>series</code> for <code>index</code>.
 */
protected double getPreviousHeight(XYDataset data, int series, int index) {
    double result = getBase();

    double tmp;
    for (int i = 0; i < series; i++) {
        tmp = data.getYValue(i, index);
        if (!Double.isNaN(tmp)) {
            result += tmp;
        }
    }
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:StackedXYBarRenderer.java

示例3: drawSeries

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Plots the data for a given series.
 * 
 * @param g2  the drawing surface.
 * @param dataArea  the data area.
 * @param info  collects plot rendering info.
 * @param plot  the plot.
 * @param dataset  the dataset.
 * @param seriesIndex  the series index.
 */
public void drawSeries(Graphics2D g2, 
                       Rectangle2D dataArea, 
                       PlotRenderingInfo info,
                       PolarPlot plot,
                       XYDataset dataset,
                       int seriesIndex) {
    
    Polygon poly = new Polygon();
    int numPoints = dataset.getItemCount(seriesIndex);
    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i);
        double radius = dataset.getYValue(seriesIndex, i);
        Point p = plot.translateValueThetaRadiusToJava2D(theta, radius, dataArea);
        poly.addPoint(p.x, p.y);
    }
    g2.setPaint(getSeriesPaint(seriesIndex));
    g2.setStroke(getSeriesStroke(seriesIndex));
    if (isSeriesFilled(seriesIndex)) {
        Composite savedComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
        g2.fill(poly);
        g2.setComposite(savedComposite);
    }
    else {
        g2.draw(poly);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:DefaultPolarItemRenderer.java

示例4: iterateXYRangeExtent

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Iterates over the data item of the xy dataset to find
 * the range extent.
 * 
 * @param dataset  the dataset (<code>null</code> not permitted).
 * 
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateXYRangeExtent(XYDataset dataset) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_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 lvalue;
            double uvalue;
            if (dataset instanceof IntervalXYDataset) {
                IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
                lvalue = intervalXYData.getStartYValue(series, item);
                uvalue = intervalXYData.getEndYValue(series, item);
            }
            else if (dataset instanceof OHLCDataset) {
                OHLCDataset highLowData = (OHLCDataset) dataset;
                lvalue = highLowData.getLowValue(series, item);
                uvalue = highLowData.getHighValue(series, item);
            }
            else {
                lvalue = dataset.getYValue(series, item);
                uvalue = lvalue;
            }
            if (!Double.isNaN(lvalue)) {
                minimum = Math.min(minimum, lvalue);
            }
            if (!Double.isNaN(uvalue)) {     
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:47,代码来源:DatasetUtilities.java

示例5: getOLSRegression

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to the data using
 * ordinary least squares regression.
 * <p>
 * The result is returned as a double[], where result[0] --> a, and result[1] --> b.
 *
 * @param data  the data.
 * @param series  the series (zero-based index).
 *
 * @return  the parameters.
 */
public static double[] getOLSRegression(final XYDataset data, final int series) {

    final int n = data.getItemCount(series);
    if (n < 2) {
        throw new IllegalArgumentException("Not enough data.");
    }

    double sumX = 0;
    double sumY = 0;
    double sumXX = 0;
    double sumXY = 0;
    for (int i = 0; i < n; i++) {
        double x = data.getXValue(series, i);
        double y = data.getYValue(series, i);
        sumX += x;
        sumY += y;
        final double xx = x * x;
        sumXX += xx;
        final double xy = x * y;
        sumXY += xy;
    }
    final double sxx = sumXX - (sumX * sumX) / n;
    final double sxy = sumXY - (sumX * sumY) / n;
    final double xbar = sumX / n;
    final double ybar = sumY / n;

    final double[] result = new double[2];
    result[1] = sxy / sxx;
    result[0] = ybar - result[1] * xbar;

    return result;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:45,代码来源:Regression.java

示例6: drawItem

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Draws the block representing the specified item.
 * 
 * @param g2  the graphics device.
 * @param state  the state.
 * @param dataArea  the data area.
 * @param info  the plot rendering info.
 * @param plot  the plot.
 * @param domainAxis  the x-axis.
 * @param rangeAxis  the y-axis.
 * @param dataset  the dataset.
 * @param series  the series index.
 * @param item  the item index.
 * @param crosshairState  the crosshair state.
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, 
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, 
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, 
        int series, int item, CrosshairState crosshairState, int pass) {
    
    double x = dataset.getXValue(series, item);
    double y = dataset.getYValue(series, item);
    double z = 0.0;
    if (dataset instanceof XYZDataset) {
        z = ((XYZDataset) dataset).getZValue(series, item);
    }
    Paint p = this.paintScale.getPaint(z);
    double xx0 = domainAxis.valueToJava2D(x + this.xOffset, dataArea, 
            plot.getDomainAxisEdge());
    double yy0 = rangeAxis.valueToJava2D(y + this.yOffset, dataArea, 
            plot.getRangeAxisEdge());
    double xx1 = domainAxis.valueToJava2D(x + this.blockWidth 
            + this.xOffset, dataArea, plot.getDomainAxisEdge());
    double yy1 = rangeAxis.valueToJava2D(y + this.blockHeight 
            + this.yOffset, dataArea, plot.getRangeAxisEdge());
    Rectangle2D block;
    PlotOrientation orientation = plot.getOrientation();
    if (orientation.equals(PlotOrientation.HORIZONTAL)) {
        block = new Rectangle2D.Double(Math.min(yy0, yy1), 
                Math.min(xx0, xx1), Math.abs(yy1 - yy0), 
                Math.abs(xx0 - xx1));
    }
    else {
        block = new Rectangle2D.Double(Math.min(xx0, xx1), 
                Math.min(yy0, yy1), Math.abs(xx1 - xx0), 
                Math.abs(yy1 - yy0));            
    }
    g2.setPaint(p);
    g2.fill(block);
    g2.setStroke(new BasicStroke(1.0f));
    g2.draw(block);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:54,代码来源:XYBlockRenderer.java

示例7: drawSeries

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Plots the data for a given series.
 * 
 * @param g2  the drawing surface.
 * @param dataArea  the data area.
 * @param info  collects plot rendering info.
 * @param plot  the plot.
 * @param dataset  the dataset.
 * @param seriesIndex  the series index.
 */
public void drawSeries(Graphics2D g2, 
                       Rectangle2D dataArea, 
                       PlotRenderingInfo info,
                       PolarPlot plot,
                       XYDataset dataset,
                       int seriesIndex) {
    
    Polygon poly = new Polygon();
    int numPoints = dataset.getItemCount(seriesIndex);
    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i);
        double radius = dataset.getYValue(seriesIndex, i);
        Point p = plot.translateValueThetaRadiusToJava2D(theta, radius, 
                dataArea);
        poly.addPoint(p.x, p.y);
    }
    g2.setPaint(getSeriesPaint(seriesIndex));
    g2.setStroke(getSeriesStroke(seriesIndex));
    if (isSeriesFilled(seriesIndex)) {
        Composite savedComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, 0.5f));
        g2.fill(poly);
        g2.setComposite(savedComposite);
    }
    else {
        g2.draw(poly);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:40,代码来源:DefaultPolarItemRenderer.java

示例8: createItemArray

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Creates the array of items that can be passed to the 
 * {@link MessageFormat} class for creating labels.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return An array of three items from the dataset formatted as
 *         <code>String</code> objects (never <code>null</code>).
 */
protected Object[] createItemArray(XYDataset dataset, int series, 
                                   int item) {
    Object[] result = new Object[3];
    result[0] = dataset.getSeriesKey(series).toString();
    
    double x = dataset.getXValue(series, item);
    if (Double.isNaN(x) && dataset.getX(series, item) == null) {
        result[1] = this.nullXString;
    }
    else {
        if (this.xDateFormat != null) {
            result[1] = this.xDateFormat.format(new Date((long) x));   
        }
        else {
            result[1] = this.xFormat.format(x);
        }
    }
    
    double y = dataset.getYValue(series, item);
    if (Double.isNaN(y) && dataset.getY(series, item) == null) {
        result[2] = this.nullYString;
    }
    else {
        if (this.yDateFormat != null) {
            result[2] = this.yDateFormat.format(new Date((long) y));   
        }
        else {
            result[2] = this.yFormat.format(y);
        }
    }
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:44,代码来源:AbstractXYItemLabelGenerator.java

示例9: iterateXYRangeBounds

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Iterates over the data item of the xy dataset to find
 * the range bounds.
 * 
 * @param dataset  the dataset (<code>null</code> not permitted).
 * 
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateXYRangeBounds(XYDataset dataset) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_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 lvalue;
            double uvalue;
            if (dataset instanceof IntervalXYDataset) {
                IntervalXYDataset intervalXYData 
                    = (IntervalXYDataset) dataset;
                lvalue = intervalXYData.getStartYValue(series, item);
                uvalue = intervalXYData.getEndYValue(series, item);
            }
            else if (dataset instanceof OHLCDataset) {
                OHLCDataset highLowData = (OHLCDataset) dataset;
                lvalue = highLowData.getLowValue(series, item);
                uvalue = highLowData.getHighValue(series, item);
            }
            else {
                lvalue = dataset.getYValue(series, item);
                uvalue = lvalue;
            }
            if (!Double.isNaN(lvalue)) {
                minimum = Math.min(minimum, lvalue);
            }
            if (!Double.isNaN(uvalue)) {     
                maximum = Math.max(maximum, uvalue);
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:48,代码来源:DatasetUtilities.java

示例10: getOLSRegression

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to 
 * the data using ordinary least squares regression. The result is returned 
 * as a double[], where result[0] --> a, and result[1] --> b.
 *
 * @param data  the data.
 * @param series  the series (zero-based index).
 *
 * @return The parameters.
 */
public static double[] getOLSRegression(XYDataset data, int series) {

    int n = data.getItemCount(series);
    if (n < 2) {
        throw new IllegalArgumentException("Not enough data.");
    }

    double sumX = 0;
    double sumY = 0;
    double sumXX = 0;
    double sumXY = 0;
    for (int i = 0; i < n; i++) {
        double x = data.getXValue(series, i);
        double y = data.getYValue(series, i);
        sumX += x;
        sumY += y;
        double xx = x * x;
        sumXX += xx;
        double xy = x * y;
        sumXY += xy;
    }
    double sxx = sumXX - (sumX * sumX) / n;
    double sxy = sumXY - (sumX * sumY) / n;
    double xbar = sumX / n;
    double ybar = sumY / n;

    double[] result = new double[2];
    result[1] = sxy / sxx;
    result[0] = ybar - result[1] * xbar;

    return result;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:44,代码来源:Regression.java

示例11: drawItem

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Draws the block representing the specified item.
 * 
 * @param g2
 *            the graphics device.
 * @param state
 *            the state.
 * @param dataArea
 *            the data area.
 * @param info
 *            the plot rendering info.
 * @param plot
 *            the plot.
 * @param domainAxis
 *            the x-axis.
 * @param rangeAxis
 *            the y-axis.
 * @param dataset
 *            the dataset.
 * @param series
 *            the series index.
 * @param item
 *            the item index.
 * @param crosshairState
 *            the crosshair state.
 * @param pass
 *            the pass index.
 */
@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 crosshairState, int pass) {

	Shape hotspot = null;
	EntityCollection entities = null;
	if (info != null) {
		entities = info.getOwner().getEntityCollection();
	}

	double x = dataset.getXValue(series, item);
	double y = dataset.getYValue(series, item);
	double colorValue = ((XYZDataset) dataset).getZValue(series, item);
	double normalized = (colorValue - minColor) / (maxColor - minColor);

	if (Double.isNaN(x) || Double.isNaN(y)) {
		// can't draw anything
		return;
	}

	double transX = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge());
	double transY = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge());

	PlotOrientation orientation = plot.getOrientation();

	Shape shape = getItemShape(series, item);
	if (orientation == PlotOrientation.HORIZONTAL) {
		shape = ShapeUtilities.createTranslatedShape(shape, transY, transX);
	} else if (orientation == PlotOrientation.VERTICAL) {
		shape = ShapeUtilities.createTranslatedShape(shape, transX, transY);
	}
	hotspot = shape;
	if (shape.intersects(dataArea)) {
		g2.setPaint(colorProvider.getPointColor(normalized));
		g2.fill(shape);
		if (getDrawOutlines()) {
			if (getUseOutlinePaint()) {
				g2.setPaint(getItemOutlinePaint(series, item));
			} else {
				g2.setPaint(getItemPaint(series, item));
			}
			g2.setStroke(getItemOutlineStroke(series, item));
			g2.draw(shape);
		}
	}

	// add an entity for the item...
	if (entities != null) {
		addEntity(entities, hotspot, dataset, series, item, transX, transY);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:81,代码来源:ColorizedShapeItemRenderer.java

示例12: createCombinedChart

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Creates an overlaid chart.
 *
 * @return The chart.
 */
private static JFreeChart createCombinedChart() {

    // create plot ...
    IntervalXYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    renderer1.setSeriesStroke(0, new BasicStroke(4.0f,
            BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);

    DateAxis domainAxis = new DateAxis("Year");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.02);
    ValueAxis rangeAxis = new NumberAxis("$billion");
    XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    IntervalXYDataset data2 = createDataset2();
    XYBarRenderer renderer2 = new XYBarRenderer() {
        public Paint getItemPaint(int series, int item) {
            XYDataset dataset = getPlot().getDataset();
            if (dataset.getYValue(series, item) >= 0.0) {
                return Color.red;
            }
            else {
                return Color.green;
            }
        }
    };
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setDrawBarOutline(false);
    renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));

    XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"),
            renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1",
            JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    chart.setBackgroundPaint(Color.white);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);
    return chart;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:67,代码来源:CombinedXYPlotDemo1.java

示例13: findMinimumRangeValue

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * 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>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumRangeValue(XYDataset dataset) {

    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return info.getMinimumRangeValue();
    }

    // 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);
        }

    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:60,代码来源:DatasetUtilities.java

示例14: findMaximumRangeValue

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Returns the maximum 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 maximum value).  Otherwise, it involves iterating over 
 * the entire data-set.  Returns <code>null</code> if all the data values are 
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The maximum value (possibly <code>null</code>).
 */
public static Number findMaximumRangeValue(XYDataset dataset) {

    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return info.getMaximumRangeValue();
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else  {

        double maximum = Double.NEGATIVE_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.getEndYValue(series, item);
                }
                else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getHighValue(series, item);
                }
                else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    maximum = Math.max(maximum, value);
                }
            }
        }
        if (maximum == Double.NEGATIVE_INFINITY) {
            return null;
        }
        else {
            return new Double(maximum);
        }

    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:59,代码来源:DatasetUtilities.java

示例15: drawItem

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Draws the block representing the specified item.
 * 
 * @param g2  the graphics device.
 * @param state  the state.
 * @param dataArea  the data area.
 * @param info  the plot rendering info.
 * @param plot  the plot.
 * @param domainAxis  the x-axis.
 * @param rangeAxis  the y-axis.
 * @param dataset  the dataset.
 * @param series  the series index.
 * @param item  the item index.
 * @param crosshairState  the crosshair state.
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, 
        Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, 
        ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, 
        int series, int item, CrosshairState crosshairState, int pass) {
    
    double x = dataset.getXValue(series, item);
    double y = dataset.getYValue(series, item);
    double dx = 0.0;
    double dy = 0.0;
    if (dataset instanceof VectorXYDataset) {
        dx = ((VectorXYDataset) dataset).getDeltaXValue(series, item);
        dy = ((VectorXYDataset) dataset).getDeltaYValue(series, item);
    }
    double xx0 = domainAxis.valueToJava2D(x, dataArea, 
            plot.getDomainAxisEdge());
    double yy0 = rangeAxis.valueToJava2D(y, dataArea, 
            plot.getRangeAxisEdge());
    double xx1 = domainAxis.valueToJava2D(x + dx, dataArea, 
            plot.getDomainAxisEdge());
    double yy1 = rangeAxis.valueToJava2D(y + dy, dataArea, 
            plot.getRangeAxisEdge());
    Line2D line;
    PlotOrientation orientation = plot.getOrientation();
    if (orientation.equals(PlotOrientation.HORIZONTAL)) {
        line = new Line2D.Double(yy0, xx0, yy1, xx1);
    }
    else {
        line = new Line2D.Double(xx0, yy0, xx1, yy1);
    }
    g2.setPaint(getItemPaint(series, item));
    g2.setStroke(getItemStroke(series, item));
    g2.draw(line);
    
    // calculate the arrow head and draw it...
    double dxx = (xx1 - xx0);
    double dyy = (yy1 - yy0);
    double bx = xx0 + (1.0 - this.baseLength) * dxx;
    double by = yy0 + (1.0 - this.baseLength) * dyy;
    
    double cx = xx0 + (1.0 - this.headLength) * dxx;
    double cy = yy0 + (1.0 - this.headLength) * dyy;
 
    double angle = 0.0;
    if (dxx != 0.0) {
        angle = Math.PI / 2.0 - Math.atan(dyy / dxx);
    }
    double deltaX = 2.0 * Math.cos(angle);
    double deltaY = 2.0 * Math.sin(angle);
    
    double leftx = cx + deltaX;
    double lefty = cy - deltaY;
    double rightx = cx - deltaX;
    double righty = cy + deltaY;
    
    GeneralPath p = new GeneralPath();
    p.moveTo((float) xx1, (float) yy1);
    p.lineTo((float) rightx, (float) righty);
    p.lineTo((float) bx, (float) by);
    p.lineTo((float) leftx, (float) lefty);
    p.closePath();
    g2.draw(p);
    
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:81,代码来源:VectorRenderer.java


注:本文中的org.jfree.data.xy.XYDataset.getYValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。