1 /*******************************************************************************
2 * Copyright (c) 2015, 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
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.aspect
;
12 import java
.util
.Comparator
;
14 import org
.eclipse
.jdt
.annotation
.Nullable
;
15 import org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.module
.LamiTableEntry
;
18 * Aspect for LAMI table entries, which normally correspond to one "row"
21 * It is not the same as a "Event aspect" used for trace events, but it is
22 * heavily inspired from it.
24 * @author Alexandre Montplaisir
25 * @see org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect
27 public abstract class LamiTableEntryAspect
{
29 private final String fName
;
30 private final @Nullable String fUnits
;
36 * Aspect name, will be used as column name in the UI
38 * The units of the value in this column
40 protected LamiTableEntryAspect(String name
, @Nullable String units
) {
46 * Get the label of this aspect.
48 * The label is composed of the name followed by the units in parentheses.
52 public String
getLabel() {
53 if (getUnits() == null) {
56 return (getName() + " (" + getUnits() + ')'); //$NON-NLS-1$
60 * Get the name of this aspect
64 public String
getName() {
69 * Get the units of this aspect.
73 public @Nullable String
getUnits() {
78 * Indicate if this aspect is numerical or not. This is used, among other
79 * things, to align the text in the table cells.
81 * @return If this aspect is numerical or not
83 public abstract boolean isContinuous();
87 * Indicate if this aspect represent timestamp or not. This can be used in chart
88 * for axis labeling etc.
89 * @return If this aspect represent a timestamp or not
91 public abstract boolean isTimeStamp();
94 * Indicate if this aspect represent a time duration or not. This can be used in
95 * chart for axis labeling etc.
96 * @return If this aspect represent a time duration or not
98 public boolean isTimeDuration() {
103 * Resolve this aspect for the given entry.
107 * @return The string to display for the given cell
109 public abstract @Nullable String
resolveString(LamiTableEntry entry
);
112 * Resolve this aspect double representation for the given entry
114 * Returned value does not matter if isNumerical() is false.
118 * @return The double value for the given cell
120 public abstract @Nullable Number
resolveNumber(LamiTableEntry entry
);
123 * Get the comparator that should be used to compare this entry (or table
124 * row) with the other rows in the table. This will be passed on to the
125 * table's content provider.
127 * @return The entry comparator
129 public abstract Comparator
<LamiTableEntry
> getComparator();
132 * Check if an aspect have the same properties.
134 * FIXME:Might want to compare the units if necessary.
137 * The aspect to compare to
138 * @return If all aspect's properties are equal
140 public boolean arePropertiesEqual(LamiTableEntryAspect aspect
) {
141 boolean timestamp
= (this.isTimeStamp() == aspect
.isTimeStamp());
142 boolean numerical
= (this.isContinuous() == aspect
.isContinuous());
143 return (timestamp
&& numerical
);