JFreeChart Boxplot Outlier and Farout appearance

∥☆過路亽.° 提交于 2019-12-06 21:15:30

While ExtendedBoxAndWhiskerRenderer is exemplary, it is somewhat dated, and much of its functionality has been incorporated into the mainline version. Your experiment suggests that the old renderer and new dataset are incompatible.

Because the outlier rendering methods are private, an alternative approach is to override the relevant draw*Item() method and let it invoke your own variations. You'll need to recapitulate the existing code, using the public accessors as required. In outline, the following variations demonstrate using Color.black, illustrated below.

plot.setRenderer(new BoxAndWhiskerRenderer() {

    @Override
    public void drawVerticalItem(Graphics2D g2, …) {
        // existing code that calls the methods below
    }

    private void drawEllipse(Point2D point, double oRadius, Graphics2D g2) {
        Paint temp = g2.getPaint();
        g2.setColor(Color.black);
        Ellipse2D dot = new Ellipse2D.Double(point.getX() + oRadius / 2,
                point.getY(), oRadius, oRadius);
        g2.draw(dot);
        g2.setPaint(temp);
    }

    private void drawHighFarOut(double aRadius, Graphics2D g2, double xx,
            double m) {
        Paint temp = g2.getPaint();
        g2.setColor(Color.black);
        double side = aRadius * 2;
        g2.draw(new Line2D.Double(xx - side, m + side, xx + side, m + side));
        g2.draw(new Line2D.Double(xx - side, m + side, xx, m));
        g2.draw(new Line2D.Double(xx + side, m + side, xx, m));
        g2.setPaint(temp);
    }
}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!