package eu.gity.jmeter.ddos.stairsddosthreadgrp.charting.elements;

import eu.gity.jmeter.ddos.stairsddosthreadgrp.charting.AbstractGraphPanelChartElement;

/**
 * {@inheritDoc}
 */
public class GraphPanelChartAverageElement extends AbstractGraphPanelChartElement {

    private static final long serialVersionUID = 240L;

    private int count = 0;
    private double avgValue = 0;

    /**
     * @param yVal
     */
    public GraphPanelChartAverageElement(double yVal) {
        add(yVal);
    }

    public GraphPanelChartAverageElement() {
    }

    /**
     * @param yVal
     */
    public void add(double yVal) {
        avgValue = (avgValue * count + yVal) / (++count);
    }

    /**
     * {@inheritDoc}
     */
    public double getValue() {
        return avgValue;
    }

    /**
     * @return the count
     */
    public int getCount() {
        return count;
    }

    @Override
    public boolean isPointRepresentative(int limit) {
        return count > limit;
    }
}
