BUG: HashCode in NumberAxis / Axis etc

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
dymaxion
Posts: 6
Joined: Mon Mar 10, 2008 4:10 pm
Location: London, UK

BUG: HashCode in NumberAxis / Axis etc

Post by dymaxion » Fri Mar 14, 2008 12:07 pm

Currently hashcode is this

public int hashCode() {
if (getLabel() != null) {
return getLabel().hashCode();
}
else {
return 0;
}
}

I'm caching label values as I need to hide and restore labels. Since there's no method to hide a LabelLabel (not tick Label), I'm setting values to null and storing in Map. Problem is obvious from above!

Also if I have two axes with same l label but different settings this hashCode doesn't guarantee uniqueness.

Please fix this hashCode contract. Is there a specific reason why this was coded like this? Alternatively please provide a setIsAxisLabelVisible(boolean) method.

Thanks,
Spencer

dymaxion
Posts: 6
Joined: Mon Mar 10, 2008 4:10 pm
Location: London, UK

Post by dymaxion » Fri Mar 14, 2008 12:44 pm

Another related error happens when I set the Axis Label to null to "hide it".
As a side effect, the rendering seems messed up also. Seems to add a load of whitespace where the label used to be, and also doesn't give enough spacing between multiple axes.

See image attached.
Image

Thanks

Locked