de.gsi.chart.axes.spi.format.FormatterLabelCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chartfx-chart Show documentation
Show all versions of chartfx-chart Show documentation
This charting library ${project.artifactId}- is an extension
in the spirit of Oracle's XYChart and performance/time-proven JDataViewer charting functionalities.
Emphasis was put on plotting performance for both large number of data points and real-time displays,
as well as scientific accuracies leading to error bar/surface plots, and other scientific plotting
features (parameter measurements, fitting, multiple axes, zoom, ...).
package de.gsi.chart.axes.spi.format;
import java.util.WeakHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.util.StringConverter;
/**
* Simple cache to keep recurring results of String formatters
*
* @author rstein
*/
public class FormatterLabelCache extends WeakHashMap {
private static final Logger LOGGER = LoggerFactory.getLogger(FormatterLabelCache.class);
public FormatterLabelCache() {
super();
}
public String get(final StringConverter formatter, final Number value) {
return computeIfAbsent(value, formatter::toString);
}
// @Override
// public String get(Object key) {
// String ret = super.get(key);
// if (ret == null) {
// System.out.println("cache missed");
// } else {
// System.out.println("cache hit");
// }
// return ret;
// }
}