Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed handling of svgs in PolygonSymbolizer #1095

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ Occam Labs UG (haftungsbeschränkt)
----------------------------------------------------------------------------*/
package org.deegree.rendering.r2d;

import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
import static org.deegree.commons.utils.math.MathUtils.round;
import static org.deegree.rendering.r2d.RenderHelper.renderMark;
import org.deegree.style.styling.components.Fill;
import org.deegree.style.styling.components.Graphic;
import org.deegree.style.styling.components.UOM;
import org.deegree.style.utils.UomCalculator;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.TexturePaint;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;

import org.deegree.style.styling.components.Fill;
import org.deegree.style.styling.components.Graphic;
import org.deegree.style.styling.components.UOM;
import org.deegree.style.utils.UomCalculator;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
import static org.deegree.commons.utils.math.MathUtils.round;
import static org.deegree.rendering.r2d.RenderHelper.renderMark;


/**
* Responsible for applying fill stylings to a graphics 2d.
Expand All @@ -76,21 +77,25 @@ class Java2DFillRenderer {
}

void applyGraphicFill( Graphic graphic, UOM uom ) {
Rectangle2D.Double graphicBounds = getGraphicBounds( graphic, 0, 0, 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 );
if ( graphic.imageURL == null ) {
renderMark( graphic.mark, graphic.size < 0 ? 6 : size, uom, renderer.rendererContext, 0, 0,
graphic.rotation );
} else {
img = renderer.rendererContext.svgRenderer.prepareSvg( graphicBounds, graphic );
}
g.dispose();
} else {
img = graphic.image;
}

graphics.setPaint( new TexturePaint( img, getGraphicBounds( graphic, 0, 0, uom ) ) );
graphics.setPaint( new TexturePaint( img, graphicBounds ) );
}

void applyFill( Fill fill, UOM uom ) {
Expand Down