public Specialized( double spacing, N floor, boolean fill, Aggregates<? extends N> aggregates) { super(spacing, floor, fill); Util.Stats<N> stats = Util.stats(aggregates, true, true, true); N bottom = floor == null ? (N) stats.min : floor; contourLevels = LocalUtils.steps(bottom, stats.max, spacing); }
@Override public ContourAggregates<N> process(Aggregates<? extends N> aggregates, Renderer rend) { Single<N>[] ts = LocalUtils.stepTransfers(contourLevels, fill); Transfer.Specialized<N, N> t = new Fan.Specialized<>(new MergeContours<N>(aggregates.defaultValue()), ts, aggregates); return (ContourAggregates<N>) rend.transfer(aggregates, t); }
/** * @param bottom Lowest value to be included * @param top Highest value to be included * @param spacing How far apart should the contours be placed? * @return List of the contour step values */ public static <N extends Number> List<N> steps(N bottom, N top, double spacing) { int stepCount = (int) Math.ceil((top.doubleValue() - bottom.doubleValue()) / spacing); ArrayList<N> steps = new ArrayList<>(stepCount); for (int i = 0; i < stepCount; i++) { steps.add(LocalUtils.addTo(bottom, (i * spacing))); } return steps; }
public Specialized(int n, boolean fill, Aggregates<? extends N> aggregates) { super(n, fill); Util.Stats<N> stats = Util.stats(aggregates, true, true, true); double spacing = (stats.max.doubleValue() - stats.min.doubleValue()) / n; contourLevels = LocalUtils.steps(stats.min, stats.max, spacing); }