blob: 733e4c506c646ede485737dc40e06c9ba72584f4 [file] [log] [blame]
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
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 */
16
17package org.onosproject.pceweb;
18
19import org.onosproject.net.Link;
20import org.onosproject.net.LinkKey;
21import org.onosproject.ui.topo.BiLink;
22import org.onosproject.ui.topo.LinkHighlight;
23import org.onosproject.ui.topo.LinkHighlight.Flavor;
24
25import java.util.Set;
26
27/**
28 * Provides the link color highlight mechanism for given links.
29 */
30public class PceWebLink extends BiLink {
31
32 private boolean primary;
33 private boolean secondary;
34 /**
35 * Initialize the Link key attributes.
36 */
37 public PceWebLink(LinkKey key, Link link) {
38 super(key, link);
39 }
40 /**
41 * Highlight the color of given selected links.
42 */
43 public void computeHilight(Set<Link> selectedLinks, Set<Link> allLinks) {
44 primary = selectedLinks.contains(this.one()) ||
45 (two() != null && selectedLinks.contains(two()));
46 secondary = allLinks.contains(this.one()) ||
47 (two() != null && allLinks.contains(two()));
48 }
49
50 @Override
51 public LinkHighlight highlight(Enum<?> anEnum) {
52 Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT :
53 (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT);
54 return new LinkHighlight(this.linkId(), flavor);
55 }
56}