Search in sources :

Example 1 with Position

use of org.eclipse.swtchart.IAxis.Position in project swtchart by eclipse.

the class AxisTick method getBounds.

/*
	 * @see IAxisTick#getBounds()
	 */
public Rectangle getBounds() {
    Rectangle r1 = axisTickMarks.getBounds();
    Rectangle r2 = axisTickLabels.getBounds();
    Position position = axis.getPosition();
    if (position == Position.Primary && axis.isHorizontalAxis()) {
        return new Rectangle(r1.x, r1.y, r1.width, r1.height + r2.height);
    } else if (position == Position.Secondary && axis.isHorizontalAxis()) {
        return new Rectangle(r1.x, r2.y, r1.width, r1.height + r2.height);
    } else if (position == Position.Primary && !axis.isHorizontalAxis()) {
        return new Rectangle(r2.x, r1.y, r1.width + r2.width, r1.height);
    } else if (position == Position.Secondary && !axis.isHorizontalAxis()) {
        return new Rectangle(r1.x, r1.y, r1.width + r2.width, r1.height);
    } else {
        throw new IllegalStateException("unknown axis position");
    }
}
Also used : Position(org.eclipse.swtchart.IAxis.Position) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 2 with Position

use of org.eclipse.swtchart.IAxis.Position in project swtchart by eclipse.

the class ChartLayout method initAxisSize.

/**
 * Initializes the size of axes.
 */
private void initAxisSize() {
    axisLayoutDataMap.clear();
    for (Axis axis : axes) {
        AxisLayoutData layoutData = new AxisLayoutData(axis);
        if (layoutData.titleLayoutdata == null || layoutData.tickLabelsLayoutdata == null || layoutData.tickMarksLayoutdata == null) {
            continue;
        }
        axisLayoutDataMap.put(axis, layoutData);
        Position position = axis.getPosition();
        if (position == Position.Primary && axis.isHorizontalAxis()) {
            bottomAxisHeight += layoutData.titleLayoutdata.heightHint + layoutData.tickLabelsLayoutdata.heightHint + layoutData.tickMarksLayoutdata.heightHint;
        } else if (position == Position.Secondary && axis.isHorizontalAxis()) {
            topAxisHeight += layoutData.titleLayoutdata.heightHint + layoutData.tickLabelsLayoutdata.heightHint + layoutData.tickMarksLayoutdata.heightHint;
        } else if (position == Position.Primary && !axis.isHorizontalAxis()) {
            leftAxisWidth += layoutData.titleLayoutdata.widthHint + layoutData.tickLabelsLayoutdata.widthHint + layoutData.tickMarksLayoutdata.widthHint;
        } else if (position == Position.Secondary && !axis.isHorizontalAxis()) {
            rightAxisWidth += layoutData.titleLayoutdata.widthHint + layoutData.tickLabelsLayoutdata.widthHint + layoutData.tickMarksLayoutdata.widthHint;
        }
    }
}
Also used : Position(org.eclipse.swtchart.IAxis.Position) IAxis(org.eclipse.swtchart.IAxis) Axis(org.eclipse.swtchart.internal.axis.Axis)

Example 3 with Position

use of org.eclipse.swtchart.IAxis.Position 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);
        }
    }
}
Also used : Position(org.eclipse.swtchart.IAxis.Position) IAxis(org.eclipse.swtchart.IAxis) Axis(org.eclipse.swtchart.internal.axis.Axis)

Aggregations

Position (org.eclipse.swtchart.IAxis.Position)3 IAxis (org.eclipse.swtchart.IAxis)2 Axis (org.eclipse.swtchart.internal.axis.Axis)2 Rectangle (org.eclipse.swt.graphics.Rectangle)1