Scatterplot facet can now filter the rows.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@492 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
85d7ed6b89
commit
3b63e0b969
@ -39,11 +39,9 @@ public class Engine implements Jsonizable {
|
||||
public FilteredRows getFilteredRows(Facet except, boolean includeContextual) {
|
||||
ConjunctiveFilteredRows cfr = new ConjunctiveFilteredRows(includeContextual, _includeDependent);
|
||||
for (Facet facet : _facets) {
|
||||
System.out.println("facet: " + facet);
|
||||
if (facet != except) {
|
||||
RowFilter rowFilter = facet.getRowFilter();
|
||||
if (rowFilter != null) {
|
||||
System.out.println(" rowFilter: " + rowFilter);
|
||||
cfr.add(rowFilter);
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,6 @@ public class ScatterplotDrawingRowVisitor implements RowVisitor {
|
||||
double l;
|
||||
double dot;
|
||||
|
||||
double from_x;
|
||||
double from_y;
|
||||
double to_x;
|
||||
double to_y;
|
||||
|
||||
double min_x;
|
||||
double max_x;
|
||||
double min_y;
|
||||
@ -44,8 +39,7 @@ public class ScatterplotDrawingRowVisitor implements RowVisitor {
|
||||
|
||||
public ScatterplotDrawingRowVisitor(
|
||||
int col_x, int col_y, double min_x, double max_x, double min_y, double max_y,
|
||||
int size, int dim_x, int dim_y, int rotation, double dot, Color color,
|
||||
double from_x, double from_y, double to_x, double to_y)
|
||||
int size, int dim_x, int dim_y, int rotation, double dot, Color color)
|
||||
{
|
||||
this.col_x = col_x;
|
||||
this.col_y = col_y;
|
||||
@ -59,10 +53,6 @@ public class ScatterplotDrawingRowVisitor implements RowVisitor {
|
||||
this.dim_x = dim_x;
|
||||
this.dim_y = dim_y;
|
||||
this.rotation = rotation;
|
||||
this.from_x = from_x;
|
||||
this.from_y = from_y;
|
||||
this.to_x = to_x;
|
||||
this.to_y = to_y;
|
||||
|
||||
l = (double) size;
|
||||
|
||||
|
@ -166,6 +166,7 @@ public class ScatterplotFacet implements Facet {
|
||||
name = o.getString(NAME);
|
||||
|
||||
size = (o.has(SIZE)) ? o.getInt(SIZE) : 100;
|
||||
l = size;
|
||||
|
||||
dot = (o.has(DOT)) ? o.getInt(DOT) : 0.5d;
|
||||
|
||||
@ -184,6 +185,10 @@ public class ScatterplotFacet implements Facet {
|
||||
Column x_column = project.columnModel.getColumnByName(columnName_x);
|
||||
if (x_column != null) {
|
||||
columnIndex_x = x_column.getCellIndex();
|
||||
|
||||
NumericBinIndex index_x = ScatterplotFacet.getBinIndex(project, x_column, eval_x, expression_x);
|
||||
min_x = index_x.getMin();
|
||||
max_x = index_x.getMax();
|
||||
} else {
|
||||
errorMessage_x = "No column named " + columnName_x;
|
||||
}
|
||||
@ -210,6 +215,10 @@ public class ScatterplotFacet implements Facet {
|
||||
Column y_column = project.columnModel.getColumnByName(columnName_y);
|
||||
if (y_column != null) {
|
||||
columnIndex_y = y_column.getCellIndex();
|
||||
|
||||
NumericBinIndex index_y = ScatterplotFacet.getBinIndex(project, y_column, eval_y, expression_y);
|
||||
min_y = index_y.getMin();
|
||||
max_y = index_y.getMax();
|
||||
} else {
|
||||
errorMessage_y = "No column named " + columnName_y;
|
||||
}
|
||||
@ -239,8 +248,11 @@ public class ScatterplotFacet implements Facet {
|
||||
protected boolean checkValues(double x, double y) {
|
||||
Point2D.Double p = new Point2D.Double(x,y);
|
||||
p = translateCoordinates(p, dim_x, dim_y, rotation, l, min_x, max_x, min_y, max_y);
|
||||
|
||||
boolean value = p.x >= from_x && p.x < to_x && p.y >= from_y && p.y < to_y;
|
||||
System.out.println(p + " " + value);
|
||||
|
||||
//System.out.println(p + " " + value);
|
||||
|
||||
return value;
|
||||
};
|
||||
};
|
||||
@ -283,8 +295,7 @@ public class ScatterplotFacet implements Facet {
|
||||
if (index_x.isNumeric() && index_y.isNumeric()) {
|
||||
ScatterplotDrawingRowVisitor drawer = new ScatterplotDrawingRowVisitor(
|
||||
columnIndex_x, columnIndex_y, min_x, max_x, min_y, max_y,
|
||||
size, dim_x, dim_y, rotation, dot, color,
|
||||
from_x, from_y, to_x, to_y
|
||||
size, dim_x, dim_y, rotation, dot, color
|
||||
);
|
||||
filteredRows.accept(project, drawer);
|
||||
|
||||
|
@ -67,7 +67,11 @@ abstract public class DualExpressionsNumberComparisonRowFilter implements RowFil
|
||||
if (vx instanceof Number && vy instanceof Number) {
|
||||
double dx = ((Number) vx).doubleValue();
|
||||
double dy = ((Number) vy).doubleValue();
|
||||
return (!Double.isInfinite(dx) && !Double.isNaN(dx) && !Double.isInfinite(dy) && !Double.isNaN(dy) && checkValue(dx,dy));
|
||||
return (!Double.isInfinite(dx) &&
|
||||
!Double.isNaN(dx) &&
|
||||
!Double.isInfinite(dy) &&
|
||||
!Double.isNaN(dy) &&
|
||||
checkValues(dx,dy));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -63,11 +63,6 @@ public class GetScatterplotCommand extends Command {
|
||||
double min_y = 0;
|
||||
double max_x = 0;
|
||||
double max_y = 0;
|
||||
|
||||
double from_x = 0;
|
||||
double to_x = 0;
|
||||
double from_y = 0;
|
||||
double to_y = 0;
|
||||
|
||||
int columnIndex_x = 0;
|
||||
int columnIndex_y = 0;
|
||||
@ -105,11 +100,6 @@ public class GetScatterplotCommand extends Command {
|
||||
Gridworks.warn("error parsing expression", e);
|
||||
}
|
||||
|
||||
if (o.has(ScatterplotFacet.FROM_X) && o.has(ScatterplotFacet.TO_X)) {
|
||||
from_x = o.getDouble(ScatterplotFacet.FROM_X);
|
||||
to_x = o.getDouble(ScatterplotFacet.TO_X);
|
||||
}
|
||||
|
||||
String columnName_y = o.getString(ScatterplotFacet.Y_COLUMN_NAME);
|
||||
String expression_y = (o.has(ScatterplotFacet.Y_EXPRESSION)) ? o.getString(ScatterplotFacet.Y_EXPRESSION) : "value";
|
||||
|
||||
@ -128,11 +118,6 @@ public class GetScatterplotCommand extends Command {
|
||||
Gridworks.warn("error parsing expression", e);
|
||||
}
|
||||
|
||||
if (o.has(ScatterplotFacet.FROM_Y) && o.has(ScatterplotFacet.TO_Y)) {
|
||||
from_y = o.getDouble(ScatterplotFacet.FROM_Y);
|
||||
to_y = o.getDouble(ScatterplotFacet.TO_Y);
|
||||
}
|
||||
|
||||
NumericBinIndex index_x = null;
|
||||
NumericBinIndex index_y = null;
|
||||
|
||||
@ -157,8 +142,7 @@ public class GetScatterplotCommand extends Command {
|
||||
if (index_x != null && index_y != null && index_x.isNumeric() && index_y.isNumeric()) {
|
||||
ScatterplotDrawingRowVisitor drawer = new ScatterplotDrawingRowVisitor(
|
||||
columnIndex_x, columnIndex_y, min_x, max_x, min_y, max_y,
|
||||
size, dim_x, dim_y, rotation, dot, color,
|
||||
from_x, from_y, to_x, to_y
|
||||
size, dim_x, dim_y, rotation, dot, color
|
||||
);
|
||||
FilteredRows filteredRows = engine.getAllFilteredRows(false);
|
||||
filteredRows.accept(project, drawer);
|
||||
|
@ -34,7 +34,7 @@ ScatterplotFacet.prototype.getJSON = function() {
|
||||
};
|
||||
|
||||
ScatterplotFacet.prototype.hasSelection = function() {
|
||||
// TODO
|
||||
return ("from_x" in this._config);
|
||||
};
|
||||
|
||||
ScatterplotFacet.prototype._initializeUI = function() {
|
||||
@ -61,7 +61,7 @@ ScatterplotFacet.prototype._initializeUI = function() {
|
||||
|
||||
var params = {
|
||||
project: theProject.id,
|
||||
engine: JSON.stringify(ui.browsingEngine.getJSON()),
|
||||
engine: JSON.stringify(ui.browsingEngine.getJSON(false, this)),
|
||||
plotter: JSON.stringify(this._config)
|
||||
};
|
||||
var url = "/command/get-scatterplot?" + $.param(params);
|
||||
|
@ -98,14 +98,14 @@ BrowsingEngine.prototype._updateFacetOrder = function() {
|
||||
this._facets = newFacets;
|
||||
};
|
||||
|
||||
BrowsingEngine.prototype.getJSON = function(keepUnrestrictedFacets) {
|
||||
BrowsingEngine.prototype.getJSON = function(keepUnrestrictedFacets, except) {
|
||||
var a = {
|
||||
facets: [],
|
||||
includeDependent: this._elmts.includeDependentRowsCheck[0].checked
|
||||
};
|
||||
for (var i = 0; i < this._facets.length; i++) {
|
||||
var facet = this._facets[i];
|
||||
if (keepUnrestrictedFacets || facet.facet.hasSelection()) {
|
||||
if ((keepUnrestrictedFacets || facet.facet.hasSelection()) && (facet.facet != except)) {
|
||||
a.facets.push(this._facets[i].facet.getJSON());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user