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

kg.apc.charting.rows.GraphRowSimple Maven / Gradle / Ivy

There is a newer version: 0.7
Show newest version
package kg.apc.charting.rows;

import kg.apc.charting.AbstractGraphRow;
import kg.apc.charting.elements.GraphPanelChartSimpleElement;
import kg.apc.charting.AbstractGraphPanelChartElement;

import java.io.Serializable;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListMap;

public class GraphRowSimple
        extends AbstractGraphRow
        implements Serializable {
    private ConcurrentSkipListMap values;

    public GraphRowSimple() {
        super();
        values = new ConcurrentSkipListMap<>();
    }

    /**
     * @param xVal coord
     * @param yVal coord
     */
    @Override
    public void add(long xVal, double yVal) {
        GraphPanelChartSimpleElement el;
        if (values.containsKey(xVal)) {
            el = (GraphPanelChartSimpleElement) values.get(xVal);
            el.add(yVal);
        } else {
            el = new GraphPanelChartSimpleElement(yVal);
            values.put(xVal, el);
        }

        super.add(xVal, yVal);
    }

    @Override
    public Iterator> iterator() {
        return values.entrySet().iterator();
    }

    @Override
    public int size() {
        return values.size();
    }

    @Override
    public AbstractGraphPanelChartElement getElement(long value) {
        return values.get(value);
    }

    @Override
    public Long getHigherKey(long value) {
        return values.navigableKeySet().higher(value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy