本文整理汇总了Java中org.jfree.data.xy.XYDataset.getItemCount方法的典型用法代码示例。如果您正苦于以下问题:Java XYDataset.getItemCount方法的具体用法?Java XYDataset.getItemCount怎么用?Java XYDataset.getItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.xy.XYDataset
的用法示例。
在下文中一共展示了XYDataset.getItemCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEmptyOrNull
import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
* Returns <code>true</code> if the dataset is empty (or <code>null</code>), and
* <code>false</code> otherwise.
*
* @param dataset the dataset (<code>null</code> permitted).
*
* @return A boolean.
*/
public static boolean isEmptyOrNull(XYDataset dataset) {
boolean result = true;
if (dataset != null) {
for (int s = 0; s < dataset.getSeriesCount(); s++) {
if (dataset.getItemCount(s) > 0) {
result = false;
continue;
}
}
}
return result;
}
示例2: calculateMaxCount
import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
* It returns the number of items in the most populous series
* in the dataset.
*
* @param dataset The dataset whose series will be iterated over.
* @return The number of items in the most populous series
* in the dataset.
*/
private int calculateMaxCount(XYDataset dataset) {
int max = 0;
for (int i = 0; i < dataset.getSeriesCount(); ++i) {
int count = dataset.getItemCount(i);
if (count > max) {
max = count;
}
}
return max;
}
示例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);
}
}
示例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);
}
}
示例5: 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);
}
}
示例6: 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;
}
示例7: getPowerRegression
import org.jfree.data.xy.XYDataset; //导入方法依赖的package包/类
/**
* Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to the data using
* a power regression equation.
* <p>
* The result is returned as an array, where double[0] --> a, and double[1] --> b.
*
* @param data the data.
* @param series the series to fit the regression line against.
*
* @return the parameters.
*/
public static double[] getPowerRegression(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 = Math.log(data.getXValue(series, i));
double y = Math.log(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] = Math.pow(Math.exp(1.0), ybar - result[1] * xbar);
return result;
}
示例8: 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);
}
}
示例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;
}
示例10: 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);
}
}
示例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;
}
示例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;
}
示例13: 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 new Double(info.getRangeUpperBound(true));
}
// 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);
}
}
}
示例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);
}
}
}
示例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);
}
}