use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class ChartLayout method adjustForRotatedTickLabels.
/**
* Adjust the axis size for rotated tick labels.
*
* @param r
* the rectangle to layout
*/
private void adjustForRotatedTickLabels(Rectangle r) {
for (IAxis axis : horizontalAxes) {
double angle = axis.getTick().getTickLabelAngle();
if (angle == 0 || !axis.getTick().isVisible()) {
continue;
}
// update tick label height
int tickLabelMaxLength = ((Axis) axis).getTick().getAxisTickLabels().getTickLabelMaxLength();
AxisLayoutData layoutData = axisLayoutDataMap.get(axis);
int height = Axis.MARGIN + (int) (tickLabelMaxLength * Math.sin(Math.toRadians(angle)) + Util.getExtentInGC(layoutData.axisTickLabels.getFont(), null).y * Math.cos(Math.toRadians(angle)));
int delta = height - layoutData.tickLabelsLayoutdata.heightHint;
layoutData.tickLabelsLayoutdata.heightHint = height;
// update axis height
if (axis.getPosition() == Position.Primary) {
bottomAxisHeight += delta;
} else {
topAxisHeight += delta;
}
// update plot area height
computePlotAreaSize(r);
updateVerticalAxisTick();
}
}
use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class ChartLayout method computeAxisSize.
/**
* Computes the size of axes updating tick labels.
*
* @param r
* the rectangle to layout
*/
private void computeAxisSize(Rectangle r) {
// update vertical axis tick labels
updateVerticalAxisTick();
// compute axis width
for (IAxis axis : verticalAxes) {
int tickAreaWidth = Axis.MARGIN;
if (axis.getTick().isVisible()) {
tickAreaWidth = ((Axis) axis).getTick().getAxisTickLabels().getTickLabelMaxLength();
}
AxisLayoutData axisLayout = axisLayoutDataMap.get(axis);
axisLayout.tickLabelsLayoutdata.widthHint += tickAreaWidth;
if (axis.getPosition() == Position.Primary) {
leftAxisWidth += tickAreaWidth;
} else {
rightAxisWidth += tickAreaWidth;
}
}
// compute axis height
for (IAxis axis : horizontalAxes) {
if (axis.getTick().isVisible()) {
continue;
}
if (axis.getPosition() == Position.Primary) {
bottomAxisHeight += Axis.MARGIN;
} else {
topAxisHeight += Axis.MARGIN;
}
}
// update plot area width
computePlotAreaSize(r);
// update horizontal axis tick labels
updateHorizontalAxisTick();
}
use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class SeriesSet method compressAllSeries.
/**
* Compresses all series data.
*/
public void compressAllSeries() {
if (!chart.isCompressEnabled()) {
return;
}
CompressConfig config = new CompressConfig();
final int PRECISION = 2;
Point p = chart.getPlotArea().getSize();
int width = p.x * PRECISION;
int height = p.y * PRECISION;
config.setSizeInPixel(width, height);
for (ISeries series : getSeries()) {
int xAxisId = series.getXAxisId();
int yAxisId = series.getYAxisId();
IAxis xAxis = chart.getAxisSet().getXAxis(xAxisId);
IAxis yAxis = chart.getAxisSet().getYAxis(yAxisId);
if (xAxis == null || yAxis == null) {
continue;
}
Range xRange = xAxis.getRange();
Range yRange = yAxis.getRange();
if (xRange == null || yRange == null) {
continue;
}
double xMin = xRange.lower;
double xMax = xRange.upper;
double yMin = yRange.lower;
double yMax = yRange.upper;
config.setXLogScale(xAxis.isLogScaleEnabled());
config.setYLogScale(yAxis.isLogScaleEnabled());
double lower = xMin - (xMax - xMin) * 0.015;
double upper = xMax + (xMax - xMin) * 0.015;
if (xAxis.isLogScaleEnabled()) {
lower = ((Series) series).getXRange().lower;
}
config.setXRange(lower, upper);
lower = yMin - (yMax - yMin) * 0.015;
upper = yMax + (yMax - yMin) * 0.015;
if (yAxis.isLogScaleEnabled()) {
lower = ((Series) series).getYRange().lower;
}
config.setYRange(lower, upper);
ICompress compressor = ((Series) series).getCompressor();
compressor.compress(config);
}
}
use of org.eclipse.swtchart.IAxis in project netxms by netxms.
the class LineChart method endSelection.
/**
* Selection end handler
*/
private void endSelection() {
if (!selectionActive)
return;
selectionActive = false;
final IPlotArea plotArea = getPlotArea();
plotArea.removeMouseMoveListener(moveListener);
if (selection.isUsableSize()) {
for (IAxis axis : getAxisSet().getAxes()) {
Point range = null;
if ((getOrientation() == SWT.HORIZONTAL && axis.getDirection() == Direction.X) || (getOrientation() == SWT.VERTICAL && axis.getDirection() == Direction.Y)) {
range = selection.getHorizontalRange();
} else {
range = selection.getVerticalRange();
}
if (range != null && range.x != range.y) {
setRange(range, axis);
}
}
zoomedToSelectionX = true;
zoomedToSelectionY = true;
}
selection.dispose();
redraw();
}
use of org.eclipse.swtchart.IAxis in project portfolio by buchen.
the class PieChart method renderLabels.
protected void renderLabels(PaintEvent e) {
for (ISeries<?> series : getSeriesSet().getSeries()) {
if (series instanceof ICircularSeries) {
IAxis xAxis = getAxisSet().getXAxis(series.getXAxisId());
IAxis yAxis = getAxisSet().getYAxis(series.getYAxisId());
List<Node> nodes = ((ICircularSeries<?>) series).getRootNode().getChildren();
if (!nodes.isEmpty()) {
for (Node node : nodes) {
renderNodeLabel(node, (ICircularSeries<?>) series, e.gc, xAxis, yAxis);
}
}
}
}
}
Aggregations