use of kg.apc.charting.AbstractGraphPanelChartElement in project jmeter-plugins by undera.
the class GraphRowExactValues method getElement.
@Override
public AbstractGraphPanelChartElement getElement(long value) {
AbstractGraphPanelChartElement ret = null;
Iterator<Entry<Long, AbstractGraphPanelChartElement>> it = values.entrySet().iterator();
while (it.hasNext() && ret == null) {
GraphPanelChartExactElement el = (GraphPanelChartExactElement) it.next().getValue();
if (el.getX() == value) {
ret = el;
}
}
return ret;
}
use of kg.apc.charting.AbstractGraphPanelChartElement in project jmeter-plugins by undera.
the class AbstractRowPlotter method paintRow.
// this method is responsible to maintain x, y, prevX, prevY
public synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor) {
Iterator<Entry<Long, AbstractGraphPanelChartElement>> it = row.iterator();
Entry<Long, AbstractGraphPanelChartElement> element;
Stroke olStroke;
prevX = -1;
prevY = chartRect.y + chartRect.height;
mustDrawFirstZeroingLine = chartSettings.isDrawFinalZeroingLines();
olStroke = g2d.getStroke();
if (row.isDrawThickLines()) {
g2d.setStroke(chartSettings.getThickStroke());
} else {
g2d.setStroke(getLineStroke());
}
g2d.setColor(color);
while (it.hasNext()) {
if (!row.isDrawOnChart()) {
continue;
}
if (limitPointFactor == 1) {
element = it.next();
AbstractGraphPanelChartElement elt = (AbstractGraphPanelChartElement) element.getValue();
// not compatible with factor != 1, ie cannot be used if limit nb of point is selected.
if (chartSettings.getHideNonRepValLimit() > 0) {
while (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit()) && it.hasNext()) {
element = it.next();
elt = (AbstractGraphPanelChartElement) element.getValue();
}
if (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit())) {
break;
}
}
calcPointX = element.getKey().doubleValue();
calcPointY = elt.getValue();
} else {
calcPointX = 0;
calcPointY = 0;
int nbPointProcessed = 0;
for (int i = 0; i < limitPointFactor; i++) {
if (it.hasNext()) {
element = it.next();
calcPointX = calcPointX + element.getKey().doubleValue();
calcPointY = calcPointY + ((AbstractGraphPanelChartElement) element.getValue()).getValue();
nbPointProcessed++;
}
}
calcPointX = calcPointX / (double) nbPointProcessed;
calcPointY = calcPointY / (double) nbPointProcessed;
}
calcPointY = calcPointY * zoomFactor;
x = chartRect.x + (int) ((calcPointX - minXVal) * dxForDVal);
int yHeight = (int) ((calcPointY - minYVal) * dyForDVal);
y = chartRect.y + chartRect.height - yHeight;
// now x and y are set, we can call plotter
processPoint(g2d, row.getGranulationValue());
// set prevX, prevY
if (isChartPointValid(x, y)) {
if (allowMarkers) {
processMarker(g2d, row);
}
prevX = x;
prevY = y;
}
if (row.isDrawValueLabel() && isChartPointValid(x, y) && y >= chartRect.y) {
drawLabels(g2d, row, calcPointY);
}
}
processFinalLines(row, g2d);
x = 0;
y = 0;
prevX = -1;
prevY = chartRect.y + chartRect.height;
postPaintRow(row, g2d);
g2d.setStroke(olStroke);
}
use of kg.apc.charting.AbstractGraphPanelChartElement in project jmeter-plugins by undera.
the class GraphRowAveragesTest method testGetElement.
/**
* Test of getElement method, of class GraphRowAverages.
*/
@Test
public void testGetElement() {
System.out.println("getElement");
long value = 100L;
AbstractGraphPanelChartElement expResult = new GraphPanelChartAverageElement(10);
instance.add(value, 10);
AbstractGraphPanelChartElement result = instance.getElement(value);
Assert.assertTrue(instance.getElement(value).getValue() == expResult.getValue());
}
use of kg.apc.charting.AbstractGraphPanelChartElement in project jmeter-plugins by undera.
the class GraphRowExactValuesTest method testGetElement.
/**
* Test of getElement method, of class GraphRowExactValues.
*/
@Test
public void testGetElement() {
System.out.println("getElement");
long value = 100L;
GraphRowExactValues instance = new GraphRowExactValues();
AbstractGraphPanelChartElement expResult = new GraphPanelChartExactElement(value, 2);
instance.add(value, 2);
AbstractGraphPanelChartElement result = instance.getElement(value);
Assert.assertTrue(instance.getElement(value).getValue() == expResult.getValue());
}
use of kg.apc.charting.AbstractGraphPanelChartElement in project jmeter-plugins by undera.
the class GraphRowPercentilesTest method testIterator_req1.
@Test
public void testIterator_req1() {
System.out.println("iterator 1req");
GraphRowPercentiles instance = new GraphRowPercentiles();
instance.add(10, 1);
instance.add(10, 1);
Iterator<Entry<Long, AbstractGraphPanelChartElement>> result = instance.iterator();
Assert.assertNotNull(result);
Assert.assertTrue(result.hasNext());
int cnt = 0;
while (result.hasNext()) {
Entry<Long, AbstractGraphPanelChartElement> obj = result.next();
Assert.assertNotNull(obj);
// System.err.println(cnt + " " + obj.getValue().getValue());
assertEquals(10, obj.getValue().getValue(), 0.01);
cnt++;
}
Assert.assertEquals(expectedCount, cnt);
}
Aggregations