tmf: Add configurable marker event source
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / internal / tmf / core / markers / Marker.java
1 /*******************************************************************************
2 * Copyright (c) 2017 Ericsson
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 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.tmf.core.markers;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import com.google.common.collect.Range;
19 import com.google.common.collect.RangeSet;
20
21 /**
22 * Model element for configurable marker.
23 */
24 public class Marker {
25
26 private final String fName;
27 private final String fColor;
28 private final List<SubMarker> fSubMarkers;
29
30 /**
31 * Private constructor.
32 *
33 * @param name
34 * the name
35 * @param color
36 * the color
37 */
38 protected Marker(String name, String color) {
39 super();
40 fName = name;
41 fColor = color;
42 fSubMarkers = new ArrayList<>();
43 }
44
45 /**
46 * Subclass for periodic marker evenly split into segments of equal length.
47 *
48 */
49 public static class PeriodicMarker extends Marker {
50
51 private final String fLabel;
52 private final String fId;
53 private final double fPeriod;
54 private final String fUnit;
55 private final Range<Long> fRange;
56 private final long fOffset;
57 private final RangeSet<Long> fIndexRange;
58
59 /**
60 * Constructor
61 *
62 * @param name
63 * the name
64 * @param label
65 * the label
66 * @param id
67 * the id
68 * @param color
69 * the color
70 * @param period
71 * the period
72 * @param unit
73 * the unit
74 * @param range
75 * the range
76 * @param offset
77 * the offset
78 * @param indexRange
79 * the index range
80 */
81 public PeriodicMarker(String name, String label, String id, String color, double period, String unit, Range<Long> range, long offset, RangeSet<Long> indexRange) {
82 super(name, color);
83 fLabel = label;
84 fId = id;
85 fPeriod = period;
86 fUnit = unit;
87 fRange = range;
88 fOffset = offset;
89 fIndexRange = indexRange;
90 }
91
92 /**
93 * @return the label
94 */
95 public String getLabel() {
96 return fLabel;
97 }
98
99 /**
100 * @return the id
101 */
102 public String getId() {
103 return fId;
104 }
105
106 /**
107 * @return the period
108 */
109 public double getPeriod() {
110 return fPeriod;
111 }
112
113 /**
114 * @return the unit
115 */
116 public String getUnit() {
117 return fUnit;
118 }
119
120 /**
121 * @return the range
122 */
123 public Range<Long> getRange() {
124 return fRange;
125 }
126
127 /**
128 * @return the offset
129 */
130 public long getOffset() {
131 return fOffset;
132 }
133
134 /**
135 * @return the index range
136 */
137 public RangeSet<Long> getIndexRange() {
138 return fIndexRange;
139 }
140 }
141
142 /**
143 * @return the name
144 */
145 public String getName() {
146 return fName;
147 }
148
149 /**
150 * @return the color
151 */
152 public String getColor() {
153 return fColor;
154 }
155
156 /**
157 * @return the sub-markers
158 */
159 public List<SubMarker> getSubMarkers() {
160 return fSubMarkers;
161 }
162
163 /**
164 * Add a sub-marker.
165 *
166 * @param subMarker the sub-marker
167 */
168 public void addSubMarker(SubMarker subMarker) {
169 fSubMarkers.add(subMarker);
170 }
171 }
This page took 0.034794 seconds and 5 git commands to generate.