Laszlo Papp | 759f0d3 | 2018-03-05 13:24:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Open Networking Foundation |
| 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.ui; |
| 18 | |
| 19 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 20 | |
| 21 | /** |
| 22 | * Represents a glyph to be used in the user interface topology view. Instances |
| 23 | * of this class are immutable. |
| 24 | */ |
| 25 | public class UiGlyph { |
| 26 | |
| 27 | private final String id; |
| 28 | private final String viewbox; |
| 29 | private final String path; |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * Creates a new glyph. |
| 34 | * |
| 35 | * The value of the viewbox parameter is a string of four numbers min-x, |
| 36 | * min-y, width and height, separated by whitespace and/or a comma. |
| 37 | * |
| 38 | * The path parameter specifies how this element is to be drawn inside of |
| 39 | * the viewbox. The ONOS GUI only uses single paths – not rectangles, |
| 40 | * strokes, circles, or anything else. One path definition has to be used |
| 41 | * for the entire glyph. |
| 42 | * |
| 43 | * @param id glyph identifier |
| 44 | * @param viewbox glyph viewbox |
| 45 | * @param path glyph path |
| 46 | */ |
| 47 | public UiGlyph(String id, String viewbox, String path) { |
| 48 | this.id = id; |
| 49 | this.viewbox = viewbox; |
| 50 | this.path = path; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns the identifier for this glyph. |
| 55 | * |
| 56 | * @return the identifier |
| 57 | */ |
| 58 | public String id() { |
| 59 | return id; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns the viewbox for this glyph. |
| 64 | * |
| 65 | * @return the viewbox |
| 66 | */ |
| 67 | public String viewbox() { |
| 68 | return viewbox; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Returns the path for this glyph. |
| 73 | * |
| 74 | * @return the path |
| 75 | */ |
| 76 | public String path() { |
| 77 | return path; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public String toString() { |
| 82 | return toStringHelper(this) |
| 83 | .add("id", id) |
| 84 | .add("viewbox", viewbox) |
| 85 | .add("path", path) |
| 86 | .toString(); |
| 87 | } |
| 88 | } |