Example usage for org.jfree.data.statistics BoxAndWhiskerCategoryDataset getQ3Value

List of usage examples for org.jfree.data.statistics BoxAndWhiskerCategoryDataset getQ3Value

Introduction

In this page you can find the example usage for org.jfree.data.statistics BoxAndWhiskerCategoryDataset getQ3Value.

Prototype

public Number getQ3Value(Comparable rowKey, Comparable columnKey);

Source Link

Document

Returns the q3median value for an item.

Usage

From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java

private RectangleEdge drawRectangles(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, ValueAxis rangeAxis, int row, int column, BoxAndWhiskerCategoryDataset bawDataset,
        double xx) {
    RectangleEdge location = plot.getRangeAxisEdge();

    Number yQ1 = bawDataset.getQ1Value(row, column);
    Number yQ3 = bawDataset.getQ3Value(row, column);
    Number yMax = bawDataset.getMaxRegularValue(row, column);
    Number yMin = bawDataset.getMinRegularValue(row, column);
    Shape box = null;//from ww  w.  j av a  2  s . c  o m
    if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) {
        double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location);
        double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location);
        double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location);
        double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location);
        double xxmid = xx + state.getBarWidth() / 2.0;

        // draw the upper shadow...
        g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3));
        g2.draw(new Line2D.Double(xx, yyMax, xx + state.getBarWidth(), yyMax));

        // draw the lower shadow...
        g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1));
        g2.draw(new Line2D.Double(xx, yyMin, xx + state.getBarWidth(), yyMin));

        // draw the body...
        box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), state.getBarWidth(), Math.abs(yyQ1 - yyQ3));
        if (getFillBox()) {
            g2.fill(box);
        }
        g2.draw(box);
    }
    return location;
}

From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.ExtendedBoxAndWhiskerRenderer.java

/**
 * Draws the visual representation of a single data item when the plot has a
 * vertical orientation.//  w w  w.  j  a va 2s  .com
 *
 * @param g2 the graphics device.
 * @param state the renderer state.
 * @param dataArea the area within which the plot 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 row the row index (zero-based).
 * @param column the column index (zero-based).
 */
@Override
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {

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

    //Determine the catgory start and end.
    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;

    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = categoryEnd - categoryStart;

    domainAxis.setCategoryMargin(0.25);

    rangeAxis.setUpperMargin(0.3);
    rangeAxis.setLowerMargin(0.3);

    double xx = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();

    if (seriesCount > 1) {
        double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1));
        double usedWidth = (state.getBarWidth() * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        xx = xx + offset + (row * (state.getBarWidth() + seriesGap));
    } else {
        // offset the start of the box if the box width is smaller than the category width
        double offset = (categoryWidth - state.getBarWidth()) / 2;
        xx = xx + offset;
    }
    double xxmid = xx + state.getBarWidth() / 2.0;

    //Draw the box.
    Paint p = getItemPaint(row, column);
    if (p != null) {
        g2.setPaint(p);
    }
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);

    RectangleEdge location = plot.getRangeAxisEdge();
    Shape box = null;

    Number yQ1 = bawDataset.getQ1Value(row, column);
    Number yQ3 = bawDataset.getQ3Value(row, column);
    Number yMax = bawDataset.getMaxRegularValue(row, column);
    Number yMin = bawDataset.getMinRegularValue(row, column);

    if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) {

        double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location);
        double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location);
        double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location);
        double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location);

        // set the paint according to the right technical replicate
        int length = GuiUtils.getAvailableColors().length;
        int colorIndex = row % length;
        Color color = GuiUtils.getAvailableColors()[colorIndex];
        g2.setPaint(color);

        // draw the upper whisker
        g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3));
        g2.draw(new Line2D.Double(xx, yyMax, xx + state.getBarWidth(), yyMax));
        // draw the lower whisker
        g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1));
        g2.draw(new Line2D.Double(xx, yyMin, xx + state.getBarWidth(), yyMin));

        // draw the body
        box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), state.getBarWidth(), Math.abs(yyQ1 - yyQ3));
        g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175));

        //            if (getFillBox()) {
        //                g2.fill(box);
        //            }
        g2.draw(box);
    }

    // draw mean 
    g2.setPaint(getArtifactPaint());
    double yyAverage = 0.0;
    double aRadius = 2.0; // mean radius                       
    Number yMean = bawDataset.getMeanValue(row, column);
    if (yMean != null) {
        yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location);
        Ellipse2D.Double avgEllipse = new Ellipse2D.Double((xxmid - aRadius), (yyAverage - aRadius),
                aRadius * 2, aRadius * 2);
        g2.draw(avgEllipse);
    }

    //draw median
    double yyMedian = 0.0;
    Number yMedian = bawDataset.getMedianValue(row, column);
    if (yMedian != null) {
        yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location);
        g2.draw(new Line2D.Double(xx, yyMedian, xx + state.getBarWidth(), yyMedian));
    }

    //Outliers and Farouts                 
    double oRadius = 2.0; //outlier radius
    double foRadius = 1.0; //farout radius

    // From outlier array sort out which are outliers and put these into a 
    // list. If there are any farouts, add them to the farout list.    
    // draw the outliers and farouts only if they are within the data area.
    double yyOutlier;
    double yyFarout;
    List outliers = new ArrayList();
    List farOutValues = new ArrayList();
    List yOutliers = bawDataset.getOutliers(row, column);
    if (yOutliers != null) {
        for (int i = 0; i < yOutliers.size(); i++) {
            Number outlierNum = (Number) yOutliers.get(i);
            double outlier = outlierNum.doubleValue();
            Number minOutlier = bawDataset.getMinOutlier(row, column);
            Number maxOutlier = bawDataset.getMaxOutlier(row, column);
            Number minRegular = bawDataset.getMinRegularValue(row, column);
            Number maxRegular = bawDataset.getMaxRegularValue(row, column);
            if (outlier > maxOutlier.doubleValue() || outlier < minOutlier.doubleValue()) {
                yyFarout = rangeAxis.valueToJava2D(outlier, dataArea, location);
                Outlier faroutToAdd = new Outlier(xxmid, yyFarout, foRadius);
                if (dataArea.contains(faroutToAdd.getPoint())) {
                    farOutValues.add(faroutToAdd);
                }
            } else if (outlier > maxRegular.doubleValue() || outlier < minRegular.doubleValue()) {
                yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
                Outlier outlierToAdd = new Outlier(xxmid, yyOutlier, oRadius);
                if (dataArea.contains(outlierToAdd.getPoint())) {
                    outliers.add(outlierToAdd);
                }
            }
        }

        //draw the outliers
        g2.setPaint(this.outlierPaint);
        for (Iterator iterator = outliers.iterator(); iterator.hasNext();) {
            Outlier outlier = (Outlier) iterator.next();
            Point2D point = outlier.getPoint();
            Shape dot = createEllipse(point, oRadius);
            g2.draw(dot);
        }

        //draw the farout values
        g2.setPaint(this.farOutColor);
        for (Iterator iterator = farOutValues.iterator(); iterator.hasNext();) {
            Outlier outlier = (Outlier) iterator.next();
            Point2D point = outlier.getPoint();
            Shape triangle = createTriangleVertical(point, foRadius);
            g2.draw(triangle);
        }
    }
}

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

/**
 * Draws the visual representation of a single data item when the plot has 
 * a horizontal orientation.//from   w  ww. j  ava  2  s.  c om
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot 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 row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {

    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;

    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = Math.abs(categoryEnd - categoryStart);

    double yy = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();

    if (seriesCount > 1) {
        double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1));
        double usedWidth = (state.getBarWidth() * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        yy = yy + offset + (row * (state.getBarWidth() + seriesGap));
    } else {
        // offset the start of the box if the box width is smaller than 
        // the category width
        double offset = (categoryWidth - state.getBarWidth()) / 2;
        yy = yy + offset;
    }

    Paint p = getItemPaint(row, column);
    if (p != null) {
        g2.setPaint(p);
    }
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);

    RectangleEdge location = plot.getRangeAxisEdge();

    Number xQ1 = bawDataset.getQ1Value(row, column);
    Number xQ3 = bawDataset.getQ3Value(row, column);
    Number xMax = bawDataset.getMaxRegularValue(row, column);
    Number xMin = bawDataset.getMinRegularValue(row, column);

    Shape box = null;
    if (xQ1 != null && xQ3 != null && xMax != null && xMin != null) {

        double xxQ1 = rangeAxis.valueToJava2D(xQ1.doubleValue(), dataArea, location);
        double xxQ3 = rangeAxis.valueToJava2D(xQ3.doubleValue(), dataArea, location);
        double xxMax = rangeAxis.valueToJava2D(xMax.doubleValue(), dataArea, location);
        double xxMin = rangeAxis.valueToJava2D(xMin.doubleValue(), dataArea, location);
        double yymid = yy + state.getBarWidth() / 2.0;

        // draw the upper shadow...
        g2.draw(new Line2D.Double(xxMax, yymid, xxQ3, yymid));
        g2.draw(new Line2D.Double(xxMax, yy, xxMax, yy + state.getBarWidth()));

        // draw the lower shadow...
        g2.draw(new Line2D.Double(xxMin, yymid, xxQ1, yymid));
        g2.draw(new Line2D.Double(xxMin, yy, xxMin, yy + state.getBarWidth()));

        // draw the box...
        box = new Rectangle2D.Double(Math.min(xxQ1, xxQ3), yy, Math.abs(xxQ1 - xxQ3), state.getBarWidth());
        if (this.fillBox) {
            g2.fill(box);
        }
        g2.draw(box);

    }

    g2.setPaint(this.artifactPaint);
    double aRadius = 0; // average radius

    // draw mean - SPECIAL AIMS REQUIREMENT...
    Number xMean = bawDataset.getMeanValue(row, column);
    if (xMean != null) {
        double xxMean = rangeAxis.valueToJava2D(xMean.doubleValue(), dataArea, location);
        aRadius = state.getBarWidth() / 4;
        Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxMean - aRadius, yy + aRadius, aRadius * 2,
                aRadius * 2);
        g2.fill(avgEllipse);
        g2.draw(avgEllipse);
    }

    // draw median...
    Number xMedian = bawDataset.getMedianValue(row, column);
    if (xMedian != null) {
        double xxMedian = rangeAxis.valueToJava2D(xMedian.doubleValue(), dataArea, location);
        g2.draw(new Line2D.Double(xxMedian, yy, xxMedian, yy + state.getBarWidth()));
    }

    // collect entity and tool tip information...
    if (state.getInfo() != null) {
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            String tip = null;
            CategoryToolTipGenerator tipster = getToolTipGenerator(row, column);
            if (tipster != null) {
                tip = tipster.generateToolTip(dataset, row, column);
            }
            String url = null;
            if (getItemURLGenerator(row, column) != null) {
                url = getItemURLGenerator(row, column).generateURL(dataset, row, column);
            }
            CategoryItemEntity entity = new CategoryItemEntity(box, tip, url, dataset, row,
                    dataset.getColumnKey(column), column);
            entities.add(entity);
        }
    }

}

From source file:extern.PlotBySplitClassRenderer.java

/**
 * Draws the visual representation of a single data item when the plot has
 * a vertical orientation.//from   w  ww  .  j av a 2s.c  o m
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot 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 (must be an instance of
 *                 {@link BoxAndWhiskerCategoryDataset}).
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {

    if (lastSplitObj != column) {
        lastSplitObj = column;
        prevX = -1;
        prevY = -1;
    }

    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;

    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = categoryEnd - categoryStart;

    double xx = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();

    double widthToUse = Math.min(state.getBarWidth(), dataArea.getWidth() / 15);

    if (seriesCount > 1) {
        double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1));
        double usedWidth = (widthToUse * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        xx = xx + offset + (row * (widthToUse + seriesGap));
    } else {
        // offset the start of the box if the box width is smaller than the
        // category width
        double offset = (categoryWidth - widthToUse) / 2;
        xx = xx + offset;
    }

    double yyAverage = 0.0;
    double yyOutlier;

    Paint itemPaint = getItemPaint(row, column);
    g2.setPaint(itemPaint);
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);

    double aRadius = 0; // average radius

    RectangleEdge location = plot.getRangeAxisEdge();

    Number yQ1 = bawDataset.getQ1Value(row, column);
    Number yQ3 = bawDataset.getQ3Value(row, column);
    Number yMax = bawDataset.getMaxRegularValue(row, column);
    Number yMin = bawDataset.getMinRegularValue(row, column);
    Shape box = null;

    double xxmid = xx + widthToUse / 2.0;
    double yyQ1 = 0;
    double yyQ3 = 0;

    if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) {

        yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location);
        yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location);
        double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location);
        double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location);

        // draw the upper shadow...
        g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3));
        g2.draw(new Line2D.Double(xx, yyMax, xx + widthToUse, yyMax));

        // draw the lower shadow...
        g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1));
        g2.draw(new Line2D.Double(xx, yyMin, xx + widthToUse, yyMin));

        // draw the body...
        box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), widthToUse, Math.abs(yyQ1 - yyQ3));
        if (this.fillBox) {
            g2.fill(box);
        }
        g2.setStroke(getItemOutlineStroke(row, column));
        g2.setPaint(getItemOutlinePaint(row, column));
        g2.draw(box);
    }

    g2.setPaint(this.artifactPaint);

    // draw mean - SPECIAL AIMS REQUIREMENT...
    Number yMean = bawDataset.getMeanValue(row, column);

    if (yMean != null && !Double.isNaN(yMean.doubleValue())) {
        yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location);
        // THIS IS WHAT WE CHANGED
        //            aRadius = widthWeWannaUse / 4;
        aRadius = 4;
        // here we check that the average marker will in fact be visible
        // before drawing it...
        // WE HAD TO CHANGE THIS TOO I DON'T KNOW WHAT THEY WERE DOING
        if ((yyAverage > (dataArea.getMinY() - aRadius)) && (yyAverage < (dataArea.getMaxY() + aRadius))) {
            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxmid - aRadius, yyAverage - aRadius,
                    aRadius * 2, aRadius * 2);

            //If this is a single point only, then draw this point with 
            //the color of its class.
            if (yQ1 != null && yQ3 != null) {
                if (aRadius / 2 > Math.abs(yyQ3 - yyQ1)) {
                    g2.setPaint(itemPaint);
                }
            }

            g2.fill(avgEllipse);
            g2.draw(avgEllipse);
        }
    }

    // draw median...
    Number yMedian = bawDataset.getMedianValue(row, column);

    if (yMedian != null && !Double.isNaN(yMedian.doubleValue())) {

        double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location);
        g2.draw(new Line2D.Double(xx, yyMedian, xx + widthToUse, yyMedian));

        // add a line to connect the means of the boxes
        if (prevX != -1 && prevY != -1) {
            g2.setPaint(artifactPaint);
            g2.draw(new Line2D.Double(prevX, prevY, xxmid, yyMedian));
        }
        prevX = xxmid;
        prevY = yyMedian;

    }

    // draw yOutliers...
    g2.setPaint(itemPaint);

    // draw outliers
    double oRadius = 4; // outlier radius
    List<Outlier> outliers = new ArrayList<Outlier>();

    // From outlier array sort out which are outliers and put these into a
    // list If there are any farouts, set the flag on the
    // OutlierListCollection
    List<Number> yOutliers = bawDataset.getOutliers(row, column);
    if (yOutliers != null) {
        for (int i = 0; i < yOutliers.size(); i++) {
            double outlier = yOutliers.get(i).doubleValue();

            yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
            outliers.add(new Outlier(xxmid, yyOutlier, oRadius));
        }

        // Process outliers. Each outlier is either added to the
        // appropriate outlier list or a new outlier list is made
        for (Outlier outlier : outliers) {
            Point2D point = outlier.getPoint();

            drawEllipse(point, oRadius, g2);
        }

    }

}

From source file:extern.NpairsBoxAndWhiskerRenderer.java

/**
 * Draws the visual representation of a single data item when the plot has
 * a vertical orientation./*from w  ww.j  a  v  a 2s  .c  om*/
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot 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 (must be an instance of
 *                 {@link BoxAndWhiskerCategoryDataset}).
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {

    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;

    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = categoryEnd - categoryStart;

    double xx = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();

    double widthToUse = Math.min(state.getBarWidth(), dataArea.getWidth() / 15);

    if (seriesCount > 1) {
        double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1));
        double usedWidth = (widthToUse * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        xx = xx + offset + (row * (widthToUse + seriesGap));
    } else {
        // offset the start of the box if the box width is smaller than the
        // category width
        double offset = (categoryWidth - widthToUse) / 2;
        xx = xx + offset;
    }

    double yyAverage = 0.0;
    double yyOutlier;

    Paint itemPaint = getItemPaint(row, column);
    g2.setPaint(itemPaint);
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);

    double aRadius = 0; // average radius

    RectangleEdge location = plot.getRangeAxisEdge();

    Number yQ1 = bawDataset.getQ1Value(row, column);
    Number yQ3 = bawDataset.getQ3Value(row, column);
    Number yMax = bawDataset.getMaxRegularValue(row, column);
    Number yMin = bawDataset.getMinRegularValue(row, column);
    Shape box = null;

    double xxmid = xx + widthToUse / 2.0;

    if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) {

        double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location);
        double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location);
        double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location);
        double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location);

        // draw the upper shadow...
        g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3));
        g2.draw(new Line2D.Double(xx, yyMax, xx + widthToUse, yyMax));

        // draw the lower shadow...
        g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1));
        g2.draw(new Line2D.Double(xx, yyMin, xx + widthToUse, yyMin));

        // draw the body...
        box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), widthToUse, Math.abs(yyQ1 - yyQ3));
        if (this.fillBox) {
            g2.fill(box);
        }
        g2.setStroke(getItemOutlineStroke(row, column));
        g2.setPaint(getItemOutlinePaint(row, column));
        g2.draw(box);
    }

    g2.setPaint(this.artifactPaint);

    // draw mean - SPECIAL AIMS REQUIREMENT...
    Number yMean = bawDataset.getMeanValue(row, column);

    if (yMean != null && !Double.isNaN(yMean.doubleValue())) {
        yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location);
        // THIS IS WHAT WE CHANGED
        //            aRadius = widthWeWannaUse / 4;
        aRadius = 4;
        // here we check that the average marker will in fact be visible
        // before drawing it...
        // WE HAD TO CHANGE THIS TOO I DON'T KNOW WHAT THEY WERE DOING
        if ((yyAverage > (dataArea.getMinY() - aRadius)) && (yyAverage < (dataArea.getMaxY() + aRadius))) {
            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxmid - aRadius, yyAverage - aRadius,
                    aRadius * 2, aRadius * 2);

            g2.fill(avgEllipse);
            g2.draw(avgEllipse);
        }
    }

    // draw median...
    Number yMedian = bawDataset.getMedianValue(row, column);
    if (yMedian != null && !Double.isNaN(yMedian.doubleValue())) {
        double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location);
        g2.draw(new Line2D.Double(xx, yyMedian, xx + widthToUse, yyMedian));

        // add a line to connect the means of the boxes
        if (prevX != -1.0 && prevY != -1.0) {
            g2.draw(new Line2D.Double(prevX, prevY, xxmid, yyMedian));
        }

        prevX = xxmid;
        prevY = yyMedian;
    }

    // draw yOutliers...
    g2.setPaint(itemPaint);

    // draw outliers
    double oRadius = 4; // outlier radius
    List<Outlier> outliers = new ArrayList<Outlier>();

    // From outlier array sort out which are outliers and put these into a
    // list If there are any farouts, set the flag on the
    // OutlierListCollection
    List<Number> yOutliers = bawDataset.getOutliers(row, column);
    if (yOutliers != null) {
        for (int i = 0; i < yOutliers.size(); i++) {
            double outlier = yOutliers.get(i).doubleValue();

            yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
            outliers.add(new Outlier(xxmid, yyOutlier, oRadius));
        }

        // Process outliers. Each outlier is either added to the
        // appropriate outlier list or a new outlier list is made
        for (Outlier outlier : outliers) {
            Point2D point = outlier.getPoint();

            drawEllipse(point, oRadius, g2);
        }

        //            for (Iterator iterator = outlierListCollection.iterator();
        //                     iterator.hasNext();) {
        //                OutlierList list = (OutlierList) iterator.next();
        //                Outlier outlier = list.getAveragedOutlier();
        //                Point2D point = outlier.getPoint();
        //
        //                if (list.isMultiple()) {
        //                    drawMultipleEllipse(point, widthWeWannaUse, oRadius,
        //                            g2);
        //                }
        //                else {
        //                    drawEllipse(point, oRadius, g2);
        //                }
        //            }
        //
        //            // draw farout indicators
        //            if (outlierListCollection.isHighFarOut()) {
        //                drawHighFarOut(aRadius / 2.0, g2,
        //                        xx + widthWeWannaUse / 2.0, maxAxisValue);
        //            }
        //
        //            if (outlierListCollection.isLowFarOut()) {
        //                drawLowFarOut(aRadius / 2.0, g2,
        //                        xx + widthWeWannaUse / 2.0, minAxisValue);
        //            }
        //        }
        //        // collect entity and tool tip information...
        //        if (state.getInfo() != null && box != null) {
        //            EntityCollection entities = state.getEntityCollection();
        //            if (entities != null) {
        //                addItemEntity(entities, dataset, row, column, box);
        //            }
    }

}

