private void handleOutline( RasterStyling styling, AbstractRaster raster ) { // TODO cleanup outline stuff if ( styling.imageOutline != null ) { LOG.trace( "Rendering image outline..." ); Geometry geom = Raster2Feature.createPolygonGeometry( raster ); Java2DRenderer vectorRenderer = new Java2DRenderer( graphics ); @SuppressWarnings("unchecked") Pair<Styling, LinkedList<Geometry>> pair = (Pair) styling.imageOutline.evaluate( null, null ); Styling ls = pair.first; vectorRenderer.render( ls, geom ); LOG.trace( "Done rendering image outline." ); } }
/** * @param graphics */ public Java2DRenderer( Graphics2D graphics ) { this.graphics = graphics; res = 1; initRenderers( null ); }
renderGeometry = transformToWorldCrsAndClip( geom ); if ( renderGeometry == null ) { return; render( styling, g );
@Override public void render( Styling styling, Geometry geom ) { if ( geom instanceof GeometryReference<?> ) { render( styling, ( (GeometryReference<?>) geom ).getReferencedObject() ); } if ( styling instanceof PointStyling ) { render( (PointStyling) styling, geom ); } if ( styling instanceof LineStyling ) { render( (LineStyling) styling, geom ); } if ( styling instanceof PolygonStyling ) { render( (PolygonStyling) styling, geom ); } }
void applyGraphicFill( Graphic graphic, UOM uom ) { BufferedImage img; if ( graphic.image == null ) { int size = round( uomCalculator.considerUOM( graphic.size, uom ) ); img = new BufferedImage( size, size, TYPE_INT_ARGB ); Graphics2D g = img.createGraphics(); Java2DRenderer renderer = new Java2DRenderer( g ); renderMark( graphic.mark, graphic.size < 0 ? 6 : size, uom, renderer.rendererContext, 0, 0, graphic.rotation ); g.dispose(); } else { img = graphic.image; } graphics.setPaint( new TexturePaint( img, getGraphicBounds( graphic, 0, 0, uom ) ) ); }
@Override public void render( final TextStyling styling, final String text, final Geometry geom ) { if ( geom == null ) { LOG.debug( "Trying to render null geometry." ); return; } if ( text == null || text.length() == 0 ) { LOG.debug( "Trying to render null or zero length text." ); return; } final Geometry renderGeometry = renderer.transformToWorldCrsAndClip( geom ); if ( renderGeometry == null ) { return; } final Font font = convertFont( styling ); handleGeometryTypes( styling, text, font, renderGeometry ); }
renderGeometry = transformToWorldCrsAndClip( geom ); if ( renderGeometry == null ) { return; final MultiGeometry<?> mc = (MultiGeometry<?>) renderGeometry; for ( final Geometry g : mc ) { render( styling, g );
@Override public void render( Styling styling, Collection<Geometry> geoms ) { for ( Geometry geom : geoms ) { if ( geom instanceof GeometryReference<?> ) { render( styling, ( (GeometryReference<?>) geom ).getReferencedObject() ); } if ( styling instanceof PointStyling ) { render( (PointStyling) styling, geom ); } if ( styling instanceof LineStyling ) { render( (LineStyling) styling, geom ); } if ( styling instanceof PolygonStyling ) { render( (PolygonStyling) styling, geom ); } } }
List<LegendItem> prepareLegend( Style style, Graphics2D g, int width, int height ) { Pair<Integer, Integer> p = getLegendSize( style ); Envelope box = geofac.createEnvelope( 0, 0, p.first, p.second, null ); Java2DRenderer renderer = new Java2DRenderer( g, width, height, box ); Java2DTextRenderer textRenderer = new Java2DTextRenderer( renderer ); Java2DRasterRenderer rasterRenderer = new Java2DRasterRenderer( g, width, height, box ); return LegendItemBuilder.prepareLegend( style, renderer, textRenderer, rasterRenderer ); }
Java2DRenderer renderer = new Java2DRenderer( graphics, imageWidth, imageHeight, tileEnv ); LOG.debug( LogUtils.createDurationTimeString( "Creating graphics object", sT, false ) ); Iterator<Feature> it = frs.iterator(); evaluator ); for ( Triple<Styling, LinkedList<Geometry>, String> tr : evald ) { renderer.render( tr.first, tr.second );
@Override public void render( final PointStyling styling, final Geometry geom ) { if ( geom == null ) { LOG.debug( "Trying to render null geometry." ); return; } if ( geom instanceof Point ) { final Point pointInWorldCrs = (Point) rendererContext.geomHelper.transform( geom ); rendererContext.pointRenderer.render( styling, pointInWorldCrs.get0(), pointInWorldCrs.get1() ); return; } final Geometry clippedGeometry = transformToWorldCrsAndClip( geom ); if ( clippedGeometry == null ) { return; } if ( clippedGeometry instanceof Surface ) { rendererContext.polygonRenderer.render( styling, (Surface) clippedGeometry ); } else if ( clippedGeometry instanceof Curve ) { rendererContext.curveRenderer.render( styling, (Curve) clippedGeometry ); } else if ( clippedGeometry instanceof MultiGeometry<?> ) { final MultiGeometry<?> mc = (MultiGeometry<?>) clippedGeometry; for ( final Geometry g : mc ) { render( styling, g ); } } }
void render( PointStyling styling, Curve curve ) { if ( curve.getCurveSegments().size() != 1 || !( curve.getCurveSegments().get( 0 ) instanceof LineStringSegment ) ) { // TODO handle non-linear and multiple curve segments throw new IllegalArgumentException(); } LineStringSegment segment = ( (LineStringSegment) curve.getCurveSegments().get( 0 ) ); // coordinate representation is still subject to change... for ( Point point : segment.getControlPoints() ) { point.setCoordinateSystem( curve.getCoordinateSystem() ); renderer.render( styling, point ); } }
public Java2DRenderContext( RenderingInfo info, Graphics2D graphics, OutputStream outputStream ) { this.graphics = graphics; this.outputStream = outputStream; renderer = new Java2DRenderer( graphics, info.getWidth(), info.getHeight(), info.getEnvelope(), info.getPixelSize() * 1000 ); textRenderer = new Java2DTextRenderer( renderer ); labelRenderer = new Java2DLabelRenderer( renderer, textRenderer ); rasterRenderer = new Java2DRasterRenderer( graphics ); tileRenderer = new Java2DTileRenderer( graphics, info.getWidth(), info.getHeight(), info.getEnvelope() ); }
/** * @param graphics * @param width * @param height * @param bbox * @param pixelSize * in mm */ public Java2DRenderer( Graphics2D graphics, int width, int height, Envelope bbox, double pixelSize ) { this( graphics, width, height, bbox ); this.pixelSize = pixelSize; initRenderers( bbox ); }
void render( PointStyling styling, Surface surface ) { for ( SurfacePatch patch : surface.getPatches() ) { if ( patch instanceof PolygonPatch ) { PolygonPatch polygonPatch = (PolygonPatch) patch; for ( Curve curve : polygonPatch.getBoundaryRings() ) { curve.setCoordinateSystem( surface.getCoordinateSystem() ); renderer.render( styling, curve ); } } else { throw new IllegalArgumentException( "Cannot render non-planar surfaces." ); } } }
/** * @param graphics * @param width * @param height * @param bbox */ public Java2DRenderer( Graphics2D graphics, int width, int height, Envelope bbox ) { this.graphics = graphics; this.width = width; if ( bbox != null ) { Pair<Envelope, DoublePair> p = RenderHelper.getWorldToScreenTransform( worldToScreen, bbox, width, height ); double scalex = p.second.first; double scaley = p.second.second; bbox = p.first; res = calculateResolution( bbox, width ); LOG.debug( "For coordinate transformations, scaling by x = {} and y = {}", scalex, -scaley ); LOG.trace( "Final transformation was {}", worldToScreen ); } else { LOG.warn( "No envelope given, proceeding with a scale of 1." ); } initRenderers( bbox ); }
void render( LineStyling styling, Surface surface ) { for ( SurfacePatch patch : surface.getPatches() ) { if ( patch instanceof PolygonPatch ) { PolygonPatch polygonPatch = (PolygonPatch) patch; for ( Curve curve : polygonPatch.getBoundaryRings() ) { if ( curve.getCoordinateSystem() == null ) { curve.setCoordinateSystem( surface.getCoordinateSystem() ); } renderer.render( styling, curve ); } } else { throw new IllegalArgumentException( "Cannot render non-planar surfaces." ); } } }