Tooltips not shown in XYZPlot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Tooltips not shown in XYZPlot

Post by John Matthews » Sun May 15, 2016 7:12 pm

As an alternative, this example uses Color.getHSBColor() to create a spectrum of colors between two hues. You might also look at scaling the saturation and/or brightness. You could also use the method to create a gamut of colors, as shown here, adding each to a LookupPaintScale.

Image

Code: Select all

class SpectrumPaintScale implements PaintScale {

        private static final float H1 = 0f;
        private static final float H2 = 1f;
        private final double lowerBound;
        private final double upperBound;

        public SpectrumPaintScale(double lowerBound, double upperBound) {
            this.lowerBound = lowerBound;
            this.upperBound = upperBound;
        }

        @Override
        public double getLowerBound() {
            return lowerBound;
        }

        @Override
        public double getUpperBound() {
            return upperBound;
        }

        @Override
        public Paint getPaint(double value) {
            float scaledValue = (float) (value / (getUpperBound() - getLowerBound()));
            float scaledH = H1 + scaledValue * (H2 - H1);
            return Color.getHSBColor(scaledH, 1f, 1f);
        }
    }

Locked