public BufferedImage createLegendImage(
      VPFSymbolAttributes attr, int width, int height, int margin) {
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
    Graphics2D g2 = image.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    switch (attr.getFeatureType()) {
      case POINT:
        this.drawPointLegend(attr, g2, width, height, margin);
        break;
      case LINE:
        this.drawLineLegend(attr, g2, width, height, margin);
        break;
      case AREA:
        this.drawAreaLegend(attr, g2, width, height, margin);
        break;
    }

    return image;
  }