Example usage for org.jfree.data.category CategoryDataset getColumnCount

List of usage examples for org.jfree.data.category CategoryDataset getColumnCount

Introduction

In this page you can find the example usage for org.jfree.data.category CategoryDataset getColumnCount.

Prototype

public int getColumnCount();

Source Link

Document

Returns the number of columns in the table.

Usage

From source file:org.operamasks.faces.render.graph.CurveAndShapeRenderer.java

private void drawSeriesCurve(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis,
        ValueAxis rangeAxis, CategoryDataset dataset, int series) {
    // do nothing if item is not visible
    if (!(getItemVisible(series, 0) && (getItemLineVisible(series, 0) || drawArea))) {
        return;//from ww w.ja va  2 s.c o  m
    }

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    PlotOrientation orientation = plot.getOrientation();

    int itemCount = dataset.getColumnCount();
    double[][] points = new double[itemCount][2];
    int count = 0;

    // get data points
    for (int i = 0; i < itemCount; i++) {
        Number value = dataset.getValue(series, i);
        if (value != null) {
            points[count][0] = domainAxis.getCategoryMiddle(i, itemCount, dataArea, xAxisLocation);
            points[count][1] = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, yAxisLocation);
            count++;
        }
    }

    if (count < 2) {
        return;
    }

    // draw curve
    CubicSplineFunction2D f = new CubicSplineFunction2D(points, count);
    GeneralPath path = new GeneralPath();

    double startX = points[0][0];
    double startY = points[0][1];
    double endX = points[count - 1][0];
    double endY = points[count - 1][1];
    double yz = rangeAxis.valueToJava2D(0.0, dataArea, yAxisLocation);

    if (orientation == PlotOrientation.HORIZONTAL) {
        if (drawArea) {
            path.moveTo((float) yz, (float) startX);
            path.lineTo((float) startY, (float) startX);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) f.getValue(x), (float) x);
            }
            path.lineTo((float) endY, (float) endX);
            path.lineTo((float) yz, (float) endX);
            path.closePath();
        } else {
            path.moveTo((float) startY, (float) startX);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) f.getValue(x), (float) x);
            }
            path.lineTo((float) endY, (float) endX);
        }
    } else {
        if (drawArea) {
            path.moveTo((float) startX, (float) yz);
            path.lineTo((float) startX, (float) startY);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) x, (float) f.getValue(x));
            }
            path.lineTo((float) endX, (float) endY);
            path.lineTo((float) endX, (float) yz);
            path.closePath();
        } else {
            path.moveTo((float) startX, (float) startY);
            for (double x = Math.floor(startX) + 1.0; x < endX; x += 1.0) {
                path.lineTo((float) x, (float) f.getValue(x));
            }
            path.lineTo((float) endX, (float) endY);
        }
    }

    Paint paint = getSeriesPaint(series);
    Stroke stroke = getSeriesStroke(series);

    if (drawArea) {
        g2.setPaint(paint);
        g2.fill(path);

        // create paint for outline
        if (paint instanceof Color) {
            paint = ((Color) paint).darker();
        } else if (paint instanceof GradientPaint) {
            paint = ((GradientPaint) paint).getColor1().darker();
        }
    }

    if (getItemLineVisible(series, 0)) {
        g2.setPaint(paint);
        g2.setStroke(stroke);
        g2.draw(path);
    }
}

From source file:org.openfaces.component.chart.impl.renderers.LineFillRenderer.java

private void processAreaAndLine(Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis,
        ValueAxis rangeAxis, CategoryDataset dataSet, LineFillItemRendererState rendererState, int row,
        int column, double currentValue, double currentItemXPoint, double currentItemYPoint, int visibleRow) {
    int totalColumns = dataSet.getColumnCount();
    int lastColumnIndex = totalColumns - 1;
    boolean isFirstItem = column == 0;
    boolean isLastItem = (column == lastColumnIndex);

    if (isFirstItem) {
        initializeRendererState(rendererState);
    }//from  w  w  w . j  a va  2  s.c  o  m

    int previousItemIndex = Math.max(column - 1, 0);
    Number previousItemValue = dataSet.getValue(row, previousItemIndex);
    int visibleSeriesCount = rendererState.getVisibleSeriesCount();
    double previousItemXPoint = (previousItemValue != null)
            ? calculateItemXPoint(plot, dataSet, domainAxis, dataArea, previousItemIndex, visibleRow,
                    visibleSeriesCount)
            : currentItemXPoint;
    double previousItemYPoint = (previousItemValue != null)
            ? calculateItemYPoint(plot, rangeAxis, dataArea, previousItemValue.doubleValue())
            : currentItemYPoint;

    processCategoryArea(dataArea, plot, domainAxis, rangeAxis, dataSet, rendererState, row, column,
            currentValue, currentItemYPoint, totalColumns, isFirstItem, isLastItem);

    if (getItemLineVisible(row, column) && !isFirstItem) {
        addItemLine(plot, rendererState.getLines(), previousItemXPoint, previousItemYPoint, currentItemXPoint,
                currentItemYPoint);
    }
}

