Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f1468e4f55ea90218ced5fd89a4a31e131d1612c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*******************************************************************************
 * Copyright (c) 2018, 2019 Ericsson
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.tracecompass.internal.tmf.ui.views.histogram;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramDataModel;
import org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramScaledData;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;

/**
 * HistogramScaledData wrapper to comply with Time data provider API.
 *
 * @author Simon Delisle
 */
public class HistogramTimeAdapter implements ITimeDataProvider {

    private final HistogramDataModel fHistogram;
    private int fTimeScale = 1;
    private TimeFormat fTimeFormat;

    /**
     * Constructor.
     *
     * @param histogram
     *            {@link HistogramScaledData} to wrap
     */
    public HistogramTimeAdapter(@NonNull HistogramDataModel histogram) {
        fHistogram = histogram;
    }

    @Override
    public void setSelectionRangeNotify(long beginTime, long endTime, boolean ensureVisible) {
        // Nothing to do
    }

    @Override
    public void setSelectionRange(long beginTime, long endTime, boolean ensureVisible) {
        // Nothing to do
    }

    @Override
    public long getSelectionBegin() {
        return fHistogram.getSelectionBegin();
    }

    @Override
    public long getSelectionEnd() {
        return fHistogram.getSelectionEnd();
    }

    @Override
    public long getBeginTime() {
        return fHistogram.getStartTime();
    }

    @Override
    public long getEndTime() {
        return fHistogram.getEndTime();
    }

    @Override
    public long getMinTime() {
        return fHistogram.getSelectionBegin();
    }

    @Override
    public long getMaxTime() {
        return getEndTime();
    }

    @Override
    public long getTime0() {
        return fHistogram.getStartTime();
    }

    @Override
    public long getTime1() {
        return getEndTime();
    }

    @Override
    public long getMinTimeInterval() {
        return fHistogram.getBucketDuration();
    }

    @Override
    public void setStartFinishTimeNotify(long time0, long time1) {
        // Nothing to do
    }

    @Override
    public void setStartFinishTime(long time0, long time1) {
        // Nothing to do
    }

    @Override
    public void notifyStartFinishTime() {
        // Nothing to do
    }

    @Override
    public void setSelectedTimeNotify(long time, boolean ensureVisible) {
        // Nothing to do
    }

    @Override
    public void setSelectedTime(long time, boolean ensureVisible) {
        // Nothing to do
    }

    @Override
    public int getNameSpace() {
        return 0;
    }

    @Override
    public void setNameSpace(int width) {
        // Nothing to do, no name space
    }

    @Override
    public int getTimeSpace() {
        return fTimeScale;
    }

    @Override
    public TimeFormat getTimeFormat() {
        return fTimeFormat;
    }

    /**
     * Set time space
     *
     * @param timeSpace
     *            the time space width
     */
    public void setTimeSpace(int timeSpace) {
        fTimeScale = timeSpace;
    }

    /**
     * Set the time format
     *
     * @param timeFormat
     *            the time format
     */
    public void setTimeFormat(org.eclipse.tracecompass.tmf.ui.views.FormatTimeUtils.TimeFormat timeFormat) {
        fTimeFormat = TimeFormat.convert(timeFormat);
    }
}

Back to the top