use of org.eclipse.swtchart.extensions.core.SeriesData in project swtchart by eclipse.
the class SeriesConverter method getSeriesScatter.
public static List<ISeriesData> getSeriesScatter(String fileName) {
List<ISeriesData> scatterSeriesList = new ArrayList<ISeriesData>();
//
BufferedReader bufferedReader = null;
try {
String line;
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
while ((line = bufferedReader.readLine()) != null) {
String[] values = line.split("\t");
String id = values[0].trim();
double[] xSeries = new double[] { Double.parseDouble(values[1].trim()) };
double[] ySeries = new double[] { Double.parseDouble(values[2].trim()) };
ISeriesData seriesData = new SeriesData(xSeries, ySeries, id);
scatterSeriesList.add(seriesData);
}
} catch (Exception e) {
//
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
//
}
}
}
return scatterSeriesList;
}
use of org.eclipse.swtchart.extensions.core.SeriesData in project swtchart by eclipse.
the class SeriesConverter method getSeriesXY.
public static ISeriesData getSeriesXY(String fileName, String id) {
int size = getNumberOfLines(fileName);
double[] xSeries = new double[size];
double[] ySeries = new double[size];
//
BufferedReader bufferedReader = null;
try {
String line;
int i = 0;
bufferedReader = new BufferedReader(new InputStreamReader(SeriesConverter.class.getResourceAsStream(fileName)));
while ((line = bufferedReader.readLine()) != null) {
if (!line.startsWith("#")) {
String[] values = line.split("\t");
xSeries[i] = Double.parseDouble(values[0].trim());
ySeries[i] = Double.parseDouble(values[1].trim());
i++;
}
}
} catch (Exception e) {
//
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
//
}
}
}
//
ISeriesData seriesData = new SeriesData(xSeries, ySeries, id);
return seriesData;
}
use of org.eclipse.swtchart.extensions.core.SeriesData in project swtchart by eclipse.
the class SeriesConverter method getSeriesFromY.
public static ISeriesData getSeriesFromY(String fileName) {
int size = getNumberOfLines(fileName);
double[] ySeries = new double[size];
//
BufferedReader bufferedReader = null;
try {
String line;
int i = 0;
bufferedReader = new BufferedReader(new InputStreamReader(SeriesConverter.class.getResourceAsStream(fileName)));
while ((line = bufferedReader.readLine()) != null) {
ySeries[i++] = Double.parseDouble(line.trim());
}
} catch (Exception e) {
//
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
//
}
}
}
//
ISeriesData seriesData = new SeriesData(ySeries, fileName);
return seriesData;
}
use of org.eclipse.swtchart.extensions.core.SeriesData in project swtchart by eclipse.
the class ScatterSeries_3_Part method initialize.
private void initialize() throws Exception {
/*
* Chart Settings
*/
IChartSettings chartSettings = getChartSettings();
RangeRestriction rangeRestriction = chartSettings.getRangeRestriction();
rangeRestriction.setExtendTypeX(RangeRestriction.ExtendType.RELATIVE);
rangeRestriction.setExtendMinX(0.25d);
rangeRestriction.setExtendMaxX(0.1d);
rangeRestriction.setExtendTypeY(RangeRestriction.ExtendType.RELATIVE);
rangeRestriction.setExtendMinY(0.25d);
rangeRestriction.setExtendMaxY(0.1d);
rangeRestriction.setRestrictZoom(false);
chartSettings.setCreateMenu(true);
//
IPrimaryAxisSettings primaryAxisSettingsX = chartSettings.getPrimaryAxisSettingsX();
primaryAxisSettingsX.setTitle("1st Dimension");
primaryAxisSettingsX.setDecimalFormat(new DecimalFormat(("0"), new DecimalFormatSymbols(Locale.ENGLISH)));
primaryAxisSettingsX.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
//
IPrimaryAxisSettings primaryAxisSettingsY = chartSettings.getPrimaryAxisSettingsY();
primaryAxisSettingsY.setTitle("2nd Dimension");
primaryAxisSettingsY.setDecimalFormat(new DecimalFormat(("0.000"), new DecimalFormatSymbols(Locale.ENGLISH)));
primaryAxisSettingsY.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
//
applySettings(chartSettings);
/*
* Create series.
*/
Map<Integer, Color> colors = new HashMap<Integer, Color>();
colors.put(1, getDisplay().getSystemColor(SWT.COLOR_RED));
colors.put(2, getDisplay().getSystemColor(SWT.COLOR_GRAY));
colors.put(3, getDisplay().getSystemColor(SWT.COLOR_GREEN));
colors.put(4, getDisplay().getSystemColor(SWT.COLOR_YELLOW));
colors.put(5, getDisplay().getSystemColor(SWT.COLOR_CYAN));
colors.put(6, getDisplay().getSystemColor(SWT.COLOR_BLUE));
colors.put(7, getDisplay().getSystemColor(SWT.COLOR_BLACK));
colors.put(8, getDisplay().getSystemColor(SWT.COLOR_DARK_MAGENTA));
colors.put(9, getDisplay().getSystemColor(SWT.COLOR_DARK_CYAN));
colors.put(10, getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN));
colors.put(11, getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
//
List<IScatterSeriesData> scatterSeriesDataList = new ArrayList<IScatterSeriesData>();
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 20; j++) {
String id = "Series_" + i + "-" + j;
int y = getRandomValue(10.0d);
double[] xSeries = new double[] { i };
double[] ySeries = new double[] { y };
ISeriesData seriesData = new SeriesData(xSeries, ySeries, id);
IScatterSeriesData scatterSeriesData = new ScatterSeriesData(seriesData);
IScatterSeriesSettings scatterSeriesSettings = scatterSeriesData.getScatterSeriesSettings();
scatterSeriesSettings.setDescription(id);
scatterSeriesSettings.setSymbolSize(getRandomValue(30.0d));
scatterSeriesSettings.setSymbolColor(colors.get(y));
scatterSeriesSettings.setSymbolType(PlotSymbolType.CIRCLE);
scatterSeriesDataList.add(scatterSeriesData);
}
}
addSeriesData(scatterSeriesDataList);
}
use of org.eclipse.swtchart.extensions.core.SeriesData in project swtchart by eclipse.
the class LineSeries_Selection_Part method applyChartSettings.
private void applyChartSettings() throws Exception {
/*
* Chart Settings
*/
IChartSettings chartSettings = lineChart.getChartSettings();
chartSettings.setCreateMenu(true);
/*
* Primary X-Axis
*/
IPrimaryAxisSettings primaryAxisSettingsX = chartSettings.getPrimaryAxisSettingsX();
primaryAxisSettingsX.setTitle("Retention Time (milliseconds)");
primaryAxisSettingsX.setDecimalFormat(new DecimalFormat(("0.0##"), new DecimalFormatSymbols(Locale.ENGLISH)));
primaryAxisSettingsX.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
/*
* Primary Y-Axis
*/
IPrimaryAxisSettings primaryAxisSettingsY = chartSettings.getPrimaryAxisSettingsY();
primaryAxisSettingsY.setTitle("Intensity");
primaryAxisSettingsY.setDecimalFormat(new DecimalFormat(("0.0#E0"), new DecimalFormatSymbols(Locale.ENGLISH)));
primaryAxisSettingsY.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
primaryAxisSettingsY.setGridLineStyle(LineStyle.NONE);
/*
* Secondary Y-Axes
*/
ISecondaryAxisSettings secondaryAxisSettingsY1 = new SecondaryAxisSettings("Relative Intensity [%]", new RelativeIntensityConverter(SWT.VERTICAL, true));
secondaryAxisSettingsY1.setPosition(Position.Secondary);
secondaryAxisSettingsY1.setDecimalFormat(new DecimalFormat(("0.00"), new DecimalFormatSymbols(Locale.ENGLISH)));
secondaryAxisSettingsY1.setColor(getDisplay().getSystemColor(SWT.COLOR_BLACK));
chartSettings.getSecondaryAxisSettingsListY().add(secondaryAxisSettingsY1);
//
lineChart.applySettings(chartSettings);
/*
* Create series.
*/
List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
ISeriesData seriesDataLine = SeriesConverter.getSeriesXY(SeriesConverter.LINE_SERIES_3);
double[] xSeries = seriesDataLine.getXSeries();
double[] ySeries = seriesDataLine.getYSeries();
xValues = new TreeSet<Double>();
yValues = new HashMap<Double, Double>();
for (int i = 0; i < xSeries.length; i++) {
double x = xSeries[i];
xValues.add(x);
yValues.put(x, ySeries[i]);
}
/*
* Line Series
*/
ILineSeriesData lineSeriesData;
ILineSeriesSettings lineSeriesSettings;
//
lineSeriesData = new LineSeriesData(seriesDataLine);
lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
lineSeriesSettings.setEnableArea(true);
ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
lineSeriesSettingsHighlight.setLineWidth(2);
lineSeriesDataList.add(lineSeriesData);
/*
* Selected Point
*/
seriesDataPoint = new SeriesData(new double[] { 0.0 }, new double[] { 0.0 }, DATA_POINT_SERIES);
lineSeriesData = new LineSeriesData(seriesDataPoint);
lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
lineSeriesSettings.setSymbolSize(5);
lineSeriesSettings.setSymbolType(PlotSymbolType.CROSS);
lineSeriesSettings.setEnableArea(true);
lineSeriesDataList.add(lineSeriesData);
/*
* Set series.
*/
lineChart.addSeriesData(lineSeriesDataList);
}
Aggregations