use of org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider in project tracecompass by tracecompass.
the class XYChartLegendImageProvider method getLegendImage.
@Override
public Image getLegendImage(int imageHeight, int imageWidth, @NonNull Long id) {
/*
* If series exists in chart, then image legend match that series. Image will
* make sense if series exists in chart. If it does not exists, an image will
* still be created.
*/
OutputElementStyle appearance = fChartViewer.getSeriesStyle(id);
BaseXYPresentationProvider presProvider = fChartViewer.getPresentationProvider();
RGBAColor rgb = presProvider.getColorStyleOrDefault(appearance, StyleProperties.COLOR, DEFAULT_COLOR);
Color lineColor = new Color(Display.getDefault(), rgb.getRed(), rgb.getGreen(), rgb.getBlue());
Color background = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
PaletteData palette = new PaletteData(background.getRGB(), lineColor.getRGB());
ImageData imageData = new ImageData(imageWidth, imageHeight, 8, palette);
imageData.transparentPixel = 0;
Image image = new Image(Display.getDefault(), imageData);
GC gc = new GC(image);
gc.setBackground(background);
gc.fillRectangle(0, 0, imageWidth, imageHeight);
drawStyleLine(gc, lineColor, imageWidth, imageHeight, appearance);
drawStyledDot(gc, lineColor, imageWidth, imageHeight, appearance);
gc.dispose();
lineColor.dispose();
return image;
}
use of org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider in project tracecompass by tracecompass.
the class TmfFilteredXYChartViewer method handleCheckStateChangedEvent.
/**
* Update the chart depending on the selected entries.
*
* @param entries
* Counters to display on the chart
*/
@Override
public void handleCheckStateChangedEvent(Collection<ITmfTreeViewerEntry> entries) {
cancelUpdate();
Iterable<TmfGenericTreeEntry> counterEntries = Iterables.filter(entries, TmfGenericTreeEntry.class);
Collection<@NonNull Long> selectedIds = Sets.newHashSet(Iterables.transform(counterEntries, e -> e.getModel().getId()));
if (!selectedIds.containsAll(fSelectedIds)) {
clearContent();
}
fSelectedIds = selectedIds;
// Update the styles as well
BaseXYPresentationProvider presProvider = getPresentationProvider();
for (ITmfTreeViewerEntry entry : entries) {
if (entry instanceof TmfGenericTreeEntry) {
TmfGenericTreeEntry<TmfTreeDataModel> genericEntry = (TmfGenericTreeEntry<TmfTreeDataModel>) entry;
TmfTreeDataModel model = genericEntry.getModel();
OutputElementStyle style = model.getStyle();
if (style != null) {
presProvider.setStyle(model.getId(), style);
}
}
}
updateContent();
}
use of org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider in project tracecompass by tracecompass.
the class TmfFilteredXYChartViewer method initializeDataProvider.
@Override
protected ITmfXYDataProvider initializeDataProvider(ITmfTrace trace) {
ITmfTreeXYDataProvider<?> dataProvider = DataProviderManager.getInstance().getDataProvider(trace, fId, ITmfTreeXYDataProvider.class);
BaseXYPresentationProvider presentationProvider = getPresentationProvider();
fUseDefaultStyleValues.computeIfAbsent(presentationProvider, pp -> {
if (dataProvider instanceof IOutputStyleProvider) {
pp.addProvider(dataProvider);
return false;
}
return true;
});
return dataProvider;
}
use of org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider in project tracecompass by tracecompass.
the class XYChartLegendImageProvider method drawStyledDot.
private void drawStyledDot(GC gc, Color lineColor, int imageWidth, int imageHeight, @NonNull OutputElementStyle appearance) {
BaseXYPresentationProvider presProvider = fChartViewer.getPresentationProvider();
String symbolStyle = (String) presProvider.getStyleOrDefault(appearance, StyleProperties.SYMBOL_TYPE, StyleProperties.SymbolType.NONE);
int symbolSize = Math.round(presProvider.getFloatStyleOrDefault(appearance, StyleProperties.HEIGHT, 1.0f).floatValue() * DEFAULT_SYMBOL_SIZE);
int centerX = imageWidth / 2;
int centerY = imageHeight / 2;
Color prevBg = gc.getBackground();
Color prevFg = gc.getForeground();
switch(symbolStyle) {
case StyleProperties.SymbolType.CIRCLE:
SymbolHelper.drawCircle(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.DIAMOND:
SymbolHelper.drawDiamond(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.SQUARE:
SymbolHelper.drawSquare(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.CROSS:
SymbolHelper.drawCross(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.PLUS:
SymbolHelper.drawPlus(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.INVERTED_TRIANGLE:
SymbolHelper.drawInvertedTriangle(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.TRIANGLE:
SymbolHelper.drawTriangle(gc, lineColor, symbolSize, centerX, centerY);
break;
default:
// Default is nothing
break;
}
gc.setForeground(prevFg);
gc.setBackground(prevBg);
}
use of org.eclipse.tracecompass.internal.provisional.tmf.ui.viewers.xychart.BaseXYPresentationProvider in project tracecompass by tracecompass.
the class XYChartLegendImageProvider method drawStyleLine.
private void drawStyleLine(GC gc, Color lineColor, int imageWidth, int imageHeight, @NonNull OutputElementStyle appearance) {
Color prev = gc.getForeground();
BaseXYPresentationProvider presProvider = fChartViewer.getPresentationProvider();
LineStyle lineStyle = LineStyle.valueOf((String) presProvider.getStyleOrDefault(appearance, StyleProperties.SERIES_STYLE, StyleProperties.SeriesStyle.SOLID));
if (lineStyle != LineStyle.NONE) {
gc.setForeground(lineColor);
gc.setLineWidth(((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.WIDTH, 1.0f)).intValue());
gc.setLineStyle(lineStyle.ordinal());
gc.drawLine(0, imageHeight / 2, imageWidth, imageHeight / 2);
gc.setForeground(prev);
}
}
Aggregations