Skip to content

Commit

Permalink
ErrorDataSetRenderer: fix error surfaces for inexact array cache
Browse files Browse the repository at this point in the history
The compaction routine for the error surface polygon vectors was not
correctly handling arrays bigger than the requested size, leading to
wrong error surfaces. This passes the actual expected size to the
compaction method so it can correctly move the 2 halves of the data
behind each other.
  • Loading branch information
wirew0rm committed Sep 29, 2023
1 parent 6dc1993 commit 0322ab1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ protected void drawErrorSurfaceNaNCompatible(final GraphicsContext gc, final Dat
count++;
} else if (count != 0) {
// remove zeros and plot intermediate segment
compactVector(xValuesSurface, count);
compactVector(yValuesSurface, count);
compactVector(xValuesSurface, nPolygoneEdges, count);
compactVector(yValuesSurface, nPolygoneEdges, count);

Check warning on line 421 in chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/ErrorDataSetRenderer.java

View check run for this annotation

Codecov / codecov/patch

chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/ErrorDataSetRenderer.java#L420-L421

Added lines #L420 - L421 were not covered by tests

gc.fillPolygon(xValuesSurface, yValuesSurface, 2 * count);
count = 0;
Expand All @@ -427,8 +427,8 @@ protected void drawErrorSurfaceNaNCompatible(final GraphicsContext gc, final Dat
if (count > 0) {
// swap y coordinates at mid-point
// remove zeros and plot intermediate segment
compactVector(xValuesSurface, count);
compactVector(yValuesSurface, count);
compactVector(xValuesSurface, nPolygoneEdges, count);
compactVector(yValuesSurface, nPolygoneEdges, count);

Check warning on line 431 in chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/ErrorDataSetRenderer.java

View check run for this annotation

Codecov / codecov/patch

chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/ErrorDataSetRenderer.java#L430-L431

Added lines #L430 - L431 were not covered by tests
if (count > 4) {
final double yTmp = yValuesSurface[count - 1];
yValuesSurface[count - 1] = yValuesSurface[count];
Expand Down Expand Up @@ -802,9 +802,9 @@ protected static void drawPolyLineStairCase(final GraphicsContext gc, final Data
gc.restore();
}

private static void compactVector(final double[] input, final int stopIndex) {
private static void compactVector(final double[] input, final int inputLength, final int stopIndex) {
if (stopIndex >= 0) {
System.arraycopy(input, input.length - stopIndex, input, stopIndex, stopIndex);
System.arraycopy(input, inputLength - stopIndex, input, stopIndex, stopIndex);

Check warning on line 807 in chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/ErrorDataSetRenderer.java

View check run for this annotation

Codecov / codecov/patch

chartfx-chart/src/main/java/io/fair_acc/chartfx/renderer/spi/ErrorDataSetRenderer.java#L807

Added line #L807 was not covered by tests
}
}

Expand Down

0 comments on commit 0322ab1

Please sign in to comment.