use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class LineChart method addSeriesData.
/**
* The data is compressed to the given length.
* If you're unsure which length to set, then use one of the following variables:
*
* HIGH_COMPRESSION
* MEDIUM_COMPRESSION
* LOW_COMPRESSION
* NO_COMPRESSION
*
* @param lineSeriesDataList
* @param compressToLength
*/
public void addSeriesData(List<ILineSeriesData> lineSeriesDataList, int compressToLength) {
/*
* Suspend the update when adding new data to improve the performance.
*/
if (lineSeriesDataList != null && lineSeriesDataList.size() > 0) {
BaseChart baseChart = getBaseChart();
baseChart.suspendUpdate(true);
for (ILineSeriesData lineSeriesData : lineSeriesDataList) {
/*
* Get the series data and apply the settings.
*/
try {
ISeriesData seriesData = lineSeriesData.getSeriesData();
ISeriesData optimizedSeriesData = calculateSeries(seriesData, compressToLength);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
// Initialize
lineSeriesSettings.getSeriesSettingsHighlight();
ILineSeries lineSeries = (ILineSeries) createSeries(optimizedSeriesData, lineSeriesSettings);
baseChart.applyLineSeriesSettings(lineSeries, lineSeriesSettings);
} catch (SeriesException e) {
//
}
}
baseChart.suspendUpdate(false);
adjustRange(true);
baseChart.redraw();
}
}
use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class ScatterChart method addSeriesData.
public void addSeriesData(List<IScatterSeriesData> scatterSeriesDataList) {
/*
* Suspend the update when adding new data to improve the performance.
*/
if (scatterSeriesDataList != null && scatterSeriesDataList.size() > 0) {
/*
* Set the data.
*/
BaseChart baseChart = getBaseChart();
baseChart.suspendUpdate(true);
for (IScatterSeriesData scatterSeriesData : scatterSeriesDataList) {
/*
* Get the series data and apply the settings.
*/
try {
ISeriesData seriesData = scatterSeriesData.getSeriesData();
ISeriesData optimizedSeriesData = calculateSeries(seriesData, ScrollableChart.NO_COMPRESS_TO_LENGTH);
IScatterSeriesSettings scatterSeriesSettings = scatterSeriesData.getScatterSeriesSettings();
// Initialize
scatterSeriesSettings.getSeriesSettingsHighlight();
ILineSeries scatterSeries = (ILineSeries) createSeries(optimizedSeriesData, scatterSeriesSettings);
baseChart.applyScatterSeriesSettings(scatterSeries, scatterSeriesSettings);
} catch (SeriesException e) {
//
}
}
baseChart.suspendUpdate(false);
adjustRange(true);
baseChart.redraw();
}
}
use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class ScatterSeries_Edit_Part method initialize.
private void initialize() {
this.setLayout(new GridLayout(1, true));
tabFolder = new TabFolder(this, SWT.BOTTOM);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
tabFolder.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
tabFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = tabFolder.getSelectionIndex();
if (index == 1) {
table.removeAll();
BaseChart baseChart = handledChart.getBaseChart();
for (String selectedSeriesId : baseChart.getSelectedSeriesIds()) {
addTableRow(table, selectedSeriesId);
}
}
}
});
createChartTabItem();
createTableTabItems();
}
use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class LineSeries_Edit_Part method createButtonRight.
private void createButtonRight(Composite parent) {
Button button = new Button(parent, SWT.PUSH);
button.setToolTipText("Move Right");
button.setText(Activator.getDefault() != null ? "" : "Move Right");
button.setImage(Activator.getDefault() != null ? Activator.getDefault().getImage(Activator.ICON_RIGHT) : null);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BaseChart baseChart = chromatogramChart.getBaseChart();
double shiftX = getShift(IExtendedChart.X_AXIS);
String selectedSeriesId = comboSelectSeries.getText().trim();
baseChart.shiftSeries(selectedSeriesId, shiftX, 0.0d);
baseChart.redraw();
}
});
}
use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class LineSeries_Edit_Part method getShift.
private double getShift(String axis) {
double shiftValue = 0.0d;
try {
/*
* Try to calculate the primary unit.
*/
BaseChart baseChart = chromatogramChart.getBaseChart();
DecimalFormat decimalFormat;
int selectedAxis;
//
if (axis.equals(IExtendedChart.X_AXIS)) {
selectedAxis = comboScaleX.getSelectionIndex();
decimalFormat = baseChart.getDecimalFormat(IExtendedChart.X_AXIS, selectedAxis);
} else {
selectedAxis = comboScaleY.getSelectionIndex();
decimalFormat = baseChart.getDecimalFormat(IExtendedChart.Y_AXIS, selectedAxis);
}
//
double secondaryValue;
if (axis.equals(IExtendedChart.X_AXIS)) {
secondaryValue = decimalFormat.parse(textShiftX.getText().trim()).doubleValue();
} else {
secondaryValue = decimalFormat.parse(textShiftY.getText().trim()).doubleValue();
}
/*
* Convert the range on demand.
*/
if (selectedAxis == 0) {
shiftValue = secondaryValue;
} else {
IAxisScaleConverter axisScaleConverter = baseChart.getAxisScaleConverter(axis, selectedAxis);
shiftValue = axisScaleConverter.convertToPrimaryUnit(secondaryValue);
}
} catch (ParseException e) {
System.out.println(e);
}
//
return shiftValue;
}
Aggregations