use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker in project opennms by OpenNMS.
the class NodeMapWidget method removeDisabledMarkers.
private void removeDisabledMarkers() {
// remove disabled markers
final List<JSNodeMarker> disabledMarkers = m_markerContainer.getDisabledMarkers();
LOG.info("NodeMapWidget.removeDisabledMarkers(): removing " + disabledMarkers.size() + " disabled markers from the map.");
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
final ListIterator<JSNodeMarker> m_markerIterator = disabledMarkers.listIterator();
@Override
public boolean execute() {
if (m_markerIterator.hasNext()) {
final JSNodeMarker marker = m_markerIterator.next();
marker.closePopup();
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.removeDisabledMarkers(): no coordinates found for marker! " + marker);
return true;
}
if (m_groupByState && StatesData.inUs(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getUsShape())) {
final int stateId = StatesData.getStateId(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getInstance());
m_stateClusterGroups[stateId].removeLayer(marker);
} else {
m_markerClusterGroup.removeLayer(marker);
}
return true;
}
LOG.info("NodeMapWidget.removeDisabledMarkers(): finished removing filtered markers (" + disabledMarkers.size() + " entries)");
return false;
}
});
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker in project opennms by OpenNMS.
the class NodeMapWidget method addNewMarkers.
private void addNewMarkers() {
// add new markers
LOG.info("NodeMapWidget.addNewMarkers(): adding " + m_markerContainer.size() + " markers to the map.");
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
final ListIterator<JSNodeMarker> m_markerIterator = m_markerContainer.listIterator();
@Override
public boolean execute() {
if (m_markerIterator.hasNext()) {
final JSNodeMarker marker = m_markerIterator.next();
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.addNewMarkers(): no coordinates found for marker! " + marker);
return true;
}
if (m_groupByState && StatesData.inUs(coordinates.latitude, coordinates.longitude, StatesData.getUsShape())) {
final int stateId = StatesData.getStateId(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getInstance());
if (!m_stateClusterGroups[stateId].hasLayer(marker)) {
m_stateClusterGroups[stateId].addLayer(marker);
}
} else {
if (!m_markerClusterGroup.hasLayer(marker)) {
m_markerClusterGroup.addLayer(marker);
}
}
return true;
}
LOG.info("NodeMapWidget.addNewMarkers(): finished adding visible markers (" + m_markerContainer.size() + " entries)");
return false;
}
});
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker in project opennms by OpenNMS.
the class NodeMapWidget method zoomToFit.
private void zoomToFit() {
// zoom on first run
if (m_firstUpdate) {
LOG.info("NodeMapWidget.zoomToFit(): first update, zooming to bounds.");
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (m_firstUpdate) {
final List<JSNodeMarker> allMarkers = m_markerContainer.getAllMarkers();
if (allMarkers.size() == 0) {
LOG.info("NodeMapWidget.zoomToFit(): no bounds yet, skipping.");
} else {
final LatLngBounds bounds = new LatLngBounds();
for (final NodeMarker marker : allMarkers) {
LOG.info("NodeMapWidget.zoomToFit(): processing marker: " + marker);
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.zoomToFit(): no coordinates found for marker! " + marker);
} else {
bounds.extend(JSNodeMarker.coordinatesToLatLng(coordinates));
}
}
LOG.info("NodeMapWidget.zoomToFit(): setting boundary to " + bounds.toBBoxString() + ".");
m_map.fitBounds(bounds);
m_firstUpdate = false;
}
}
}
});
}
}
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 NodeMarkerClusterCallback method run.
@Override
public final void run(final MarkerClusterEvent event) {
final StringBuilder sb = new StringBuilder();
final MarkerCluster cluster = event.getMarkerCluster();
final List<JSNodeMarker> markers = (List<JSNodeMarker>) cluster.getAllChildMarkers();
LOG.fine("Clicked, processing " + markers.size() + " markers.");
Collections.sort(markers, new NodeMarkerComparator());
if (markers.size() == 1) {
final JSNodeMarker marker = markers.get(0);
sb.append("<div class=\"node-marker-single\">");
sb.append(getPopupTextForMarker(marker));
sb.append("</div>");
} else {
final StringBuilder nodeListBuilder = new StringBuilder();
final StringBuilder nodeBuilder = new StringBuilder();
int unacked = 0;
final ListIterator<JSNodeMarker> iterator = markers.listIterator();
while (iterator.hasNext()) {
final JSNodeMarker marker = iterator.next();
unacked += marker.getUnackedCount();
nodeBuilder.append("<tr class=\"node-marker-" + marker.getSeverityLabel() + "\">");
nodeBuilder.append("<td class=\"node-marker-label\">");
nodeBuilder.append("<a class=\"node\" href=\"element/node.jsp?node=").append(marker.getNodeId()).append("\" " + TARGET_NONE + ">").append(marker.getNodeLabel()).append("</a>");
nodeBuilder.append("</td>");
nodeBuilder.append("<td class=\"node-marker-ipaddress\">");
nodeBuilder.append(marker.getIpAddress());
nodeBuilder.append("</td>");
nodeBuilder.append("<td class=\"node-marker-severity severity " + marker.getSeverityLabel() + "\">");
nodeBuilder.append("<a href=\"alarm/list.htm?sortby=id&acktype=unack&limit=20&filter=node%3D").append(marker.getNodeId()).append("\" " + TARGET_BLANK + ">").append(marker.getSeverityLabel()).append("</a>");
nodeBuilder.append("</td>");
nodeBuilder.append("</tr>");
nodeListBuilder.append(marker.getNodeId());
if (iterator.hasNext()) {
nodeListBuilder.append(",");
}
}
sb.append("<div class=\"node-marker-multiple\">");
sb.append("<h2># of nodes: ").append(markers.size()).append(" ");
sb.append("(").append(unacked).append(" Unacknowledged Alarms)");
sb.append("</h2>");
if (nodeListBuilder.length() > 0) {
sb.append("<p><a " + TARGET_BLANK + " href=\"topology?provider=Enhanced+Linkd&focus-vertices=" + nodeListBuilder.toString() + "\">View in Topology Map</a>");
}
sb.append("<table class=\"node-marker-list\">").append(nodeBuilder).append("</table>");
sb.append("</div>");
}
final PopupOptions options = new PopupOptions();
options.setMaxWidth(500);
options.setProperty("maxHeight", 250);
options.setProperty("className", "node-marker-popup");
final Popup popup = new Popup(options);
popup.setContent(sb.toString());
popup.setLatLng(cluster.getLatLng());
/*
final Element element = popup.getJSObject().cast();
DomEvent.addListener(new AbstractDomEventCallback("keydown", null) {
@Override protected void onEvent(final NativeEvent event) {
VConsole.log("marker cluster popup keydown event");
}
}, element);
*/
final Map map = new Map(cluster.getGroup().getMapObject());
LOG.fine("current zoom: " + map.getZoom() + ", max zoom: " + map.getMaxZoom());
if (map.getZoom() == map.getMaxZoom()) {
LOG.fine("at max zoom, skipping popup");
} else {
PopupImpl.openOn(popup.getJSObject(), cluster.getGroup().getMapObject());
}
}
Aggregations