use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class SeriesSet method updateStackAndRiserData.
/**
* Updates the stack and riser data for given axes.
*
* @param xAxis
* the X axis
* @param yAxis
* the Y axis
*/
private void updateStackAndRiserData(IAxis xAxis, IAxis yAxis) {
int riserCnt = 0;
int stackRiserPosition = -1;
double[] stackBarSeries = null;
double[] stackLineSeries = null;
if (((Axis) xAxis).isValidCategoryAxis()) {
String[] categorySeries = xAxis.getCategorySeries();
if (categorySeries != null) {
int size = categorySeries.length;
stackBarSeries = new double[size];
stackLineSeries = new double[size];
}
}
for (ISeries series : getSeries()) {
if (series.getXAxisId() != xAxis.getId() || series.getYAxisId() != yAxis.getId() || !series.isVisible()) {
continue;
}
if (series.isStackEnabled() && !chart.getAxisSet().getYAxis(series.getYAxisId()).isLogScaleEnabled() && ((Axis) xAxis).isValidCategoryAxis()) {
if (series.getType() == SeriesType.BAR) {
if (stackRiserPosition == -1) {
stackRiserPosition = riserCnt;
riserCnt++;
}
((BarSeries) series).setRiserIndex(((Axis) xAxis).getNumRisers() + stackRiserPosition);
setStackSeries(stackBarSeries, series);
} else if (series.getType() == SeriesType.LINE) {
setStackSeries(stackLineSeries, series);
}
} else {
if (series.getType() == SeriesType.BAR) {
((BarSeries) series).setRiserIndex(((Axis) xAxis).getNumRisers() + riserCnt++);
}
}
}
((Axis) xAxis).setNumRisers(((Axis) xAxis).getNumRisers() + riserCnt);
}
use of org.eclipse.swtchart.IAxis in project tracecompass by tracecompass.
the class SWTBotCustomChartUtils method assertAxisRange.
/**
* Verify that the internal range of the axis corresponds to the expected
* values. This method should be called on axis using numerical or time
* stamp formatters
*
* @param chart
* The chart to verify
* @param axisType
* The axis to test for
* @param min
* The minimum range value
* @param max
* The maximum range value
*/
public static void assertAxisRange(Chart chart, AxisType axisType, Number min, Number max) {
IAxis axis = (axisType == AxisType.X ? chart.getAxisSet().getXAxes()[0] : chart.getAxisSet().getYAxes()[0]);
Format format = axis.getTick().getFormat();
// Get the range map for the format, it has to have one
ChartRangeMap map = null;
if (format instanceof ChartTimeStampFormat) {
map = ((ChartTimeStampFormat) format).getRangeMap();
} else if (format instanceof ChartDecimalUnitFormat) {
map = ((ChartDecimalUnitFormat) format).getRangeMap();
}
assertNotNull(map);
ChartRange inputDataRange = map.getInputDataRange();
assertEquals(min.doubleValue(), inputDataRange.getMinimum().doubleValue(), 1);
assertEquals(max.doubleValue(), inputDataRange.getMaximum().doubleValue(), 1);
}
use of org.eclipse.swtchart.IAxis in project tracecompass by tracecompass.
the class SWTBotCustomChartUtils method assertAxisLogscale.
/**
* Verify an axis log scale status
*
* @param chart
* The chart to verify
* @param axisType
* The axis to test for
* @param logscale
* <code>true</code> if this axis should be logscale,
* <code>false</code> otherwise
*/
public static void assertAxisLogscale(Chart chart, AxisType axisType, boolean logscale) {
IAxis axis = (axisType == AxisType.X ? chart.getAxisSet().getXAxes()[0] : chart.getAxisSet().getYAxes()[0]);
assertEquals("Log scale", logscale, axis.isLogScaleEnabled());
}
use of org.eclipse.swtchart.IAxis in project tracecompass by tracecompass.
the class TmfXYChartViewer method getPointAreaWidth.
/**
* Get the width of the point area. We consider the point area to be from where
* the first point could be drawn to where the last point could be drawn. The
* point area differs from the plot area because there might be a gap between
* where the plot area start and where the fist point is drawn. This also
* matches the width that the use can select.
*
* @return the width in pixels
*/
public int getPointAreaWidth() {
IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes();
if (xAxes.length > 0) {
IAxis axis = xAxes[0];
int x1 = getPointAreaOffset();
int x2 = axis.getPixelCoordinate(axis.getRange().upper);
x2 = getSwtChart().toControl(((Composite) fSwtChart.getPlotArea()).toDisplay(x2, 0)).x;
int width = x2 - x1;
return width;
}
return getSwtChart().getPlotArea().getSize().x;
}
use of org.eclipse.swtchart.IAxis in project tracecompass by tracecompass.
the class TmfXYChartViewer method getPointAreaOffset.
/**
* Get the offset of the point area, relative to the XY chart viewer control. We
* consider the point area to be from where the first point could be drawn to
* where the last point could be drawn.
*
* @return the offset in pixels
*/
public int getPointAreaOffset() {
int pixelCoordinate = 0;
IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes();
if (xAxes.length > 0) {
IAxis axis = xAxes[0];
pixelCoordinate = axis.getPixelCoordinate(axis.getRange().lower);
}
return getSwtChart().toControl(((Composite) fSwtChart.getPlotArea()).toDisplay(pixelCoordinate, 0)).x;
}
Aggregations