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");
}
}
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;
}
}
}
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);
}
}
}