use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class LineSeries_Edit_Part method createButtonDown.
private void createButtonDown(Composite parent) {
Button button = new Button(parent, SWT.PUSH);
button.setToolTipText("Move Down");
button.setText(Activator.getDefault() != null ? "" : "Move Down");
button.setImage(Activator.getDefault() != null ? Activator.getDefault().getImage(Activator.ICON_DOWN) : null);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BaseChart baseChart = chromatogramChart.getBaseChart();
double shiftY = getShift(IExtendedChart.Y_AXIS) * -1.0d;
String selectedSeriesId = comboSelectSeries.getText().trim();
baseChart.shiftSeries(selectedSeriesId, 0.0d, shiftY);
baseChart.redraw();
}
});
}
use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class ScatterSeries_Edit_Part method createButtonReset.
private void createButtonReset(Composite parent) {
Button button = new Button(parent, SWT.PUSH);
button.setToolTipText("Reset the data");
button.setText(Activator.getDefault() != null ? "" : "Reset");
button.setImage(Activator.getDefault() != null ? Activator.getDefault().getImage(Activator.ICON_RESET) : null);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
isCustomSelection = false;
BaseChart baseChart = handledChart.getBaseChart();
baseChart.resetSeriesSettings();
enableButtons();
}
});
}
use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class BarChart method addSeriesData.
/**
* BarWidthStyle.STRETCHED will be used automatically instead of BarWidthStyle.FIXED
* if the series data is too large. This leads to a better performance.
*
* @param barSeriesDataList
*/
public void addSeriesData(List<IBarSeriesData> barSeriesDataList, int compressToLength) {
/*
* Suspend the update when adding new data to improve the performance.
*/
if (barSeriesDataList != null && barSeriesDataList.size() > 0) {
BaseChart baseChart = getBaseChart();
baseChart.suspendUpdate(true);
for (IBarSeriesData barSeriesData : barSeriesDataList) {
/*
* Get the series data and apply the settings.
*/
try {
ISeriesData seriesData = barSeriesData.getSeriesData();
ISeriesData optimizedSeriesData = calculateSeries(seriesData, compressToLength);
IBarSeriesSettings barSeriesSettings = barSeriesData.getBarSeriesSettings();
// Initialize
barSeriesSettings.getSeriesSettingsHighlight();
IBarSeries barSeries = (IBarSeries) createSeries(optimizedSeriesData, barSeriesSettings);
baseChart.applyBarSeriesSettings(barSeries, barSeriesSettings);
/*
* Automatically use stretched if it is a large data set.
*/
if (isLargeDataSet(optimizedSeriesData.getXSeries(), optimizedSeriesData.getYSeries(), LENGTH_HINT_DATA_POINTS)) {
barSeries.setBarWidthStyle(BarWidthStyle.STRETCHED);
} else {
barSeries.setBarWidthStyle(barSeriesSettings.getBarWidthStyle());
}
} 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 LaTeXTableExportHandler method execute.
@Override
public void execute(Shell shell, ScrollableChart scrollableChart) {
BaseChart baseChart = scrollableChart.getBaseChart();
/*
* Select the export file.
*/
FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
fileDialog.setOverwrite(true);
fileDialog.setText(TITLE);
fileDialog.setFilterExtensions(new String[] { FILE_EXTENSION });
//
String fileName = fileDialog.open();
if (fileName != null) {
/*
* Select the X and Y axis to export.
*/
ExportSettingsDialog exportSettingsDialog = new ExportSettingsDialog(shell, baseChart);
exportSettingsDialog.create();
if (exportSettingsDialog.open() == Window.OK) {
//
int indexAxisX = exportSettingsDialog.getIndexAxisSelectionX();
int indexAxisY = exportSettingsDialog.getIndexAxisSelectionY();
//
if (indexAxisX >= 0 && indexAxisY >= 0) {
/*
* X Axis Settings
*/
IAxisSettings axisSettingsX = baseChart.getXAxisSettings(indexAxisX);
IAxisScaleConverter axisScaleConverterX = null;
if (axisSettingsX instanceof ISecondaryAxisSettings) {
ISecondaryAxisSettings secondaryAxisSettings = (ISecondaryAxisSettings) axisSettingsX;
axisScaleConverterX = secondaryAxisSettings.getAxisScaleConverter();
}
/*
* Y Axis Settings
*/
IAxisSettings axisSettingsY = baseChart.getYAxisSettings(indexAxisY);
IAxisScaleConverter axisScaleConverterY = null;
if (axisSettingsY instanceof ISecondaryAxisSettings) {
ISecondaryAxisSettings secondaryAxisSettings = (ISecondaryAxisSettings) axisSettingsY;
axisScaleConverterY = secondaryAxisSettings.getAxisScaleConverter();
}
/*
* Print the XY data.
*/
PrintWriter printWriter = null;
try {
printWriter = new PrintWriter(new File(fileName));
/*
* Header
*/
printWriter.println("\\begin{center}");
printWriter.println("\\begin{tabular}{ c c }");
//
printWriter.print(TAB);
printWriter.print(axisSettingsX.getLabel());
printWriter.print(DELIMITER);
printWriter.print(axisSettingsY.getLabel());
printWriter.println(LINE_END);
/*
* Axis settings.
*/
boolean exportVisibleOnly = exportSettingsDialog.isExportVisibleOnly();
AxisSettings axisSettings = new AxisSettings();
axisSettings.setIndexAxisX(indexAxisX);
axisSettings.setIndexAxisY(indexAxisY);
axisSettings.setAxisSettingsX(axisSettingsX);
axisSettings.setAxisScaleConverterX(axisScaleConverterX);
axisSettings.setAxisSettingsY(axisSettingsY);
axisSettings.setAxisScaleConverterY(axisScaleConverterY);
axisSettings.setExportVisibleOnly(exportVisibleOnly);
/*
* Data
*/
int widthPlotArea = baseChart.getPlotArea().getBounds().width;
ISeries[] series = baseChart.getSeriesSet().getSeries();
for (ISeries dataSeries : series) {
if (dataSeries != null) {
if (exportVisibleOnly) {
if (dataSeries.isVisible()) {
exportSeries(dataSeries, widthPlotArea, axisSettings, printWriter);
}
} else {
exportSeries(dataSeries, widthPlotArea, axisSettings, printWriter);
}
}
}
//
printWriter.println("\\end{tabular}");
printWriter.println("\\end{center}");
printWriter.flush();
MessageDialog.openInformation(shell, TITLE, MESSAGE_OK);
} catch (FileNotFoundException e) {
MessageDialog.openError(shell, TITLE, MESSAGE_ERROR);
System.out.println(e);
} finally {
if (printWriter != null) {
printWriter.close();
}
}
}
}
}
}
use of org.eclipse.swtchart.extensions.core.BaseChart in project swtchart by eclipse.
the class RScriptExportHandler method printScatterPlot.
private void printScatterPlot(String fileName, PrintWriter printWriter, ScrollableChart scrollableChart, AxisSettings axisSettings) {
IAxisSettings axisSettingsX = axisSettings.getAxisSettingsX();
IAxisSettings axisSettingsY = axisSettings.getAxisSettingsY();
boolean exportVisibleOnly = axisSettings.isExportVisibleOnly();
//
BaseChart baseChart = scrollableChart.getBaseChart();
ISeries[] series = baseChart.getSeriesSet().getSeries();
/*
* Read from script.
*/
printExecuteInfo(fileName, printWriter);
/*
* Header
*/
printWriter.println("# Header");
printWriter.println("scatter_labels <- NULL");
printWriter.println("x_values <- NULL");
printWriter.println("y_values <- NULL");
printWriter.println("");
/*
* Data
*/
printWriter.println("# Data");
int widthPlotArea = baseChart.getPlotArea().getBounds().width;
for (ISeries dataSeries : series) {
if (dataSeries != null) {
if (exportVisibleOnly) {
if (dataSeries.isVisible()) {
printScatterData(dataSeries, widthPlotArea, axisSettings, printWriter);
}
} else {
printScatterData(dataSeries, widthPlotArea, axisSettings, printWriter);
}
}
}
printWriter.println("");
/*
* Footer
*/
printWriter.println("# Footer");
printWriter.println("plot_data<-cbind(x_values, y_values)");
printWriter.println("plot(plot_data, xlab=\"" + axisSettingsX.getLabel() + "\", ylab=\"" + axisSettingsY.getLabel() + "\")");
printWriter.println("text(plot_data[,1], plot_data[,2], scatter_labels, pos=3)");
printWriter.println("abline(h=0)");
printWriter.println("abline(v=0)");
}
Aggregations