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
;
16 import java
.util
.Objects
;
19 * Generic TimeEvent implementation
22 * @author Patrick Tasse
24 public class TimeEvent
implements ITimeEvent
{
26 /** TimeGraphEntry matching this time event */
27 protected ITimeGraphEntry fEntry
;
29 /** Beginning timestamp of this time event */
32 /** Duration of this time event */
33 protected long fDuration
;
35 private final int fValue
;
38 * Default value when no other value present
40 private static final int NOVALUE
= Integer
.MIN_VALUE
;
43 * Standard constructor
46 * The entry matching this event
48 * The timestamp of this event
50 * The duration of the event
52 public TimeEvent(ITimeGraphEntry entry
, long time
, long duration
) {
53 this(entry
, time
, duration
, NOVALUE
);
61 * The entry to which this time event is assigned
63 * The timestamp of this event
65 * The duration of this event
67 * The status assigned to the event
69 public TimeEvent(ITimeGraphEntry entry
, long time
, long duration
,
78 * Get this event's status
80 * @return The integer matching this status
82 public int getValue() {
87 * Return whether an event has a value
89 * @return true if the event has a value
91 public boolean hasValue() {
92 return (fValue
!= NOVALUE
);
96 public ITimeGraphEntry
getEntry() {
101 public long getTime() {
106 public long getDuration() {
111 public ITimeEvent
splitBefore(long splitTime
) {
112 return (splitTime
> fTime ?
113 new TimeEvent(fEntry
, fTime
, Math
.min(fDuration
, splitTime
- fTime
), fValue
) :
118 public ITimeEvent
splitAfter(long splitTime
) {
119 return (splitTime
< fTime
+ fDuration ?
120 new TimeEvent(fEntry
, Math
.max(fTime
, splitTime
), fDuration
- Math
.max(0, splitTime
- fTime
),
126 public int hashCode() {
127 return Objects
.hash(fEntry
, fTime
, fDuration
, fValue
);
131 public boolean equals(Object obj
) {
138 if (getClass() != obj
.getClass()) {
141 TimeEvent other
= (TimeEvent
) obj
;
142 return Objects
.equals(fEntry
, other
.fEntry
) &&
143 Objects
.equals(fTime
, other
.fTime
) &&
144 Objects
.equals(fDuration
, other
.fDuration
) &&
145 Objects
.equals(fValue
, other
.fValue
);
149 public String
toString() {
150 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.042601 seconds and 5 git commands to generate.