1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson, École Polytechnique de Montréal
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 - Move code to provide base classes for time graph view
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
;
16 import java
.util
.ArrayList
;
17 import java
.util
.Iterator
;
18 import java
.util
.List
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
23 * An entry for use in the time graph views
27 public class TimeGraphEntry
implements ITimeGraphEntry
{
29 /** Id field that may be used by views, so they don't have to extend this class if they don't need to */
30 private final int fEntryId
;
31 private final ITmfTrace fTrace
;
34 private TimeGraphEntry fParent
= null;
36 /** List of child entries */
37 private final List
<TimeGraphEntry
> fChildren
= new ArrayList
<TimeGraphEntry
>();
39 /** Name of this entry (text to show) */
41 private long fStartTime
= -1;
42 private long fEndTime
= -1;
43 private List
<ITimeEvent
> fEventList
= new ArrayList
<ITimeEvent
>();
44 private List
<ITimeEvent
> fZoomedEventList
= null;
50 * Some id attribute for the entry whose state is shown on this
53 * The trace on which we are working
55 * The exec_name of this entry
57 * The start time of this process's lifetime
59 * The end time of this process
61 public TimeGraphEntry(int entryid
, ITmfTrace trace
, String name
, long startTime
, long endTime
) {
65 fStartTime
= startTime
;
69 // ---------------------------------------------
70 // Getters and setters
71 // ---------------------------------------------
74 public ITimeGraphEntry
getParent() {
79 * Sets the entry's parent
81 * @param entry The new parent entry
83 protected void setParent(TimeGraphEntry entry
) {
88 public boolean hasChildren() {
89 return fChildren
.size() > 0;
93 public List
<TimeGraphEntry
> getChildren() {
98 public String
getName() {
103 * Update the entry name
106 * the updated entry name
108 public void setName(String name
) {
113 public long getStartTime() {
118 public long getEndTime() {
123 public boolean hasTimeEvents() {
128 public Iterator
<ITimeEvent
> getTimeEventsIterator() {
129 if (hasTimeEvents()) {
130 return new EventIterator(fEventList
, fZoomedEventList
);
136 public Iterator
<ITimeEvent
> getTimeEventsIterator(long startTime
, long stopTime
, long visibleDuration
) {
137 if (!hasTimeEvents()) {
140 return new EventIterator(fEventList
, fZoomedEventList
, startTime
, stopTime
);
144 * Get the id of this entry
146 * @return The entry id
148 public int getEntryId() {
153 * Get the trace object
157 public ITmfTrace
getTrace() {
162 * Add an event to this process's timeline
167 public void addEvent(ITimeEvent event
) {
168 long start
= event
.getTime();
169 long end
= start
+ event
.getDuration();
170 synchronized (fEventList
) {
171 fEventList
.add(event
);
172 if (fStartTime
== -1 || start
< fStartTime
) {
175 if (fEndTime
== -1 || end
> fEndTime
) {
182 * Set the general event list of this entry.
184 * Creates a copy of the list to avoid the caller still modifying the list
187 * The list of time events
189 public void setEventList(List
<ITimeEvent
> eventList
) {
190 if (eventList
!= null) {
191 fEventList
= new ArrayList
<ITimeEvent
>(eventList
);
193 // the event list should never be null
194 fEventList
= new ArrayList
<ITimeEvent
>();
199 * Set the zoomed event list of this entry.
201 * Creates a copy of the list to avoid the caller still modifying the list
204 * The list of time events
206 public void setZoomedEventList(List
<ITimeEvent
> eventList
) {
207 if (eventList
!= null) {
208 fZoomedEventList
= new ArrayList
<ITimeEvent
>(eventList
);
210 // the zoomed event list can be null
211 fZoomedEventList
= null;
216 * Add a child entry to this one (to show relationships between processes as
222 public void addChild(TimeGraphEntry child
) {
223 child
.fParent
= this;
224 fChildren
.add(child
);
228 public String
toString() {
229 return getClass().getSimpleName() + '(' + fName
+ ')';
This page took 0.040085 seconds and 5 git commands to generate.