Skip to content
Open
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 @@ -127,14 +127,7 @@ else if (isLine) {
paintLegendText(origin, opts, text, textRenderer);

// normalize symbol sizes
double maxSize = 0;
if (isPoint) {
for (Styling s : stylings) {
if (s instanceof PointStyling) {
maxSize = max(((PointStyling) s).graphic.size, maxSize);
}
}
}
double maxSize = calculateMaxSize(isPoint);

if (rule == null) {
for (Styling s : stylings) {
Expand All @@ -146,6 +139,21 @@ else if (isLine) {
paintRule(isPoint, maxSize, opts, geom);
}

private double calculateMaxSize(boolean isPoint) {
double maxSize = 0;
if (isPoint) {
for (Styling s : stylings) {
if (s instanceof PointStyling) {
maxSize = max(((PointStyling) s).graphic.size, maxSize);
}
}
}
if (maxSize > 0)
return maxSize;
// fallback to default size 6 to avoid infinite legend size if maxSize is 0
return 6;
}

private void paintRule(boolean isPoint, double maxSize, LegendOptions opts, Geometry geom) {
LinkedList<Symbolizer<?>> syms = new LinkedList<Symbolizer<?>>();
rule.evaluate(syms, null, null);
Expand All @@ -159,6 +167,10 @@ private void paintRule(boolean isPoint, double maxSize, LegendOptions opts, Geom
if (styling instanceof PointStyling && isPoint) {
PointStyling ps = ((PointStyling) styling).copy();
ps.uom = Metre;
// fallback to default size 6 to avoid infinite legend size if maxSize
// is 0
if (ps.graphic.size <= 0)
ps.graphic.size = 6;
ps.graphic.size = ps.graphic.size / maxSize * min(opts.baseWidth, opts.baseHeight);
styling = ps;
}
Expand Down