1

I'm using JFreeChart in SWT and want to set a gradient background to a DialPlot as described here. But I always get a white background.

GradientPaint gradient = new GradientPaint(new Point(), Color.white, new Point(), Color.darkGray);
DialBackground background = new DialBackground(gradient);
background.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));

StandardDialFrame frame = new StandardDialFrame();
frame.setBackgroundPaint(Color.lightGray);
frame.setForegroundPaint(Color.darkGray);

// some layers

DialPlot plot = new DialPlot(getDataset());
plot.setDialFrame(frame);
plot.setBackground(background);

The resulting plot.

Any suggestions of what I am doing wrong?

Nrzonline
  • 1,600
  • 2
  • 18
  • 37
Stefan Warminski
  • 1,845
  • 1
  • 9
  • 18

1 Answers1

1

It's not clear where your fragment goes awry. Starting from this Swing example, the following changes in buildDialPlot() seem to work:

private ChartPanel buildDialPlot(int minimumValue, int maximumValue, int majorTickGap) {
    …
    GradientPaint gradient =
        new GradientPaint(new Point(), Color.white, new Point(), Color.gray);
    DialBackground background = new DialBackground(gradient);
    background.setGradientPaintTransformer(
        new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    plot.setBackground(background);

    return new ChartPanel(new JFreeChart(plot)) {…};
}

image

This may be a problem in the SWT bridge or elsewhere in your code.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045