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


Java XYDataset.getXValue方法代码示例

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


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

示例1: generateURL

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Generates a URL for a particular item within a series.
 *
 * @param dataset  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The generated URL.
 */
public String generateURL(XYDataset dataset, int series, int item) {
    String result = this.prefix;
    boolean firstParameter = result.indexOf("?") == -1;
    Comparable seriesKey = dataset.getSeriesKey(series);
    if (seriesKey != null) {
        result += firstParameter ? "?" : "&";
        result += this.seriesParameterName + "=" + seriesKey.toString();
        firstParameter = false;
    }

    long x = (long) dataset.getXValue(series, item);
    String xValue = this.dateFormat.format(new Date(x));
    result += firstParameter ? "?" : "&";
    result += this.itemParameterName + "=" + xValue;

    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:TimeSeriesURLGenerator.java

示例2: 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

示例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: iterateDomainExtent

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Iterates over the items in an {@link XYDataset} to find
 * the range of x-values. 
 *  
 * @param dataset  the dataset (<code>null</code> not permitted).
 * 
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateDomainExtent(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");   
    }
    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.getStartXValue(series, item);
                uvalue = intervalXYData.getEndXValue(series, item);
            }
            else {
                lvalue = dataset.getXValue(series, item);
                uvalue = lvalue;
            }
            minimum = Math.min(minimum, lvalue);
            maximum = Math.max(maximum, uvalue);
        }
    }
    if (minimum > maximum) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源: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: 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

示例10: 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

示例11: findMinimumDomainValue

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Finds the minimum domain (or X) value for the specified dataset.  This is easy if 
 * the dataset implements the {@link DomainInfo} interface (a good idea if there is an 
 * efficient way to determine the minimum value).  Otherwise, it involves iterating over 
 * the entire data-set.
 * <p>
 * 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 findMinimumDomainValue(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Number result = null;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return info.getMinimumDomainValue();
    }
    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.getStartXValue(series, item);
                }
                else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

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

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

示例12: findMaximumDomainValue

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Returns the maximum domain value for the specified dataset.  This is easy if the 
 * dataset implements the {@link DomainInfo} 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 in the dataset 
 * are <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The maximum value (possibly <code>null</code>).
 */
public static Number findMaximumDomainValue(XYDataset dataset) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Number result = null;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return info.getMaximumDomainValue();
    }

    // hasn't implemented DomainInfo, so 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.getEndXValue(series, item);
                }
                else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    maximum = Math.max(maximum, value);
                }
            }
        }
        if (maximum == Double.NEGATIVE_INFINITY) {
            result = null;
        }
        else {
            result = new Double(maximum);
        }

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

示例13: 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

示例14: drawPrimaryLine

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Draws the item (first pass). This method draws the lines
 * connecting the items.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param plot  the plot (can be used to obtain standard color 
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param pass  the pass.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 */
protected void drawPrimaryLine(XYItemRendererState state,
                               Graphics2D g2,
                               XYPlot plot,
                               XYDataset dataset,
                               int pass,
                               int series,
                               int item,
                               ValueAxis domainAxis,
                               ValueAxis rangeAxis,
                               Rectangle2D dataArea) {
    if (item == 0) {
        return;
    }

    // get the data point...
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);
    if (Double.isNaN(y1) || Double.isNaN(x1)) {
        return;
    }

    double x0 = dataset.getXValue(series, item - 1);
    double y0 = dataset.getYValue(series, item - 1);
    if (Double.isNaN(y0) || Double.isNaN(x0)) {
        return;
    }

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();

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

    double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

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

    PlotOrientation orientation = plot.getOrientation();
    if (orientation == PlotOrientation.HORIZONTAL) {
        state.workingLine.setLine(transY0, transX0, transY1, transX1);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        state.workingLine.setLine(transX0, transY0, transX1, transY1);
    }

    if (state.workingLine.intersects(dataArea)) {
        drawFirstPassShape(g2, pass, series, item, state.workingLine);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:71,代码来源:XYLineAndShapeRenderer.java

示例15: drawPrimaryLineAsPath

import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
 * Draws the item (first pass). This method draws the lines
 * connecting the items. Instead of drawing separate lines,
 * a GeneralPath is constructed and drawn at the end of
 * the series painting.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param plot  the plot (can be used to obtain standard color information 
 *              etc).
 * @param dataset  the dataset.
 * @param pass  the pass.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataArea  the area within which the data is being drawn.
 */
protected void drawPrimaryLineAsPath(XYItemRendererState state,
                                     Graphics2D g2, XYPlot plot,
                                     XYDataset dataset,
                                     int pass,
                                     int series,
                                     int item,
                                     ValueAxis domainAxis,
                                     ValueAxis rangeAxis,
                                     Rectangle2D dataArea) {


    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();

    // get the data point...
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);
    double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

    State s = (State) state;
    // update path to reflect latest point
    if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) {
        float x = (float) transX1;
        float y = (float) transY1;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            x = (float) transY1;
            y = (float) transX1;
        }
        if (s.isLastPointGood()) {
            s.seriesPath.lineTo(x, y);
        }
        else {
            s.seriesPath.moveTo(x, y);
        }
        s.setLastPointGood(true);
    }
    else {
        s.setLastPointGood(false);
    }
    // if this is the last item, draw the path ...
    if (item == dataset.getItemCount(series) - 1) {
        // draw path
        drawFirstPassShape(g2, pass, series, item, s.seriesPath);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:66,代码来源:XYLineAndShapeRenderer.java


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