
step.plugins.views.functions.AbstractTimeBasedView Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (C) 2020, exense GmbH
*
* This file is part of STEP
*
* STEP is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* STEP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with STEP. If not, see .
******************************************************************************/
package step.plugins.views.functions;
import java.util.Map.Entry;
import java.util.TreeMap;
import step.core.views.AbstractView;
public abstract class AbstractTimeBasedView extends AbstractView> {
int resolutions[] = new int[]{5000,60000,3600000,86400000};
int threshold = 20;
@Override
public AbstractTimeBasedModel init() {
AbstractTimeBasedModel model = new AbstractTimeBasedModel<>();
model.setIntervals(new TreeMap<>());
model.setResolution(resolutions[0]);
model.setResolutionIndex(0);
return model;
}
public void setResolutions(int[] resolutions) {
this.resolutions = resolutions;
}
protected void addPoint(AbstractTimeBasedModel model, long time, T point) {
decreaseResolutionIfNeeded(model);
addPointToInterval(model.getIntervals(), time, model.getResolution(), point);
updateMinAndMaxTime(model, time);
}
protected void removePoint(AbstractTimeBasedModel model, long time, T point) {
//increaseResolutionIfNeeded(model);
removePointFromInterval(model.getIntervals(), time, model.getResolution(), point);
//updateMinAndMaxTime(model, time);
}
private void updateMinAndMaxTime(AbstractTimeBasedModel model, long time) {
if(model.getMinTime()>time) {
model.setMinTime(time);
}
if(model.getMaxTime()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy