Suggestion for extension to Meters

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Bob Orchard

Suggestion for extension to Meters

Post by Bob Orchard » Wed Aug 21, 2002 9:01 pm

The support of meters is quite nice but:

1. the docs I purchased do not cover them (soon to be added?); in fact the docs seem to not cover a lot of things in much detail I found the code was the only way to find out how things worked.

2. it is not possible to change the color of the needle (green), the backgound (black) or the value displayed (cyan?). I added the following code to allow this to be done. Can this or something like it be added in the near future. I can send the modified file if required.

In MeterPlot.java

add:
static final Color DEFAULT_METER_NEEDLE_COLOR = Color.green;
static final Color DEFAULT_METER_BACKGROUND_COLOR = Color.black;
static final Color DEFAULT_METER_VALUE_COLOR = Color.cyan;

protected Color meterValueColor = DEFAULT_METER_VALUE_COLOR;
protected Color meterNeedleColor = DEFAULT_METER_NEEDLE_COLOR;
protected Color meterBackgroundColor = DEFAULT_METER_BACKGROUND_COLOR;

public Color getMeterNeedleColor() { return meterNeedleColor; }
public Color getMeterValueColor() { return meterValueColor; }
public Color getMeterBackgroundColor() { return meterBackgroundColor; }

public void setMeterNeedleColor( Color color) {
this.meterNeedleColor = color == null ? DEFAULT_METER_NEEDLE_COLOR : color;
}

public void setMeterBackgroundColor( Color color) {
this.meterBackgroundColor = color == null ? DEFAULT_METER_BACKGROUND_COLOR : color;
}

public void setMeterValueColor( Color color) {
this.meterValueColor = color == null ? DEFAULT_METER_VALUE_COLOR : color;
}

then:

change all places where the Color.green, Color.black and Color.cyan are used to draw these areas. Would have enclosed the changed file except I can't see how to do that with this forum.

Cheers, bob.

David Gilbert

Re: Suggestion for extension to Meters

Post by David Gilbert » Thu Aug 22, 2002 10:40 am

Bob Orchard wrote:
> 1. the docs I purchased do not cover them (soon to be
> added?); in fact the docs seem to not cover a lot of things
> in much detail I found the code was the only way to find out
> how things worked.

There are some areas where the documentation still needs attention, I'm working on it all the time. Recent updates include sections on JDBC and servlets...I'll add a section for the meter plots (and fill in the class reference section) at the same time as I integrate your code below.

> 2. it is not possible to change the color of the needle
> (green), the backgound (black) or the value displayed
> (cyan?). I added the following code to allow this to be done.
> Can this or something like it be added in the near future. I
> can send the modified file if required.

It will be added in CVS today, and included in 0.9.3 which I hope to release as soon as I've finished some more work on the documentation.

Regards,

DG.

Locked