Commit | Line | Data |
---|---|---|
8c8bf09f | 1 | /******************************************************************************* |
be4a197a | 2 | * Copyright (c) 2009, 2014 Ericsson |
4f8ca6a1 | 3 | * |
8c8bf09f ASL |
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 | |
4f8ca6a1 | 8 | * |
8c8bf09f ASL |
9 | * Contributors: |
10 | * Francois Chouinard - Initial API and implementation | |
0fcf3b09 | 11 | * Patrick Tasse - Support selection range |
8c8bf09f ASL |
12 | *******************************************************************************/ |
13 | ||
2bdf0193 | 14 | package org.eclipse.tracecompass.tmf.core.signal; |
8c8bf09f | 15 | |
2bdf0193 | 16 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; |
8c8bf09f ASL |
17 | |
18 | /** | |
0fcf3b09 PT |
19 | * A new time or time range selection has been made. |
20 | * | |
21 | * This is the selected time or time range. To synchronize on the visible | |
22 | * (zoom) range, use {@link TmfRangeSynchSignal}. | |
23 | * | |
4b7b3670 FC |
24 | * @author Francois Chouinard |
25 | */ | |
8c8bf09f ASL |
26 | public class TmfTimeSynchSignal extends TmfSignal { |
27 | ||
0fcf3b09 PT |
28 | private final ITmfTimestamp fBeginTime; |
29 | private final ITmfTimestamp fEndTime; | |
4f8ca6a1 AM |
30 | |
31 | /** | |
32 | * Constructor | |
33 | * | |
34 | * @param source | |
35 | * Object sending this signal | |
36 | * @param ts | |
0fcf3b09 | 37 | * Timestamp of selection |
4f8ca6a1 AM |
38 | */ |
39 | public TmfTimeSynchSignal(Object source, ITmfTimestamp ts) { | |
40 | super(source); | |
0fcf3b09 PT |
41 | fBeginTime = ts; |
42 | fEndTime = ts; | |
43 | } | |
44 | ||
45 | /** | |
46 | * Constructor | |
47 | * | |
48 | * @param source | |
49 | * Object sending this signal | |
50 | * @param begin | |
51 | * Timestamp of begin of selection range | |
52 | * @param end | |
53 | * Timestamp of end of selection range | |
0fcf3b09 PT |
54 | */ |
55 | public TmfTimeSynchSignal(Object source, ITmfTimestamp begin, ITmfTimestamp end) { | |
56 | super(source); | |
57 | fBeginTime = begin; | |
58 | fEndTime = end; | |
4f8ca6a1 AM |
59 | } |
60 | ||
0fcf3b09 PT |
61 | /** |
62 | * @return The begin timestamp of selection | |
0fcf3b09 PT |
63 | */ |
64 | public ITmfTimestamp getBeginTime() { | |
65 | return fBeginTime; | |
66 | } | |
67 | ||
68 | /** | |
69 | * @return The end timestamp of selection | |
0fcf3b09 PT |
70 | */ |
71 | public ITmfTimestamp getEndTime() { | |
72 | return fEndTime; | |
4f8ca6a1 AM |
73 | } |
74 | ||
4f8ca6a1 AM |
75 | @Override |
76 | public String toString() { | |
0fcf3b09 PT |
77 | StringBuilder sb = new StringBuilder(); |
78 | sb.append("[TmfTimeSynchSignal ("); //$NON-NLS-1$ | |
79 | if (fBeginTime != null) { | |
80 | sb.append(fBeginTime.toString()); | |
81 | if (!fBeginTime.equals(fEndTime) && fEndTime != null) { | |
82 | sb.append('-'); | |
83 | sb.append(fEndTime.toString()); | |
84 | } | |
85 | } | |
86 | sb.append(")]"); //$NON-NLS-1$ | |
87 | return sb.toString(); | |
4f8ca6a1 | 88 | } |
8d2e2848 | 89 | |
8c8bf09f | 90 | } |