Skip to content

Commit

Permalink
sanitization of cue chunk,point pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
hageldave committed Jun 28, 2022
1 parent f56dda8 commit 19b1bcc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.*;
import java.util.stream.Collectors;

/**
*
Expand Down Expand Up @@ -997,9 +998,16 @@ public void highlight(Iterable<Pair<Integer, Integer>> toHighlight) {
selectionModel.setSelection(toHighlight);
}

protected SortedSet<Pair<Integer, Integer>> sanitizeCueSet(SortedSet<Pair<Integer, Integer>> cueset) {
return cueset.stream()
.filter(p->p.first >= 0 && p.second >= 0 && p.first < dataModel.numChunks())
.filter(p->p.second < dataModel.chunkSize(p.first))
.collect(Collectors.toCollection(TreeSet::new));
}

protected void createCue(final String cueType) {
SimpleSelectionModel<Pair<Integer, Integer>> selectionModel = this.cueSelectionModels.get(cueType);
SortedSet<Pair<Integer, Integer>> instancesToCue = selectionModel.getSelection();
SortedSet<Pair<Integer, Integer>> instancesToCue = sanitizeCueSet(selectionModel.getSelection());

clearCue(cueType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ private void renderFallbackLinesVT(
double prevX = 0;
double prevY = 0;

for (SegmentDetails seg : lines.getSegments()) {
for (SegmentDetails seg : lines.getIntersectingSegments(view)) {
double x1, y1, x2, y2;
x1 = seg.p0.getX();
y1 = seg.p0.getY();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static void main(String[] args) throws IOException, InterruptedException,
allGroups.add(groupSetosa);
allGroups.add(groupVersicolor);
allGroups.add(groupVirginica);
allGroups.add(groupSetosa);
allGroups.add(groupVersicolor);
allGroups.add(groupVirginica);

LinkedList<double[]> allValues = new LinkedList<>();
allValues.add(setosaValues);
Expand All @@ -102,6 +105,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
allHistograms.add(setosaHistogramValues);
allHistograms.add(versicolorHistogramValues);
allHistograms.add(virginicaHistogramValues);


// now calculate mean for all values and save it in an array
int index = 0;
Expand Down Expand Up @@ -154,6 +158,10 @@ public static void main(String[] args) throws IOException, InterruptedException,
createHistogramGroup(0.0, petalLength, classcolors, setosaHistogramValues.get(2), versicolorHistogramValues.get(2), virginicaHistogramValues.get(2));
createHistogramGroup(0.0, petalWidth, classcolors, setosaHistogramValues.get(3), versicolorHistogramValues.get(3), virginicaHistogramValues.get(3));

histogramChart.addData(sepalLength);
histogramChart.addData(sepalWidth);
histogramChart.addData(petalLength);
histogramChart.addData(petalWidth);
histogramChart.addData(sepalLength);
histogramChart.addData(sepalWidth);
histogramChart.addData(petalLength);
Expand Down

0 comments on commit 19b1bcc

Please sign in to comment.