From source file:org.openfaces.component.chart.impl.renderers.LineFillRenderer.java

private double calculateItemXPoint(CategoryPlot plot, CategoryDataset dataSet, CategoryAxis domainAxis,
        Rectangle2D dataArea, int column, int visibleRow, int visibleRowCount) {
    double itemXPoint;
    if (getUseSeriesOffset()) {
        itemXPoint = domainAxis.getCategorySeriesMiddle(column, dataSet.getColumnCount(), visibleRow,
                visibleRowCount, getItemMargin(), dataArea, plot.getDomainAxisEdge());
    } else {/*from   w  w w.  j a  va 2 s  . c o  m*/
        itemXPoint = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
    }

    return itemXPoint;
}

From source file:extern.NpairsBoxAndWhiskerRenderer.java

/**
 * Initialises the renderer.  This method gets called once at the start of
 * the process of drawing a chart./*from   ww w  . j  a  va  2 s .co m*/
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot,
        int rendererIndex, PlotRenderingInfo info) {
    prevX = -1.0;
    prevY = -1.0;

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info);

    // calculate the box 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 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 / (dataset.getColumnCount() * dataset.getRowCount()), maxWidth));
        } else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }

    return state;

}

From source file:gov.nih.nci.caintegrator.application.graphing.BoxAndWhiskerDotsRenderer.java

/**
 * Initialises the renderer.  This method gets called once at the start of 
 * the process of drawing a chart.//w  ww .  j a  va2  s . c  om
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot,
        int rendererIndex, PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info);

    // calculate the box 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() * dataset.getRowCount()));
        } else {
            state.setBarWidth(used);
        }
    }

    if (state.getBarWidth() > maxBarWidth)
        state.setBarWidth(maxBarWidth);
    return state;

}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.renderer.FormattedScatterRenderer.java

/**
 * This function is taken directly from JFreeChart with adjustments to draw differently colored
 * items./*ww w  . ja va  2s.c  o  m*/
 * 
 * When updating JFreeChart this function must probably be adapted.
 * 
 */
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot,
        CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(row, column)) {
        return;
    }
    int visibleRow = state.getVisibleSeriesIndex(row);
    if (visibleRow < 0) {
        return;
    }
    int visibleRowCount = state.getVisibleSeriesCount();

    PlotOrientation orientation = plot.getOrientation();

    ValueSourceToMultiValueCategoryDatasetAdapter dataSet = (ValueSourceToMultiValueCategoryDatasetAdapter) dataset;
    List values = dataSet.getValues(row, column);
    if (values == null) {
        return;
    }
    int valueCount = values.size();
    for (int i = 0; i < valueCount; i++) {
        // current data point...
        double x1;
        if (getUseSeriesOffset()) {
            x1 = domainAxis.getCategorySeriesMiddle(column, dataset.getColumnCount(), visibleRow,
                    visibleRowCount, getItemMargin(), dataArea, plot.getDomainAxisEdge());
        } else {
            x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
        }
        Number n = (Number) values.get(i);
        int idx = dataSet.getValueIndex(row, column, i);
        double value = n.doubleValue();
        double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());

        Shape shape = getItemShape(row, idx);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, y1, x1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, x1, y1);
        }
        if (getItemShapeFilled(row, column)) {
            if (getUseFillPaint()) {
                g2.setPaint(getItemFillPaint(row, column));
            } else {
                g2.setPaint(getItemPaint(row, idx));
            }
            g2.fill(shape);
        }
        if (getDrawOutlines()) {
            if (getUseOutlinePaint()) {
                g2.setPaint(getItemOutlinePaint(row, column));
            } else {
                g2.setPaint(getItemPaint(row, idx));
            }
            g2.setStroke(getItemOutlineStroke(row, column));
            g2.draw(shape);
        }
    }
}

From source file:edu.dlnu.liuwenpeng.render.BarRenderer.java

/**    
* Calculates the bar width and stores it in the renderer state.    
*    /*w  ww.  j a v  a  2s  . c om*/
* @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));
        }
    }
}

