* @param p1 First Point of the selected rectangle
* @param p2 Second Point of the selected rectangle
*/
private void updateSelection(Projection proj, SVGPoint p1, SVGPoint p2) {
DBIDSelection selContext = context.getSelection();
ModifiableDBIDs selection;
if(selContext != null) {
selection = DBIDUtil.newHashSet(selContext.getSelectedIds());
}
else {
selection = DBIDUtil.newHashSet();
}
DoubleDoublePair[] ranges;
if(p1 == null || p2 == null) {
logger.warning("no rect selected: p1: " + p1 + " p2: " + p2);
}
else {
double x1 = Math.min(p1.getX(), p2.getX());
double x2 = Math.max(p1.getX(), p2.getX());
double y1 = Math.max(p1.getY(), p2.getY());
double y2 = Math.min(p1.getY(), p2.getY());
if(selContext instanceof RangeSelection) {
ranges = ((RangeSelection) selContext).getRanges();
}
else {
ranges = new DoubleDoublePair[dim];
}
updateSelectionRectKoordinates(x1, x2, y1, y2, ranges);
selection.clear();
boolean idIn = true;
for(DBID id : rel.iterDBIDs()) {
NV dbTupel = rel.get(id);
idIn = true;
for(int i = 0; i < dim; i++) {
if(ranges != null && ranges[i] != null) {
if(dbTupel.doubleValue(i + 1) < ranges[i].first || dbTupel.doubleValue(i + 1) > ranges[i].second) {
idIn = false;
break;
}
}
}
if(idIn == true) {
selection.add(id);
}
}
context.setSelection(new RangeSelection(selection, ranges));
}
}