Skip to content

Commit

Permalink
AER-1008 Allow extending a ColorLabelsLegend (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtenbosch authored Sep 7, 2023
1 parent f134c85 commit 4735b65
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package nl.aerius.geo.domain.legend;

import java.util.Arrays;
import java.util.stream.Stream;

/**
* Data class for legend with a list of legend names with for each name
Expand Down Expand Up @@ -124,6 +125,18 @@ public int size() {
return labels.length;
}

/**
* Adds a single item to the legend
* @param label string label
* @param color string color
* @param iconSize optional iconSize
*/
public void addItem(final String label, final String color, final Integer iconSize) {
this.labels = Stream.concat(Arrays.stream(this.labels), Stream.of(label)).toArray(String[]::new);
this.colors = Stream.concat(Arrays.stream(this.colors), Stream.of(color)).toArray(String[]::new);
this.iconSizes = Stream.concat(Arrays.stream(this.iconSizes), Stream.of(iconSize)).toArray(Integer[]::new);
}

@Override
public String toString() {
return "ColorLabelsLegend[" +
Expand Down

0 comments on commit 4735b65

Please sign in to comment.