diff --git a/src/main/java/com/metaweb/gridworks/browsing/facets/ExpressionNumericRowBinner.java b/src/main/java/com/metaweb/gridworks/browsing/facets/ExpressionNumericRowBinner.java
index 8c5cd7e2b..4af316717 100644
--- a/src/main/java/com/metaweb/gridworks/browsing/facets/ExpressionNumericRowBinner.java
+++ b/src/main/java/com/metaweb/gridworks/browsing/facets/ExpressionNumericRowBinner.java
@@ -16,6 +16,7 @@ public class ExpressionNumericRowBinner implements RowVisitor {
final public int[] bins;
+ public int numericCount;
public int nonNumericCount;
public int blankCount;
public int errorCount;
@@ -50,6 +51,8 @@ public class ExpressionNumericRowBinner implements RowVisitor {
errorCount++;
} else if (ExpressionUtils.isNonBlankData(value)) {
if (value instanceof Number) {
+ numericCount++;
+
double d = ((Number) value).doubleValue();
int bin = (int) Math.round((d - _index.getMin()) / _index.getStep());
diff --git a/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java b/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java
index e5693806b..3779c050a 100644
--- a/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java
+++ b/src/main/java/com/metaweb/gridworks/browsing/facets/RangeFacet.java
@@ -28,6 +28,7 @@ public class RangeFacet implements Facet {
protected double _step;
protected int[] _baseBins;
protected int[] _bins;
+ protected int _numericCount;
protected int _nonNumericCount;
protected int _blankCount;
protected int _errorCount;
@@ -35,6 +36,7 @@ public class RangeFacet implements Facet {
protected double _from;
protected double _to;
protected boolean _selected;
+ protected boolean _selectNumeric;
protected boolean _selectNonNumeric;
protected boolean _selectBlank;
protected boolean _selectError;
@@ -78,6 +80,7 @@ public class RangeFacet implements Facet {
}
}
+ writer.key("numericCount"); writer.value(_numericCount);
writer.key("nonNumericCount"); writer.value(_nonNumericCount);
writer.key("blankCount"); writer.value(_blankCount);
writer.key("errorCount"); writer.value(_errorCount);
@@ -112,11 +115,12 @@ public class RangeFacet implements Facet {
}
}
+ _selectNumeric = JSONUtilities.getBoolean(o, "selectNumeric", true);
_selectNonNumeric = JSONUtilities.getBoolean(o, "selectNonNumeric", true);
_selectBlank = JSONUtilities.getBoolean(o, "selectBlank", true);
_selectError = JSONUtilities.getBoolean(o, "selectError", true);
- if (!_selectNonNumeric || !_selectBlank || !_selectError) {
+ if (!_selectNumeric || !_selectNonNumeric || !_selectBlank || !_selectError) {
_selected = true;
}
}
@@ -124,19 +128,25 @@ public class RangeFacet implements Facet {
public RowFilter getRowFilter() {
if (_selected) {
if ("min".equals(_mode)) {
- return new ExpressionNumberComparisonRowFilter(_eval, _cellIndex, _selectNonNumeric, _selectBlank, _selectError) {
+ return new ExpressionNumberComparisonRowFilter(
+ _eval, _cellIndex, _selectNumeric, _selectNonNumeric, _selectBlank, _selectError) {
+
protected boolean checkValue(double d) {
return d >= _from;
};
};
} else if ("max".equals(_mode)) {
- return new ExpressionNumberComparisonRowFilter(_eval, _cellIndex, _selectNonNumeric, _selectBlank, _selectError) {
+ return new ExpressionNumberComparisonRowFilter(
+ _eval, _cellIndex, _selectNumeric, _selectNonNumeric, _selectBlank, _selectError) {
+
protected boolean checkValue(double d) {
return d <= _to;
};
};
} else {
- return new ExpressionNumberComparisonRowFilter(_eval, _cellIndex, _selectNonNumeric, _selectBlank, _selectError) {
+ return new ExpressionNumberComparisonRowFilter(
+ _eval, _cellIndex, _selectNumeric, _selectNonNumeric, _selectBlank, _selectError) {
+
protected boolean checkValue(double d) {
return d >= _from && d <= _to;
};
@@ -176,6 +186,7 @@ public class RangeFacet implements Facet {
filteredRows.accept(project, binner);
_bins = binner.bins;
+ _numericCount = binner.numericCount;
_nonNumericCount = binner.nonNumericCount;
_blankCount = binner.blankCount;
_errorCount = binner.errorCount;
diff --git a/src/main/java/com/metaweb/gridworks/browsing/filters/ExpressionNumberComparisonRowFilter.java b/src/main/java/com/metaweb/gridworks/browsing/filters/ExpressionNumberComparisonRowFilter.java
index 1fbf8ca18..473de962b 100644
--- a/src/main/java/com/metaweb/gridworks/browsing/filters/ExpressionNumberComparisonRowFilter.java
+++ b/src/main/java/com/metaweb/gridworks/browsing/filters/ExpressionNumberComparisonRowFilter.java
@@ -11,6 +11,7 @@ import com.metaweb.gridworks.model.Row;
abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
final protected Evaluable _evaluable;
final protected int _cellIndex;
+ final protected boolean _selectNumeric;
final protected boolean _selectNonNumeric;
final protected boolean _selectBlank;
final protected boolean _selectError;
@@ -18,12 +19,14 @@ abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
public ExpressionNumberComparisonRowFilter(
Evaluable evaluable,
int cellIndex,
+ boolean selectNumeric,
boolean selectNonNumeric,
boolean selectBlank,
boolean selectError
) {
_evaluable = evaluable;
_cellIndex = cellIndex;
+ _selectNumeric = selectNumeric;
_selectNonNumeric = selectNonNumeric;
_selectBlank = selectBlank;
_selectError = selectError;
@@ -56,7 +59,7 @@ abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
return _selectError;
} else if (ExpressionUtils.isNonBlankData(v)) {
if (v instanceof Number) {
- return checkValue(((Number) v).doubleValue());
+ return _selectNumeric && checkValue(((Number) v).doubleValue());
} else {
return _selectNonNumeric;
}
diff --git a/src/main/webapp/scripts/facets/range-facet.js b/src/main/webapp/scripts/facets/range-facet.js
index 97506b3d4..764ab81c6 100644
--- a/src/main/webapp/scripts/facets/range-facet.js
+++ b/src/main/webapp/scripts/facets/range-facet.js
@@ -5,10 +5,13 @@ function RangeFacet(div, config, options) {
this._from = ("from" in this._config) ? this._config.from : null;
this._to = ("to" in this._config) ? this._config.to : null;
+
+ this._selectNumeric = ("selectNumeric" in this._config) ? this._config.selectNumeric : true;
this._selectNonNumeric = ("selectNonNumeric" in this._config) ? this._config.selectNonNumeric : true;
this._selectBlank = ("selectBlank" in this._config) ? this._config.selectBlank : true;
this._selectError = ("selectError" in this._config) ? this._config.selectError : true;
+ this._numericCount = 0;
this._nonNumericCount = 0;
this._blankCount = 0;
this._errorCount = 0;
@@ -30,6 +33,7 @@ RangeFacet.prototype._setDefaults = function() {
this._to = this._config.max;
}
+ this._selectNumeric = true;
this._selectNonNumeric = true;
this._selectBlank = true;
this._selectError = true;
@@ -56,6 +60,7 @@ RangeFacet.prototype.getJSON = function() {
mode: this._config.mode,
expression: this._config.expression,
columnName: this._config.columnName,
+ selectNumeric: this._selectNumeric,
selectNonNumeric: this._selectNonNumeric,
selectBlank: this._selectBlank,
selectError: this._selectError
@@ -76,7 +81,7 @@ RangeFacet.prototype.getJSON = function() {
};
RangeFacet.prototype.hasSelection = function() {
- if (!this._selectNonNumeric || !this._selectBlank || !this._selectError) {
+ if (!this._selectNumeric || !this._selectNonNumeric || !this._selectBlank || !this._selectError) {
return true;
}
@@ -114,6 +119,7 @@ RangeFacet.prototype._initializeUI = function() {
self._sliderDiv.slider("values", 0, self._from);
self._sliderDiv.slider("values", 1, self._to);
}
+ self._selectNumeric = true;
self._selectNonNumeric = true;
self._selectBlank = true;
self._selectError = true;
@@ -156,6 +162,7 @@ RangeFacet.prototype._initializeUI = function() {
self._setRangeIndicators();
};
var onStop = function() {
+ self._selectNumeric = true;
self._updateRest();
};
var sliderConfig = {
@@ -198,7 +205,20 @@ RangeFacet.prototype._renderOtherChoices = function() {
var tr1 = table.insertRow(1);
var td00 = $(tr0.insertCell(0)).attr("width", "1%");
- var nonNumericCheck = $('').appendTo(td00).change(function() {
+ var numericCheck = $('').appendTo(td00).change(function() {
+ self._selectNumeric = !self._selectNumeric;
+ self._updateRest();
+ });
+ if (this._selectNumeric) {
+ numericCheck[0].checked = true;
+ }
+
+ var td01 = $(tr0.insertCell(1));
+ $('').text("Numeric ").addClass("facet-choice-label").appendTo(td01);
+ $('').text(this._numericCount).addClass("facet-choice-count").appendTo(td01);
+
+ var td02 = $(tr0.insertCell(2)).attr("width", "1%");
+ var nonNumericCheck = $('').appendTo(td02).change(function() {
self._selectNonNumeric = !self._selectNonNumeric;
self._updateRest();
});
@@ -206,9 +226,9 @@ RangeFacet.prototype._renderOtherChoices = function() {
nonNumericCheck[0].checked = true;
}
- var td01 = $(tr0.insertCell(1)).attr("colspan", "3");
- $('').text("Non-numeric ").addClass("facet-choice-label").appendTo(td01);
- $('').text(this._nonNumericCount).addClass("facet-choice-count").appendTo(td01);
+ var td03 = $(tr0.insertCell(3));
+ $('').text("Non-numeric ").addClass("facet-choice-label").appendTo(td03);
+ $('').text(this._nonNumericCount).addClass("facet-choice-count").appendTo(td03);
var td10 = $(tr1.insertCell(0)).attr("width", "1%");
var blankCheck = $('').appendTo(td10).change(function() {
@@ -278,6 +298,7 @@ RangeFacet.prototype.updateState = function(data) {
}
}
+ this._numericCount = data.numericCount;
this._nonNumericCount = data.nonNumericCount;
this._blankCount = data.blankCount;
this._errorCount = data.errorCount;