ONOS-3182 Starting on path visualization app.

Change-Id: Id9b074afb22599473b1849acc380fa189061e8bb
diff --git a/apps/pathpainter/pom.xml b/apps/pathpainter/pom.xml
new file mode 100644
index 0000000..c14294c
--- /dev/null
+++ b/apps/pathpainter/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2014 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-apps</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-app-pp</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>Path visualization application</description>
+
+    <properties>
+        <onos.app.name>org.onosproject.pathpainter</onos.app.name>
+    </properties>
+
+</project>
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathLink.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathLink.java
new file mode 100644
index 0000000..5724170
--- /dev/null
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathLink.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pathpainter;
+
+import org.onosproject.net.Link;
+import org.onosproject.net.LinkKey;
+import org.onosproject.ui.topo.BiLink;
+import org.onosproject.ui.topo.LinkHighlight;
+import org.onosproject.ui.topo.LinkHighlight.Flavor;
+
+import java.util.Set;
+
+/**
+ * Bi-directional link capable of different hilights.
+ */
+public class PathLink extends BiLink {
+
+    private boolean primary = false;
+    private boolean secondary = false;
+
+    public PathLink(LinkKey key, Link link) {
+        super(key, link);
+    }
+
+    public void computeHilight(Set<Link> selectedLinks, Set<Link> allLinks) {
+        primary = selectedLinks.contains(this.one()) ||
+                (two() != null && selectedLinks.contains(two()));
+        secondary = allLinks.contains(this.one()) ||
+                (two() != null && allLinks.contains(two()));
+    }
+
+    @Override
+    public LinkHighlight highlight(Enum<?> anEnum) {
+        Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT :
+                (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT);
+        return new LinkHighlight(this.linkId(), flavor);
+    }
+}
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathLinkMap.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathLinkMap.java
new file mode 100644
index 0000000..9f2ea21
--- /dev/null
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathLinkMap.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pathpainter;
+
+import org.onosproject.net.Link;
+import org.onosproject.net.LinkKey;
+import org.onosproject.ui.topo.BiLinkMap;
+
+/**
+ * Our concrete link map.
+ */
+public class PathLinkMap extends BiLinkMap<PathLink> {
+    @Override
+    protected PathLink create(LinkKey linkKey, Link link) {
+        return new PathLink(linkKey, link);
+    }
+}
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainter.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainter.java
new file mode 100644
index 0000000..07ce3fe
--- /dev/null
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainter.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pathpainter;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.ui.UiExtension;
+import org.onosproject.ui.UiExtensionService;
+import org.onosproject.ui.UiMessageHandlerFactory;
+import org.onosproject.ui.UiTopoOverlayFactory;
+import org.onosproject.ui.UiView;
+import org.onosproject.ui.UiViewHidden;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Skeletal ONOS UI Topology-Overlay application component.
+ */
+@Component(immediate = true)
+public class PathPainter {
+
+    private static final ClassLoader CL = PathPainter.class.getClassLoader();
+    private static final String VIEW_ID = "ppTopov";
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected UiExtensionService uiExtensionService;
+
+    // List of application views
+    private final List<UiView> uiViews = ImmutableList.of(
+            new UiViewHidden(VIEW_ID)
+    );
+
+    // Factory for UI message handlers
+    private final UiMessageHandlerFactory messageHandlerFactory =
+            () -> ImmutableList.of(
+                    new PathPainterTopovMessageHandler()
+            );
+
+    // Factory for UI topology overlays
+    private final UiTopoOverlayFactory topoOverlayFactory =
+            () -> ImmutableList.of(
+                    new PathPainterTopovOverlay()
+            );
+
+    // Application UI extension
+    protected UiExtension extension =
+            new UiExtension.Builder(CL, uiViews)
+                    .resourcePath(VIEW_ID)
+                    .messageHandlerFactory(messageHandlerFactory)
+                    .topoOverlayFactory(topoOverlayFactory)
+                    .build();
+
+    @Activate
+    protected void activate() {
+        uiExtensionService.register(extension);
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        uiExtensionService.unregister(extension);
+        log.info("Stopped");
+    }
+
+}
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
new file mode 100644
index 0000000..c7eba1e
--- /dev/null
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pathpainter;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.onlab.osgi.ServiceDirectory;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.ElementId;
+import org.onosproject.net.HostId;
+import org.onosproject.net.Link;
+import org.onosproject.net.Path;
+import org.onosproject.net.topology.PathService;
+import org.onosproject.ui.RequestHandler;
+import org.onosproject.ui.UiConnection;
+import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.topo.Highlights;
+import org.onosproject.ui.topo.TopoJson;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Skeletal ONOS UI Topology-Overlay message handler.
+ */
+public class PathPainterTopovMessageHandler extends UiMessageHandler {
+
+    private static final String PAINTER_SET_SRC = "ppTopovSetSrc";
+    private static final String PAINTER_SET_DST = "ppTopovSetDst";
+    private static final String PAINTER_SWAP_SRC_DST = "ppTopovSwapSrcDst";
+    private static final String PAINTER_SET_MODE = "ppTopovSetMode";
+
+    private static final String PAINTER_NEXT_PATH = "ppTopovNextPath";
+    private static final String PAINTER_PREV_PATH = "ppTopovPrevPath";
+
+    private static final String ID = "id";
+    private static final String MODE = "mode";
+
+    private Set<Link> allPathLinks;
+
+    private enum Mode {
+        SHORTEST, DISJOINT, SRLG
+    }
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private PathService pathService;
+
+    private Mode currentMode = Mode.SHORTEST;
+    private ElementId src, dst;
+    private Mode mode = Mode.SHORTEST;
+    private List<Path> paths;
+    private int pathIndex;
+
+
+    // ===============-=-=-=-=-=-======================-=-=-=-=-=-=-================================
+
+
+    @Override
+    public void init(UiConnection connection, ServiceDirectory directory) {
+        super.init(connection, directory);
+        pathService = directory.get(PathService.class);
+    }
+
+    @Override
+    protected Collection<RequestHandler> createRequestHandlers() {
+        return ImmutableSet.of(
+                new SetSrcHandler(),
+                new SetDstHandler(),
+                new NextPathHandler(),
+                new PrevPathHandler()
+        );
+    }
+
+    // === -------------------------
+    // === Handler classes
+
+    private final class SetSrcHandler extends RequestHandler {
+        public SetSrcHandler() {
+            super(PAINTER_SET_SRC);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String id = string(payload, ID);
+            src = elementId(id);
+            if (src.equals(dst)) {
+                dst = null;
+            }
+            findAndSendPaths();
+        }
+    }
+
+    private final class SetDstHandler extends RequestHandler {
+        public SetDstHandler() {
+            super(PAINTER_SET_DST);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String id = string(payload, ID);
+            dst = elementId(id);
+            if (src.equals(dst)) {
+                src = null;
+            }
+            findAndSendPaths();
+        }
+    }
+
+    private final class NextPathHandler extends RequestHandler {
+        public NextPathHandler() {
+            super(PAINTER_NEXT_PATH);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            pathIndex = (pathIndex >= paths.size() - 1 ? 0 : pathIndex + 1);
+            hilightAndSendPaths();
+        }
+    }
+
+    private final class PrevPathHandler extends RequestHandler {
+        public PrevPathHandler() {
+            super(PAINTER_PREV_PATH);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            pathIndex = (pathIndex <= 0 ? paths.size() - 1 : pathIndex - 1);
+            hilightAndSendPaths();
+        }
+    }
+
+    // === ------------
+
+    private ElementId elementId(String id) {
+        try {
+            return DeviceId.deviceId(id);
+        } catch (IllegalArgumentException e) {
+            return HostId.hostId(id);
+        }
+    }
+
+    private void findAndSendPaths() {
+        log.info("src={}; dst={}; mode={}", src, dst, mode);
+        if (src != null && dst != null) {
+            paths = ImmutableList.copyOf(pathService.getPaths(src, dst));
+            pathIndex = 0;
+
+            ImmutableSet.Builder<Link> builder = ImmutableSet.builder();
+            paths.forEach(path -> path.links().forEach(builder::add));
+            allPathLinks = builder.build();
+        } else {
+            paths = ImmutableList.of();
+            allPathLinks = ImmutableSet.of();
+        }
+        hilightAndSendPaths();
+    }
+
+    private void hilightAndSendPaths() {
+        PathLinkMap linkMap = new PathLinkMap();
+        allPathLinks.forEach(linkMap::add);
+
+        // Prepare two working sets; one containing selected path links and
+        // the other containing all paths links.
+        Set<Link> selectedPathLinks = paths.isEmpty() ?
+                ImmutableSet.of() : ImmutableSet.copyOf(paths.get(pathIndex).links());
+
+        Highlights highlights = new Highlights();
+        for (PathLink plink : linkMap.biLinks()) {
+            plink.computeHilight(selectedPathLinks, allPathLinks);
+            highlights.add(plink.highlight(null));
+        }
+
+        sendMessage(TopoJson.highlightsMessage(highlights));
+    }
+
+    /*
+    private void addDeviceBadge(Highlights h, DeviceId devId, int n) {
+        DeviceHighlight dh = new DeviceHighlight(devId.toString());
+        dh.setBadge(createBadge(n));
+        h.add(dh);
+    }
+
+    private NodeBadge createBadge(int n) {
+        Status status = n > 3 ? Status.ERROR : Status.WARN;
+        String noun = n > 3 ? "(critical)" : "(problematic)";
+        String msg = "Egress links: " + n + " " + noun;
+        return NodeBadge.number(status, n, msg);
+    }
+   */
+
+}
\ No newline at end of file
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovOverlay.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovOverlay.java
new file mode 100644
index 0000000..47ae0d3
--- /dev/null
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovOverlay.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.pathpainter;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.HostId;
+import org.onosproject.ui.UiTopoOverlay;
+import org.onosproject.ui.topo.ButtonId;
+import org.onosproject.ui.topo.PropertyPanel;
+
+/**
+ * Our topology overlay.
+ */
+public class PathPainterTopovOverlay extends UiTopoOverlay {
+
+    // NOTE: this must match the ID defined in ppTopovOverlay.js
+    private static final String OVERLAY_ID = "pp-overlay";
+
+    private static final ButtonId SRC_BUTTON = new ButtonId("src");
+    private static final ButtonId DST_BUTTON = new ButtonId("dst");
+
+    public PathPainterTopovOverlay() {
+        super(OVERLAY_ID);
+    }
+
+    @Override
+    public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
+        pp.addButton(SRC_BUTTON).addButton(DST_BUTTON);
+    }
+
+    @Override
+    public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
+        pp.addButton(SRC_BUTTON).addButton(DST_BUTTON);
+    }
+
+
+}
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/package-info.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/package-info.java
new file mode 100644
index 0000000..e625933
--- /dev/null
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Path visualization GUI topology view overlay.
+ */
+package org.onosproject.pathpainter;
\ No newline at end of file
diff --git a/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.css b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.css
new file mode 100644
index 0000000..cbf460f
--- /dev/null
+++ b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.css
@@ -0,0 +1,2 @@
+/* css for sample app topology overlay  */
+
diff --git a/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.html b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.html
new file mode 100644
index 0000000..9141975
--- /dev/null
+++ b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.html
@@ -0,0 +1,4 @@
+<!-- partial HTML -->
+<div id="ov-pp-topov">
+    <p>This is a hidden view .. just a placeholder to house the javascript</p>
+</div>
diff --git a/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.js b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.js
new file mode 100644
index 0000000..523142e
--- /dev/null
+++ b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopov.js
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ Sample Demo module. This contains the "business logic" for the topology
+ overlay that we are implementing.
+ */
+
+(function () {
+    'use strict';
+
+    // injected refs
+    var $log, fs, flash, wss;
+
+    // constants
+    var srcMessage = 'ppTopovSetSrc',
+        dstMessage = 'ppTopovSetDst',
+        modeMessage = 'ppTopovSetMode',
+        nextPathMessage = 'ppTopovNextPath',
+        prevPathMessage = 'ppTopovPrevPath';
+
+    // internal state
+    var currentMode = null;
+
+
+    // === ---------------------------
+    // === Helper functions
+
+
+    // === ---------------------------
+    // === Main API functions
+
+
+    function setSrc(node) {
+        wss.sendEvent(srcMessage, {
+            id: node.id
+        });
+        flash.flash('Source node: ' + node.id);
+    }
+
+    function setDst(node) {
+        wss.sendEvent(dstMessage, {
+            id: node.id
+        });
+        flash.flash('Destination node: ' + node.id);
+    }
+
+    function nextPath(node) {
+        wss.sendEvent(nextPathMessage);
+    }
+
+    function prevPath(node) {
+        wss.sendEvent(prevPathMessage);
+    }
+
+
+    function setMode(mode) {
+        if (currentMode === mode) {
+            $log.debug('(in mode', mode, 'already)');
+        } else {
+            currentMode = mode;
+            wss.sendEvent(modeMessage, {
+                mode: mode
+            });
+            flash.flash('Path mode: ' + mode);
+        }
+    }
+
+    // === ---------------------------
+    // === Module Factory Definition
+
+    angular.module('ovPpTopov', [])
+        .factory('PathPainterTopovService',
+        ['$log', 'FnService', 'FlashService', 'WebSocketService',
+
+        function (_$log_, _fs_, _flash_, _wss_) {
+            $log = _$log_;
+            fs = _fs_;
+            flash = _flash_;
+            wss = _wss_;
+
+            return {
+                setSrc: setSrc,
+                setDst: setDst,
+                setMode: setMode,
+                nextPath: nextPath,
+                prevPath: prevPath
+            };
+        }]);
+}());
diff --git a/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopovOverlay.js b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopovOverlay.js
new file mode 100644
index 0000000..52f4f68
--- /dev/null
+++ b/apps/pathpainter/src/main/resources/app/view/ppTopov/ppTopovOverlay.js
@@ -0,0 +1,139 @@
+// path painter topology overlay - client side
+//
+// This is the glue that binds our business logic (in ppTopovDemo.js)
+// to the overlay framework.
+
+(function () {
+    'use strict';
+
+    // injected refs
+    var $log, tov, pps;
+
+    // internal state should be kept in the service module (not here)
+    var selection;
+
+    // our overlay definition
+    var overlay = {
+        // NOTE: this must match the ID defined in AppUiTopovOverlay
+        overlayId: 'pp-overlay',
+        // FIXME: new icon for the overlay
+        glyphId: '*star4',
+        tooltip: 'Path Painter Topo Overlay',
+
+        // These glyphs get installed using the overlayId as a prefix.
+        // e.g. 'star4' is installed as 'meowster-overlay-star4'
+        // They can be referenced (from this overlay) as '*star4'
+        // That is, the '*' prefix stands in for 'meowster-overlay-'
+        glyphs: {
+            star4: {
+                vb: '0 0 8 8',
+                d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z'
+            },
+            banner: {
+                vb: '0 0 6 6',
+                d: 'M1,1v4l2,-2l2,2v-4z'
+            }
+        },
+
+        activate: function () {
+            $log.debug("Path painter topology overlay ACTIVATED");
+        },
+        deactivate: function () {
+            $log.debug("Path painter topology overlay DEACTIVATED");
+        },
+
+        // detail panel button definitions
+        // FIXME: new icons for src/dst
+        buttons: {
+            src: {
+                gid: 'triangleUp',
+                tt: 'Set source node',
+                cb: function (data) {
+                    $log.debug('Set src action invoked with data:', data);
+                    pps.setSrc(selection);
+                }
+            },
+            dst: {
+                gid: 'triangleDown',
+                tt: 'Set destination node',
+                cb: function (data) {
+                    $log.debug('Set dst action invoked with data:', data);
+                    pps.setDst(selection);
+                }
+            }
+        },
+
+        // Key bindings for traffic overlay buttons
+        // NOTE: fully qual. button ID is derived from overlay-id and key-name
+        // FIXME: use into [ and ] instead of 1 and 2
+        // FIXME: new icons for src/dst
+        // TODO: add keys for shortest paths & disjoint paths modes
+        // TODO: add key for src/dst swap; with its own icon
+        keyBindings: {
+            1: {
+                cb: function () { pps.setSrc(selection); },
+                tt: 'Set source node',
+                gid: 'triangleUp'
+            },
+            2: {
+                cb: function () { pps.setDst(selection); },
+                tt: 'Set destination node',
+                gid: 'triangleDown'
+            },
+            leftArrow: {
+                cb: function () { pps.prevPath(); },
+                tt: 'Highlight previous path',
+                gid: 'prevIntent'
+            },
+            rightArrow: {
+                cb: function () { pps.nextPath(); },
+                tt: 'Highlight next path',
+                gid: 'nextIntent'
+            },
+
+            _keyOrder: [
+                '1', '2', 'leftArrow', 'rightArrow'
+            ]
+        },
+
+        hooks: {
+            // hook for handling escape key
+            // Must return true to consume ESC, false otherwise.
+            escape: function () {
+                selectionCallback();
+                pps.setSrc();
+                pps.setDst();
+            },
+
+            // hooks for when the selection changes...
+            empty: function () {
+                selectionCallback();
+            },
+            single: function (data) {
+                selectionCallback(data);
+            }
+        }
+    };
+
+
+    function buttonCallback(x) {
+        $log.debug('Toolbar-button callback', x);
+    }
+
+    function selectionCallback(d) {
+        $log.debug('Selection callback', d);
+        selection = d;
+    }
+
+    // invoke code to register with the overlay service
+    angular.module('ovPpTopov')
+        .run(['$log', 'TopoOverlayService', 'PathPainterTopovService',
+
+        function (_$log_, _tov_, _pps_) {
+            $log = _$log_;
+            tov = _tov_;
+            pps = _pps_;
+            tov.register(overlay);
+        }]);
+
+}());
diff --git a/apps/pathpainter/src/main/resources/ppTopov/css.html b/apps/pathpainter/src/main/resources/ppTopov/css.html
new file mode 100644
index 0000000..56b32b4
--- /dev/null
+++ b/apps/pathpainter/src/main/resources/ppTopov/css.html
@@ -0,0 +1 @@
+<link rel="stylesheet" href="app/view/ppTopov/ppTopov.css">
\ No newline at end of file
diff --git a/apps/pathpainter/src/main/resources/ppTopov/js.html b/apps/pathpainter/src/main/resources/ppTopov/js.html
new file mode 100644
index 0000000..24124bf
--- /dev/null
+++ b/apps/pathpainter/src/main/resources/ppTopov/js.html
@@ -0,0 +1,2 @@
+<script src="app/view/ppTopov/ppTopov.js"></script>
+<script src="app/view/ppTopov/ppTopovOverlay.js"></script>
\ No newline at end of file
diff --git a/apps/pom.xml b/apps/pom.xml
index c72cf5a..4acba4c 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -59,6 +59,7 @@
         <module>pim</module>
         <module>mlb</module>
         <module>openstackswitching</module>
+        <module>pathpainter</module>
   </modules>
 
     <properties>