use of org.swtchart.internal.axis.Axis in project netxms by netxms.
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]) {
rs[i] = compressedBounds[cnt++];
}
}
return rs;
}
use of org.swtchart.internal.axis.Axis in project netxms by netxms.
the class Series method draw.
/**
* Draws series.
*
* @param gc
* the graphics context
* @param width
* the width to draw series
* @param height
* the height to draw series
*/
public void draw(GC gc, int width, int height) {
if (!visible || width < 0 || height < 0 || xSeries == null || xSeries.length == 0 || ySeries == null || ySeries.length == 0) {
return;
}
Axis xAxis = (Axis) chart.getAxisSet().getXAxis(getXAxisId());
Axis yAxis = (Axis) chart.getAxisSet().getYAxis(getYAxisId());
if (xAxis == null || yAxis == null) {
return;
}
draw(gc, width, height, xAxis, yAxis);
}
use of org.swtchart.internal.axis.Axis in project netxms by netxms.
the class ChartLayout method computeControlSize.
/**
* Computes the size of child controls.
*/
private void computeControlSize() {
titleWidth = ((ChartLayoutData) title.getLayoutData()).widthHint;
titleHeight = ((ChartLayoutData) title.getLayoutData()).heightHint;
legendWidth = ((ChartLayoutData) legend.getLayoutData()).widthHint;
legendHeight = ((ChartLayoutData) legend.getLayoutData()).heightHint;
for (Axis axis : axes) {
AxisLayoutData layoutData = new AxisLayoutData(axis);
if (layoutData.titleLayoutdata == null || layoutData.tickLabelsLayoutdata == null || layoutData.tickMarksLayoutdata == null) {
continue;
}
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.swtchart.internal.axis.Axis in project netxms by netxms.
the class BarSeries method getBoundsForCompressedSeries.
/**
* Gets the array of bar rectangles for compressed series.
*
* @return the array of bar rectangles for compressed series
*/
private Rectangle[] getBoundsForCompressedSeries() {
Axis xAxis = (Axis) chart.getAxisSet().getXAxis(xAxisId);
Axis yAxis = (Axis) chart.getAxisSet().getYAxis(yAxisId);
// get x and y series
double[] xseries = compressor.getCompressedXSeries();
double[] yseries = compressor.getCompressedYSeries();
int[] indexes = compressor.getCompressedIndexes();
if (xAxis.isValidCategoryAxis()) {
for (int i = 0; i < xseries.length; i++) {
xseries[i] = indexes[i];
}
}
Rectangle[] rectangles = new Rectangle[xseries.length];
Range xRange = xAxis.getRange();
Range yRange = yAxis.getRange();
for (int i = 0; i < xseries.length; i++) {
int x = xAxis.getPixelCoordinate(xseries[i]);
int y = yAxis.getPixelCoordinate(isValidStackSeries() ? stackSeries[indexes[i]] : yseries[i]);
double baseYCoordinate = yAxis.getRange().lower > 0 ? yAxis.getRange().lower : 0;
double riserwidth = getRiserWidth(xseries, i, xAxis, xRange.lower, xRange.upper);
double riserHeight = Math.abs(yAxis.getPixelCoordinate(yseries[i], yRange.lower, yRange.upper) - yAxis.getPixelCoordinate(yAxis.isLogScaleEnabled() ? yRange.lower : baseYCoordinate, yRange.lower, yRange.upper));
// adjust riser x coordinate and riser width for multiple series
int riserCnt = xAxis.getNumRisers();
if (riserCnt > 1) {
if (xAxis.isHorizontalAxis()) {
x = (int) (x - riserwidth / 2d + riserwidth / riserCnt * (riserIndex + 0.5));
} else {
x = (int) (x - riserwidth / 2d + riserwidth / riserCnt * (riserCnt - riserIndex - 0.5));
}
riserwidth /= riserCnt;
}
if (xAxis.isHorizontalAxis()) {
// adjust coordinate for negative series
if (y > yAxis.getPixelCoordinate(0)) {
y = yAxis.getPixelCoordinate(0);
}
int width = (int) Math.ceil(riserwidth);
width = (width == 0) ? 1 : width;
rectangles[i] = getVisibleRectangle((int) Math.floor(x - riserwidth / 2d), y, width, (int) riserHeight);
} else {
// adjust coordinate for negative series
if (y < yAxis.getPixelCoordinate(0)) {
y = yAxis.getPixelCoordinate(0);
}
int height = (int) Math.ceil(riserwidth);
height = (height == 0) ? 1 : height;
rectangles[i] = getVisibleRectangle((int) (y - riserHeight), (int) Math.floor(x - riserwidth / 2d), (int) riserHeight, height);
}
}
return rectangles;
}
use of org.swtchart.internal.axis.Axis in project netxms by netxms.
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 = new AxisLayoutData(axis);
if (layoutData.titleLayoutdata == null || layoutData.tickLabelsLayoutdata == null || layoutData.tickMarksLayoutdata == null) {
continue;
}
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);
}
}
}
Aggregations