final String transform = SVGUtil.makeMarginTransform(task.getWidth(), task.getHeight(), xsize, ysize, margin);
SVGUtil.setAtt(layer, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, transform);
// Styling policy
final StylingPolicy spol = style.getStylingPolicy();
final ClassStylingPolicy cspol;
if(spol instanceof ClassStylingPolicy) {
cspol = (ClassStylingPolicy) spol;
}
else {
cspol = null;
}
// TODO also use min style?
setupCSS(svgp, (cspol != null) ? cspol.getMaxStyle() : 0);
// Create histograms
final int off = (cspol != null) ? cspol.getMinStyle() : 0;
final int numc = (cspol != null) ? (cspol.getMaxStyle() - cspol.getMinStyle()) : 0;
DoubleMinMax minmax = new DoubleMinMax();
final double frac = 1. / relation.size(); // TODO: sampling?
final int cols = numc + 1;
AggregatingHistogram<double[], double[]> histogram = new AggregatingHistogram<double[], double[]>(bins, -.5, .5, new AggregatingHistogram.Adapter<double[], double[]>() {
@Override
public double[] aggregate(double[] existing, double[] data) {
for(int i = 0; i < existing.length; i++) {
existing[i] += data[i];
}
return existing;
}
@Override
public double[] make() {
return new double[cols];
}
});
if(cspol != null) {
for(int snum = 0; snum < numc; snum++) {
double[] inc = new double[cols];
inc[0] = frac;
inc[snum + 1] = frac;
for(Iterator<DBID> iter = cspol.iterateClass(snum + off); iter.hasNext();) {
DBID id = iter.next();
try {
double pos = proj.fastProjectDataToRenderSpace(relation.get(id)) / Projection.SCALE;
histogram.aggregate(pos, inc);
}