use of org.eclipse.swtchart.Range in project org.eclipse.linuxtools by eclipse-linuxtools.
the class AbstractChartWithAxisBuilder method applyRangeX.
/**
* Updates the visible range of the chart's x-axis.
* @param min The smallest x-value that should be in range.
* @param max The largest x-value that should be in range.
*/
private void applyRangeX(double min, double max) {
IAxis axis = chart.getAxisSet().getXAxis(0);
double actualRange = max - min;
double scaledRange = actualRange * scale;
double marginL = scaledRange > 0 ? scaledRange * getChartMarginXL() : 1;
double marginU = scaledRange > 0 ? scaledRange * getChartMarginXU() : 1;
double lower = (actualRange - scaledRange) * scroll + min;
axis.setRange(new Range(lower - marginL, lower + scaledRange + marginU));
}
use of org.eclipse.swtchart.Range in project org.eclipse.linuxtools by eclipse-linuxtools.
the class BarChartBuilder method applyCategoryRange.
/**
* This updates the visible range of the chart's x-axis.
*/
private void applyCategoryRange(int numItems) {
// The number of items to display
int itemRange = Math.max(1, (int) Math.ceil(numItems * scale));
int lower = (int) Math.round((numItems - itemRange) * scroll);
chart.getAxisSet().getXAxis(0).setRange(new Range(lower, lower + itemRange - 1));
}
use of org.eclipse.swtchart.Range in project org.eclipse.linuxtools by eclipse-linuxtools.
the class PieChartBuilder method applyCategoryRange.
/**
* This updates the visible range of the chart's x-axis.
*/
private void applyCategoryRange(int numItems) {
// The number of items to display
int itemRange = Math.max(1, (int) Math.ceil(numItems * scale));
int lower = (int) Math.round((numItems - itemRange) * scroll);
chart.getAxisSet().getXAxis(0).setRange(new Range(lower, lower + itemRange - 1));
}
use of org.eclipse.swtchart.Range in project org.eclipse.linuxtools by eclipse-linuxtools.
the class BarChart method fitLabels.
/**
* Given an array of label names, return a new set of names that have been trimmed down
* in order to fit in the chart axis without getting cut off.
* @param labels An array of label names that may be trimmed.
* @return A new array containing label names that have been trimmed to fit in the axis display.
*/
private String[] fitLabels(String[] labels) {
Range range = xAxis.getRange();
int maxLabelSize = (int) Math.max(getClientArea().width / (Math.max(range.upper - range.lower, 1) * fontSize), MIN_LABEL_SIZE);
String[] trimlabels = new String[labels.length];
for (int i = 0; i < labels.length; i++) {
if (labels[i].length() > maxLabelSize) {
trimlabels[i] = labels[i].substring(0, maxLabelSize - MIN_LABEL_SIZE).concat(Messages.BarChartBuilder_LabelTrimTag);
} else {
trimlabels[i] = labels[i];
}
}
return trimlabels;
}
use of org.eclipse.swtchart.Range in project tracecompass by tracecompass.
the class PatternScatterChartViewTest method testWithTrace.
/**
* Test the pattern latency scatter graph. This method test if the chart has one
* series and the series has data
*/
@Test
public void testWithTrace() {
// Get the chart viewer and wait for the view to be ready
WaitUtils.waitForJobs();
TmfXYChartViewer chartViewer = getChartViewer();
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
// Check all the items in the tree
final Chart chart = fScatterChart;
assertNotNull(chart);
SWTBotView viewBot = fBot.viewById(VIEW_ID);
SWTBotTreeItem[] items = viewBot.bot().tree().getAllItems();
for (SWTBotTreeItem item : items) {
item.check();
}
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
// Look at the presence of data in the chart
SWTBotChart chartBot = new SWTBotChart(chart);
assertVisible(chartBot);
final Range range = chart.getAxisSet().getXAxes()[0].getRange();
assertEquals(100000000, range.upper - range.lower, 0);
ISeriesSet seriesSet = fScatterChart.getSeriesSet();
assertNotNull(seriesSet);
ISeries<?>[] series = seriesSet.getSeries();
assertNotNull(series);
// Verify that the chart has more than 1 series
assertTrue(series.length > 1);
// Verify that each series has data
for (int i = 0; i < series.length; i++) {
assertTrue("Verifying series " + i, ((IndexedSeriesModel<?>) series[i].getDataModel()).size() > 0);
}
}
Aggregations