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
;
21 * An entry for use in the time graph views
25 public class TimeGraphEntry
implements ITimeGraphEntry
{
28 private TimeGraphEntry fParent
= null;
30 /** List of child entries */
31 private final List
<TimeGraphEntry
> fChildren
= new ArrayList
<>();
33 /** Name of this entry (text to show) */
35 private long fStartTime
= -1;
36 private long fEndTime
= -1;
37 private List
<ITimeEvent
> fEventList
= new ArrayList
<>();
38 private List
<ITimeEvent
> fZoomedEventList
= new ArrayList
<>();
44 * The name of this entry
46 * The start time of this entry
48 * The end time of this entry
50 public TimeGraphEntry(String name
, long startTime
, long endTime
) {
52 fStartTime
= startTime
;
56 // ---------------------------------------------
57 // Getters and setters
58 // ---------------------------------------------
61 public ITimeGraphEntry
getParent() {
66 * Sets the entry's parent
68 * @param entry The new parent entry
70 protected void setParent(TimeGraphEntry entry
) {
75 public boolean hasChildren() {
76 return fChildren
.size() > 0;
80 public List
<TimeGraphEntry
> getChildren() {
85 public String
getName() {
90 * Update the entry name
93 * the updated entry name
95 public void setName(String name
) {
100 public long getStartTime() {
105 public long getEndTime() {
110 public boolean hasTimeEvents() {
115 public Iterator
<ITimeEvent
> getTimeEventsIterator() {
116 if (hasTimeEvents()) {
117 return new EventIterator(fEventList
, fZoomedEventList
);
123 public Iterator
<ITimeEvent
> getTimeEventsIterator(long startTime
, long stopTime
, long visibleDuration
) {
124 if (!hasTimeEvents()) {
127 return new EventIterator(fEventList
, fZoomedEventList
, startTime
, stopTime
);
131 * Add an event to this entry's event list. If necessary, update the start
132 * and end time of the entry.
137 public void addEvent(ITimeEvent event
) {
138 long start
= event
.getTime();
139 long end
= start
+ event
.getDuration();
140 synchronized (fEventList
) {
141 fEventList
.add(event
);
142 if (fStartTime
== -1 || start
< fStartTime
) {
145 if (fEndTime
== -1 || end
> fEndTime
) {
152 * Set the general event list of this entry.
155 * The list of time events
157 public void setEventList(List
<ITimeEvent
> eventList
) {
158 if (eventList
!= null) {
159 fEventList
= new ArrayList
<>(eventList
);
161 fEventList
= new ArrayList
<>();
166 * Set the zoomed event list of this entry.
169 * The list of time events
171 public void setZoomedEventList(List
<ITimeEvent
> eventList
) {
172 if (eventList
!= null) {
173 fZoomedEventList
= new ArrayList
<>(eventList
);
175 fZoomedEventList
= new ArrayList
<>();
180 * Add a child entry to this one
185 public void addChild(TimeGraphEntry child
) {
186 child
.fParent
= this;
187 fChildren
.add(child
);
191 public String
toString() {
192 return getClass().getSimpleName() + '(' + fName
+ ')';
This page took 0.033829 seconds and 5 git commands to generate.