Added item count to LinePlotSeries & Subsampling to visualizer
This commit is contained in:
@@ -58,6 +58,9 @@ public class Visualizer {
|
||||
private int ecount;
|
||||
private boolean clearPlot;
|
||||
private List<SeriesDataFilter> filters;
|
||||
|
||||
int subsampling;
|
||||
int subsamplingCounter=0;
|
||||
|
||||
private boolean first = true;
|
||||
public Visualizer(VDescriptor vdescriptor){
|
||||
@@ -85,6 +88,8 @@ public class Visualizer {
|
||||
XYSeries sxy = (XYSeries)s;
|
||||
XYSeriesDataFilter filter = new XYSeriesDataFilter(sxy.getX(), sxy.getY(), plot);
|
||||
filter.setSeriesName(sxy.getY());
|
||||
if (sxy.getMaxItemCount()>=0)
|
||||
filter.setMaxNumberOfPoints(sxy.getMaxItemCount());
|
||||
filters.add(filter);
|
||||
}
|
||||
else if(s instanceof YSeries){
|
||||
@@ -164,6 +169,15 @@ public class Visualizer {
|
||||
}
|
||||
clearPlot = false;
|
||||
}
|
||||
|
||||
if (subsampling>1){
|
||||
if ((subsamplingCounter++) > subsampling) {
|
||||
subsamplingCounter=0;
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(SeriesDataFilter filter: filters){
|
||||
if(filter instanceof XYSeriesDataFilter){
|
||||
@@ -171,7 +185,9 @@ public class Visualizer {
|
||||
|
||||
if(xyfilter.getSeries()==null || xyfilter.isNewseries()){
|
||||
// First series that is filled by this filter!
|
||||
LinePlotSeries s = new LinePlotSeries(xyfilter.getSeriesName() + " " + ecount + "-" + xyfilter.getCount());
|
||||
LinePlotSeries s = new LinePlotSeries(xyfilter.getSeriesName() + " " + ecount + "-" + xyfilter.getCount());
|
||||
if (xyfilter.getMaxNumberOfPoints()>=0)
|
||||
s.setMaxItemCount(xyfilter.getMaxNumberOfPoints());
|
||||
((LinePlot)xyfilter.getPlot()).addSeries(s);
|
||||
xyfilter.setSeries(s);
|
||||
xyfilter.setNewseries(false);
|
||||
@@ -182,15 +198,9 @@ public class Visualizer {
|
||||
// There might be other values than double in the data, therefore we have to check for it
|
||||
Object dX = message.getData(xyfilter.getIdX());
|
||||
Object dY = message.getData(xyfilter.getIdY());
|
||||
Double dataX = Double.NaN;
|
||||
Double dataY = Double.NaN;
|
||||
if(dX instanceof Double){
|
||||
dataX = (Double) dX;
|
||||
}
|
||||
if(dY instanceof Double){
|
||||
dataY = (Double) dY;
|
||||
}
|
||||
|
||||
Double dataX = getDoubleValue (dX);
|
||||
Double dataY = getDoubleValue (dY);
|
||||
|
||||
// Add Data to the series
|
||||
((LinePlot)xyfilter.getPlot()).setUpdatesEnabled(updateAtStreamElement);
|
||||
series.appendData(dataX , dataY);
|
||||
@@ -274,6 +284,27 @@ public class Visualizer {
|
||||
}
|
||||
}
|
||||
|
||||
Double getDoubleValue(Object value){
|
||||
if(value instanceof Double){
|
||||
return (Double) value;
|
||||
}
|
||||
if(value instanceof Integer){
|
||||
return (double)((Integer) value);
|
||||
}
|
||||
else if(value instanceof Short){
|
||||
return (double)((Short) value);
|
||||
}
|
||||
else if(value instanceof Long){
|
||||
return (double)((Long) value);
|
||||
}
|
||||
else if(value instanceof Float){
|
||||
return (double)((Float) value);
|
||||
}
|
||||
else if(value instanceof Boolean){
|
||||
return (double)(((Boolean) value)?1.0:0.0;
|
||||
}
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStreamDelimiterMessage(StreamDelimiterMessage message){
|
||||
@@ -367,5 +398,12 @@ public class Visualizer {
|
||||
public void setUpdateAtEndOfStream(boolean updateAtEndOfStream) {
|
||||
this.updateAtEndOfStream = updateAtEndOfStream;
|
||||
}
|
||||
|
||||
|
||||
public boolean getSubsampling() {
|
||||
return subsampling;
|
||||
}
|
||||
public void setSubsampling(int factor) {
|
||||
this.subsampling = factor;
|
||||
subsamplingCounter=subsampling;//To plot first point
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@ public class XYSeriesDataFilter implements SeriesDataFilter{
|
||||
|
||||
// Number of series generated for this filter
|
||||
private int count = 0;
|
||||
|
||||
// Max number of points per series (additional appends make oldest value to be )
|
||||
private int maxNumberOfPoints=-1;
|
||||
|
||||
// Plot the data of this filter goes to
|
||||
private final LinePlot plot;
|
||||
@@ -86,5 +89,10 @@ public class XYSeriesDataFilter implements SeriesDataFilter{
|
||||
public void setNewseries(boolean newseries) {
|
||||
this.newseries = newseries;
|
||||
}
|
||||
|
||||
public int getMaxNumberOfPoints() {
|
||||
return maxNumberOfPoints;
|
||||
}
|
||||
public void setMaxNumberOfPoints(int count) {
|
||||
this.maxNumberOfPoints = count;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user