From source file:extern.NpairsBoxAndWhiskerRenderer.java

/**
 * Draws the visual representation of a single data item when the plot has
 * a horizontal orientation.//from w  w w  . j  av a 2s  . co  m
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot 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 (must be an instance of
 *                 {@link BoxAndWhiskerCategoryDataset}).
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {

    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;

    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = Math.abs(categoryEnd - categoryStart);

    double yy = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();

    double widthWeWannaUse = Math.min(state.getBarWidth(), dataArea.getWidth() / 10);

    if (seriesCount > 1) {
        double seriesGap = dataArea.getHeight() * getItemMargin() / (categoryCount * (seriesCount - 1));
        //            double usedWidth = (state.getBarWidth() * seriesCount)
        //                               + (seriesGap * (seriesCount - 1));
        double usedWidth = (widthWeWannaUse * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        //            yy = yy + offset + (row * (state.getBarWidth() + seriesGap));
        yy = yy + offset + (row * (widthWeWannaUse + seriesGap));
    } else {
        // offset the start of the box if the box width is smaller than
        // the category width
        //            double offset = (categoryWidth - state.getBarWidth()) / 2;
        double offset = (categoryWidth - widthWeWannaUse) / 2;
        yy = yy + offset;
    }

    g2.setPaint(getItemPaint(row, column));
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);

    RectangleEdge location = plot.getRangeAxisEdge();

    Number xQ1 = bawDataset.getQ1Value(row, column);
    Number xQ3 = bawDataset.getQ3Value(row, column);
    Number xMax = bawDataset.getMaxRegularValue(row, column);
    Number xMin = bawDataset.getMinRegularValue(row, column);

    Shape box = null;
    if (xQ1 != null && xQ3 != null && xMax != null && xMin != null) {

        double xxQ1 = rangeAxis.valueToJava2D(xQ1.doubleValue(), dataArea, location);
        double xxQ3 = rangeAxis.valueToJava2D(xQ3.doubleValue(), dataArea, location);
        double xxMax = rangeAxis.valueToJava2D(xMax.doubleValue(), dataArea, location);
        double xxMin = rangeAxis.valueToJava2D(xMin.doubleValue(), dataArea, location);
        //            double yymid = yy + state.getBarWidth() / 2.0;
        double yymid = yy + widthWeWannaUse / 2.0;

        // draw the upper shadow...
        g2.draw(new Line2D.Double(xxMax, yymid, xxQ3, yymid));
        //            g2.draw(new Line2D.Double(xxMax, yy, xxMax,
        //                    yy + state.getBarWidth()));
        g2.draw(new Line2D.Double(xxMax, yy, xxMax, yy + widthWeWannaUse));

        // draw the lower shadow...
        g2.draw(new Line2D.Double(xxMin, yymid, xxQ1, yymid));
        //            g2.draw(new Line2D.Double(xxMin, yy, xxMin,
        //                    yy + state.getBarWidth()));
        g2.draw(new Line2D.Double(xxMin, yy, xxMin, yy + widthWeWannaUse));

        // draw the box...
        //            box = new Rectangle2D.Double(Math.min(xxQ1, xxQ3), yy,
        //                    Math.abs(xxQ1 - xxQ3), state.getBarWidth());
        box = new Rectangle2D.Double(Math.min(xxQ1, xxQ3), yy, Math.abs(xxQ1 - xxQ3), widthWeWannaUse);
        if (this.fillBox) {
            g2.fill(box);
        }
        g2.setStroke(getItemOutlineStroke(row, column));
        g2.setPaint(getItemOutlinePaint(row, column));
        g2.draw(box);
    }

    g2.setPaint(this.artifactPaint);
    double aRadius = 0; // average radius

    // draw mean - SPECIAL AIMS REQUIREMENT...
    Number xMean = bawDataset.getMeanValue(row, column);
    if (xMean != null) {
        double xxMean = rangeAxis.valueToJava2D(xMean.doubleValue(), dataArea, location);
        //            aRadius = state.getBarWidth() / 4;
        aRadius = widthWeWannaUse / 4;
        // here we check that the average marker will in fact be visible
        // before drawing it...
        if ((xxMean > (dataArea.getMinX() - aRadius)) && (xxMean < (dataArea.getMaxX() + aRadius))) {
            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxMean - aRadius, yy + aRadius, aRadius * 2,
                    aRadius * 2);
            g2.fill(avgEllipse);
            g2.draw(avgEllipse);
        }
    }

    // draw median...
    Number xMedian = bawDataset.getMedianValue(row, column);
    if (xMedian != null) {
        double xxMedian = rangeAxis.valueToJava2D(xMedian.doubleValue(), dataArea, location);
        //            g2.draw(new Line2D.Double(xxMedian, yy, xxMedian,
        //                    yy + state.getBarWidth()));
        g2.draw(new Line2D.Double(xxMedian, yy, xxMedian, yy + widthWeWannaUse));
    }

    // collect entity and tool tip information...
    if (state.getInfo() != null && box != null) {
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            addItemEntity(entities, dataset, row, column, box);
        }
    }

}

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

/**
 * Draws the visual representation of a single data item when the plot has 
 * a vertical orientation./*  ww  w  . jav  a2s.co  m*/
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot 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 row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {

    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;

    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());

    double categoryWidth = (categoryEnd - categoryStart);

    double xx = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();

    if (seriesCount > 1) {
        double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1));
        double usedWidth = (state.getBarWidth() * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        xx = xx + offset + (row * (state.getBarWidth() + seriesGap));
    } else {
        // offset the start of the box if the box width is smaller than the 
        // category width
        double offset = (categoryWidth - state.getBarWidth()) / 2;
        xx = xx + offset;
    }

    double yyAverage = 0.0;
    double yyOutlier;

    //bar colors are determined by the Paint p obtained here in a rotational
    //manner (from a Color array).  By switching the column and raw values,
    //you can get a different color pattern for the bar:  In the method 
    //getItemPaint(), only the first argument counts for the color. The original
    //code Paint p = getItemPaint(row, column); is commented out for a difference.
    //Paint p = getItemPaint(row, column);
    Paint p = getItemPaint(column, row); // <-- this is wrong, dont know who put this here
    // Paint p = PaintUtilities.stringToColor("red"); // coin plot should all be one color
    if (p != null) {
        g2.setPaint(p);
    }
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);

    double aRadius = 0; // average radius

    RectangleEdge location = plot.getRangeAxisEdge();

    Number yQ1 = bawDataset.getQ1Value(row, column);
    Number yQ3 = bawDataset.getQ3Value(row, column);
    Number yMax = bawDataset.getMaxRegularValue(row, column);
    Number yMin = bawDataset.getMinRegularValue(row, column);
    Shape box = null;
    if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) {

        double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location);
        double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location);
        double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location);
        double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location);
        double xxmid = xx + state.getBarWidth() / 2.0;

        // draw the upper shadow...
        g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3));
        g2.draw(new Line2D.Double(xx, yyMax, xx + state.getBarWidth(), yyMax));

        // draw the lower shadow...
        g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1));
        g2.draw(new Line2D.Double(xx, yyMin, xx + state.getBarWidth(), yyMin));

        // draw the body...
        box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), state.getBarWidth(), Math.abs(yyQ1 - yyQ3));
        if (this.fillBox) {
            g2.fill(box);
        }
        //The following draw the boxes where mean and media are located.
        g2.draw(box);

    }

    g2.setPaint(this.artifactPaint);

    // draw median...
    Number yMedian = bawDataset.getMedianValue(row, column);
    if (yMedian != null) {
        double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location);
        g2.draw(new Line2D.Double(xx, yyMedian, xx + state.getBarWidth(), yyMedian));
    }

    //caIntegrator:  The outLiner is no longer needed to be here.
    // draw the rawData around the box...
    /////////////////////////////////caIntegrator: Begin of drawing dots around the box
    double maxAxisValue = rangeAxis.valueToJava2D(rangeAxis.getUpperBound(), dataArea, location) + aRadius;
    double minAxisValue = rangeAxis.valueToJava2D(rangeAxis.getLowerBound(), dataArea, location) - aRadius;

    g2.setPaint(p);

    //caIntegrator: oRadius is the radius of the outlier circles. It was used to be 3.
    double oRadius = state.getBarWidth() / 10; // outlier radius

    List outliers = new ArrayList();

    //Get the raw item data for a given row/column pair for plotting.
    //getRawItemData() method is added to bawDataset object for 
    //this purpose.

    //List yOutliers = bawDataset.getRawItemData(row, column);
    List yOutliers = this.caintegOutliers.get(String.valueOf(row) + "_" + String.valueOf(column));

    if (yOutliers != null) {
        for (int i = 0; i < yOutliers.size(); i++) {
            double outlier = ((Number) yOutliers.get(i)).doubleValue();
            yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
            outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, yyOutlier, oRadius));

            Collections.sort(outliers);
        }

        //Sort the raw data according to its Y axis first as groups.
        //Grouping of these raw data is based on a single standard:
        //if any number of data, when plotted on a vertical line, overlap
        //with one another, they belong to the same group. In this case, 
        //the grouping is largely determined by the diameter of the dot, that
        //represents each raw data.
        boolean firstOutlier = true;
        double topY = 0;
        double bottomY = 0;
        List groupList = new ArrayList();
        List tempList = null;
        double diameter = 2 * oRadius;

        double difference = 0;
        for (Iterator iterator = outliers.iterator(); iterator.hasNext();) {

            Outlier outlier = (Outlier) iterator.next();

            //Set the smallest outlier as the base bottom line
            if (firstOutlier) {
                firstOutlier = false;
                bottomY = outlier.getY();
                tempList = new ArrayList();
                tempList.add(outlier);
                continue;
            }

            topY = outlier.getY();

            //If this one and the one before it is overlapping,
            //Then put them in the same group, so we can spread them
            //horizontally
            difference = topY - bottomY;

            if (difference < diameter) {
                tempList.add(outlier);
            }
            //They do not overlap, they belong to the different groups.
            else {
                bottomY = topY;
                groupList.add(tempList);
                tempList = new ArrayList();
                tempList.add(outlier);
            }
        }

        //caIntegrator - x axis cloud
        //Process each outlier's x coordinates  
        boolean isOdd = true;
        double offSet = 0;
        int listSize = 0;

        for (int m = 0; m < groupList.size(); m++) {
            List list = (List) groupList.get(m);
            if (list != null && list.size() > 1) {
                listSize = list.size();
                isOdd = (listSize % 2 == 1) ? true : false;

                if (isOdd) {
                    offSet = diameter * (listSize / 2);
                } else {
                    offSet = diameter * (listSize / 2) - oRadius;
                }

                Random r = new Random();
                offSet = (Math.abs(r.nextInt()) % 3) * 3;
                offSet = 0;

                for (int n = 0; n < list.size(); n++) {
                    Outlier outlier = (Outlier) list.get(n);

                    outlier.setPoint(new Point2D.Double(outlier.getX() - offSet, outlier.getY()));
                    offSet = offSet - diameter;
                    r = new Random();
                    int randInt = Math.abs(r.nextInt()) % 3;
                    offSet = randInt * 2;
                }
            }
        }

        //Draw these dots on the graph.         
        for (Iterator iterator = groupList.iterator(); iterator.hasNext();) {

            List list = (List) iterator.next();
            for (int i = 0; i < list.size(); i++) {
                Outlier outlier = (Outlier) list.get(i);
                Point2D point = outlier.getPoint();
                drawEllipse(point, oRadius, g2);
            }
        }
    }
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.BoxAndWhiskerCoinPlotRenderer.java

