Skip to content
Snippets Groups Projects
Commit 12970f40 authored by Georg Graßnick's avatar Georg Graßnick :thinking:
Browse files

Truncate legend values to two rational digits

parent 6f0c9d43
No related branches found
No related tags found
1 merge request!43Feat/scatterplot rasterizer 34
......@@ -12,6 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
......@@ -26,6 +27,7 @@ public class ScatterPlotRasterizer implements Rasterizer<ScatterPlot> {
private static final int X_AXIS_STEP_WIDTH = 3; // The distance between two tick marks on the x axis [cells]
private static final int Y_AXIS_STEP_WIDTH = 3; // The distance between two tick marks on the y axis [cells]
private static final int AXIS_TICK_SIZE = 1; // The length of the ticks on the axis [dots]
private static final Locale NUMBER_LOCALE = new Locale("en", "US");
private static final Logger LOG = LoggerFactory.getLogger(ScatterPlotRasterizer.class);
......@@ -173,7 +175,7 @@ public class ScatterPlotRasterizer implements Rasterizer<ScatterPlot> {
int tickPos = x * xAxisStepWidth;
double val = tickPos / xRatio;
LOG.debug("Adding x axis label {{},{}} for tick #{}", label, val, x);
xAxisLegendSymbols.put(String.valueOf(label), String.valueOf(val));
xAxisLegendSymbols.put(String.valueOf(label), formatDouble(val));
label++;
}
......@@ -189,7 +191,7 @@ public class ScatterPlotRasterizer implements Rasterizer<ScatterPlot> {
int tickPos = y * yAxisStepWidth;
double val = tickPos / yRatio;
LOG.debug("Adding y axis label {{},{}} for tick #{}", label, val, y);
yAxisLegendSymbols.put(String.valueOf(label), String.valueOf(val));
yAxisLegendSymbols.put(String.valueOf(label), formatDouble(val));
label++;
}
......@@ -220,4 +222,8 @@ public class ScatterPlotRasterizer implements Rasterizer<ScatterPlot> {
LOG.trace("Stretching {} to {}, cellSize: {}", dots, result, cellDots);
return result;
}
private static String formatDouble(final double d) {
return String.format(NUMBER_LOCALE, "%.2f", d);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment