use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class BaseChart method multiplySeries.
/**
* axisId = IExtendedChart.X_AXIS or IExtendedChart.Y_AXIS.
*
* @param selectedSeriesId
* @param axisId
* @param factor
*/
public void multiplySeries(String selectedSeriesId, String axisId, double factor) {
ISeries dataSeries = getSeriesSet().getSeries(selectedSeriesId);
if (dataSeries != null) {
//
double[] xSeries = dataSeries.getXSeries();
double[] ySeries = dataSeries.getYSeries();
//
if (IExtendedChart.X_AXIS.equals(axisId)) {
dataSeries.setXSeries(multiplySeries(xSeries, factor));
} else if (IExtendedChart.Y_AXIS.equals(axisId)) {
dataSeries.setYSeries(multiplySeries(ySeries, factor));
}
//
double seriesMinX = Arrays.stream(xSeries).min().getAsDouble();
double seriesMaxX = Arrays.stream(xSeries).max().getAsDouble();
double seriesMinY = Arrays.stream(ySeries).min().getAsDouble();
double seriesMaxY = Arrays.stream(ySeries).max().getAsDouble();
//
updateCoordinates(seriesMinX, seriesMaxX, seriesMinY, seriesMaxY);
fireSeriesModificationEvent();
}
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class BaseChart method selectSeries.
public void selectSeries(String selectedSeriesId, boolean fireUpdate) {
if (isSeriesContained(selectedSeriesId)) {
ISeries dataSeries = getSeriesSet().getSeries(selectedSeriesId);
ISeriesSettings seriesSettings = getSeriesSettings(selectedSeriesId);
selectedSeriesIds.add(selectedSeriesId);
applySeriesSettings(dataSeries, seriesSettings.getSeriesSettingsHighlight());
if (fireUpdate) {
fireSeriesStatusEvent(selectedSeriesId, ISeriesStatusListener.SELECT);
}
}
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class BaseChart method shiftSeries.
public void shiftSeries(String selectedSeriesId, double shiftX, double shiftY) {
ISeries dataSeries = getSeriesSet().getSeries(selectedSeriesId);
if (dataSeries != null) {
//
if (shiftX != 0.0d || shiftY != 0.0d) {
//
double seriesMinX = Double.MAX_VALUE;
double seriesMaxX = Double.MIN_VALUE;
double seriesMinY = Double.MAX_VALUE;
double seriesMaxY = Double.MIN_VALUE;
//
if (shiftX != 0.0d) {
/*
* Shift X
*/
double[] xSeriesShifted = adjustArray(dataSeries.getXSeries(), shiftX, IExtendedChart.X_AXIS);
dataSeries.setXSeries(xSeriesShifted);
seriesMinX = xSeriesShifted[0];
seriesMaxX = xSeriesShifted[xSeriesShifted.length - 1];
}
//
if (shiftY != 0.0d) {
/*
* Shift Y
*/
double[] ySeriesShifted = adjustArray(dataSeries.getYSeries(), shiftY, IExtendedChart.Y_AXIS);
dataSeries.setYSeries(ySeriesShifted);
seriesMinY = ySeriesShifted[0];
seriesMaxY = ySeriesShifted[ySeriesShifted.length - 1];
}
/*
* Track the shifts.
*/
Range rangeX = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS).getRange();
Range rangeY = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS).getRange();
List<double[]> shiftRecord = getShiftRecord(selectedSeriesId);
shiftRecord.add(new double[] { rangeX.lower, rangeX.upper, shiftX, rangeY.lower, rangeY.upper, shiftY, shiftConstraints });
//
updateCoordinates(seriesMinX, seriesMaxX, seriesMinY, seriesMaxY);
fireSeriesModificationEvent();
}
}
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class BaseChart method resetSeriesSettings.
public void resetSeriesSettings(boolean fireUpdate) {
ISeries[] series = getSeriesSet().getSeries();
//
for (ISeries dataSeries : series) {
ISeriesSettings seriesSettings = getSeriesSettings(dataSeries.getId());
applySeriesSettings(dataSeries, seriesSettings);
}
//
selectedSeriesIds.clear();
redraw();
if (fireUpdate) {
fireSeriesStatusEvent(SELECTED_SERIES_NONE, ISeriesStatusListener.RESET);
}
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class SeriesLabelMarker method paintControl.
@Override
public void paintControl(PaintEvent e) {
if (isDraw()) {
BaseChart baseChart = getBaseChart();
ISeriesSet seriesSet = baseChart.getSeriesSet();
ISeries[] series = seriesSet.getSeries();
for (ISeries serie : series) {
String label = serie.getId();
ISeriesSettings seriesSettings = baseChart.getSeriesSettings(label);
if (seriesSettings.isVisible()) {
/*
* Only draw is series is visible.
*/
int symbolSize = 1;
if (seriesSettings instanceof IPointSeriesSettings) {
symbolSize = ((IPointSeriesSettings) seriesSettings).getSymbolSize();
}
/*
* Draw the label
*/
e.gc.setForeground(getForegroundColor());
for (int i = 0; i < serie.getXSeries().length; i++) {
Point point = serie.getPixelCoordinates(i);
Point labelSize = e.gc.textExtent(label);
e.gc.drawText(label, (int) (point.x - labelSize.x / 2.0d), (int) (point.y - labelSize.y - symbolSize / 2.0d), true);
}
}
}
}
}
Aggregations