Search in sources :

Example 1 with TmfXyModel

use of org.eclipse.tracecompass.tmf.core.model.TmfXyModel in project tracecompass by tracecompass.

the class TmfXyResponseFactory method create.

/**
 * Create a {@link TmfModelResponse} for values with a common X axis values,
 * with a either RUNNING or COMPLETED status. Model is not null, it's either
 * partial or full.
 *
 * @param title
 *            Chart title
 * @param xValues
 *            The x values requested by the viewer
 * @param yModels
 *            Collection of IYModel
 * @param isComplete
 *            Tells whether the computed model is complete or partial
 * @return A {@link TmfModelResponse} with either a running status or a
 *         completed status
 */
public static TmfModelResponse<ITmfXyModel> create(String title, long[] xValues, Collection<IYModel> yModels, boolean isComplete) {
    List<ISeriesModel> series = Lists.transform(new ArrayList<>(yModels), model -> {
        SeriesModelBuilder builder = new SeriesModelBuilder(model.getId(), model.getName(), xValues, model.getData());
        TmfXYAxisDescription yAxis = model.getYAxisDescription();
        if (yAxis != null) {
            builder.yAxisDescription(yAxis);
        }
        return builder.build();
    });
    ITmfXyModel model = new TmfXyModel(title, series);
    if (isComplete) {
        return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, Objects.requireNonNull(CommonStatusMessage.COMPLETED));
    }
    return new TmfModelResponse<>(model, ITmfResponse.Status.RUNNING, Objects.requireNonNull(CommonStatusMessage.RUNNING));
}
Also used : ISeriesModel(org.eclipse.tracecompass.tmf.core.model.xy.ISeriesModel) TmfXYAxisDescription(org.eclipse.tracecompass.tmf.core.model.xy.TmfXYAxisDescription) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) SeriesModelBuilder(org.eclipse.tracecompass.tmf.core.model.SeriesModel.SeriesModelBuilder) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel) TmfXyModel(org.eclipse.tracecompass.tmf.core.model.TmfXyModel) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)

Aggregations

SeriesModelBuilder (org.eclipse.tracecompass.tmf.core.model.SeriesModel.SeriesModelBuilder)1 TmfXyModel (org.eclipse.tracecompass.tmf.core.model.TmfXyModel)1 ISeriesModel (org.eclipse.tracecompass.tmf.core.model.xy.ISeriesModel)1 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)1 TmfXYAxisDescription (org.eclipse.tracecompass.tmf.core.model.xy.TmfXYAxisDescription)1 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)1