use of org.eclipse.swtchart.internal.axis.Axis in project swtchart by eclipse.
the class ChartLayout method adjustForMostLeftRightTickLabel.
/**
* Adjust the axis size for most left/right tick label.
*
* @param r
* the rectangle to layout
*/
private void adjustForMostLeftRightTickLabel(Rectangle r) {
// get axis margin hint
int rightAxisMarginHint = 0;
int leftAxisMarginHint = 0;
for (IAxis axis : horizontalAxes) {
if (!axis.getTick().isVisible()) {
continue;
}
rightAxisMarginHint = Math.max(rightAxisMarginHint, ((Axis) axis).getTick().getAxisTickLabels().getRightMarginHint(plotAreaWidth));
leftAxisMarginHint = Math.max(leftAxisMarginHint, ((Axis) axis).getTick().getAxisTickLabels().getLeftMarginHint(plotAreaWidth));
}
// have space to draw most right tick label on horizontal axis
if ((legendWidth == 0 || legend.getPosition() != SWT.RIGHT) && rightAxisWidth < rightAxisMarginHint) {
rightAxisWidth = rightAxisMarginHint;
computePlotAreaSize(r);
updateHorizontalAxisTick();
}
// have space to draw most left tick label on horizontal axis
if ((legendWidth == 0 || legend.getPosition() != SWT.LEFT) && leftAxisWidth < leftAxisMarginHint) {
leftAxisWidth = leftAxisMarginHint;
computePlotAreaSize(r);
updateHorizontalAxisTick();
}
}
use of org.eclipse.swtchart.internal.axis.Axis in project swtchart by eclipse.
the class ChartLayout method layoutAxes.
/**
* Layouts the axes.
*
* @param r
* the rectangle to layout
*/
private void layoutAxes(Rectangle r) {
bottomAxisOffset = 0;
topAxisOffset = 0;
leftAxisOffset = 0;
rightAxisOffset = 0;
for (Axis axis : axes) {
AxisLayoutData layoutData = axisLayoutDataMap.get(axis);
Position position = axis.getPosition();
if (position == Position.Primary && axis.isHorizontalAxis()) {
layoutBottomAxis(r, layoutData);
} else if (position == Position.Secondary && axis.isHorizontalAxis()) {
layoutTopAxis(r, layoutData);
} else if (position == Position.Primary && !axis.isHorizontalAxis()) {
layoutLeftAxis(r, layoutData);
} else if (position == Position.Secondary && !axis.isHorizontalAxis()) {
layoutRightAxis(r, layoutData);
}
}
}
use of org.eclipse.swtchart.internal.axis.Axis in project swtchart by eclipse.
the class Series method getYRange.
/**
* Gets the Y range of series.
*
* @return the Y range of series
*/
public Range getYRange() {
double min = minY;
double max = maxY;
Axis xAxis = (Axis) chart.getAxisSet().getXAxis(xAxisId);
if (isValidStackSeries() && xAxis.isValidCategoryAxis()) {
for (int i = 0; i < stackSeries.length; i++) {
if (max < stackSeries[i]) {
max = stackSeries[i];
}
}
}
return new Range(min, max);
}
use of org.eclipse.swtchart.internal.axis.Axis in project swtchart by eclipse.
the class BarSeries method getBounds.
/*
* @see IBarSeries#getBounds()
*/
public Rectangle[] getBounds() {
Rectangle[] compressedBounds = getBoundsForCompressedSeries();
if (((Axis) chart.getAxisSet().getXAxis(xAxisId)).isValidCategoryAxis()) {
return compressedBounds;
}
Rectangle[] rs = new Rectangle[xSeries.length];
double[] comporessedXSeries = compressor.getCompressedXSeries();
int cnt = 0;
for (int i = 0; i < xSeries.length; i++) {
if (cnt < comporessedXSeries.length && comporessedXSeries[cnt] == xSeries[i]) {
if (compressedBounds[cnt].width != 0 && compressedBounds[cnt].height != 0) {
rs[i] = compressedBounds[cnt];
}
cnt++;
}
}
return rs;
}
use of org.eclipse.swtchart.internal.axis.Axis in project swtchart by eclipse.
the class SeriesSet method createSeries.
/*
* @see ISeriesSet#createSeries(ISeries.SeriesType, String)
*/
public ISeries createSeries(SeriesType type, String id) {
if (id == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
// to suppress warning...
return null;
}
String trimmedId = id.trim();
if ("".equals(trimmedId)) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
Series series = null;
if (type == SeriesType.BAR) {
series = new BarSeries(chart, trimmedId);
} else if (type == SeriesType.LINE) {
series = new LineSeries(chart, trimmedId);
} else {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
// to suppress warning...
return null;
}
Series oldSeries = seriesMap.get(trimmedId);
if (oldSeries != null) {
oldSeries.dispose();
}
int[] xAxisIds = chart.getAxisSet().getXAxisIds();
int[] yAxisIds = chart.getAxisSet().getYAxisIds();
series.setXAxisId(xAxisIds[0]);
series.setYAxisId(yAxisIds[0]);
seriesMap.put(trimmedId, series);
Axis axis = (Axis) chart.getAxisSet().getXAxis(xAxisIds[0]);
if (axis != null) {
updateStackAndRiserData();
}
// legend will be shown if there is previously no series.
chart.updateLayout();
return series;
}
Aggregations