From source file:open.dolphin.impl.lbtest.IgnoreNullLineRenderer.java

/**
 * Draw a single data item.//from   w  w  w.j  a  v a  2 s .c om
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area in which the data is drawn.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 * @param pass  the pass index.
 */
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot,
        CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(row, column)) {
        return;
    }

    // do nothing if both the line and shape are not visible
    if (!getItemLineVisible(row, column) && !getItemShapeVisible(row, column)) {
        return;
    }

    // nothing is drawn for null...
    Number v = dataset.getValue(row, column);
    if (v == null) {
        return;
    }

    int visibleRow = state.getVisibleSeriesIndex(row);
    if (visibleRow < 0) {
        return;
    }
    int visibleRowCount = state.getVisibleSeriesCount();

    PlotOrientation orientation = plot.getOrientation();

    // current data point...
    double x1;
    if (getUseSeriesOffset()) {
        x1 = domainAxis.getCategorySeriesMiddle(column, dataset.getColumnCount(), visibleRow, visibleRowCount,
                getItemMargin(), dataArea, plot.getDomainAxisEdge());
    } else {
        x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
    }
    double value = v.doubleValue();
    double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());

    if (pass == 0 && getItemLineVisible(row, column)) {
        if (column != 0) {
            int prevColumn = getPreviousNotNullColumn(dataset, row, column - 1);
            Number previousValue = (prevColumn != -1) ? dataset.getValue(row, prevColumn) : null;
            if (previousValue != null) {
                // previous data point...
                double previous = previousValue.doubleValue();
                double x0;
                if (getUseSeriesOffset()) {
                    x0 = domainAxis.getCategorySeriesMiddle(prevColumn, dataset.getColumnCount(), visibleRow,
                            visibleRowCount, getItemMargin(), dataArea, plot.getDomainAxisEdge());
                } else {
                    x0 = domainAxis.getCategoryMiddle(prevColumn, getColumnCount(), dataArea,
                            plot.getDomainAxisEdge());
                }
                double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge());

                Line2D line = null;
                if (orientation == PlotOrientation.HORIZONTAL) {
                    line = new Line2D.Double(y0, x0, y1, x1);
                } else if (orientation == PlotOrientation.VERTICAL) {
                    line = new Line2D.Double(x0, y0, x1, y1);
                }
                g2.setPaint(getItemPaint(row, column));
                g2.setStroke(getItemStroke(row, column));
                g2.draw(line);
            }
        }
    }

    if (pass == 1) {
        Shape shape = getItemShape(row, column);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, y1, x1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, x1, y1);
        }

        if (getItemShapeVisible(row, column)) {
            if (getItemShapeFilled(row, column)) {
                if (getUseFillPaint()) {
                    g2.setPaint(getItemFillPaint(row, column));
                } else {
                    g2.setPaint(getItemPaint(row, column));
                }
                g2.fill(shape);
            }
            if (getDrawOutlines()) {
                if (getUseOutlinePaint()) {
                    g2.setPaint(getItemOutlinePaint(row, column));
                } else {
                    g2.setPaint(getItemPaint(row, column));
                }
                g2.setStroke(getItemOutlineStroke(row, column));
                g2.draw(shape);
            }
        }

        // draw the item label if there is one...
        if (isItemLabelVisible(row, column)) {
            if (orientation == PlotOrientation.HORIZONTAL) {
                drawItemLabel(g2, orientation, dataset, row, column, y1, x1, (value < 0.0));
            } else if (orientation == PlotOrientation.VERTICAL) {
                drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value < 0.0));
            }
        }

        // submit the current data point as a crosshair candidate
        int datasetIndex = plot.indexOf(dataset);
        updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column),
                value, datasetIndex, x1, y1, orientation);

        // add an item entity, if this information is being collected
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            addItemEntity(entities, dataset, row, column, shape);
        }
    }

}

From source file:edu.jhuapl.graphs.jfreechart.CategoryLineGraphRenderer.java