/**
 * Draws the visual representation of a single data item when the plot has 
 * a vertical orientation.//from   ww  w . j a  v  a  2s.c  o m
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot 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 row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {

    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;

    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = categoryEnd - categoryStart;

    double xx = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();

    if (seriesCount > 1) {
        double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1));
        double usedWidth = (state.getBarWidth() * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        xx = xx + offset + (row * (state.getBarWidth() + seriesGap));
    } else {
        // offset the start of the box if the box width is smaller than the 
        // category width
        double offset = (categoryWidth - state.getBarWidth()) / 2;
        xx = xx + offset;
    }

    double yyAverage = 0.0;
    double yyOutlier;

    //      bar colors are determined by the Paint p obtained here in a rotational
    //manner (from a Color array).  By switching the column and raw values,
    //you can get a different color pattern for the bar:  In the method 
    //getItemPaint(), only the first argument counts for the color. The original
    //code Paint p = getItemPaint(row, column); is commented out for a difference.
    Paint p = null;
    if (this.getPlotColor() != null) {
        p = PaintUtilities.stringToColor(getPlotColor()); // coin plot should all be one color
    } else {
        p = getItemPaint(row, column);
    }

    // Paint p = PaintUtilities.stringToColor("red"); 
    if (p != null) {
        g2.setPaint(p);
    }

    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);

    double aRadius = 0; // average radius

    RectangleEdge location = plot.getRangeAxisEdge();

    Number yQ1 = bawDataset.getQ1Value(row, column);
    Number yQ3 = bawDataset.getQ3Value(row, column);
    Number yMax = bawDataset.getMaxRegularValue(row, column);
    Number yMin = bawDataset.getMinRegularValue(row, column);
    Shape box = null;
    if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) {

        double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location);
        double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location);
        double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location);
        double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location);
        double xxmid = xx + state.getBarWidth() / 2.0;

        // draw the upper shadow...
        g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3));
        g2.draw(new Line2D.Double(xx, yyMax, xx + state.getBarWidth(), yyMax));

        // draw the lower shadow...
        g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1));
        g2.draw(new Line2D.Double(xx, yyMin, xx + state.getBarWidth(), yyMin));

        // draw the body...
        box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), state.getBarWidth(), Math.abs(yyQ1 - yyQ3));
        if (getFillBox()) {
            g2.fill(box);
        }
        g2.draw(box);

    }

    g2.setPaint(getArtifactPaint());

    if (this.isDisplayMean()) {
        // draw mean - SPECIAL AIMS REQUIREMENT...
        Number yMean = bawDataset.getMeanValue(row, column);
        if (yMean != null) {
            yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location);
            aRadius = state.getBarWidth() / 4;
            Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx + aRadius, yyAverage - aRadius, aRadius * 2,
                    aRadius * 2);
            g2.fill(avgEllipse);
            g2.draw(avgEllipse);
        }
    }

    if (this.isDisplayMedian()) {
        // draw median...
        Number yMedian = bawDataset.getMedianValue(row, column);
        if (yMedian != null) {
            double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location);
            g2.draw(new Line2D.Double(xx, yyMedian, xx + state.getBarWidth(), yyMedian));
        }
    }

    // draw yOutliers...
    double maxAxisValue = rangeAxis.valueToJava2D(rangeAxis.getUpperBound(), dataArea, location) + aRadius;
    double minAxisValue = rangeAxis.valueToJava2D(rangeAxis.getLowerBound(), dataArea, location) - aRadius;

    g2.setPaint(p);

    if (this.isDisplayCoinCloud()) {
        //draw coin clouds
        drawCoinCloud(g2, state, dataArea, location, rangeAxis, xx, row, column, bawDataset);
    }
    //caIntegrator: oRadius is the radius of the outlier circles. It was used to be 3.
    // draw outliers
    double oRadius = state.getBarWidth() / this.outlierRadiusDenominator; // outlier radius
    List outliers = new ArrayList();
    OutlierListCollection outlierListCollection = new OutlierListCollection();

    List yOutliers = bawDataset.getOutliers(row, column);
    if (yOutliers != null) {
        for (int i = 0; i < yOutliers.size(); i++) {
            double outlier = ((Number) yOutliers.get(i)).doubleValue();
            Number minOutlier = bawDataset.getMinOutlier(row, column);
            Number maxOutlier = bawDataset.getMaxOutlier(row, column);
            Number minRegular = bawDataset.getMinRegularValue(row, column);
            Number maxRegular = bawDataset.getMaxRegularValue(row, column);
            if (outlier > maxOutlier.doubleValue()) {
                outlierListCollection.setHighFarOut(true);
            } else if (outlier < minOutlier.doubleValue()) {
                outlierListCollection.setLowFarOut(true);
            } else if (outlier > maxRegular.doubleValue()) {
                yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
                outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, yyOutlier, oRadius));
            } else if (outlier < minRegular.doubleValue()) {
                yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
                outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, yyOutlier, oRadius));
            }

            Collections.sort(outliers);
        }
        //display farouts as JFreeChart Implemetation
        if (!displayAllOutliers) {
            // Process outliers. Each outlier is either added to the 
            // appropriate outlier list or a new outlier list is made
            for (int i = 0; i < yOutliers.size(); i++) {
                Number minRegular = bawDataset.getMinRegularValue(row, column);
                Number maxRegular = bawDataset.getMaxRegularValue(row, column);
                double outlier = ((Number) yOutliers.get(i)).doubleValue();
                if (outlier < minRegular.doubleValue() || outlier > maxRegular.doubleValue()) {
                    yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
                    outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, yyOutlier, oRadius));
                }
            }

            for (Iterator iterator = outliers.iterator(); iterator.hasNext();) {
                Outlier outlier = (Outlier) iterator.next();
                outlierListCollection.add(outlier);
            }

            for (Iterator iterator = outlierListCollection.iterator(); iterator.hasNext();) {
                OutlierList list = (OutlierList) iterator.next();
                Outlier outlier = list.getAveragedOutlier();
                Point2D point = outlier.getPoint();

                if (list.isMultiple()) {
                    drawMultipleEllipse(point, state.getBarWidth(), oRadius, g2);
                } else {
                    drawEllipse(point, oRadius, g2);
                }
            }
            // draw farout indicators
            if (outlierListCollection.isHighFarOut()) {
                drawHighFarOut(aRadius / 2.0, g2, xx + state.getBarWidth() / 2.0, maxAxisValue);
            }

            if (outlierListCollection.isLowFarOut()) {
                drawLowFarOut(aRadius / 2.0, g2, xx + state.getBarWidth() / 2.0, minAxisValue);
            }
        } else {
            for (int i = 0; i < yOutliers.size(); i++) {
                Number minRegular = bawDataset.getMinRegularValue(row, column);
                Number maxRegular = bawDataset.getMaxRegularValue(row, column);
                double outlier = ((Number) yOutliers.get(i)).doubleValue();
                if (outlier < minRegular.doubleValue() || outlier > maxRegular.doubleValue()) {
                    yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location);
                    outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, yyOutlier, oRadius));
                }
            }
            Collections.sort(outliers);
            for (Iterator iterator = outliers.iterator(); iterator.hasNext();) {
                Outlier outlier = (Outlier) iterator.next();
                Point2D point = outlier.getPoint();

                drawEllipse(point, oRadius, g2);
            }
        }
    }
    // collect entity and tool tip information...
    if (state.getInfo() != null) {
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            String tip = null;
            CategoryToolTipGenerator tipster = getToolTipGenerator(row, column);
            if (tipster != null) {
                tip = tipster.generateToolTip(dataset, row, column);
            }
            String url = null;
            if (getItemURLGenerator(row, column) != null) {
                url = getItemURLGenerator(row, column).generateURL(dataset, row, column);
            }
            CategoryItemEntity entity = new CategoryItemEntity(box, tip, url, dataset, row,
                    dataset.getColumnKey(column), column);
            entities.add(entity);
        }
    }

}