@Override
  public void accept(PainterVisitor visitor, Object group, Bbox bounds, boolean recursive) {
    map.getVectorContext().drawGroup(group, this);
    adjustScale(map.getMapModel().getMapView().getCurrentScale());
    // Draw a dummy at 0,0 so that Internet Explorer knows where coordinate 0,0 is. If this is not
    // drawn, the text
    // will disappear, because the parent group will have coordinate 0,0 at the upper left corner of
    // the union of
    // all the rectangles that are drawn here.
    map.getVectorContext()
        .drawRectangle(this, dummy.getId(), dummy.getBounds(), (ShapeStyle) dummy.getStyle());

    map.getVectorContext()
        .drawRectangle(this, backGround.getId(), backGround.getBounds(), backGround.getStyle());
    map.getVectorContext()
        .drawRectangle(this, bottomLine.getId(), bottomLine.getBounds(), bottomLine.getStyle());
    map.getVectorContext()
        .drawRectangle(this, leftMarker.getId(), leftMarker.getBounds(), leftMarker.getStyle());
    map.getVectorContext()
        .drawRectangle(this, rightMarker.getId(), rightMarker.getBounds(), rightMarker.getStyle());
    map.getVectorContext()
        .drawText(
            this,
            distance.getId(),
            distance.getContent(),
            distance.getPosition(),
            distance.getStyle());
  }
 /**
  * Set map size.
  *
  * @param mapWidth map width
  * @param mapHeight map height
  */
 public void setMapSize(int mapWidth, int mapHeight) {
   super.setMapSize(mapWidth, mapHeight);
   if (null == unitType) {
     throw new IllegalStateException("Please initialize scale bar before using");
   }
   backGround.getBounds().setX(getUpperLeftCorner().getX());
   backGround.getBounds().setY(getUpperLeftCorner().getY());
   bottomLine.getBounds().setX(getUpperLeftCorner().getX() + HORIZONTAL_PADDING);
   bottomLine.getBounds().setY(getUpperLeftCorner().getY() + VERTICAL_PADDING + MARKER_HEIGHT);
   leftMarker.getBounds().setX(getUpperLeftCorner().getX() + HORIZONTAL_PADDING);
   leftMarker.getBounds().setY(getUpperLeftCorner().getY() + VERTICAL_PADDING);
   rightMarker.getBounds().setY(getUpperLeftCorner().getY() + VERTICAL_PADDING);
   distance.setPosition(
       new Coordinate(
           getUpperLeftCorner().getX() + HORIZONTAL_PADDING + 6,
           getUpperLeftCorner().getY() + VERTICAL_PADDING));
 }
 private void updatePaintables() {
   distance.setContent(formatUnits(widthInUnits));
   backGround.getBounds().setWidth(widthInPixels + 2 * HORIZONTAL_PADDING);
   rightMarker.getBounds().setX(leftMarker.getBounds().getX() + widthInPixels - 1);
   bottomLine.getBounds().setWidth(widthInPixels);
 }