Skip to content

Commit

Permalink
Fix bug in (error) point reduction
Browse files Browse the repository at this point in the history
When reducing the points, the reducer would for some reason swap the
positive and negative error for the last point. When no actual reduction
is taking place, this leads to the values actually having the same value
which would give strange results in the error bars/surfaces.

This commit removes the swapping of the errors of the last point.

The error surface renderer would also swap these points again before
rendering, so this is also removed with this commit.

To ease testing, an option to enable/disable parallel point caching in
the renderer was added to the ErrorDataSetRendererStylingSample.
  • Loading branch information
wirew0rm authored and RalphSteinhagen committed Oct 1, 2020
1 parent e5f9425 commit 08727d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import java.security.InvalidParameterException;

import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;

import de.gsi.chart.renderer.RendererDataReducer;
import de.gsi.dataset.utils.AssertUtils;
import de.gsi.dataset.utils.ProcessingProfiler;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;

/**
* Default data reduction algorithm implementation for the ErrorDataSet Renderer <br>
Expand All @@ -17,7 +18,6 @@
* @author rstein
*/
public class DefaultDataReducer implements RendererDataReducer {

protected IntegerProperty minPointPixelDistance = new SimpleIntegerProperty(this, "minPixelDistance", 6) {
@Override
public void set(final int value) {
Expand Down Expand Up @@ -218,8 +218,8 @@ private int reducePointsInternal(final double[] xValues, final double[] yValues,
yValues[count] = yValues[indexMax - 1];
xPointErrorsNeg[count] = xPointErrorsPos[indexMax - 1];
xPointErrorsPos[count] = xPointErrorsNeg[indexMax - 1];
yPointErrorsNeg[count] = yPointErrorsPos[indexMax - 1];
yPointErrorsPos[count] = yPointErrorsNeg[indexMax - 1];
yPointErrorsNeg[count] = yPointErrorsNeg[indexMax - 1];
yPointErrorsPos[count] = yPointErrorsPos[indexMax - 1];
pointSelected[count] = pointSelected[indexMax - 1];
styles[count] = styles[indexMax - 1];
count++;
Expand Down Expand Up @@ -480,5 +480,4 @@ private int reducePointsInternal(final double[] xValues, final double[] yValues,
public final void setMinPointPixelDistance(final int minPixelDistance) {
minPointPixelDistanceProperty().setValue(minPixelDistance);
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package de.gsi.chart.renderer.spi;

import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.*;

import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
Expand Down Expand Up @@ -493,12 +488,6 @@ protected void drawErrorSurface(final GraphicsContext gc, final CachedDataPoints
xValuesSurface[xend - i] = localCachedPoints.xValues[i];
yValuesSurface[xend - i] = localCachedPoints.errorYPos[i];
}
// swap y coordinates at mid-point
if (nDataCount > 4) {
final double yTmp = yValuesSurface[nDataCount - 1];
yValuesSurface[nDataCount - 1] = yValuesSurface[xend - nDataCount + 1];
yValuesSurface[xend - nDataCount + 1] = yTmp;
}

gc.setFillRule(FillRule.EVEN_ODD);
gc.fillPolygon(xValuesSurface, yValuesSurface, nPolygoneEdges);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,12 @@ private ParameterTab getRendererTab(final XYChart chart, final ErrorDataSetRende
assumeSorted.selectedProperty().addListener((ch, old, selected) -> chart.requestLayout());
pane.addToParameterPane("Assume sorted data: ", assumeSorted);

pane.addToParameterPane(" ", null);
final CheckBox cacheParallel = new CheckBox();
cacheParallel.selectedProperty().bindBidirectional(errorRenderer.parallelImplementationProperty());
cacheParallel.selectedProperty().addListener((ch, old, selected) -> chart.requestLayout());
pane.addToParameterPane(" Point cache parallel: ", cacheParallel);

return pane;
}

Expand Down

0 comments on commit 08727d5

Please sign in to comment.