blob: ed4b42986fd438bdd5f5ccbcbfd5960b46528e83 [file] [log] [blame]
Thomas Vachuskab4d3ff72015-12-01 09:53:51 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuskab4d3ff72015-12-01 09:53:51 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.pathpainter;
17
18import org.onosproject.net.Link;
19import org.onosproject.net.LinkKey;
20import org.onosproject.ui.topo.BiLink;
21import org.onosproject.ui.topo.LinkHighlight;
22import org.onosproject.ui.topo.LinkHighlight.Flavor;
23
24import java.util.Set;
25
26/**
Andrea Campanellaa4ef01d2017-02-02 09:34:26 -080027 * Bi-directional link capable of different highlights.
Thomas Vachuskab4d3ff72015-12-01 09:53:51 -080028 */
29public class PathLink extends BiLink {
30
31 private boolean primary = false;
32 private boolean secondary = false;
33
34 public PathLink(LinkKey key, Link link) {
35 super(key, link);
36 }
37
38 public void computeHilight(Set<Link> selectedLinks, Set<Link> allLinks) {
39 primary = selectedLinks.contains(this.one()) ||
40 (two() != null && selectedLinks.contains(two()));
41 secondary = allLinks.contains(this.one()) ||
42 (two() != null && allLinks.contains(two()));
43 }
44
45 @Override
46 public LinkHighlight highlight(Enum<?> anEnum) {
47 Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT :
48 (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT);
49 return new LinkHighlight(this.linkId(), flavor);
50 }
51}