Search in sources :

Example 1 with AbstractGraphPanelChartElement

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;
}
Also used : Entry(java.util.Map.Entry) GraphPanelChartExactElement(kg.apc.charting.elements.GraphPanelChartExactElement) AbstractGraphPanelChartElement(kg.apc.charting.AbstractGraphPanelChartElement)

Example 2 with AbstractGraphPanelChartElement

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);
}
Also used : Entry(java.util.Map.Entry) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) AbstractGraphPanelChartElement(kg.apc.charting.AbstractGraphPanelChartElement)

Example 3 with AbstractGraphPanelChartElement

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());
}
Also used : GraphPanelChartAverageElement(kg.apc.charting.elements.GraphPanelChartAverageElement) AbstractGraphPanelChartElement(kg.apc.charting.AbstractGraphPanelChartElement)

Example 4 with AbstractGraphPanelChartElement

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());
}
Also used : GraphPanelChartExactElement(kg.apc.charting.elements.GraphPanelChartExactElement) AbstractGraphPanelChartElement(kg.apc.charting.AbstractGraphPanelChartElement) GraphRowExactValues(kg.apc.charting.rows.GraphRowExactValues)

Example 5 with AbstractGraphPanelChartElement

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);
}
Also used : Entry(java.util.Map.Entry) AbstractGraphPanelChartElement(kg.apc.charting.AbstractGraphPanelChartElement) GraphRowPercentiles(kg.apc.charting.rows.GraphRowPercentiles)

Aggregations

AbstractGraphPanelChartElement (kg.apc.charting.AbstractGraphPanelChartElement)13 Entry (java.util.Map.Entry)5 GraphRowPercentiles (kg.apc.charting.rows.GraphRowPercentiles)4 GraphPanelChartAverageElement (kg.apc.charting.elements.GraphPanelChartAverageElement)3 GraphPanelChartExactElement (kg.apc.charting.elements.GraphPanelChartExactElement)2 GraphRowOverallAverages (kg.apc.charting.rows.GraphRowOverallAverages)2 BasicStroke (java.awt.BasicStroke)1 Stroke (java.awt.Stroke)1 GraphPanelChartSimpleElement (kg.apc.charting.elements.GraphPanelChartSimpleElement)1 GraphPanelChartSumElement (kg.apc.charting.elements.GraphPanelChartSumElement)1 GraphRowExactValues (kg.apc.charting.rows.GraphRowExactValues)1