Added "numeric" choice to numeric range facets.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@272 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
b1fca11342
commit
86a8e13d88
@ -16,6 +16,7 @@ public class ExpressionNumericRowBinner implements RowVisitor {
|
|||||||
|
|
||||||
final public int[] bins;
|
final public int[] bins;
|
||||||
|
|
||||||
|
public int numericCount;
|
||||||
public int nonNumericCount;
|
public int nonNumericCount;
|
||||||
public int blankCount;
|
public int blankCount;
|
||||||
public int errorCount;
|
public int errorCount;
|
||||||
@ -50,6 +51,8 @@ public class ExpressionNumericRowBinner implements RowVisitor {
|
|||||||
errorCount++;
|
errorCount++;
|
||||||
} else if (ExpressionUtils.isNonBlankData(value)) {
|
} else if (ExpressionUtils.isNonBlankData(value)) {
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
|
numericCount++;
|
||||||
|
|
||||||
double d = ((Number) value).doubleValue();
|
double d = ((Number) value).doubleValue();
|
||||||
|
|
||||||
int bin = (int) Math.round((d - _index.getMin()) / _index.getStep());
|
int bin = (int) Math.round((d - _index.getMin()) / _index.getStep());
|
||||||
|
@ -28,6 +28,7 @@ public class RangeFacet implements Facet {
|
|||||||
protected double _step;
|
protected double _step;
|
||||||
protected int[] _baseBins;
|
protected int[] _baseBins;
|
||||||
protected int[] _bins;
|
protected int[] _bins;
|
||||||
|
protected int _numericCount;
|
||||||
protected int _nonNumericCount;
|
protected int _nonNumericCount;
|
||||||
protected int _blankCount;
|
protected int _blankCount;
|
||||||
protected int _errorCount;
|
protected int _errorCount;
|
||||||
@ -35,6 +36,7 @@ public class RangeFacet implements Facet {
|
|||||||
protected double _from;
|
protected double _from;
|
||||||
protected double _to;
|
protected double _to;
|
||||||
protected boolean _selected;
|
protected boolean _selected;
|
||||||
|
protected boolean _selectNumeric;
|
||||||
protected boolean _selectNonNumeric;
|
protected boolean _selectNonNumeric;
|
||||||
protected boolean _selectBlank;
|
protected boolean _selectBlank;
|
||||||
protected boolean _selectError;
|
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("nonNumericCount"); writer.value(_nonNumericCount);
|
||||||
writer.key("blankCount"); writer.value(_blankCount);
|
writer.key("blankCount"); writer.value(_blankCount);
|
||||||
writer.key("errorCount"); writer.value(_errorCount);
|
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);
|
_selectNonNumeric = JSONUtilities.getBoolean(o, "selectNonNumeric", true);
|
||||||
_selectBlank = JSONUtilities.getBoolean(o, "selectBlank", true);
|
_selectBlank = JSONUtilities.getBoolean(o, "selectBlank", true);
|
||||||
_selectError = JSONUtilities.getBoolean(o, "selectError", true);
|
_selectError = JSONUtilities.getBoolean(o, "selectError", true);
|
||||||
|
|
||||||
if (!_selectNonNumeric || !_selectBlank || !_selectError) {
|
if (!_selectNumeric || !_selectNonNumeric || !_selectBlank || !_selectError) {
|
||||||
_selected = true;
|
_selected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,19 +128,25 @@ public class RangeFacet implements Facet {
|
|||||||
public RowFilter getRowFilter() {
|
public RowFilter getRowFilter() {
|
||||||
if (_selected) {
|
if (_selected) {
|
||||||
if ("min".equals(_mode)) {
|
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) {
|
protected boolean checkValue(double d) {
|
||||||
return d >= _from;
|
return d >= _from;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else if ("max".equals(_mode)) {
|
} 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) {
|
protected boolean checkValue(double d) {
|
||||||
return d <= _to;
|
return d <= _to;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return new ExpressionNumberComparisonRowFilter(_eval, _cellIndex, _selectNonNumeric, _selectBlank, _selectError) {
|
return new ExpressionNumberComparisonRowFilter(
|
||||||
|
_eval, _cellIndex, _selectNumeric, _selectNonNumeric, _selectBlank, _selectError) {
|
||||||
|
|
||||||
protected boolean checkValue(double d) {
|
protected boolean checkValue(double d) {
|
||||||
return d >= _from && d <= _to;
|
return d >= _from && d <= _to;
|
||||||
};
|
};
|
||||||
@ -176,6 +186,7 @@ public class RangeFacet implements Facet {
|
|||||||
filteredRows.accept(project, binner);
|
filteredRows.accept(project, binner);
|
||||||
|
|
||||||
_bins = binner.bins;
|
_bins = binner.bins;
|
||||||
|
_numericCount = binner.numericCount;
|
||||||
_nonNumericCount = binner.nonNumericCount;
|
_nonNumericCount = binner.nonNumericCount;
|
||||||
_blankCount = binner.blankCount;
|
_blankCount = binner.blankCount;
|
||||||
_errorCount = binner.errorCount;
|
_errorCount = binner.errorCount;
|
||||||
|
@ -11,6 +11,7 @@ import com.metaweb.gridworks.model.Row;
|
|||||||
abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
|
abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
|
||||||
final protected Evaluable _evaluable;
|
final protected Evaluable _evaluable;
|
||||||
final protected int _cellIndex;
|
final protected int _cellIndex;
|
||||||
|
final protected boolean _selectNumeric;
|
||||||
final protected boolean _selectNonNumeric;
|
final protected boolean _selectNonNumeric;
|
||||||
final protected boolean _selectBlank;
|
final protected boolean _selectBlank;
|
||||||
final protected boolean _selectError;
|
final protected boolean _selectError;
|
||||||
@ -18,12 +19,14 @@ abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
|
|||||||
public ExpressionNumberComparisonRowFilter(
|
public ExpressionNumberComparisonRowFilter(
|
||||||
Evaluable evaluable,
|
Evaluable evaluable,
|
||||||
int cellIndex,
|
int cellIndex,
|
||||||
|
boolean selectNumeric,
|
||||||
boolean selectNonNumeric,
|
boolean selectNonNumeric,
|
||||||
boolean selectBlank,
|
boolean selectBlank,
|
||||||
boolean selectError
|
boolean selectError
|
||||||
) {
|
) {
|
||||||
_evaluable = evaluable;
|
_evaluable = evaluable;
|
||||||
_cellIndex = cellIndex;
|
_cellIndex = cellIndex;
|
||||||
|
_selectNumeric = selectNumeric;
|
||||||
_selectNonNumeric = selectNonNumeric;
|
_selectNonNumeric = selectNonNumeric;
|
||||||
_selectBlank = selectBlank;
|
_selectBlank = selectBlank;
|
||||||
_selectError = selectError;
|
_selectError = selectError;
|
||||||
@ -56,7 +59,7 @@ abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
|
|||||||
return _selectError;
|
return _selectError;
|
||||||
} else if (ExpressionUtils.isNonBlankData(v)) {
|
} else if (ExpressionUtils.isNonBlankData(v)) {
|
||||||
if (v instanceof Number) {
|
if (v instanceof Number) {
|
||||||
return checkValue(((Number) v).doubleValue());
|
return _selectNumeric && checkValue(((Number) v).doubleValue());
|
||||||
} else {
|
} else {
|
||||||
return _selectNonNumeric;
|
return _selectNonNumeric;
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,13 @@ function RangeFacet(div, config, options) {
|
|||||||
|
|
||||||
this._from = ("from" in this._config) ? this._config.from : null;
|
this._from = ("from" in this._config) ? this._config.from : null;
|
||||||
this._to = ("to" in this._config) ? this._config.to : 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._selectNonNumeric = ("selectNonNumeric" in this._config) ? this._config.selectNonNumeric : true;
|
||||||
this._selectBlank = ("selectBlank" in this._config) ? this._config.selectBlank : true;
|
this._selectBlank = ("selectBlank" in this._config) ? this._config.selectBlank : true;
|
||||||
this._selectError = ("selectError" in this._config) ? this._config.selectError : true;
|
this._selectError = ("selectError" in this._config) ? this._config.selectError : true;
|
||||||
|
|
||||||
|
this._numericCount = 0;
|
||||||
this._nonNumericCount = 0;
|
this._nonNumericCount = 0;
|
||||||
this._blankCount = 0;
|
this._blankCount = 0;
|
||||||
this._errorCount = 0;
|
this._errorCount = 0;
|
||||||
@ -30,6 +33,7 @@ RangeFacet.prototype._setDefaults = function() {
|
|||||||
this._to = this._config.max;
|
this._to = this._config.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._selectNumeric = true;
|
||||||
this._selectNonNumeric = true;
|
this._selectNonNumeric = true;
|
||||||
this._selectBlank = true;
|
this._selectBlank = true;
|
||||||
this._selectError = true;
|
this._selectError = true;
|
||||||
@ -56,6 +60,7 @@ RangeFacet.prototype.getJSON = function() {
|
|||||||
mode: this._config.mode,
|
mode: this._config.mode,
|
||||||
expression: this._config.expression,
|
expression: this._config.expression,
|
||||||
columnName: this._config.columnName,
|
columnName: this._config.columnName,
|
||||||
|
selectNumeric: this._selectNumeric,
|
||||||
selectNonNumeric: this._selectNonNumeric,
|
selectNonNumeric: this._selectNonNumeric,
|
||||||
selectBlank: this._selectBlank,
|
selectBlank: this._selectBlank,
|
||||||
selectError: this._selectError
|
selectError: this._selectError
|
||||||
@ -76,7 +81,7 @@ RangeFacet.prototype.getJSON = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
RangeFacet.prototype.hasSelection = function() {
|
RangeFacet.prototype.hasSelection = function() {
|
||||||
if (!this._selectNonNumeric || !this._selectBlank || !this._selectError) {
|
if (!this._selectNumeric || !this._selectNonNumeric || !this._selectBlank || !this._selectError) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +119,7 @@ RangeFacet.prototype._initializeUI = function() {
|
|||||||
self._sliderDiv.slider("values", 0, self._from);
|
self._sliderDiv.slider("values", 0, self._from);
|
||||||
self._sliderDiv.slider("values", 1, self._to);
|
self._sliderDiv.slider("values", 1, self._to);
|
||||||
}
|
}
|
||||||
|
self._selectNumeric = true;
|
||||||
self._selectNonNumeric = true;
|
self._selectNonNumeric = true;
|
||||||
self._selectBlank = true;
|
self._selectBlank = true;
|
||||||
self._selectError = true;
|
self._selectError = true;
|
||||||
@ -156,6 +162,7 @@ RangeFacet.prototype._initializeUI = function() {
|
|||||||
self._setRangeIndicators();
|
self._setRangeIndicators();
|
||||||
};
|
};
|
||||||
var onStop = function() {
|
var onStop = function() {
|
||||||
|
self._selectNumeric = true;
|
||||||
self._updateRest();
|
self._updateRest();
|
||||||
};
|
};
|
||||||
var sliderConfig = {
|
var sliderConfig = {
|
||||||
@ -198,7 +205,20 @@ RangeFacet.prototype._renderOtherChoices = function() {
|
|||||||
var tr1 = table.insertRow(1);
|
var tr1 = table.insertRow(1);
|
||||||
|
|
||||||
var td00 = $(tr0.insertCell(0)).attr("width", "1%");
|
var td00 = $(tr0.insertCell(0)).attr("width", "1%");
|
||||||
var nonNumericCheck = $('<input type="checkbox" />').appendTo(td00).change(function() {
|
var numericCheck = $('<input type="checkbox" />').appendTo(td00).change(function() {
|
||||||
|
self._selectNumeric = !self._selectNumeric;
|
||||||
|
self._updateRest();
|
||||||
|
});
|
||||||
|
if (this._selectNumeric) {
|
||||||
|
numericCheck[0].checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var td01 = $(tr0.insertCell(1));
|
||||||
|
$('<span>').text("Numeric ").addClass("facet-choice-label").appendTo(td01);
|
||||||
|
$('<span>').text(this._numericCount).addClass("facet-choice-count").appendTo(td01);
|
||||||
|
|
||||||
|
var td02 = $(tr0.insertCell(2)).attr("width", "1%");
|
||||||
|
var nonNumericCheck = $('<input type="checkbox" />').appendTo(td02).change(function() {
|
||||||
self._selectNonNumeric = !self._selectNonNumeric;
|
self._selectNonNumeric = !self._selectNonNumeric;
|
||||||
self._updateRest();
|
self._updateRest();
|
||||||
});
|
});
|
||||||
@ -206,9 +226,9 @@ RangeFacet.prototype._renderOtherChoices = function() {
|
|||||||
nonNumericCheck[0].checked = true;
|
nonNumericCheck[0].checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var td01 = $(tr0.insertCell(1)).attr("colspan", "3");
|
var td03 = $(tr0.insertCell(3));
|
||||||
$('<span>').text("Non-numeric ").addClass("facet-choice-label").appendTo(td01);
|
$('<span>').text("Non-numeric ").addClass("facet-choice-label").appendTo(td03);
|
||||||
$('<span>').text(this._nonNumericCount).addClass("facet-choice-count").appendTo(td01);
|
$('<span>').text(this._nonNumericCount).addClass("facet-choice-count").appendTo(td03);
|
||||||
|
|
||||||
var td10 = $(tr1.insertCell(0)).attr("width", "1%");
|
var td10 = $(tr1.insertCell(0)).attr("width", "1%");
|
||||||
var blankCheck = $('<input type="checkbox" />').appendTo(td10).change(function() {
|
var blankCheck = $('<input type="checkbox" />').appendTo(td10).change(function() {
|
||||||
@ -278,6 +298,7 @@ RangeFacet.prototype.updateState = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._numericCount = data.numericCount;
|
||||||
this._nonNumericCount = data.nonNumericCount;
|
this._nonNumericCount = data.nonNumericCount;
|
||||||
this._blankCount = data.blankCount;
|
this._blankCount = data.blankCount;
|
||||||
this._errorCount = data.errorCount;
|
this._errorCount = data.errorCount;
|
||||||
|
Loading…
Reference in New Issue
Block a user