Import views plugins
[deliverable/tracecompass.git] / tmf / org.lttng.scope.tmf2.views.core / src / org / lttng / scope / tmf2 / views / core / timegraph / model / render / drawnevents / TimeGraphDrawnEvent.java
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.lttng.scope.tmf2.views.core.timegraph.model.render.drawnevents;
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 import org.lttng.scope.tmf2.views.core.timegraph.model.render.TimeGraphEvent;
18
19 /**
20 * Model representation of a drawn event.
21 *
22 * A drawn event is a UI representation of a single {@link TimeGraphEvent}, with
23 * a given style.
24 *
25 * Additional properties can also be part of the drawn event, for example to be
26 * shown on mouse-over.
27 *
28 * @author Alexandre Montplaisir
29 */
30 public class TimeGraphDrawnEvent {
31
32 private final TimeGraphEvent fTimeGraphEvent;
33 private final TimeGraphDrawnEventSeries fEventSeries;
34 private final @Nullable Supplier<Map<String, String>> fPropertySupplier;
35
36 /**
37 * Constructor
38 *
39 * @param event
40 * Time graph event (location)
41 * @param eventSeries
42 * Series of this event, which contains all the styling
43 * information
44 * @param propertySupplier
45 * Supplier of additional properties, which can be accessed only
46 * the first time {@link #getProperties()} is called.
47 */
48 public TimeGraphDrawnEvent(TimeGraphEvent event,
49 TimeGraphDrawnEventSeries eventSeries,
50 @Nullable Supplier<Map<String, String>> propertySupplier) {
51 fTimeGraphEvent = event;
52 fEventSeries = eventSeries;
53 fPropertySupplier = propertySupplier;
54 }
55
56 /**
57 * Get the timegraph event wrapped by this drawn event.
58 *
59 * @return The time graph event
60 */
61 public TimeGraphEvent getEvent() {
62 return fTimeGraphEvent;
63 }
64
65 /**
66 * Get the event series of this drawn event.
67 *
68 * @return The event's series
69 */
70 public TimeGraphDrawnEventSeries getEventSeries() {
71 return fEventSeries;
72 }
73
74 /**
75 * Get the additional properties of this drawn event.
76 *
77 * @return The event's properties
78 */
79 public Map<String, String> getProperties() {
80 Supplier<Map<String, String>> supplier = fPropertySupplier;
81 if (supplier == null) {
82 return Collections.EMPTY_MAP;
83 }
84 return supplier.get();
85 }
86 }
This page took 0.031758 seconds and 5 git commands to generate.