use of org.discotools.gwt.leaflet.client.types.DivIcon in project opennms by OpenNMS.
the class IconCreateCallback method createIcon.
// public JSObject createIcon(final MarkerCluster cluster) {
// final DivIconOptions options = new DivIconOptions();
// options.setHtml("<div><span>" + cluster.getChildCount() + "</span></div>");
// options.setIconSize(new Point(40, 40));
//
// int severity = 0;
// String severityLabel = "Normal";
// for (final JSNodeMarker marker : (List<JSNodeMarker>)cluster.getAllChildMarkers()) {
// final int nodeSeverity = marker.getSeverity();
// if (nodeSeverity > severity) {
// severity = nodeSeverity;
// severityLabel = marker.getSeverityLabel();
// }
// if (severity == 7) break;
// }
//
// options.setClassName("marker-cluster marker-cluster-" + severityLabel);
//
// return new DivIcon(options).getJSObject();
// }
public JSObject createIcon(final MarkerCluster cluster) {
final DivIconOptions options = new DivIconOptions();
options.setIconSize(new Point(40, 40));
int severity = 0;
int total = 0;
double[] dataArray = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
//class array corresponds to data array
String[] classArray = { "Indeterminate", "Cleared", "Normal", "Warning", "Minor", "Major", "Critical" };
String severityLabel = "Normal";
for (final JSNodeMarker marker : (List<JSNodeMarker>) cluster.getAllChildMarkers()) {
final int nodeSeverity = marker.getSeverity();
total++;
dataArray[nodeSeverity - 1] += 1.0;
if (nodeSeverity > severity) {
severity = nodeSeverity;
severityLabel = marker.getSeverityLabel();
}
}
String svg = getChartSvg(20.0, 20.0, 18.0, 12.0, dataArray, classArray, (double) total);
options.setHtml(svg + "<div><span>" + cluster.getChildCount() + "</span></div>");
options.setClassName("marker-cluster marker-cluster-" + severityLabel);
return new DivIcon(options).getJSObject();
}
Aggregations