Skip to content
Merged
Show file tree
Hide file tree
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 @@ -53,10 +53,7 @@ Occam Labs UG (haftungsbeschränkt)
import java.net.URL;
import java.util.List;

import javax.imageio.ImageIO;

import org.deegree.commons.utils.Pair;
import org.deegree.commons.utils.net.HttpUtils;
import org.deegree.geometry.Envelope;
import org.deegree.geometry.GeometryFactory;
import org.deegree.rendering.r2d.Java2DRasterRenderer;
Expand Down Expand Up @@ -92,6 +89,9 @@ List<LegendItem> prepareLegend(Style style, Graphics2D g, int width, int height)
}

Pair<Integer, Integer> getLegendSize(Style style) {
if (style.getLegendSize() != null) {
return style.getLegendSize();
}
URL url = style.getLegendURL();
File file = style.getLegendFile();
if (url == null) {
Expand All @@ -108,7 +108,7 @@ Pair<Integer, Integer> getLegendSize(Style style) {
try {
BufferedImage legend = get(IMAGE, url.toExternalForm(), null);
if (legend != null) {
return new Pair<Integer, Integer>(legend.getWidth(), legend.getHeight());
style.setLegendSize(new Pair<>(legend.getWidth(), legend.getHeight()));
}
else {
LOG.warn("Legend file {} could not be read, using dynamic legend.", url);
Expand All @@ -131,7 +131,8 @@ Pair<Integer, Integer> getLegendSize(Style style) {
res.second = 2 * opts.spacing + opts.baseWidth;
}

return res;
style.setLegendSize(res);
return style.getLegendSize();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public class Style implements Copyable<Style> {

private boolean prefersGetLegendGraphicUrl;

private Pair<Integer, Integer> legendSize;

/**
* @param rules
* @param labels
Expand Down Expand Up @@ -451,6 +453,14 @@ public URL getLegendURL() {
return legendUrl;
}

public Pair<Integer, Integer> getLegendSize() {
return legendSize;
}

public void setLegendSize(Pair<Integer, Integer> legendSize) {
this.legendSize = legendSize;
}

public void setPrefersGetLegendGraphicUrl(boolean prefers) {
this.prefersGetLegendGraphicUrl = prefers;
}
Expand Down