Search in sources :

Example 96 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class TimeCompressionBar method selectTimeDelta.

/**
 * Selects the time delta for given delta y coordinate and direction.
 *
 * @param dy
 *            The delta in y coordinate.
 * @param direction
 *            0 no direction, 1 = down, 2 = up
 */
protected void selectTimeDelta(int dy, int direction) {
    SDTimeEvent lastM1 = null;
    SDTimeEvent lastM2 = null;
    int lastY1 = 0;
    int lastY2 = 0;
    boolean done = false;
    if (fFrame != null) {
        for (int i = 0; i < fNodeList.size() - 1; i++) {
            SDTimeEvent m1 = fNodeList.get(i);
            SDTimeEvent m2 = fNodeList.get(i + 1);
            if (skipIfLifelineIsNull(m1, m2)) {
                continue;
            }
            PairOfYs poy = adjustHeights(m1, m2);
            int m1Y = Math.round(poy.getY1() * fZoomValue);
            int m2Y = Math.round(poy.getY2() * fZoomValue);
            if ((m1Y < dy) && (m2Y > dy) || (!done && m2Y > dy && direction == 1 && lastM1 != null) || (!done && m1Y > dy && direction == 2 && lastM1 != null)) {
                if (m1Y > dy && direction == 2) {
                    m1 = lastM1;
                    m2 = lastM2;
                    m1Y = lastY1;
                    m2Y = lastY2;
                }
                done = true;
                fPrevNodeY = m1Y;
                fNextNodeY = m2Y;
                ITmfTimestamp minMaxdelta = fMaxTime.getDelta(fMinTime);
                double gr = (minMaxdelta.getValue()) / (double) NUMBER_STEPS;
                ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(fMinTime);
                long absDelta = Math.abs(delta.getValue());
                int colIndex = 0;
                if (gr != 0) {
                    colIndex = Math.round((float) (absDelta / gr));
                    if (colIndex >= fColors.length) {
                        colIndex = fColors.length - 1;
                    } else if (colIndex < 0) {
                        colIndex = 0;
                    }
                } else {
                    colIndex = 0;
                }
                if (m1.getGraphNode() instanceof BaseMessage) {
                    BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
                    if (mes1.getEndLifeline() != null) {
                        fLifeline = mes1.getEndLifeline();
                        fLifelineStart = m1.getEvent();
                        fLifelineNumEvents = m2.getEvent() - m1.getEvent();
                        fLifelineColor = fColors[colIndex];
                    } else if (m2.getGraphNode() instanceof BaseMessage && ((BaseMessage) m2.getGraphNode()).getStartLifeline() != null) {
                        fLifeline = ((BaseMessage) m2.getGraphNode()).getStartLifeline();
                        fLifelineStart = m1.getEvent();
                        fLifelineNumEvents = m2.getEvent() - m1.getEvent();
                        fLifelineColor = fColors[colIndex];
                    } else {
                        fLifeline = mes1.getStartLifeline();
                        fLifelineStart = m1.getEvent();
                        fLifelineNumEvents = m2.getEvent() - m1.getEvent();
                        fLifelineColor = fColors[colIndex];
                    }
                } else if (m1.getGraphNode() instanceof ExecutionOccurrence) {
                    if (m2.getGraphNode() instanceof ExecutionOccurrence) {
                        ExecutionOccurrence eo = (ExecutionOccurrence) m2.getGraphNode();
                        fLifeline = eo.getLifeline();
                        fLifelineStart = m1.getEvent();
                        fLifelineNumEvents = m2.getEvent() - m1.getEvent();
                        fLifelineColor = fColors[colIndex];
                    } else {
                        ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
                        fLifeline = eo.getLifeline();
                        fLifelineStart = m1.getEvent();
                        fLifelineNumEvents = m2.getEvent() - m1.getEvent();
                        fLifelineColor = fColors[colIndex];
                    }
                }
                for (int j = 0; j < fListenerList.size(); j++) {
                    ITimeCompressionListener list = fListenerList.get(j);
                    list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor);
                }
                break;
            }
            lastM1 = m1;
            lastM2 = m2;
            lastY1 = m1Y;
            lastY2 = m2Y;
        }
    }
}
Also used : SDTimeEvent(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.SDTimeEvent) ExecutionOccurrence(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.ExecutionOccurrence) BaseMessage(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.BaseMessage) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)

