1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
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
8 *******************************************************************************/
10 package org
.lttng
.scope
.tmf2
.views
.core
.timegraph
.model
.render
.states
;
13 import java
.util
.Objects
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.lttng
.scope
.tmf2
.views
.core
.config
.ConfigOption
;
17 import org
.lttng
.scope
.tmf2
.views
.core
.timegraph
.model
.render
.ColorDefinition
;
18 import org
.lttng
.scope
.tmf2
.views
.core
.timegraph
.model
.render
.LineThickness
;
19 import org
.lttng
.scope
.tmf2
.views
.core
.timegraph
.model
.render
.TimeGraphEvent
;
20 import org
.lttng
.scope
.tmf2
.views
.core
.timegraph
.model
.render
.tree
.TimeGraphTreeElement
;
22 import com
.google
.common
.base
.MoreObjects
;
25 * Basic implementation of {@link TimeGraphStateInterval}.
27 * @author Alexandre Montplaisir
29 public class BasicTimeGraphStateInterval
implements TimeGraphStateInterval
{
31 private final TimeGraphEvent fStartEvent
;
32 private final TimeGraphEvent fEndEvent
;
34 private final String fStateName
;
35 private final @Nullable String fLabel
;
36 private final ConfigOption
<ColorDefinition
> fColor
;
37 private final ConfigOption
<LineThickness
> fLineThickness
;
39 private final Map
<String
, String
> fProperties
;
44 * It requires supplying the start time, end time, and tree element. The
45 * corresponding {@link TimeGraphEvent} will be created from those.
52 * Tree element of this interval
56 * Label, see {@link #getLabel()}
59 * @param lineThickness
64 public BasicTimeGraphStateInterval(long start
,
66 TimeGraphTreeElement treeElement
,
68 @Nullable String label
,
69 ConfigOption
<ColorDefinition
> color
,
70 ConfigOption
<LineThickness
> lineThickness
,
71 Map
<String
, String
> properties
) {
73 if (start
> end
|| start
< 0 || end
< 0) {
74 throw new IllegalArgumentException();
77 fStartEvent
= new TimeGraphEvent(start
, treeElement
);
78 fEndEvent
= new TimeGraphEvent(end
, treeElement
);
80 fStateName
= stateName
;
83 fLineThickness
= lineThickness
;
84 fProperties
= properties
;
88 public TimeGraphEvent
getStartEvent() {
93 public TimeGraphEvent
getEndEvent() {
98 public String
getStateName() {
103 public @Nullable String
getLabel() {
108 public ConfigOption
<ColorDefinition
> getColorDefinition() {
113 public ConfigOption
<LineThickness
> getLineThickness() {
114 return fLineThickness
;
118 public boolean isMultiState() {
123 public Map
<String
, String
> getProperties() {
128 public int hashCode() {
129 return Objects
.hash(fStartEvent
, fEndEvent
, fStateName
, fLabel
, fColor
, fLineThickness
);
133 public boolean equals(@Nullable Object obj
) {
140 if (getClass() != obj
.getClass()) {
143 BasicTimeGraphStateInterval other
= (BasicTimeGraphStateInterval
) obj
;
144 return (Objects
.equals(fStartEvent
, other
.fStartEvent
)
145 && Objects
.equals(fEndEvent
, other
.fEndEvent
)
146 && Objects
.equals(fStateName
, other
.fStateName
)
147 && Objects
.equals(fLabel
, other
.fLabel
)
148 && Objects
.equals(fColor
, other
.fColor
)
149 && fLineThickness
== other
.fLineThickness
);
153 public String
toString() {
154 return MoreObjects
.toStringHelper(this)
155 .add("start", fStartEvent
.getTimestamp()) //$NON-NLS-1$
156 .add("end", fEndEvent
.getTimestamp()) //$NON-NLS-1$
157 .add("name", fStateName
) //$NON-NLS-1$