/** * @param mark * @param size * @param rotation * @return a shape representing the mark */ public static Shape getShapeFromMark( Mark mark, double size, double rotation ) { return getShapeFromMark( mark, size, rotation, false, -1, -1 ); }
/** * @param url * @param size * @param rotation * @return a shape object from the given svg */ public static Shape getShapeFromSvg( String url, double size, double rotation ) { try { Shape shape = getShapeFromSvg( new URL( url ).openStream(), url ); if ( shape != null ) { AffineTransform at = getScaleInstance( size, size ); at.rotate( toRadians( rotation ) ); return at.createTransformedShape( shape ); } } catch ( IOException e ) { LOG.warn( "The svg image at '{}' could not be read: {}", url, e.getLocalizedMessage() ); LOG.debug( "Stack trace", e ); } return null; }
private boolean applyGraphicStroke( Stroke stroke, UOM uom, Shape object, double perpendicularOffset, PerpendicularOffsetType type ) { if ( stroke.stroke.image == null && stroke.stroke.imageURL != null ) { Shape shape = getShapeFromSvg( stroke.stroke.imageURL, uomCalculator.considerUOM( stroke.stroke.size, uom ), stroke.stroke.rotation ); graphics.setStroke( new ShapeStroke( shape, uomCalculator.considerUOM( stroke.strokeGap Shape shape = getShapeFromMark( stroke.stroke.mark, sz <= 0 ? 6 : uomCalculator.considerUOM( sz, uom ), stroke.stroke.rotation ); if ( sz <= 0 ) {
break; case STAR: { path.append( calculateStarPolygon( 5, 2, size ), false ); break;
if ( svg != null ) { try { res.mark.shape = getShapeFromSvg( new ByteArrayInputStream( svg.getBytes( "UTF-8" ) ), null ); } catch ( UnsupportedEncodingException e ) { LOG.trace( "Stack trace:", e );
/** * @param mark * @param size * @param uom * @param context * @param x * @param y * @param rotation */ public static void renderMark( Mark mark, int size, UOM uom, RendererContext context, double x, double y, double rotation ) { if ( size == 0 ) { LOG.debug( "Not rendering a symbol because the size is zero." ); return; } if ( mark.fill == null && mark.stroke == null ) { LOG.debug( "Not rendering a symbol because no fill/stroke is available/configured." ); return; } Shape shape = getShapeFromMark( mark, size - 1, rotation, true, x, y ); if ( mark.fill != null ) { context.fillRenderer.applyFill( mark.fill, uom ); context.graphics.fill( shape ); } if ( mark.stroke != null ) { context.strokeRenderer.applyStroke( mark.stroke, uom, shape, 0, null ); } }
base.shape = ShapeHelper.getShapeFromSvg( is, pair.second );