Making Standard Dial Range on JFreeChart thicker

326 views Asked by At

I made a dial chart Using JFreeChart. I was wondering if it was possible to make the indicators thicker. The code I am using to make them now are:

        StandardDialRange standarddialrange;
        StandardDialRange standarddialrange2;
        StandardDialRange standarddialrange3;
        if(isPercentageIV==true){
            standarddialrange = new StandardDialRange(90D, 100D, Color.GREEN);
            standarddialrange2 = new StandardDialRange(60D, 90D, Color.orange);
            standarddialrange3 = new StandardDialRange(0D, 60D, Color.RED);
        }
        else{
            standarddialrange = new StandardDialRange(.9*goal*dialScale, goal*dialScale, Color.GREEN);
            standarddialrange2 = new StandardDialRange(.6*goal*dialScale, .9*goal*dialScale, Color.orange);
            standarddialrange3 = new StandardDialRange(0, .6*goal*dialScale, Color.RED);
        }
        // Sets the scale/radius of all the indicators.
        standarddialrange.setScaleIndex(0);
        standarddialrange.setInnerRadius(0.58999999999999997D);
        standarddialrange.setOuterRadius(0.58999999999999997D);
        dialplot.addLayer(standarddialrange);

        standarddialrange2.setScaleIndex(0);
        standarddialrange2.setInnerRadius(0.58999999999999997D);
        standarddialrange2.setOuterRadius(0.58999999999999997D);
        dialplot.addLayer(standarddialrange2);

        standarddialrange3.setScaleIndex(0);
        standarddialrange3.setInnerRadius(0.58999999999999997D);
        standarddialrange3.setOuterRadius(0.58999999999999997D);
        dialplot.addLayer(standarddialrange3);

I tried looking online and I could not figure out how to make it thicker. The way they are now makes them kind of hard to see on a display from far away. I tried changing the outer radius but it just made it so their were two thin lines, instead of one big thick one.

1

There are 1 answers

0
trashgod On BEST ANSWER

Override the draw() method of StandardDialRange and specify your preferred Stroke; I've used 4.0f in the example below. You'll need to recapitulate the existing code, using the public accessors as required.

image

plot.addLayer(new StandardDialRange(3 * maximumValue / 4, maximumValue, Color.red) {

    @Override
    public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) {
        …
        g2.setPaint(this.getPaint());
        g2.setStroke(new BasicStroke(4.0f));
        g2.draw(arcInner);
        g2.draw(arcOuter);
    }
});