use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class Axis method zoomOut.
/*
* @see IAxis#zoomOut(double)
*/
public void zoomOut(double coordinate) {
double lower = min;
double upper = max;
if (isValidCategoryAxis()) {
if ((min + max) / 2d < coordinate && min != 0) {
lower = min - 1;
} else if (coordinate < (min + max) / 2d && max != categorySeries.length - 1) {
upper = max + 1;
} else {
lower = min - 1;
upper = max + 1;
}
} else if (isLogScaleEnabled()) {
double digitMin = Math.log10(min);
double digitMax = Math.log10(max);
double digitCoordinate = Math.log10(coordinate);
lower = Math.pow(10, (digitMin - ZOOM_RATIO * digitCoordinate) / (1 - ZOOM_RATIO));
upper = Math.pow(10, (digitMax - ZOOM_RATIO * digitCoordinate) / (1 - ZOOM_RATIO));
} else {
lower = (min - 2 * ZOOM_RATIO * coordinate) / (1 - 2 * ZOOM_RATIO);
upper = (max - 2 * ZOOM_RATIO * coordinate) / (1 - 2 * ZOOM_RATIO);
}
setRange(new Range(lower, upper));
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class Axis method scrollUp.
/*
* @see IAxis#scrollUp()
*/
public void scrollUp() {
double lower = min;
double upper = max;
if (isValidCategoryAxis()) {
if (upper < categorySeries.length - 1) {
lower = min + 1;
upper = max + 1;
}
} else if (isLogScaleEnabled()) {
double digitMax = Math.log10(upper);
double digitMin = Math.log10(lower);
upper = Math.pow(10, digitMax + (digitMax - digitMin) * SCROLL_RATIO);
lower = Math.pow(10, digitMin + (digitMax - digitMin) * SCROLL_RATIO);
} else {
lower = min + (max - min) * SCROLL_RATIO;
upper = max + (max - min) * SCROLL_RATIO;
}
setRange(new Range(lower, upper));
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class Axis method scrollDown.
/*
* @see IAxis#scrollDown()
*/
public void scrollDown() {
double lower = min;
double upper = max;
if (isValidCategoryAxis()) {
if (lower >= 1) {
lower = min - 1;
upper = max - 1;
}
} else if (isLogScaleEnabled()) {
double digitMax = Math.log10(upper);
double digitMin = Math.log10(lower);
upper = Math.pow(10, digitMax - (digitMax - digitMin) * SCROLL_RATIO);
lower = Math.pow(10, digitMin - (digitMax - digitMin) * SCROLL_RATIO);
} else {
lower = min - (max - min) * SCROLL_RATIO;
upper = max - (max - min) * SCROLL_RATIO;
}
setRange(new Range(lower, upper));
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class LineSeries method getAdjustedRange.
/*
* @see Series#getAdjustedRange(Axis, int)
*/
@Override
public Range getAdjustedRange(Axis axis, int length) {
Range range;
if (axis.getDirection() == Direction.X) {
range = getXRange();
} else {
range = getYRange();
}
int lowerPlotMargin = getSymbolSize() + MARGIN_AT_MIN_MAX_PLOT;
int upperPlotMargin = getSymbolSize() + MARGIN_AT_MIN_MAX_PLOT;
return getRangeWithMargin(lowerPlotMargin, upperPlotMargin, length, axis, range);
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class Series method getRangeWithMargin.
/**
* Gets the range with given margin.
*
* @param lowerPlotMargin
* the lower margin in pixels
* @param upperPlotMargin
* the upper margin in pixels
* @param length
* the axis length in pixels
* @param axis
* the axis
* @param range
* the range
* @return the range with margin
*/
protected Range getRangeWithMargin(int lowerPlotMargin, int upperPlotMargin, int length, Axis axis, Range range) {
if (length == 0) {
return range;
}
int lowerPixelCoordinate = axis.getPixelCoordinate(range.lower, range.lower, range.upper) + lowerPlotMargin * (axis.isHorizontalAxis() ? -1 : 1);
int upperPixelCoordinate = axis.getPixelCoordinate(range.upper, range.lower, range.upper) + upperPlotMargin * (axis.isHorizontalAxis() ? 1 : -1);
double lower = axis.getDataCoordinate(lowerPixelCoordinate, range.lower, range.upper);
double upper = axis.getDataCoordinate(upperPixelCoordinate, range.lower, range.upper);
return new Range(lower, upper);
}
Aggregations