createShapePainter<T extends Renderinstruction> method

Future<ShapePainter<T>> createShapePainter<T extends Renderinstruction>(
  1. RenderInfo<T> renderInfo
)

Creates a shape painter for the given render information.

Returns cached painter if available, otherwise creates a new painter based on the rendering instruction type. Some painters (like captions) are context-dependent and not cached for reuse.

renderInfo Render information containing the instruction and context Returns appropriate shape painter for the instruction type

Implementation

Future<ShapePainter<T>> createShapePainter<T extends Renderinstruction>(RenderInfo<T> renderInfo) async {
  switch (renderInfo.renderInstruction.getType()) {
    case "area":
      ShapePainter<T> shapePainter = await ShapePainterArea.create(renderInfo.renderInstruction as RenderinstructionArea) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    case "caption":
      ShapePainter<T> shapePainter = await ShapePainterCaption.create(renderInfo.renderInstruction as RenderinstructionCaption) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    case "circle":
      ShapePainter<T> shapePainter = await ShapePainterCircle.create(renderInfo.renderInstruction as RenderinstructionCircle) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    // case "Hillshading":
    //   shapePainter = ShapePaintHillshading(shape as ShapeHillshading) as ShapePainter<T>;
    //   break;
    case "icon":
      ShapePainter<T> shapePainter = await ShapePainterIcon.create(renderInfo.renderInstruction as RenderinstructionIcon) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    case "linesymbol":
      ShapePainter<T> shapePainter = await ShapePainterLinesymbol.create(renderInfo.renderInstruction as RenderinstructionLinesymbol) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    case "polyline":
      // same as area but for open ways
      ShapePainter<T> shapePainter = await ShapePainterPolyline.create(renderInfo.renderInstruction as RenderinstructionPolyline) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    case "polylinetext":
      ShapePainter<T> shapePainter = await ShapePainterPolylineText.create(renderInfo.renderInstruction as RenderinstructionPolylineText) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    case "rect":
      ShapePainter<T> shapePainter = await ShapePainterRect.create(renderInfo.renderInstruction as RenderinstructionRect) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    case "symbol":
      ShapePainter<T> shapePainter = await ShapePainterSymbol.create(renderInfo.renderInstruction as RenderinstructionSymbol) as ShapePainter<T>;
      renderInfo.shapePainter = shapePainter;
      return shapePainter;
    default:
      throw Exception("cannot find ShapePaint for ${renderInfo.renderInstruction.getType()} of type ${renderInfo.runtimeType}");
  }
}