我使用JFreeChart制作了拨号图。我想知道是否有可能使指标更粗。我现在用来制作它们的代码是:
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);
我尝试在网上查找内容,但无法弄清楚如何使其更厚。现在的状态使它们很难在远处的显示器上看到。我尝试更改外半径,但这样做只是使它们是两条细线,而不是一条大粗线。
最佳答案
覆盖draw()
的StandardDialRange
方法,并指定您首选的Stroke
;我在以下示例中使用了4.0f
。您需要根据需要使用公共访问器来概括现有代码。
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);
}
});