use of org.discotools.gwt.leaflet.client.types.Point in project opennms by OpenNMS.
the class NodeMapConnector method initializeIcons.
private void initializeIcons() {
if (m_icons == null) {
m_icons = new HashMap<String, Icon>();
for (final String severity : new String[] { "Normal", "Warning", "Minor", "Major", "Critical" }) {
IconOptions options = new IconOptions();
options.setIconSize(new Point(25, 41));
options.setIconAnchor(new Point(12, 41));
options.setPopupAnchor(new Point(1, -34));
options.setShadowUrl(new Point(41, 41));
String basePath = GWT.getModuleBaseForStaticFiles() + "images/";
if (isRetina()) {
options.setIconUrl(basePath + severity + "@2x.png");
} else {
options.setIconUrl(basePath + severity + ".png");
}
Icon icon = new Icon(options);
m_icons.put(severity, icon);
}
}
}
use of org.discotools.gwt.leaflet.client.types.Point 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