MapBounds bounds = mapParams.getMapBounds();
bounds = CreateMapProcessor.adjustBoundsToScaleAndMapSize(
mapParams, mapParams.getRequestorDPI(), paintArea, bounds);
paintArea.setBounds(0, 0, (int) (paintArea.width * dpiRatio), (int) (paintArea.height * dpiRatio));
final DistanceUnit mapUnit = getUnit(bounds);
// to calculate the scale the requestor DPI is used , because the paint area is already adjusted
final Scale scale = bounds.getScaleDenominator(paintArea, mapParams.getRequestorDPI());
DistanceUnit scaleUnit = scalebarParams.getUnit();
if (scaleUnit == null) {
scaleUnit = mapUnit;
}
// adjust scalebar width and height to the DPI value