Topojsons have all been formatted with jsonlint
Added topojson files for all supportted maps, optimised the countries topojson files to remove unused properties.
Added Javadocs for UiTopoMap
Refactored Topo Maps to use UiTopoMapFactory, UiTopoMap classes.
Change-Id: I976137baa7f62a81e48231e1612b967d39dc641d
Refactored Topo Maps to use UiTopoMapFactory, UiTopoMap classes.
Change-Id: I976137baa7f62a81e48231e1612b967d39dc641d
Added Copyright
Change-Id: Ie62171ba6ab08bbf955bc444cd2db41d0c30baaa
Added file path for topojson or svg
Change-Id: Ib1fc79672079ec4c6e2cd35bc39a28abeafca297
Line break to account for the soft limit
Change-Id: Ib2b57ceee139b20a73d7ad0110b37fc1b5326ed7
Added File Path to the Map Class
Change-Id: Ic6ae4ca507e58155bb106ad46be14e048dc3a95c
Added File Path to the Map Class
Change-Id: Ib2200b0bf315f9dccb581447ddb4b6f6669e34ff
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/MapSelectorMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/MapSelectorMessageHandler.java
index 20c7cf1..4fc5af66 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/MapSelectorMessageHandler.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/MapSelectorMessageHandler.java
@@ -18,10 +18,12 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.onosproject.ui.RequestHandler;
import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.UiExtensionService;
+import org.onosproject.ui.UiTopoMapFactory;
+import org.onosproject.ui.UiTopoMap;
import java.util.Collection;
import java.util.List;
@@ -38,21 +40,9 @@
private static final String MAPS = "maps";
private static final String MAP_ID = "id";
private static final String DESCRIPTION = "description";
+ private static final String FILE_PATH = "filePath";
private static final String SCALE = "scale";
- private static final List<Map> SUPPORTED_MAPS =
- ImmutableList.of(new Map("australia", "Australia", 1.0),
- new Map("ns_america", "North, Central and South America", 0.7),
- new Map("s_america", "South America", 0.9),
- new Map("usa", "United States", 1.0),
- new Map("bayarea", "Bay Area, California", 1.0),
- new Map("europe", "Europe", 2.5),
- new Map("italy", "Italy", 0.8),
- new Map("uk", "United Kingdom and Ireland", 0.6),
- new Map("japan", "Japan", 0.8),
- new Map("s_korea", "South Korea", 0.75),
- new Map("taiwan", "Taiwan", 0.7));
-
@Override
protected Collection<RequestHandler> createRequestHandlers() {
return ImmutableSet.of(
@@ -72,30 +62,30 @@
}
private ObjectNode mapsJson() {
+
ObjectNode payload = objectNode();
ArrayNode order = arrayNode();
ObjectNode maps = objectNode();
payload.set(ORDER, order);
payload.set(MAPS, maps);
- SUPPORTED_MAPS.forEach(m -> {
- maps.set(m.id, objectNode().put(MAP_ID, m.id)
- .put(DESCRIPTION, m.description)
- .put(SCALE, m.scale));
- order.add(m.id);
+
+ UiExtensionService service = get(UiExtensionService.class);
+ service.getExtensions().forEach(ext -> {
+ UiTopoMapFactory mapFactory = ext.topoMapFactory();
+
+ if (mapFactory != null) {
+ List<UiTopoMap> topoMaps = mapFactory.newMaps();
+
+ topoMaps.forEach(m -> {
+ maps.set(m.getId(), objectNode().put(MAP_ID, m.getId())
+ .put(DESCRIPTION, m.getDescription())
+ .put(FILE_PATH, m.getFilePath())
+ .put(SCALE, m.getScale()));
+ order.add(m.getId());
+ });
+ }
});
+
return payload;
}
-
- private static final class Map {
- private final String id;
- private final String description;
- private final double scale;
-
- private Map(String id, String description, double scale) {
- this.id = id;
- this.description = description;
- this.scale = scale;
- }
- }
-
}
\ No newline at end of file
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
index 3d82dc5..400a2cd 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
@@ -52,8 +52,10 @@
import org.onosproject.ui.UiMessageHandlerFactory;
import org.onosproject.ui.UiPreferencesService;
import org.onosproject.ui.UiTopoOverlayFactory;
+import org.onosproject.ui.UiTopoMapFactory;
import org.onosproject.ui.UiView;
import org.onosproject.ui.UiViewHidden;
+import org.onosproject.ui.UiTopoMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -165,9 +167,29 @@
new TrafficOverlay()
);
+ UiTopoMapFactory topoMapFactory =
+ () -> ImmutableList.of(
+ new UiTopoMap("australia", "Australia", "*australia", 1.0),
+ new UiTopoMap("americas", "North, Central and South America", "*americas", 0.7),
+ new UiTopoMap("n_america", "North America", "*n_america", 0.9),
+ new UiTopoMap("s_america", "South America", "*s_america", 0.9),
+ new UiTopoMap("usa", "United States", "*continental_us", 1.0),
+ new UiTopoMap("bayareaGEO", "Bay Area, California", "*bayarea", 1.0),
+ new UiTopoMap("europe", "Europe", "*europe", 2.5),
+ new UiTopoMap("italy", "Italy", "*italy", 0.8),
+ new UiTopoMap("uk", "United Kingdom and Ireland", "*uk", 0.6),
+ new UiTopoMap("japan", "Japan", "*japan", 0.8),
+ new UiTopoMap("s_korea", "South Korea", "*s_korea", 0.75),
+ new UiTopoMap("taiwan", "Taiwan", "*taiwan", 0.7),
+ new UiTopoMap("africa", "Africa", "*africa", 0.7),
+ new UiTopoMap("oceania", "Oceania", "*oceania", 0.7),
+ new UiTopoMap("asia", "Asia", "*asia", 0.7)
+ );
+
return new UiExtension.Builder(CL, coreViews)
.messageHandlerFactory(messageHandlerFactory)
.topoOverlayFactory(topoOverlayFactory)
+ .topoMapFactory(topoMapFactory)
.resourcePath(CORE)
.build();
}