Skip to content

Commit

Permalink
bug fix: two filters for fields in LOD interfered with each other
Browse files Browse the repository at this point in the history
  • Loading branch information
yarden-livnat committed Jun 10, 2015
1 parent 5607f05 commit 82f70dc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
50 changes: 41 additions & 9 deletions cyclist/src/edu/utah/sci/cyclist/core/ui/views/ChartView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Integer, Filter> p : getLODFilters()) {
Iterator<MultiKey> 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) {
Expand All @@ -1451,7 +1457,33 @@ private void reassignData(Filter filter) {
checkForInfinities(_currentSpec.seriesMap.keySet());
}


private List<Pair<Integer, Filter>> getLODFilters() {
List<Pair<Integer, Filter>> 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<Integer, Filter>(idx, f));
found = true;
break;
}
}
if (!found) {
for (Filter f : remoteFilters()) {
if (f.getField().getName().equals(name)) {
list.add(new Pair<Integer, Filter>(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
Expand Down
6 changes: 6 additions & 0 deletions cyclist/src/edu/utexas/cycic/Cycic.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 82f70dc

Please sign in to comment.