blob: 16a1212a90e2264735881bfbe16116338d4a24eb [file] [log] [blame]
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +05303 *
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;
Mahesh Raju-Huaweie8536022016-05-18 20:03:43 +053034
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053035 /**
Mahesh Raju-Huaweie8536022016-05-18 20:03:43 +053036 * Initialize the Link and key attributes.
37 * @param key the link key identifier
38 * @param link the link to be highlighted.
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053039 */
40 public PceWebLink(LinkKey key, Link link) {
41 super(key, link);
42 }
Mahesh Raju-Huaweie8536022016-05-18 20:03:43 +053043
44 /**
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053045 * Highlight the color of given selected links.
Mahesh Raju-Huaweie8536022016-05-18 20:03:43 +053046 * @param selectedLinks the primary links
47 * @param allLinks the secondary links
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053048 */
49 public void computeHilight(Set<Link> selectedLinks, Set<Link> allLinks) {
50 primary = selectedLinks.contains(this.one()) ||
51 (two() != null && selectedLinks.contains(two()));
52 secondary = allLinks.contains(this.one()) ||
53 (two() != null && allLinks.contains(two()));
54 }
55
56 @Override
57 public LinkHighlight highlight(Enum<?> anEnum) {
58 Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT :
59 (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT);
60 return new LinkHighlight(this.linkId(), flavor);
61 }
62}