void applyStroke( Stroke stroke, UOM uom, Shape object, double perpendicularOffset, PerpendicularOffsetType type ) { if ( stroke == null || isZero( stroke.width ) ) { graphics.setPaint( new Color( 0, 0, 0, 0 ) ); return; } if ( stroke.fill == null ) { graphics.setPaint( stroke.color ); } else { fillRenderer.applyGraphicFill( stroke.fill, uom ); } if ( stroke.stroke != null ) { if ( applyGraphicStroke( stroke, uom, object, perpendicularOffset, type ) ) { return; } } else { applyNormalStroke( stroke, uom, object, perpendicularOffset, type ); } graphics.draw( object ); }
/** * @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 ); } }
private void applyNormalStroke( Stroke stroke, UOM uom, Shape object, double perpendicularOffset, PerpendicularOffsetType type ) { int linecap = getLinecap( stroke ); float miterLimit = 10; int linejoin = getLinejoin( stroke ); float dashoffset = (float) uomCalculator.considerUOM( stroke.dashoffset, uom ); float[] dasharray = stroke.dasharray == null ? null : new float[stroke.dasharray.length]; if ( dasharray != null ) { for ( int i = 0; i < stroke.dasharray.length; ++i ) { dasharray[i] = (float) uomCalculator.considerUOM( stroke.dasharray[i], uom ); } } BasicStroke bs = new BasicStroke( (float) uomCalculator.considerUOM( stroke.width, uom ), linecap, linejoin, miterLimit, dasharray, dashoffset ); double poff = uomCalculator.considerUOM( perpendicularOffset, uom ); if ( !isZero( poff ) ) { graphics.setStroke( new OffsetStroke( poff, bs, type ) ); } else { graphics.setStroke( bs ); } }
RendererContext( double pixelSize, double res, Graphics2D graphics, Java2DRenderer renderer, Envelope bbox, int width, AffineTransform worldToScreen ) { this.graphics = graphics; if ( bbox != null ) { geomHelper = new GeometryHelper( bbox, width, worldToScreen ); clipper = new GeometryClipper( bbox, width ); } uomCalculator = new UomCalculator( pixelSize, res ); fillRenderer = new Java2DFillRenderer( uomCalculator, graphics ); strokeRenderer = new Java2DStrokeRenderer( graphics, uomCalculator, fillRenderer ); svgRenderer = new SvgRenderer(); polygonRenderer = new PolygonRenderer( geomHelper, fillRenderer, strokeRenderer, graphics, renderer ); curveRenderer = new CurveRenderer( renderer ); pointRenderer = new PointRenderer( renderer.worldToScreen, this ); }
void render( PolygonStyling styling, Surface surface ) { for ( SurfacePatch patch : surface.getPatches() ) { if ( patch instanceof PolygonPatch ) { LinkedList<Double> lines = new LinkedList<Double>(); PolygonPatch polygonPatch = (PolygonPatch) patch; // just appending the holes appears to work, the Java2D rendering mechanism can determine that they lie // inside and thus no substraction etc. is needed. This speeds up things SIGNIFICANTLY GeneralPath polygon = new GeneralPath( WIND_EVEN_ODD ); for ( Curve curve : polygonPatch.getBoundaryRings() ) { Double d = geomHelper.fromCurve( curve, true ); lines.add( d ); polygon.append( d, false ); } fillRenderer.applyFill( styling.fill, styling.uom ); graphics.fill( polygon ); for ( Double d : lines ) { strokeRenderer.applyStroke( styling.stroke, styling.uom, d, styling.perpendicularOffset, styling.perpendicularOffsetType ); } } else { throw new IllegalArgumentException( "Cannot render non-planar surfaces." ); } } }
rendererContext.strokeRenderer.applyStroke( styling.stroke, styling.uom, line, styling.perpendicularOffset, styling.perpendicularOffsetType ); } else if ( renderGeometry instanceof Surface ) {
applyStroke( stroke.stroke.mark.stroke, uom, transed, 0, null ); graphics.draw( transed );