use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class AbstractExtendedChart method adjustMinMaxRange.
@Override
public void adjustMinMaxRange(IAxis axis) {
if (axis != null && !isUpdateSuspended()) {
Range range = axis.getRange();
if (axis.getDirection().equals(Direction.X)) {
/*
* X-AXIS
*/
if (rangeRestriction.isZeroX()) {
range.lower = (range.lower < 0) ? 0 : range.lower;
} else {
range.lower = (range.lower < minX) ? minX : range.lower;
}
extendRange(IExtendedChart.X_AXIS, range, extendedMinX, extendedMaxX, rangeRestriction.getExtendMinX(), rangeRestriction.getExtendMaxX());
} else {
/*
* Y-AXIS
*/
if (rangeRestriction.isForceZeroMinY()) {
range.lower = 0.0d;
} else {
if (rangeRestriction.isZeroY()) {
range.lower = (range.lower < 0) ? 0 : range.lower;
} else {
range.lower = (range.lower < minY) ? minY : range.lower;
}
}
//
extendRange(IExtendedChart.Y_AXIS, range, extendedMinY, extendedMaxY, rangeRestriction.getExtendMinY(), rangeRestriction.getExtendMaxY());
}
/*
* Adjust the range.
*/
axis.setRange(range);
}
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class AbstractExtendedChart method adjustSecondaryXAxes.
@Override
public void adjustSecondaryXAxes() {
IAxisSet axisSet = getAxisSet();
IAxis xAxis = axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
Range range = xAxis.getRange();
for (int id : axisSet.getXAxisIds()) {
if (id != BaseChart.ID_PRIMARY_X_AXIS) {
IAxis axis = axisSet.getXAxis(id);
IAxisSettings axisSettings = xAxisSettingsMap.get(id);
if (axis != null && axisSettings instanceof ISecondaryAxisSettings) {
IAxisScaleConverter axisScaleConverter = ((ISecondaryAxisSettings) axisSettings).getAxisScaleConverter();
axisScaleConverter.setChartDataCoordinates(this);
double start = axisScaleConverter.convertToSecondaryUnit(range.lower);
double end = axisScaleConverter.convertToSecondaryUnit(range.upper);
if (end > start) {
Range adjustedRange = new Range(start, end);
axis.setRange(adjustedRange);
} else {
System.out.println("Can't set secondary x axes range: " + start + "\t" + end);
}
}
}
}
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class BaseChart method trackUndoSelection.
private void trackUndoSelection() {
Range xRange = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS).getRange();
Range yRange = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS).getRange();
handledSelectionEvents.push(new double[] { xRange.lower, xRange.upper, yRange.lower, yRange.upper });
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class InteractiveChart method setRange.
/**
* Sets the axis range.
*
* @param range
* the axis range in pixels
* @param axis
* the axis to set range
*/
private void setRange(Point range, IAxis axis) {
if (range == null) {
return;
}
double min = axis.getDataCoordinate(range.x);
double max = axis.getDataCoordinate(range.y);
axis.setRange(new Range(min, max));
}
use of org.eclipse.swtchart.Range in project swtchart by eclipse.
the class BaseChart method trackRedoSelection.
private void trackRedoSelection() {
Range xRange = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS).getRange();
Range yRange = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS).getRange();
redoSelection = new double[] { xRange.lower, xRange.upper, yRange.lower, yRange.upper };
}
Aggregations