From 82f70dcbc9a075beca2fba2d08ff691f269de85c Mon Sep 17 00:00:00 2001 From: Yarden Livnat Date: Tue, 9 Jun 2015 22:09:37 -0500 Subject: [PATCH] bug fix: two filters for fields in LOD interfered with each other --- .../sci/cyclist/core/ui/views/ChartView.java | 50 +++++++++++++++---- cyclist/src/edu/utexas/cycic/Cycic.java | 6 +++ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/cyclist/src/edu/utah/sci/cyclist/core/ui/views/ChartView.java b/cyclist/src/edu/utah/sci/cyclist/core/ui/views/ChartView.java index 6cf9e66e..a47de9de 100644 --- a/cyclist/src/edu/utah/sci/cyclist/core/ui/views/ChartView.java +++ b/cyclist/src/edu/utah/sci/cyclist/core/ui/views/ChartView.java @@ -10,6 +10,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -68,6 +69,7 @@ import edu.utah.sci.cyclist.Cyclist; import edu.utah.sci.cyclist.core.controller.IMemento; +import edu.utah.sci.cyclist.core.event.Pair; import edu.utah.sci.cyclist.core.event.dnd.DnD; import edu.utah.sci.cyclist.core.event.ui.FilterEvent; import edu.utah.sci.cyclist.core.model.Context; @@ -1301,7 +1303,7 @@ public void invalidated(Observable o) { // LOD filters only show/hide data. No need to fetch new data // TODO: is this true only for classification == C? Seems to be true for any field that is not range if(_currentSpec != null && isInLodArea(filter.getField()) && filter.getField().getClassification() == Classification.C ) { - invalidateLODFilters(filter); +// invalidateLODFilters(filter); filter.setValid(true); reassignData(filter); } else { @@ -1428,15 +1430,19 @@ private void reassignData(Filter filter) { keys.clear(); // add series - for (MultiKey multikey : _currentSpec.dataMap.keySet()) { - Object keyValue = multikey.getKey(idx); - if (filter.getSelectedValues().contains(keyValue) - && !_currentSpec.seriesMap.containsKey(multikey)) { + + keys = new ArrayList<>(_currentSpec.dataMap.keySet()); + for (Pair p : getLODFilters()) { + Iterator i = keys.iterator(); + while (i.hasNext()) { + MultiKey key = i.next(); + Object keyValue = key.getKey(p.v1+2); + if (!p.v2.getSelectedValues().contains(keyValue) + || _currentSpec.seriesMap.containsKey(key)) { - // add - keys.add(multikey); + i.remove(); } - } + } } for (MultiKey multikey : keys) { @@ -1451,7 +1457,33 @@ private void reassignData(Filter filter) { checkForInfinities(_currentSpec.seriesMap.keySet()); } - + private List> getLODFilters() { + List> list = new ArrayList<>(); + int idx = -1; + for (FieldInfo info : _currentSpec.lod) { + idx++; + boolean found = false; + String name = info.field.getName(); + for (Filter f : filters()) { + if (f.getField().getName().equals(name)) { + list.add(new Pair(idx, f)); + found = true; + break; + } + } + if (!found) { + for (Filter f : remoteFilters()) { + if (f.getField().getName().equals(name)) { + list.add(new Pair(idx, f)); + found = true; + break; + } + } + } + } + return list; + } + /*Name: setAreaFiltersListeners * This method handles fields which are connected to a filter * If the field SQL function has changed the filter has to be changed accordingly diff --git a/cyclist/src/edu/utexas/cycic/Cycic.java b/cyclist/src/edu/utexas/cycic/Cycic.java index 8fe867d4..205dafb9 100644 --- a/cyclist/src/edu/utexas/cycic/Cycic.java +++ b/cyclist/src/edu/utexas/cycic/Cycic.java @@ -517,6 +517,12 @@ public void handle(MouseEvent e){ Dragboard db = circle.startDragAndDrop(TransferMode.COPY); ClipboardContent content = new ClipboardContent(); content.put(DnD.VALUE_FORMAT, name); + + SnapshotParameters snapParams = new SnapshotParameters(); + snapParams.setFill(Color.TRANSPARENT); + + content.putImage(circle.snapshot(snapParams, null)); + db.setContent(content); e.consume(); }