use of org.eclipse.swtchart.extensions.barcharts.IBarSeriesSettings in project swtchart by eclipse.
the class BaseChart method applySeriesSettings.
private void applySeriesSettings(ISeries dataSeries, ISeriesSettings seriesSettings) {
if (dataSeries instanceof ILineSeries) {
ILineSeries lineSeries = (ILineSeries) dataSeries;
if (seriesSettings instanceof ILineSeriesSettings) {
/*
* Line Series
*/
ILineSeriesSettings lineSeriesSettings = (ILineSeriesSettings) seriesSettings;
applyLineSeriesSettings(lineSeries, lineSeriesSettings);
} else if (seriesSettings instanceof IScatterSeriesSettings) {
/*
* Scatter Series
*/
IScatterSeriesSettings scatterSeriesSettings = (IScatterSeriesSettings) seriesSettings;
applyScatterSeriesSettings(lineSeries, scatterSeriesSettings);
}
} else if (dataSeries instanceof IBarSeries) {
/*
* Bar Series
*/
IBarSeries barSeries = (IBarSeries) dataSeries;
IBarSeriesSettings barSeriesSettings = (IBarSeriesSettings) seriesSettings;
applyBarSeriesSettings(barSeries, barSeriesSettings);
}
}
use of org.eclipse.swtchart.extensions.barcharts.IBarSeriesSettings in project swtchart by eclipse.
the class ImageFactory_2_UITest method test1.
public void test1() {
try {
/*
* Create the factory.
*/
ImageFactory<MassSpectrumChart> imageFactory = new ImageFactory<MassSpectrumChart>(MassSpectrumChart.class, 800, 600);
/*
* Modify the chart.
*/
MassSpectrumChart massSpectrumChart = imageFactory.getChart();
massSpectrumChart.setBackground(massSpectrumChart.getBaseChart().getDisplay().getSystemColor(SWT.COLOR_WHITE));
List<IBarSeriesData> barSeriesDataList = new ArrayList<IBarSeriesData>();
ISeriesData seriesData = SeriesConverter.getSeriesXY(TestPathHelper.getAbsolutePath(TestPathHelper.TESTFILE_BAR_SERIES_1));
//
IBarSeriesData barSeriesData = new BarSeriesData(seriesData);
IBarSeriesSettings barSeriesSettings = barSeriesData.getBarSeriesSettings();
barSeriesSettings.setDescription("");
barSeriesDataList.add(barSeriesData);
massSpectrumChart.addSeriesData(barSeriesDataList);
/*
* Export the images.
*/
String exportFolder = TestPathHelper.getAbsolutePath(TestPathHelper.TESTFOLDER_EXPORT);
String prefix = "BarSeries1";
//
String png = exportFolder + File.separator + prefix + ".png";
imageFactory.saveImage(png, SWT.IMAGE_PNG);
File filePng = new File(png);
assertTrue(filePng.exists());
filePng.delete();
//
String jpg = exportFolder + File.separator + prefix + ".jpg";
imageFactory.saveImage(jpg, SWT.IMAGE_JPEG);
File fileJpg = new File(jpg);
assertTrue(fileJpg.exists());
fileJpg.delete();
//
String bmp = exportFolder + File.separator + prefix + ".bmp";
imageFactory.saveImage(bmp, SWT.IMAGE_BMP);
File fileBmp = new File(bmp);
assertTrue(fileBmp.exists());
fileBmp.delete();
//
imageFactory.closeShell();
//
} catch (InstantiationException e) {
System.out.println(e);
} catch (IllegalAccessException e) {
System.out.println(e);
}
}
use of org.eclipse.swtchart.extensions.barcharts.IBarSeriesSettings in project swtchart by eclipse.
the class BarSeries_Preferences_Part method applySeriesSettings.
private void applySeriesSettings() {
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
Color barColorSeries1 = getColor(PreferenceConverter.getColor(preferenceStore, BarSeriesPreferenceConstants.P_BAR_COLOR_SERIES_1));
Color barColorSeries1Highlight = getColor(PreferenceConverter.getColor(preferenceStore, BarSeriesPreferenceConstants.P_BAR_COLOR_SERIES_1_HIGHLIGHT));
//
barChart.deleteSeries();
List<IBarSeriesData> barSeriesDataList = new ArrayList<IBarSeriesData>();
ISeriesData seriesData;
IBarSeriesData barSeriesData;
IBarSeriesSettings barSeriesSettings;
/*
* Series 1
*/
seriesData = SeriesConverter.getSeriesXY(SeriesConverter.BAR_SERIES_1);
barSeriesData = new BarSeriesData(seriesData);
barSeriesSettings = barSeriesData.getBarSeriesSettings();
barSeriesSettings.setDescription(preferenceStore.getString(BarSeriesPreferenceConstants.P_DESCRIPTION_SERIES_1));
//
barSeriesSettings.setVisible(preferenceStore.getBoolean(BarSeriesPreferenceConstants.P_VISIBLE_SERIES_1));
barSeriesSettings.setVisibleInLegend(preferenceStore.getBoolean(BarSeriesPreferenceConstants.P_VISIBLE_IN_LEGEND_SERIES_1));
barSeriesSettings.setBarColor(barColorSeries1);
barSeriesSettings.setBarPadding(preferenceStore.getInt(BarSeriesPreferenceConstants.P_BAR_PADDING_SERIES_1));
barSeriesSettings.setBarWidth(preferenceStore.getInt(BarSeriesPreferenceConstants.P_BAR_WIDTH_SERIES_1));
barSeriesSettings.setBarWidthStyle(BarWidthStyle.valueOf(preferenceStore.getString(BarSeriesPreferenceConstants.P_BAR_WIDTH_STYLE_SERIES_1)));
//
IBarSeriesSettings barSeriesSettingsHighlight = (IBarSeriesSettings) barSeriesSettings.getSeriesSettingsHighlight();
barSeriesSettingsHighlight.setVisible(preferenceStore.getBoolean(BarSeriesPreferenceConstants.P_VISIBLE_SERIES_1_HIGHLIGHT));
barSeriesSettingsHighlight.setVisibleInLegend(preferenceStore.getBoolean(BarSeriesPreferenceConstants.P_VISIBLE_IN_LEGEND_SERIES_1_HIGHLIGHT));
barSeriesSettingsHighlight.setBarColor(barColorSeries1Highlight);
barSeriesSettingsHighlight.setBarPadding(preferenceStore.getInt(BarSeriesPreferenceConstants.P_BAR_PADDING_SERIES_1_HIGHLIGHT));
barSeriesSettingsHighlight.setBarWidth(preferenceStore.getInt(BarSeriesPreferenceConstants.P_BAR_WIDTH_SERIES_1_HIGHLIGHT));
barSeriesSettingsHighlight.setBarWidthStyle(BarWidthStyle.valueOf(preferenceStore.getString(BarSeriesPreferenceConstants.P_BAR_WIDTH_STYLE_SERIES_1_HIGHLIGHT)));
//
barSeriesDataList.add(barSeriesData);
//
barChart.addSeriesData(barSeriesDataList);
}
use of org.eclipse.swtchart.extensions.barcharts.IBarSeriesSettings in project swtchart by eclipse.
the class BarSeries_3_Part method initialize.
private void initialize() {
IChartSettings chartSettings = getChartSettings();
RangeRestriction rangeRestriction = chartSettings.getRangeRestriction();
rangeRestriction.setExtendTypeY(RangeRestriction.ExtendType.RELATIVE);
rangeRestriction.setExtendMinY(0.1d);
applySettings(chartSettings);
//
setNumberOfHighestIntensitiesToLabel(5);
setLabelOption(LabelOption.NOMIMAL);
setCustomLabels(null);
/*
* Create series.
*/
List<IBarSeriesData> barSeriesDataList = new ArrayList<IBarSeriesData>();
ISeriesData seriesData;
IBarSeriesData barSeriesData;
IBarSeriesSettings barSeriesSettings;
/*
* Positive
*/
seriesData = SeriesConverter.getSeriesXY(SeriesConverter.BAR_SERIES_3_POSITIVE);
barSeriesData = new BarSeriesData(seriesData);
barSeriesSettings = barSeriesData.getBarSeriesSettings();
barSeriesSettings.setBarColor(getDisplay().getSystemColor(SWT.COLOR_RED));
barSeriesDataList.add(barSeriesData);
/*
* Negative
*/
seriesData = SeriesConverter.getSeriesXY(SeriesConverter.BAR_SERIES_3_NEGATIVE);
barSeriesData = new BarSeriesData(seriesData);
barSeriesSettings = barSeriesData.getBarSeriesSettings();
barSeriesSettings.setBarColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
barSeriesDataList.add(barSeriesData);
/*
* Set series.
*/
addSeriesData(barSeriesDataList);
}
Aggregations