1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 * Geneviève Bastien - Added the fValue parameter to avoid subclassing
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
;
17 * Generic TimeEvent implementation
20 * @author Patrick Tasse
22 public class TimeEvent
implements ITimeEvent
{
24 /** TimeGraphEntry matching this time event */
25 protected ITimeGraphEntry fEntry
;
27 /** Beginning timestamp of this time event */
30 /** Duration of this time event */
31 protected long fDuration
;
33 private final int fValue
;
36 * Default value when no other value present
38 private static final int NOVALUE
= Integer
.MIN_VALUE
;
41 * Standard constructor
44 * The entry matching this event
46 * The timestamp of this event
48 * The duration of the event
50 public TimeEvent(ITimeGraphEntry entry
, long time
, long duration
) {
51 this(entry
, time
, duration
, NOVALUE
);
59 * The entry to which this time event is assigned
61 * The timestamp of this event
63 * The duration of this event
65 * The status assigned to the event
67 public TimeEvent(ITimeGraphEntry entry
, long time
, long duration
,
76 * Get this event's status
78 * @return The integer matching this status
80 public int getValue() {
85 * Return whether an event has a value
87 * @return true if the event has a value
89 public boolean hasValue() {
90 return (fValue
!= NOVALUE
);
94 public ITimeGraphEntry
getEntry() {
99 public long getTime() {
104 public long getDuration() {
109 public ITimeEvent
splitBefore(long splitTime
) {
110 return (splitTime
> fTime ?
111 new TimeEvent(fEntry
, fTime
, Math
.min(fDuration
, splitTime
- fTime
), fValue
) :
116 public ITimeEvent
splitAfter(long splitTime
) {
117 return (splitTime
< fTime
+ fDuration ?
118 new TimeEvent(fEntry
, Math
.max(fTime
, splitTime
), fDuration
- Math
.max(0, splitTime
- fTime
),
124 public String
toString() {
125 return getClass().getSimpleName() + " start=" + fTime
+ " end=" + (fTime
+ fDuration
) + " duration=" + fDuration
+ (hasValue() ?
(" value=" + fValue
) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
This page took 0.033868 seconds and 5 git commands to generate.