void init(MultiVertexGeometryImpl geom, double toleranceXY,
int rasterSizeBytes) {
// _ASSERT(CanUseAccelerator(geom));
m_width = Math.max((int) (Math.sqrt(rasterSizeBytes) * 2 + 0.5), 64);
m_scanLineSize = (m_width * 2 + 31) / 32; // 2 bits per pixel
m_geomEnv = new Envelope2D();
m_toleranceXY = toleranceXY;
// calculate bitmap size
int size = 0;
int width = m_width;
int scanLineSize = m_scanLineSize;
while (width >= 8) {
size += width * scanLineSize;
width /= 2;
scanLineSize = (width * 2 + 31) / 32;
}
// allocate the bitmap, that contains the base and the mip-levels
m_bitmap = new int[size];
for (int i = 0; i < size; i++)
m_bitmap[i] = 0;
m_rasterizer = new SimpleRasterizer();
ScanCallbackImpl callback = new ScanCallbackImpl(m_bitmap,
m_scanLineSize);
m_callback = callback;
m_rasterizer.setup(m_width, m_width, callback);
geom.queryEnvelope2D(m_geomEnv);
if (m_geomEnv.getWidth() > m_width * m_geomEnv.getHeight()
|| m_geomEnv.getHeight() > m_geomEnv.getWidth() * m_width) {
// the geometry is thin and the rasterizer is not needed.
}
m_geomEnv.inflate(toleranceXY, toleranceXY);
Envelope2D worldEnv = new Envelope2D();
Envelope2D pixEnv = Envelope2D
.construct(1, 1, m_width - 2, m_width - 2);
double minWidth = toleranceXY * pixEnv.getWidth(); // min width is such
// that the size of
// one pixel is
// equal to the
// tolerance
double minHeight = toleranceXY * pixEnv.getHeight();
worldEnv.setCoords(m_geomEnv.getCenter(),
Math.max(minWidth, m_geomEnv.getWidth()),
Math.max(minHeight, m_geomEnv.getHeight()));
m_stroke_half_widthX_pix = worldEnv.getWidth() / pixEnv.getWidth();
m_stroke_half_widthY_pix = worldEnv.getHeight() / pixEnv.getHeight();
// The stroke half width. Later it will be inflated to account for
// pixels size.
m_stroke_half_width = m_toleranceXY;