diff --git a/main/src/com/google/refine/browsing/facets/ScatterplotFacet.java b/main/src/com/google/refine/browsing/facets/ScatterplotFacet.java index 1aa721ef0..83ea01159 100644 --- a/main/src/com/google/refine/browsing/facets/ScatterplotFacet.java +++ b/main/src/com/google/refine/browsing/facets/ScatterplotFacet.java @@ -104,7 +104,7 @@ public class ScatterplotFacet implements Facet { protected int rotation; @JsonIgnore - protected double l; + protected double l = 1.; @JsonProperty(DOT) protected double dot; diff --git a/main/src/com/google/refine/commands/browsing/GetScatterplotCommand.java b/main/src/com/google/refine/commands/browsing/GetScatterplotCommand.java index 73fbb2d08..465286464 100644 --- a/main/src/com/google/refine/commands/browsing/GetScatterplotCommand.java +++ b/main/src/com/google/refine/commands/browsing/GetScatterplotCommand.java @@ -140,6 +140,16 @@ public class GetScatterplotCommand extends Command { public void setDimY(String dim) { dim_y = dim.equals("lin") ? ScatterplotFacet.LIN : ScatterplotFacet.LOG; } + + // rotation can be set to "none" (a JSON string) in which case it should be ignored + @JsonProperty(ScatterplotFacet.ROTATION) + public void setRotation(Object rotation) { + try { + this.rotation = Integer.parseInt(rotation.toString()); + } catch(NumberFormatException e) { + ; + } + } } public void draw(OutputStream output, Project project, Engine engine, PlotterConfig o) throws IOException { diff --git a/main/tests/server/src/com/google/refine/browsing/facets/ScatterplotFacetTests.java b/main/tests/server/src/com/google/refine/browsing/facets/ScatterplotFacetTests.java index 2b2de40ba..b788ee041 100644 --- a/main/tests/server/src/com/google/refine/browsing/facets/ScatterplotFacetTests.java +++ b/main/tests/server/src/com/google/refine/browsing/facets/ScatterplotFacetTests.java @@ -26,6 +26,9 @@ ******************************************************************************/ package com.google.refine.browsing.facets; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + import java.io.IOException; import org.testng.annotations.Test; @@ -34,6 +37,7 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.google.refine.RefineTest; import com.google.refine.browsing.Engine; +import com.google.refine.browsing.RowFilter; import com.google.refine.browsing.facets.ScatterplotFacet; import com.google.refine.browsing.facets.ScatterplotFacet.ScatterplotFacetConfig; import com.google.refine.model.Cell; @@ -102,7 +106,11 @@ public class ScatterplotFacetTests extends RefineTest { ScatterplotFacet facet = config.apply(project); facet.computeChoices(project, engine.getAllFilteredRows()); - TestUtils.isSerializedTo(facet, facetJson); + + RowFilter filter = facet.getRowFilter(project); + assertTrue(filter.filterRow(project, 0, project.rows.get(0))); + assertFalse(filter.filterRow(project, 1, project.rows.get(1))); + assertTrue(filter.filterRow(project, 3, project.rows.get(3))); } } diff --git a/main/tests/server/src/com/google/refine/commands/browsing/ScatterplotDrawCommandTests.java b/main/tests/server/src/com/google/refine/commands/browsing/ScatterplotDrawCommandTests.java index c624e8620..b3b416d4a 100644 --- a/main/tests/server/src/com/google/refine/commands/browsing/ScatterplotDrawCommandTests.java +++ b/main/tests/server/src/com/google/refine/commands/browsing/ScatterplotDrawCommandTests.java @@ -58,6 +58,25 @@ public class ScatterplotDrawCommandTests { + "\"color\":\"ff6a00\"" + "}"; + + public static String configJsonWithNone = "{" + + "\"name\":\"b (x) vs. y (y)\"," + + "\"cx\":\"b\"," + + "\"cy\":\"y\"," + + "\"l\":150," + + "\"ex\":\"value\"," + + "\"ey\":\"value\"," + + "\"dot\":1.4," + + "\"dim_x\":\"lin\"," + + "\"dim_y\":\"lin\"," + + "\"r\":\"none\"," + + "\"type\":\"scatterplot\"," + + "\"from_x\":0," + + "\"to_x\":0," + + "\"from_y\":0," + + "\"to_y\":0," + + "\"color\":\"ff6a00\"}"; + @Test public void testParseConfig() throws JsonParseException, JsonMappingException, IOException { GetScatterplotCommand.PlotterConfig config = ParsingUtilities.mapper.readValue(configJson, GetScatterplotCommand.PlotterConfig.class); @@ -66,5 +85,11 @@ public class ScatterplotDrawCommandTests { Assert.assertEquals(ScatterplotFacet.LOG, config.dim_x); Assert.assertEquals(ScatterplotFacet.LIN, config.dim_y); } + + @Test + public void testParseConfigWithNone() throws JsonParseException, JsonMappingException, IOException { + GetScatterplotCommand.PlotterConfig config = ParsingUtilities.mapper.readValue(configJsonWithNone, GetScatterplotCommand.PlotterConfig.class); + Assert.assertEquals(0, config.rotation); + } }