Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.pceweb; |
| 18 | |
| 19 | import org.onosproject.net.Link; |
| 20 | import org.onosproject.net.LinkKey; |
| 21 | import org.onosproject.ui.topo.BiLink; |
| 22 | import org.onosproject.ui.topo.LinkHighlight; |
| 23 | import org.onosproject.ui.topo.LinkHighlight.Flavor; |
| 24 | |
| 25 | import java.util.Set; |
| 26 | |
| 27 | /** |
| 28 | * Provides the link color highlight mechanism for given links. |
| 29 | */ |
| 30 | public class PceWebLink extends BiLink { |
| 31 | |
| 32 | private boolean primary; |
| 33 | private boolean secondary; |
Mahesh Raju-Huawei | e853602 | 2016-05-18 20:03:43 +0530 | [diff] [blame] | 34 | |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 35 | /** |
Mahesh Raju-Huawei | e853602 | 2016-05-18 20:03:43 +0530 | [diff] [blame] | 36 | * Initialize the Link and key attributes. |
| 37 | * @param key the link key identifier |
| 38 | * @param link the link to be highlighted. |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 39 | */ |
| 40 | public PceWebLink(LinkKey key, Link link) { |
| 41 | super(key, link); |
| 42 | } |
Mahesh Raju-Huawei | e853602 | 2016-05-18 20:03:43 +0530 | [diff] [blame] | 43 | |
| 44 | /** |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 45 | * Highlight the color of given selected links. |
Mahesh Raju-Huawei | e853602 | 2016-05-18 20:03:43 +0530 | [diff] [blame] | 46 | * @param selectedLinks the primary links |
| 47 | * @param allLinks the secondary links |
Mahesh Raju-Huawei | 8593005 | 2016-04-26 21:09:57 +0530 | [diff] [blame] | 48 | */ |
| 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 | } |