use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker 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();
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker in project opennms by OpenNMS.
the class MarkerCluster method getAllChildMarkers.
public final List<JSNodeMarker> getAllChildMarkers() {
final List<JSNodeMarker> markers = new ArrayList<>();
final JsArray<JSObject> markerObjects = getMarkerObjects();
if (markerObjects == null)
return markers;
for (int i = 0; i < markerObjects.length(); i++) {
final JSObject markerObject = markerObjects.get(i);
final JSNodeMarker marker = new JSNodeMarker(markerObject);
markers.add(marker);
}
return markers;
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker in project opennms by OpenNMS.
the class MarkerContainer method getDisabledMarkers.
public List<JSNodeMarker> getDisabledMarkers() {
final ArrayList<JSNodeMarker> markers = new ArrayList<>();
final List<JSNodeMarker> existingMarkers = getMarkers();
if (existingMarkers != null) {
for (final NodeMarker marker : existingMarkers) {
if (marker instanceof JSNodeMarker) {
final JSNodeMarker m = (JSNodeMarker) marker;
if (!m_filteredMarkers.contains(m)) {
markers.add(m);
}
}
}
}
return Collections.unmodifiableList(markers);
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker in project opennms by OpenNMS.
the class MarkerContainer method refresh.
public void refresh() {
logger.info("MarkerContainer.refresh()");
final List<JSNodeMarker> markers = new ArrayList<>();
final List<JSNodeMarker> existingMarkers = getAllMarkers();
if (existingMarkers != null) {
for (final JSNodeMarker marker : existingMarkers) {
if (m_filter.matches(marker)) {
markers.add(marker);
}
}
}
m_filteredMarkers = markers;
logger.info("MarkerContainer.refresh(): out of " + getMarkers().size() + " markers, " + markers.size() + " matched the search filter.");
m_eventManager.fireEvent(new FilteredMarkersUpdatedEvent());
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker in project opennms by OpenNMS.
the class NodeMapConnector method updateNodes.
private void updateNodes() {
final List<MapNode> nodes = getState().nodes;
LOG.info("NodeMapConnector.onStateChanged(): nodes list is now: " + nodes);
final List<JSNodeMarker> featureCollection = new ArrayList<>();
if (nodes.isEmpty()) {
getWidget().setMarkers(featureCollection);
return;
}
for (final MapNode node : nodes) {
final JSNodeMarker marker = new JSNodeMarker(new LatLng(node.getLatitude(), node.getLongitude()));
marker.putProperty(JSNodeMarker.Property.NODE_ID, node.getNodeId());
marker.putProperty(JSNodeMarker.Property.NODE_LABEL, node.getNodeLabel());
marker.putProperty(JSNodeMarker.Property.FOREIGN_SOURCE, node.getForeignSource());
marker.putProperty(JSNodeMarker.Property.FOREIGN_ID, node.getForeignId());
marker.putProperty(JSNodeMarker.Property.DESCRIPTION, node.getDescription());
marker.putProperty(JSNodeMarker.Property.MAINTCONTRACT, node.getMaintcontract());
marker.putProperty(JSNodeMarker.Property.IP_ADDRESS, node.getIpAddress());
marker.putProperty(JSNodeMarker.Property.SEVERITY, node.getSeverity());
marker.putProperty(JSNodeMarker.Property.SEVERITY_LABEL, node.getSeverityLabel());
final List<String> categories = node.getCategories();
if (categories != null) {
marker.setCategories(categories.toArray(new String[] {}));
}
// TODO: Icon handling should be moved to the Widget
if (m_icons.containsKey(marker.getSeverityLabel())) {
marker.setIcon(m_icons.get(marker.getSeverityLabel()));
} else {
marker.setIcon(m_icons.get("Normal"));
}
// TODO: This should be moved to the Widget
marker.bindPopup(NodeMarkerClusterCallback.getPopupTextForMarker(marker));
featureCollection.add(marker);
}
getWidget().setMarkers(featureCollection);
getConnection().getLoadingIndicator().hide();
}
Aggregations