Example 97 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class TimeCompressionBar method contentsMouseHover.

@Override
protected void contentsMouseHover(MouseEvent e) {
    if (fTooltip == null) {
        fTooltip = new DrawableToolTip(this);
    }
    if (fFrame != null) {
        setFocus(0);
        for (int i = 0; i < fNodeList.size() - 1; i++) {
            SDTimeEvent m1 = fNodeList.get(i);
            SDTimeEvent m2 = fNodeList.get(i + 1);
            if (skipIfLifelineIsNull(m1, m2)) {
                continue;
            }
            PairOfYs poy = adjustHeights(m1, m2);
            int m1Y = Math.round(poy.getY1() * fZoomValue);
            int m2Y = Math.round(poy.getY2() * fZoomValue);
            if ((m1Y < e.y) && (m2Y >= e.y)) {
                ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
                fTooltip.showToolTip(delta, fMinTime, fMaxTime);
            }
        }
    }
    setFocus(0);
}
Also used : SDTimeEvent(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.SDTimeEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)

Example 98 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class BasicFrame method buildTimeArray.

/**
 * Builds the time array based on the list of graph nodes.
 *
 * @return the time array else empty list.
 */
protected List<SDTimeEvent> buildTimeArray() {
    if (!hasChildren()) {
        return new ArrayList<>();
    }
    Iterator<String> it = getForwardSortMap().keySet().iterator();
    List<SDTimeEvent> timeArray = new ArrayList<>();
    while (it.hasNext()) {
        String nodeType = it.next();
        List<GraphNode> list = checkNotNull(getNodeMap().get(nodeType));
        for (int i = 0; i < list.size(); i++) {
            Object timedNode = list.get(i);
            if ((timedNode instanceof ITimeRange) && ((ITimeRange) timedNode).hasTimeInfo()) {
                int event = list.get(i).getStartOccurrence();
                ITmfTimestamp time = ((ITimeRange) list.get(i)).getStartTime();
                SDTimeEvent f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
                timeArray.add(f);
                if (event != list.get(i).getEndOccurrence()) {
                    event = (list.get(i)).getEndOccurrence();
                    time = ((ITimeRange) list.get(i)).getEndTime();
                    f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
                    timeArray.add(f);
                }
            }
        }
    }
    return timeArray;
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ArrayList(java.util.ArrayList)

Example 99 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class JsonTraceTest method testSortedTrace.

/**
 * Test the unsorted json trace
 *
 * @throws TmfTraceException
 *             If there is a problem while initializing the trace
 */
@Test
public void testSortedTrace() throws TmfTraceException {
    // $NON-NLS-1$
    String path = "traces/sortedTrace.json";
    long nbEvents = 5;
    ITmfTimestamp startTime = TmfTimestamp.fromNanos(1);
    ITmfTimestamp endTime = TmfTimestamp.fromNanos(5);
    testJsonTrace(path, nbEvents, startTime, endTime);
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 100 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class JsonTraceTest method testUnsortedTrace.

/**
 * Test the unsorted json trace
 *
 * @throws TmfTraceException
 *             If there is a problem while initializing the trace
 */
@Test
public void testUnsortedTrace() throws TmfTraceException {
    // $NON-NLS-1$
    String path = "traces/unsortedTrace.json";
    long nbEvents = 5;
    ITmfTimestamp startTime = TmfTimestamp.fromNanos(1);
    ITmfTimestamp endTime = TmfTimestamp.fromNanos(5);
    testJsonTrace(path, nbEvents, startTime, endTime);
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Aggregations

ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)162 Test (org.junit.Test)102 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)52 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)12 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)11 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)10 Point (org.eclipse.swt.graphics.Point)8 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)8 ArrayList (java.util.ArrayList)6 NonNull (org.eclipse.jdt.annotation.NonNull)5 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)5 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)5 IOException (java.io.IOException)4 IStatus (org.eclipse.core.runtime.IStatus)4 File (java.io.File)3 Path (java.nio.file.Path)3 HashSet (java.util.HashSet)3 CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3