EntityCollection entities = null;
if (info != null) {
entities = info.getOwner().getEntityCollection();
}
BoxAndWhiskerXYDataset boxAndWhiskerData
= (BoxAndWhiskerXYDataset) dataset;
Number x = boxAndWhiskerData.getX(series, item);
Number yMax = boxAndWhiskerData.getMaxRegularValue(series, item);
Number yMin = boxAndWhiskerData.getMinRegularValue(series, item);
Number yMedian = boxAndWhiskerData.getMedianValue(series, item);
Number yAverage = boxAndWhiskerData.getMeanValue(series, item);
Number yQ1Median = boxAndWhiskerData.getQ1Value(series, item);
Number yQ3Median = boxAndWhiskerData.getQ3Value(series, item);
List yOutliers = boxAndWhiskerData.getOutliers(series, item);
double xx = domainAxis.valueToJava2D(x.doubleValue(), dataArea,
plot.getDomainAxisEdge());
RectangleEdge location = plot.getRangeAxisEdge();
double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea,
location);
double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea,
location);
double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(),
dataArea, location);
double yyAverage = 0.0;
if (yAverage != null) {
yyAverage = rangeAxis.valueToJava2D(yAverage.doubleValue(),
dataArea, location);
}
double yyQ1Median = rangeAxis.valueToJava2D(yQ1Median.doubleValue(),
dataArea, location);
double yyQ3Median = rangeAxis.valueToJava2D(yQ3Median.doubleValue(),
dataArea, location);
double yyOutlier;
double exactBoxWidth = getBoxWidth();
double width = exactBoxWidth;
double dataAreaX = dataArea.getMaxX() - dataArea.getMinX();
double maxBoxPercent = 0.1;
double maxBoxWidth = dataAreaX * maxBoxPercent;
if (exactBoxWidth <= 0.0) {
int itemCount = boxAndWhiskerData.getItemCount(series);
exactBoxWidth = dataAreaX / itemCount * 4.5 / 7;
if (exactBoxWidth < 3) {
width = 3;
}
else if (exactBoxWidth > maxBoxWidth) {
width = maxBoxWidth;
}
else {
width = exactBoxWidth;
}
}
g2.setPaint(getItemPaint(series, item));
Stroke s = getItemStroke(series, item);
g2.setStroke(s);
// draw the upper shadow
g2.draw(new Line2D.Double(xx, yyMax, xx, yyQ3Median));
g2.draw(new Line2D.Double(xx - width / 2, yyMax, xx + width / 2,
yyMax));
// draw the lower shadow
g2.draw(new Line2D.Double(xx, yyMin, xx, yyQ1Median));
g2.draw(new Line2D.Double(xx - width / 2, yyMin, xx + width / 2,
yyMin));
// draw the body
Shape box = null;
if (yyQ1Median > yyQ3Median) {
box = new Rectangle2D.Double(xx - width / 2, yyQ3Median, width,
yyQ1Median - yyQ3Median);
}
else {
box = new Rectangle2D.Double(xx - width / 2, yyQ1Median, width,
yyQ3Median - yyQ1Median);
}
if (this.fillBox) {
g2.setPaint(lookupBoxPaint(series, item));
g2.fill(box);
}
g2.setStroke(getItemOutlineStroke(series, item));
g2.setPaint(getItemOutlinePaint(series, item));
g2.draw(box);
// draw median
g2.setPaint(getArtifactPaint());
g2.draw(new Line2D.Double(xx - width / 2, yyMedian, xx + width / 2,
yyMedian));
double aRadius = 0; // average radius
double oRadius = width / 3; // outlier radius
// draw average - SPECIAL AIMS REQUIREMENT
if (yAverage != null) {
aRadius = width / 4;
// here we check that the average marker will in fact be visible
// before drawing it...
if ((yyAverage > (dataArea.getMinY() - aRadius))
&& (yyAverage < (dataArea.getMaxY() + aRadius))) {
Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx - aRadius,
yyAverage - aRadius, aRadius * 2, aRadius * 2);
g2.fill(avgEllipse);
g2.draw(avgEllipse);
}
}
List outliers = new ArrayList();
OutlierListCollection outlierListCollection
= new OutlierListCollection();
/* From outlier array sort out which are outliers and put these into
* an arraylist. If there are any farouts, set the flag on the
* OutlierListCollection
*/
for (int i = 0; i < yOutliers.size(); i++) {
double outlier = ((Number) yOutliers.get(i)).doubleValue();
if (outlier > boxAndWhiskerData.getMaxOutlier(series,
item).doubleValue()) {
outlierListCollection.setHighFarOut(true);
}
else if (outlier < boxAndWhiskerData.getMinOutlier(series,
item).doubleValue()) {
outlierListCollection.setLowFarOut(true);
}
else if (outlier > boxAndWhiskerData.getMaxRegularValue(series,
item).doubleValue()) {
yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea,
location);
outliers.add(new Outlier(xx, yyOutlier, oRadius));
}
else if (outlier < boxAndWhiskerData.getMinRegularValue(series,
item).doubleValue()) {
yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea,
location);
outliers.add(new Outlier(xx, yyOutlier, oRadius));
}