kg.apc.charting.rows.GraphRowExactValues Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmeter-plugins-cmn-jmeter Show documentation
Show all versions of jmeter-plugins-cmn-jmeter Show documentation
Various utility classes to ease development of plugins
package kg.apc.charting.rows;
import kg.apc.charting.AbstractGraphRow;
import kg.apc.charting.elements.GraphPanelChartExactElement;
import kg.apc.charting.AbstractGraphPanelChartElement;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListMap;
public class GraphRowExactValues
extends AbstractGraphRow
implements Iterator> {
private ConcurrentSkipListMap values;
private Iterator> iterator;
public GraphRowExactValues() {
super();
values = new ConcurrentSkipListMap<>();
}
@Override
public void add(long xVal, double yVal) {
GraphPanelChartExactElement el;
el = new GraphPanelChartExactElement(xVal, yVal);
values.put((long) values.size(), el);
super.add(xVal, yVal);
}
@Override
public Iterator> iterator() {
iterator = values.entrySet().iterator();
return this;
}
public boolean hasNext() {
return iterator != null && iterator.hasNext();
}
public Entry next() {
GraphPanelChartExactElement el = (GraphPanelChartExactElement) iterator.next().getValue();
return new ExactEntry(el.getX(), el);
}
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
private static class ExactEntry
implements Entry {
private long key;
private final AbstractGraphPanelChartElement value;
public ExactEntry(long aKey, AbstractGraphPanelChartElement aValue) {
key = aKey;
value = aValue;
}
public Long getKey() {
return key;
}
public AbstractGraphPanelChartElement getValue() {
return value;
}
public AbstractGraphPanelChartElement setValue(AbstractGraphPanelChartElement value) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
@Override
public int size() {
return values.size();
}
@Override
public AbstractGraphPanelChartElement getElement(long value) {
AbstractGraphPanelChartElement ret = null;
Iterator> it = values.entrySet().iterator();
while (it.hasNext() && ret == null) {
GraphPanelChartExactElement el = (GraphPanelChartExactElement) it.next().getValue();
if (el.getX() == value) {
ret = el;
}
}
return ret;
}
}