| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials are |
| 5 | * made available under the terms of the Eclipse Public License v1.0 which |
| 6 | * accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | *******************************************************************************/ |
| 9 | |
| 10 | package org.eclipse.tracecompass.internal.provisional.tmf.core.views.timegraph2; |
| 11 | |
| 12 | import java.util.Collections; |
| 13 | import java.util.Map; |
| 14 | import java.util.function.Supplier; |
| 15 | |
| 16 | import org.eclipse.jdt.annotation.Nullable; |
| 17 | |
| 18 | import com.google.common.base.Objects; |
| 19 | |
| 20 | public class TimeGraphStateInterval { |
| 21 | |
| 22 | public enum LineThickness { |
| 23 | NORMAL, |
| 24 | SMALL |
| 25 | } |
| 26 | |
| 27 | private final TimeGraphEvent fStartEvent; |
| 28 | private final TimeGraphEvent fEndEvent; |
| 29 | |
| 30 | private final String fStateName; |
| 31 | private final ColorDefinition fColor; |
| 32 | private final LineThickness fLineThickness; |
| 33 | |
| 34 | private final @Nullable Supplier<Map<String, String>> fPropertySupplier; |
| 35 | |
| 36 | public TimeGraphStateInterval(long start, |
| 37 | long end, |
| 38 | TimeGraphTreeElement treeElement, |
| 39 | String stateName, |
| 40 | ColorDefinition color, |
| 41 | LineThickness lineThickness, |
| 42 | @Nullable Supplier<Map<String, String>> propertySupplier) { |
| 43 | |
| 44 | fStartEvent = new TimeGraphEvent(start, treeElement); |
| 45 | fEndEvent = new TimeGraphEvent(end, treeElement); |
| 46 | |
| 47 | fStateName = stateName; |
| 48 | fColor = color; |
| 49 | fLineThickness = lineThickness; |
| 50 | fPropertySupplier = propertySupplier; |
| 51 | |
| 52 | } |
| 53 | |
| 54 | public TimeGraphEvent getStartEvent() { |
| 55 | return fStartEvent; |
| 56 | } |
| 57 | |
| 58 | public TimeGraphEvent getEndEvent() { |
| 59 | return fEndEvent; |
| 60 | } |
| 61 | |
| 62 | public String getStateName() { |
| 63 | return fStateName; |
| 64 | } |
| 65 | |
| 66 | public ColorDefinition getColorDefinition() { |
| 67 | return fColor; |
| 68 | } |
| 69 | |
| 70 | public LineThickness getLineThickness() { |
| 71 | return fLineThickness; |
| 72 | } |
| 73 | |
| 74 | public Map<String, String> getProperties() { |
| 75 | Supplier<Map<String, String>> supplier = fPropertySupplier; |
| 76 | if (supplier == null) { |
| 77 | return Collections.EMPTY_MAP; |
| 78 | } |
| 79 | return supplier.get(); |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public String toString() { |
| 84 | return Objects.toStringHelper(this) |
| 85 | .add("start", fStartEvent.getTimestamp()) |
| 86 | .add("end", fEndEvent.getTimestamp()) |
| 87 | .add("name", fStateName) |
| 88 | .toString(); |
| 89 | } |
| 90 | } |