@Override public void render(PdfContext context) { @SuppressWarnings("deprecation") float w = getSize().getWidth(); @SuppressWarnings("deprecation") float h = getSize().getHeight(); Rectangle iconRect = new Rectangle(0, 0, w, h); Color fillColor = Color.white; Color strokeColor = Color.black; float[] dashArray = null; if (styleInfo != null) { fillColor = context.getColor(styleInfo.getFillColor(), styleInfo.getFillOpacity(), Color.white); strokeColor = context.getColor(styleInfo.getStrokeColor(), styleInfo.getStrokeOpacity(), Color.black); dashArray = context.getDashArray(styleInfo.getDashArray()); } float baseWidth = iconRect.getWidth() / 10; // draw symbol switch (layerType) { case RASTER: Image img = context.getImage("/images/layer-raster.png"); context.drawImage(img, iconRect, null); break; case POINT: case MULTIPOINT: drawPoint(context, iconRect, fillColor, strokeColor); break; case LINESTRING: case MULTILINESTRING: drawLine(context, iconRect, strokeColor, dashArray); break; case POLYGON: case MULTIPOLYGON: context.fillRectangle(iconRect, fillColor); context.strokeRectangle(iconRect, strokeColor, baseWidth, dashArray); break; case GEOMETRY: drawPoint(context, iconRect, fillColor, strokeColor); drawLine(context, iconRect, strokeColor, dashArray); break; default: log.warn("Cannot draw unknown layerType " + layerType); } }
private void drawPoint( PdfContext context, Rectangle iconRect, Color fillColor, Color strokeColor) { float baseWidth = iconRect.getWidth() / 10; SymbolInfo symbol = styleInfo.getSymbol(); if (symbol.getImage() != null) { try { Image pointImage = Image.getInstance(symbol.getImage().getHref()); context.drawImage(pointImage, iconRect, iconRect); } catch (Exception ex) { // NOSONAR log.error("Not able to create image for POINT Symbol", ex); } } else if (symbol.getRect() != null) { context.fillRectangle(iconRect, fillColor); context.strokeRectangle(iconRect, strokeColor, baseWidth / 2); } else { context.fillEllipse(iconRect, fillColor); context.strokeEllipse(iconRect, strokeColor, baseWidth / 2); } }