Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix: two filters for fields in LOD interfered with each other #131

Merged
merged 1 commit into from
Jun 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 additions & 4 deletions cyclist/src/edu/utexas/cycic/Cycic.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,11 @@ 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));
snapParams.setFill(Color.TRANSPARENT);

content.putImage(circle.snapshot(snapParams, null));

db.setContent(content);
e.consume();
}
Expand Down