/**
 * Draw a single data item.//from w w  w .  j  a v  a 2  s.  c  om
 *
 * @param g2         the graphics device.
 * @param state      the renderer state.
 * @param dataArea   the area in which the data is drawn.
 * @param plot       the plot.
 * @param domainAxis the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset    the dataset.
 * @param row        the row index (zero-based).
 * @param column     the column index (zero-based).
 * @param pass       the pass index.
 */
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot,
        CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(row, column)) {
        return;
    }

    // do nothing if both the line and shape are not visible
    if (!getItemLineVisible(row, column) && !getItemShapeVisible(row, column)) {
        return;
    }

    // nothing is drawn for null...
    Number v = dataset.getValue(row, column);
    if (v == null) {
        return;
    }

    int visibleRow = state.getVisibleSeriesIndex(row);
    if (visibleRow < 0) {
        return;
    }
    int visibleRowCount = state.getVisibleSeriesCount();

    PlotOrientation orientation = plot.getOrientation();

    // current data point...
    double x1;
    if (getUseSeriesOffset()) {
        x1 = domainAxis.getCategorySeriesMiddle(column, dataset.getColumnCount(), visibleRow, visibleRowCount,
                getItemMargin(), dataArea, plot.getDomainAxisEdge());
    } else {
        x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
    }
    double value = v.doubleValue();
    double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());

    if (pass == 0 && getItemLineVisible(row, column)) {
        if (column != 0) {
            Number previousValue = dataset.getValue(row, column - 1);

            // Added by Wayne Loschen 5/25/2010
            // Modified this method to draw a line between the last non-null value
            // instead of only drawing a line if the column - 1 value was non-null
            int prevColumnIndex = column - 1;
            if (previousValue == null) {
                while (prevColumnIndex > 0 && previousValue == null) {
                    prevColumnIndex--;
                    previousValue = dataset.getValue(row, prevColumnIndex);
                }
            }

            if (previousValue != null) {
                // previous data point...
                double previous = previousValue.doubleValue();
                double x0;
                if (getUseSeriesOffset()) {
                    // WAL - Replaced column - 1 with prevColumnIndex
                    x0 = domainAxis.getCategorySeriesMiddle(prevColumnIndex, dataset.getColumnCount(),
                            visibleRow, visibleRowCount, getItemMargin(), dataArea, plot.getDomainAxisEdge());
                } else {
                    // WAL - Replaced column - 1 with prevColumnIndex
                    x0 = domainAxis.getCategoryMiddle(prevColumnIndex, getColumnCount(), dataArea,
                            plot.getDomainAxisEdge());
                }
                double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge());

                Line2D line = null;
                if (orientation == PlotOrientation.HORIZONTAL) {
                    line = new Line2D.Double(y0, x0, y1, x1);
                } else if (orientation == PlotOrientation.VERTICAL) {
                    line = new Line2D.Double(x0, y0, x1, y1);
                }
                g2.setPaint(getItemPaint(row, column));
                g2.setStroke(getItemStroke(row, column));
                g2.draw(line);
            }
        }
    }

    if (pass == 1) {
        Shape shape = getItemShape(row, column);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, y1, x1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, x1, y1);
        }

        if (getItemShapeVisible(row, column)) {
            if (getItemShapeFilled(row, column)) {
                if (getUseFillPaint()) {
                    g2.setPaint(getItemFillPaint(row, column));
                } else {
                    g2.setPaint(getItemPaint(row, column));
                }
                g2.fill(shape);
            }
            if (getDrawOutlines()) {
                if (getUseOutlinePaint()) {
                    g2.setPaint(getItemOutlinePaint(row, column));
                } else {
                    g2.setPaint(getItemPaint(row, column));
                }
                g2.setStroke(getItemOutlineStroke(row, column));
                g2.draw(shape);
            }
        }

        // draw the item label if there is one...
        if (isItemLabelVisible(row, column)) {
            if (orientation == PlotOrientation.HORIZONTAL) {
                drawItemLabel(g2, orientation, dataset, row, column, y1, x1, (value < 0.0));
            } else if (orientation == PlotOrientation.VERTICAL) {
                drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value < 0.0));
            }
        }

        // submit the current data point as a crosshair candidate
        int datasetIndex = plot.indexOf(dataset);
        updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column),
                value, datasetIndex, x1, y1, orientation);

        // add an item entity, if this information is being collected
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            addItemEntity(entities, dataset, row, column, shape);
        }
    }

}

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

/**
 * Creates a pie dataset from a table dataset by taking all the values
 * for a single row./* w  w  w. j av  a2  s  .c o  m*/
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param row  the row (zero-based index).
 *
 * @return A pie dataset.
 */
public static PieDataset createPieDatasetForRow(CategoryDataset dataset, int row) {
    DefaultPieDataset result = new DefaultPieDataset();
    int columnCount = dataset.getColumnCount();
    for (int current = 0; current < columnCount; current++) {
        Comparable columnKey = dataset.getColumnKey(current);
        result.setValue(columnKey, dataset.getValue(row, current));
    }
    return result;
}