All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.gsi.chart.axes.spi.format.FormatterLabelCache Maven / Gradle / Ivy

Go to download

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, ...).

There is a newer version: 11.2.7
Show newest version
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;
    // }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy