本文整理汇总了Java中org.jfree.data.category.CategoryDataset.getRowCount方法的典型用法代码示例。如果您正苦于以下问题:Java CategoryDataset.getRowCount方法的具体用法?Java CategoryDataset.getRowCount怎么用?Java CategoryDataset.getRowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.category.CategoryDataset
的用法示例。
在下文中一共展示了CategoryDataset.getRowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEmptyOrNull
import org.jfree.data.category.CategoryDataset; //导入方法依赖的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(CategoryDataset dataset) {
if (dataset == null) {
return true;
}
int rowCount = dataset.getRowCount();
int columnCount = dataset.getColumnCount();
if (rowCount == 0 || columnCount == 0) {
return true;
}
for (int r = 0; r < rowCount; r++) {
for (int c = 0; c < columnCount; c++) {
if (dataset.getValue(r, c) != null) {
return false;
}
}
}
return true;
}
示例2: isEmptyOrNull
import org.jfree.data.category.CategoryDataset; //导入方法依赖的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(CategoryDataset dataset) {
if (dataset == null) {
return true;
}
int rowCount = dataset.getRowCount();
int columnCount = dataset.getColumnCount();
if (rowCount == 0 || columnCount == 0) {
return true;
}
for (int r = 0; r < rowCount; r++) {
for (int c = 0; c < columnCount; c++) {
if (dataset.getValue(r, c) != null) {
return false;
}
}
}
return true;
}
示例3: initialise
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Initialises the renderer and returns a state object that will be used
* for the remainder of the drawing process for a single chart. The state
* object allows for the fact that the renderer may be used simultaneously
* by multiple threads (each thread will work with a separate state object).
*
* @param g2 the graphics device.
* @param dataArea the data area.
* @param plot the plot.
* @param rendererIndex the renderer index.
* @param info an object for returning information about the structure of
* the plot (<code>null</code> permitted).
*
* @return The renderer state.
*/
public CategoryItemRendererState initialise(Graphics2D g2,
Rectangle2D dataArea,
CategoryPlot plot,
int rendererIndex,
PlotRenderingInfo info) {
setPlot(plot);
CategoryDataset data = plot.getDataset(rendererIndex);
if (data != null) {
this.rowCount = data.getRowCount();
this.columnCount = data.getColumnCount();
}
else {
this.rowCount = 0;
this.columnCount = 0;
}
return createState(info);
}
示例4: getLegendItems
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Returns a (possibly empty) collection of legend items for the series
* that this renderer is responsible for drawing.
*
* @return The legend item collection (never <code>null</code>).
*
* @see #getLegendItem(int, int)
*/
public LegendItemCollection getLegendItems() {
if (this.plot == null) {
return new LegendItemCollection();
}
LegendItemCollection result = new LegendItemCollection();
int index = this.plot.getIndexOf(this);
CategoryDataset dataset = this.plot.getDataset(index);
if (dataset != null) {
int seriesCount = dataset.getRowCount();
for (int i = 0; i < seriesCount; i++) {
if (isSeriesVisibleInLegend(i)) {
LegendItem item = getLegendItem(index, i);
if (item != null) {
result.add(item);
}
}
}
}
return result;
}
示例5: createPieDatasetForColumn
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Creates a pie dataset from a {@link CategoryDataset} by taking all the
* values for a single column.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param column the column (zero-based index).
*
* @return A pie dataset.
*/
public static PieDataset createPieDatasetForColumn(CategoryDataset dataset,
int column) {
DefaultPieDataset result = new DefaultPieDataset();
int rowCount = dataset.getRowCount();
for (int i = 0; i < rowCount; i++) {
Comparable rowKey = dataset.getRowKey(i);
result.setValue(rowKey, dataset.getValue(i, column));
}
return result;
}
示例6: findMaximumStackedRangeValue
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Returns the maximum value in the dataset range, assuming that values in
* each category are "stacked".
*
* @param dataset the dataset (<code>null</code> permitted).
*
* @return The maximum value (possibly <code>null</code>).
*/
public static Number findMaximumStackedRangeValue(CategoryDataset dataset) {
Number result = null;
if (dataset != null) {
double maximum = 0.0;
int categoryCount = dataset.getColumnCount();
for (int item = 0; item < categoryCount; item++) {
double total = 0.0;
int seriesCount = dataset.getRowCount();
for (int series = 0; series < seriesCount; series++) {
Number number = dataset.getValue(series, item);
if (number != null) {
double value = number.doubleValue();
if (value > 0.0) {
total = total + value;
}
}
}
maximum = Math.max(maximum, total);
}
result = new Double(maximum);
}
return result;
}
示例7: calculateBarWidth
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Calculates the bar width and stores it in the renderer state.
*
* @param plot the plot.
* @param dataArea the data area.
* @param rendererIndex the renderer index.
* @param state the renderer state.
*/
protected void calculateBarWidth(CategoryPlot plot,
Rectangle2D dataArea,
int rendererIndex,
CategoryItemRendererState state) {
// calculate the bar width
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
CategoryDataset dataset = plot.getDataset(rendererIndex);
if (dataset != null) {
int columns = dataset.getColumnCount();
int rows = dataset.getRowCount();
double space = 0.0;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
space = dataArea.getHeight();
}
else if (orientation == PlotOrientation.VERTICAL) {
space = dataArea.getWidth();
}
double categoryMargin = 0.0;
double currentItemMargin = 0.0;
if (columns > 1) {
categoryMargin = domainAxis.getCategoryMargin();
}
if (rows > 1) {
currentItemMargin = getItemMargin();
}
double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin()
- categoryMargin - currentItemMargin);
if ((rows * columns) > 0) {
state.setBarWidth(used / (dataset.getColumnCount()));
}
else {
state.setBarWidth(used);
}
}
}
示例8: calculateItemWidth
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Calculates the bar width and stores it in the renderer state.
*
* @param plot the plot.
* @param dataArea the data area.
* @param rendererIndex the renderer index.
* @param state the renderer state.
*/
protected void calculateItemWidth(CategoryPlot plot,
Rectangle2D dataArea,
int rendererIndex,
CategoryItemRendererState state) {
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
CategoryDataset dataset = plot.getDataset(rendererIndex);
if (dataset != null) {
int columns = dataset.getColumnCount();
int rows = dataset.getRowCount();
double space = 0.0;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
space = dataArea.getHeight();
}
else if (orientation == PlotOrientation.VERTICAL) {
space = dataArea.getWidth();
}
double maxWidth = space * getMaxItemWidth();
double categoryMargin = 0.0;
double currentItemMargin = 0.0;
if (columns > 1) {
categoryMargin = domainAxis.getCategoryMargin();
}
if (rows > 1) {
currentItemMargin = getItemMargin();
}
double used = space * (1 - domainAxis.getLowerMargin()
- domainAxis.getUpperMargin()
- categoryMargin - currentItemMargin);
if ((rows * columns) > 0) {
state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
}
else {
state.setBarWidth(Math.min(used, maxWidth));
}
}
}
示例9: createPieDatasetForColumn
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Creates a pie dataset from a {@link CategoryDataset} by taking all the values
* for a single column.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param column the column (zero-based index).
*
* @return A pie dataset.
*/
public static PieDataset createPieDatasetForColumn(CategoryDataset dataset,
int column) {
DefaultPieDataset result = new DefaultPieDataset();
int rowCount = dataset.getRowCount();
for (int i = 0; i < rowCount; i++) {
Comparable rowKey = dataset.getRowKey(i);
result.setValue(rowKey, dataset.getValue(i, column));
}
return result;
}
示例10: iterateCategoryRangeExtent
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Iterates over the data item of the category 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 iterateCategoryRangeExtent(CategoryDataset dataset) {
double minimum = Double.POSITIVE_INFINITY;
double maximum = Double.NEGATIVE_INFINITY;
int rowCount = dataset.getRowCount();
int columnCount = dataset.getColumnCount();
for (int row = 0; row < rowCount; row++) {
for (int column = 0; column < columnCount; column++) {
Number lvalue;
Number uvalue;
if (dataset instanceof IntervalCategoryDataset) {
IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;
lvalue = icd.getStartValue(row, column);
uvalue = icd.getEndValue(row, column);
}
else {
lvalue = dataset.getValue(row, column);
uvalue = lvalue;
}
if (lvalue != null) {
minimum = Math.min(minimum, lvalue.doubleValue());
}
if (uvalue != null) {
maximum = Math.max(maximum, uvalue.doubleValue());
}
}
}
if (minimum == Double.POSITIVE_INFINITY) {
return null;
}
else {
return new Range(minimum, maximum);
}
}
示例11: findMinimumStackedRangeValue
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Returns the minimum value in the dataset range, assuming that values in
* each category are "stacked".
*
* @param dataset the dataset.
*
* @return the minimum value.
*/
public static Number findMinimumStackedRangeValue(CategoryDataset dataset) {
Number result = null;
if (dataset != null) {
double minimum = 0.0;
int categoryCount = dataset.getRowCount();
for (int item = 0; item < categoryCount; item++) {
double total = 0.0;
int seriesCount = dataset.getColumnCount();
for (int series = 0; series < seriesCount; series++) {
Number number = dataset.getValue(series, item);
if (number != null) {
double value = number.doubleValue();
if (value < 0.0) {
total = total + value; // '+', remember value is negative
}
}
}
minimum = Math.min(minimum, total);
}
result = new Double(minimum);
}
return result;
}
示例12: calculateBarWidth
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
/**
* Calculates the bar width and stores it in the renderer state.
*
* @param plot the plot.
* @param dataArea the data area.
* @param rendererIndex the renderer index.
* @param state the renderer state.
*/
protected void calculateBarWidth(CategoryPlot plot,
Rectangle2D dataArea,
int rendererIndex,
CategoryItemRendererState state) {
CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
CategoryDataset dataset = plot.getDataset(rendererIndex);
if (dataset != null) {
int columns = dataset.getColumnCount();
int rows = dataset.getRowCount();
double space = 0.0;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
space = dataArea.getHeight();
}
else if (orientation == PlotOrientation.VERTICAL) {
space = dataArea.getWidth();
}
double maxWidth = space * getMaximumBarWidth();
double categoryMargin = 0.0;
double currentItemMargin = 0.0;
if (columns > 1) {
categoryMargin = domainAxis.getCategoryMargin();
}
if (rows > 1) {
currentItemMargin = getItemMargin();
}
double used = space * (1 - domainAxis.getLowerMargin()
- domainAxis.getUpperMargin()
- categoryMargin - currentItemMargin);
if ((rows * columns) > 0) {
state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
}
else {
state.setBarWidth(Math.min(used, maxWidth));
}
}
}
示例13: createNominalChart
import org.jfree.data.category.CategoryDataset; //导入方法依赖的package包/类
private JFreeChart createNominalChart() {
JFreeChart chart;
CategoryDataset dataset = createNominalDataSet();
// create the chart...
String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
chart = ChartFactory.createBarChart(null, // chart title
domainName, // x axis label
RANGE_AXIS_NAME, // y axis label
dataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
CategoryPlot plot = chart.getCategoryPlot();
BarRenderer renderer = new BarRenderer();
if (dataset.getRowCount() == 1) {
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
} else {
for (int i = 0; i < dataset.getRowCount(); i++) {
Color color = getColorProvider(true).getPointColor((double) i / (double) (dataset.getRowCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setBarPainter(new RapidBarPainter());
renderer.setDrawBarOutline(true);
plot.setRenderer(renderer);
// rotate labels
if (isLabelRotating()) {
plot.getDomainAxis().setTickLabelsVisible(true);
plot.getDomainAxis().setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
}
return chart;
}
示例14: findMinimumRangeValue
import org.jfree.data.category.CategoryDataset; //导入方法依赖的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(CategoryDataset dataset) {
// check parameters...
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.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);
}
}
}
示例15: findMaximumRangeValue
import org.jfree.data.category.CategoryDataset; //导入方法依赖的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(CategoryDataset 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.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.getEndValue(series, item);
}
else {
value = dataset.getValue(series, item);
}
if (value != null) {
maximum = Math.max(maximum, value.doubleValue());
}
}
}
if (maximum == Double.NEGATIVE_INFINITY) {
return null;
}
else {
return new Double(maximum);
}
}
}