use of org.eclipse.swtchart.IDisposeListener in project swtchart by eclipse.
the class AxisTickPage method apply.
/*
* @see AbstractPreferencePage#apply()
*/
@Override
public void apply() {
for (int i = 0; i < axes.length; i++) {
axes[i].getTick().setVisible(visibilityStates[i]);
FontData fontData = axes[i].getTick().getFont().getFontData()[0];
fontData.setHeight(fontSizes[i]);
Font font = new Font(Display.getDefault(), fontData);
axes[i].getTick().setFont(font);
final String fontKey = AXIS_TICK_FONT + axes[i].getDirection() + axes[i].getId();
if (resources.getFont(fontKey) == null) {
axes[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeFont(fontKey);
}
});
}
resources.put(fontKey, font);
Color color = new Color(Display.getDefault(), foregroundColors[i]);
axes[i].getTick().setForeground(color);
final String colorKey = AXIS_TICK_FOREGROUND + axes[i].getDirection() + axes[i].getId();
if (resources.getColor(colorKey) == null) {
axes[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeColor(colorKey);
}
});
}
resources.put(colorKey, color);
}
}
use of org.eclipse.swtchart.IDisposeListener in project swtchart by eclipse.
the class SeriesLabelPage method apply.
/*
* @see AbstractPreferencePage#apply()
*/
@Override
public void apply() {
for (int i = 0; i < series.length; i++) {
series[i].getLabel().setVisible(visibleStates[i]);
Color color = new Color(Display.getDefault(), colors[i]);
series[i].getLabel().setForeground(color);
final String colorKey = SERIES_LABEL_FOREGROUND + series[i].getId();
if (resources.getColor(colorKey) == null) {
series[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeColor(colorKey);
}
});
}
resources.put(colorKey, color);
FontData fontData = series[i].getLabel().getFont().getFontData()[0];
fontData.setHeight(fontSizes[i]);
Font font = new Font(Display.getDefault(), fontData);
series[i].getLabel().setFont(font);
final String fontKey = SERIES_LABEL_FONT + series[i].getId();
if (resources.getFont(fontKey) == null) {
series[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeFont(fontKey);
}
});
}
resources.put(fontKey, font);
}
}
use of org.eclipse.swtchart.IDisposeListener in project swtchart by eclipse.
the class SeriesPage method apply.
/*
* @see AbstractPreferencePage#apply()
*/
@Override
public void apply() {
for (int i = 0; i < series.length; i++) {
series[i].setVisible(visibleStates[i]);
if (series[i] instanceof ILineSeries) {
Color lineColor = new Color(Display.getDefault(), lineColors[i]);
((ILineSeries) series[i]).setLineColor(lineColor);
final String lineColorKey = SERIES_LINE_COLOR + series[i].getId();
if (resources.getColor(lineColorKey) == null) {
series[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeColor(lineColorKey);
}
});
}
resources.put(lineColorKey, lineColor);
Color symbolColor = new Color(Display.getDefault(), symbolColors[i]);
((ILineSeries) series[i]).setSymbolColor(symbolColor);
final String symbolColorKey = SERIES_SYMBOL_COLOR + series[i].getId();
if (resources.getColor(symbolColorKey) == null) {
series[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeColor(symbolColorKey);
}
});
}
resources.put(symbolColorKey, symbolColor);
((ILineSeries) series[i]).setLineStyle(lineStyles[i]);
((ILineSeries) series[i]).setSymbolType(symbolTypes[i]);
((ILineSeries) series[i]).setSymbolSize(symbolSizes[i]);
} else if (series[i] instanceof IBarSeries) {
Color barColor = new Color(Display.getDefault(), barColors[i]);
((IBarSeries) series[i]).setBarColor(barColor);
final String barColorKey = SERIES_BAR_COLOR + series[i].getId();
if (resources.getColor(barColorKey) == null) {
series[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeColor(barColorKey);
}
});
}
resources.put(barColorKey, barColor);
((IBarSeries) series[i]).setBarPadding(paddings[i]);
}
try {
series[i].enableStack(stackedStates[i]);
} catch (IllegalArgumentException e) {
stackedStates[i] = false;
stackedButton.setSelection(false);
}
series[i].setXAxisId(xAxisIds[i]);
series[i].setYAxisId(yAxisIds[i]);
}
}
use of org.eclipse.swtchart.IDisposeListener in project swtchart by eclipse.
the class Axis method dispose.
/**
* Disposes the resources.
*/
protected void dispose() {
tick.getAxisTickLabels().dispose();
tick.getAxisTickMarks().dispose();
title.dispose();
for (IDisposeListener listener : listeners) {
listener.disposed(new Event());
}
}
use of org.eclipse.swtchart.IDisposeListener in project swtchart by eclipse.
the class AxisPage method apply.
/*
* @see AbstractPreferencePage#apply()
*/
@Override
public void apply() {
for (int i = 0; i < axes.length; i++) {
axes[i].getTitle().setVisible(titleVisibleStates[i]);
axes[i].getTitle().setText(titleTexts[i]);
FontData fontData = axes[i].getTitle().getFont().getFontData()[0];
fontData.setHeight(titleFontSizes[i]);
Font font = new Font(Display.getDefault(), fontData);
axes[i].getTitle().setFont(font);
final String fontKey = AXIS_TITLE_FONT + axes[i].getDirection() + axes[i].getId();
if (resources.getFont(fontKey) == null) {
axes[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeFont(fontKey);
}
});
}
resources.put(fontKey, font);
Color color = new Color(Display.getDefault(), titleColors[i]);
axes[i].getTitle().setForeground(color);
final String colorKey = AXIS_TITLE_FOREGROUND + axes[i].getDirection() + axes[i].getId();
if (resources.getColor(colorKey) == null) {
axes[i].addDisposeListener(new IDisposeListener() {
public void disposed(Event e) {
resources.removeColor(colorKey);
}
});
}
resources.put(colorKey, color);
axes[i].setRange(new Range(minRanges[i], maxRanges[i]));
axes[i].setPosition(positions[i]);
try {
axes[i].enableLogScale(logScaleStates[i]);
} catch (IllegalStateException e) {
axes[i].enableLogScale(false);
logScaleButton.setSelection(false);
}
if (direction == Direction.X) {
axes[i].enableCategory(categoryStates[i]);
}
}
}
Aggregations