| /********************************************************************** |
| * Copyright (c) 2017, 2018 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.tmf.core.model.timegraph; |
| |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| import org.eclipse.jdt.annotation.Nullable; |
| |
| /** |
| * Implementation of {@link ITimeGraphState} |
| * |
| * @author Simon Delisle |
| * @since 4.0 |
| */ |
| public class TimeGraphState implements ITimeGraphState { |
| private final long fStartTime; |
| private final long fDuration; |
| private final int fValue; |
| private final @Nullable String fLabel; |
| /** |
| * A map of properties to activate or deactivate |
| */ |
| private int fActiveProperties = 0; |
| |
| /** |
| * Constructor |
| * |
| * @param time |
| * Time |
| * @param duration |
| * State duration |
| * @param value |
| * Type of state (event type) |
| */ |
| public TimeGraphState(long time, long duration, int value) { |
| fStartTime = time; |
| fDuration = duration; |
| fValue = value; |
| fLabel = null; |
| } |
| |
| /** |
| * Constructor |
| * |
| * @param time |
| * Time |
| * @param duration |
| * State duration |
| * @param value |
| * Type of state (event type) |
| * @param label |
| * State label |
| */ |
| public TimeGraphState(long time, long duration, int value, String label) { |
| fStartTime = time; |
| fDuration = duration; |
| fValue = value; |
| fLabel = label; |
| } |
| |
| @Override |
| public long getStartTime() { |
| return fStartTime; |
| } |
| |
| @Override |
| public long getDuration() { |
| return fDuration; |
| } |
| |
| @Override |
| public int getValue() { |
| return fValue; |
| } |
| |
| @Override |
| public @Nullable String getLabel() { |
| return fLabel; |
| } |
| |
| @Override |
| public Map<String, String> computeData() { |
| Map<String, String> toTest = new HashMap<>(); |
| String label = getLabel(); |
| if (label != null) { |
| toTest.put(IElementResolver.LABEL_KEY, label); |
| } |
| return toTest; |
| } |
| |
| @Override |
| public int getActiveProperties() { |
| return fActiveProperties; |
| } |
| |
| @Override |
| public void setActiveProperties(int activeProperties) { |
| fActiveProperties = activeProperties; |
| } |
| } |